aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalazs Grill2013-02-19 10:14:49 (EST)
committerZoltan Ujhelyi2013-02-19 10:14:49 (EST)
commit9656dc8fdd17c1f25b3af5bb3c8f3059c7bcb277 (patch)
tree6408efbc8bc7b87533fb42e045c493d7dfcd744a
parentdf3fea4679db72cab518f869f35483c8d0ec1762 (diff)
downloadorg.eclipse.incquery-9656dc8fdd17c1f25b3af5bb3c8f3059c7bcb277.zip
org.eclipse.incquery-9656dc8fdd17c1f25b3af5bb3c8f3059c7bcb277.tar.gz
org.eclipse.incquery-9656dc8fdd17c1f25b3af5bb3c8f3059c7bcb277.tar.bz2
[398720] Fixed an NPE if file not found
REOPENED - Enable importing EPackages registered by target platform https://bugs.eclipse.org/bugs/show_bug.cgi?id=398720
-rw-r--r--plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/targetplatform/TargetPlatformMetamodelsIndex.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/targetplatform/TargetPlatformMetamodelsIndex.java b/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/targetplatform/TargetPlatformMetamodelsIndex.java
index 0eaed22..fdf14a6 100644
--- a/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/targetplatform/TargetPlatformMetamodelsIndex.java
+++ b/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/targetplatform/TargetPlatformMetamodelsIndex.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.log4j.Logger;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
@@ -37,6 +38,7 @@ import org.eclipse.pde.core.plugin.PluginRegistry;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
+import com.google.inject.Inject;
/**
* This class is responsible for querying the active target platform data for registered GenModels
@@ -47,8 +49,11 @@ public final class TargetPlatformMetamodelsIndex implements ITargetPlatformMetam
private static final String EP_GENPACKAGE = "org.eclipse.emf.ecore.generated_package";
private static final String PACKAGE = "package";
private static final String ATTR_URI = "uri";
- private static final String ATTR_GENMODEL = "genModel";
-
+ private static final String ATTR_GENMODEL = "genModel";
+
+ @Inject
+ Logger logger;
+
private static final Multimap<String, TargetPlatformMetamodel> entries = ArrayListMultimap.create();
private void update(){
@@ -97,8 +102,10 @@ public final class TargetPlatformMetamodelsIndex implements ITargetPlatformMetam
String genModel = genAttrib.getValue();
if (!genModel.startsWith("/"))
genModel = "/" + genModel;
- metamodels.add(new TargetPlatformMetamodel(URI.createURI(resolvePluginResource(
- base.getPluginModel(), genModel)), uri));
+ String resourceURI = resolvePluginResource(base.getPluginModel(), genModel);
+ if (resourceURI != null){
+ metamodels.add(new TargetPlatformMetamodel(URI.createURI(resourceURI), uri));
+ }
}
}
}
@@ -165,13 +172,19 @@ public final class TargetPlatformMetamodelsIndex implements ITargetPlatformMetam
}
- private static String resolvePluginResource(IPluginModelBase modelbase, String path){
+ private String resolvePluginResource(IPluginModelBase modelbase, String path) {
IResource res = modelbase.getUnderlyingResource();
if (res != null) {
IProject project = res.getProject();
- URI platformUri = URI.createPlatformResourceURI(project.findMember(path).getFullPath().toString(),
- false);
- return platformUri.toString();
+ IResource file = project.findMember(path);
+ if (file != null){
+ URI platformUri = URI.createPlatformResourceURI(file.getFullPath().toString(),
+ false);
+ return platformUri.toString();
+ }else{
+ logger.warn("Could not find resource '" + path + "' in project " + project.getName() + ".");
+ return null;
+ }
}
String location = modelbase.getInstallLocation();
if (location.endsWith(".jar")) {