X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.osgi%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fosgi%2Finternal%2FBundleModuleSource.java;h=92385a1ed3f9be600ffb0ea33d0ff5e10cda913b;hb=4f38bc070c3e1e40d02bd8da64cc93a798c9aace;hp=244c7463f0d5ade4ba574a373fd13ee9940a99b0;hpb=8561e498009a25473db94b0e667866aa79de90b1;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java index 244c7463f..92385a1ed 100644 --- a/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java +++ b/bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java @@ -1,13 +1,12 @@ package org.simantics.scl.osgi.internal; +import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; @@ -15,6 +14,7 @@ import java.util.Arrays; import org.eclipse.core.runtime.FileLocator; import org.osgi.framework.Bundle; import org.osgi.framework.wiring.BundleWiring; +import org.simantics.scl.compiler.internal.codegen.types.JavaReferenceValidatorFactory; import org.simantics.scl.compiler.module.ImportDeclaration; import org.simantics.scl.compiler.module.repository.UpdateListener; import org.simantics.scl.compiler.source.EncodedTextualModuleSource; @@ -125,15 +125,24 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up } } } - - private Path getPath() throws IOException { - try { - return Paths.get(FileLocator.toFileURL(url).toURI()); - } catch (URISyntaxException e) { - throw new IOException(e); + + /* + * This code is a copy from org.simantics.utils.ui.BundleUtils + */ + public static File resolveWritableBundleFile(URL url) throws IOException { + // This returns file, jar, http etc. - essentially resolves the bundle protocol + URL resolved = FileLocator.resolve(url); + if (resolved.getProtocol().equals("file")) { + return new File(resolved.getPath()); } + return null; } - + + private Path getPath() throws IOException { + File file = resolveWritableBundleFile(url); + return file != null ? file.toPath() : null; + } + @Override public boolean isUpdateable() { try { @@ -161,4 +170,7 @@ public class BundleModuleSource extends EncodedTextualModuleSource implements Up } } + public JavaReferenceValidatorFactory getJavaReferenceValidatorFactory() { + return new OsgiJavaReferenceValidatorFactory(bundle); + } }