[565000] performance impact of org.eclipse.emf.codegen.jet content type

Reduce the file-patterns for jet content type to a single pattern
exploiting the implementation details of
org.eclipse.core.internal.content.ContentTypeCatalog.toRegexp(String)
which converts a file pattern to a regular expression.

Also eliminate NPEs for JET files in a project without a JET nature.

Signed-off-by: Ed Merks <ed.merks@gmail.com>
diff --git a/plugins/org.eclipse.emf.codegen/plugin.xml b/plugins/org.eclipse.emf.codegen/plugin.xml
index 166805f..355c712 100644
--- a/plugins/org.eclipse.emf.codegen/plugin.xml
+++ b/plugins/org.eclipse.emf.codegen/plugin.xml
@@ -41,7 +41,7 @@
         point="org.eclipse.core.contenttype.contentTypes">
      <content-type
            base-type="org.eclipse.core.runtime.text"
-           file-patterns="*.jet,*.?jet,*.??jet,*.???jet,*.????jet,*.?????jet,*.??????jet,*.???????jet,*.????????jet,*.?????????jet,*.??????????jet,*.jetinc,*.?jetinc,*.??jetinc,*.???jetinc,,*.????jetinc,*.?????jetinc,,*.??????jetinc,*.???????jetinc,*.????????jetinc,*.?????????jetinc,*.??????????jetinc"
+           file-patterns="*.*(jet|jetinc)"
            id="org.eclipse.emf.codegen.jet"
            name="%_UI_JET_TEMPLATE"
            priority="normal">
diff --git a/plugins/org.eclipse.emf.codegen/src/org/eclipse/emf/codegen/jet/JETCompileTemplateOperation.java b/plugins/org.eclipse.emf.codegen/src/org/eclipse/emf/codegen/jet/JETCompileTemplateOperation.java
index ae0226d..b25ffa0 100644
--- a/plugins/org.eclipse.emf.codegen/src/org/eclipse/emf/codegen/jet/JETCompileTemplateOperation.java
+++ b/plugins/org.eclipse.emf.codegen/src/org/eclipse/emf/codegen/jet/JETCompileTemplateOperation.java
@@ -144,10 +144,16 @@
    */
   public JETCompileTemplateOperation(IFile file, JETCompilationMonitor compilationMonitor) throws CoreException
   {
-    this(file.getProject(), JETNature.getRuntime(file.getProject()).getTemplateContainers(), Collections.singleton(file));
+    this(file.getProject(), getTemplateContainers(file.getProject()), Collections.singleton(file));
     this.compilationMonitor = compilationMonitor;
   }
 
+  private static List<Object> getTemplateContainers(IProject project)
+  {
+    JETNature nature = JETNature.getRuntime(project);
+    return nature == null ? Collections.emptyList() : nature.getTemplateContainers();
+  }
+
   State getNewState()
   {
     return newState;
@@ -260,6 +266,11 @@
         progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("_UI_JETCompile_message", new Object []{ fileName }));
 
         JETNature nature = JETNature.getRuntime(project);
+        if (nature == null)
+        {
+          break;
+        }
+
         IContainer directory = nature.getJavaSourceContainer();
 
         // Only create the source container if we are not monitoring compilation and the folder doesn't already exist.