[maven-release-plugin]  copy for tag ruta-2.6.1

git-svn-id: https://svn.apache.org/repos/asf/uima/ruta/tags/ruta-2.6.1@1801585 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java b/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
index ef6701b..608459a 100755
--- a/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
+++ b/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
@@ -44,7 +44,9 @@
 import org.apache.uima.cas.text.AnnotationIndex;

 import org.apache.uima.jcas.tcas.Annotation;

 import org.apache.uima.resource.ResourceInitializationException;

+import org.apache.uima.resource.ResourceManager;

 import org.apache.uima.resource.ResourceSpecifier;

+import org.apache.uima.resource.impl.ResourceManager_impl;

 import org.apache.uima.resource.metadata.FsIndexDescription;

 import org.apache.uima.resource.metadata.TypeSystemDescription;

 import org.apache.uima.ruta.addons.RutaAddonsPlugin;

@@ -109,6 +111,7 @@
     public void done(IJobChangeEvent event) {

       if (event.getResult().isOK()) {

         page.getControl().getDisplay().asyncExec(new Runnable() {

+          @Override

           public void run() {

             page.updateInfoPanel();

           }

@@ -158,8 +161,10 @@
       IPath typeSystemDescriptorPath = null;

       try {

         ClassLoader classLoader = RutaProjectUtils.getClassLoader(project);

-        engineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(r.getLocation(), project, classLoader);

-        typeSystemDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(fScript.getLocation(), project, classLoader);

+        engineDescriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(r.getLocation(),

+                project, classLoader);

+        typeSystemDescriptorPath = RutaProjectUtils

+                .getTypeSystemDescriptorPath(fScript.getLocation(), project, classLoader);

       } catch (CoreException e) {

         RutaAddonsPlugin.error(e);

       }

@@ -177,8 +182,11 @@
         IStatus status = evalRutaOnlyScript(monitor, testPageView, debugPage, fScript, project,

                 engineDescriptorPath, testCasData);

         if (status.getSeverity() == IStatus.ERROR) {

-          Shell shell = Display.getCurrent().getActiveShell();

-          MessageDialog.openWarning(shell, "Error", status.getMessage());

+          Display current = Display.getCurrent();

+          if (current != null) {

+            Shell shell = current.getActiveShell();

+            MessageDialog.openWarning(shell, "Error", status.getMessage());

+          }

         }

         return status;

       } else {

@@ -216,6 +224,9 @@
         // * for each (goldFile, runFile)-pair:

         XMLInputSource in = new XMLInputSource(typeSystemDescriptorPath.toPortableString());

         TypeSystemDescription tsd = UIMAFramework.getXMLParser().parseTypeSystemDescription(in);

+        ClassLoader classLoader = RutaProjectUtils.getClassLoader(project);

+        ResourceManager resourceManager = new ResourceManager_impl(classLoader);

+        tsd.resolveImports(resourceManager);

         CAS runCas = CasCreationUtils.createCas(tsd, null, null);

         CAS goldCas = CasCreationUtils.createCas(tsd, null, null);

         for (TestCasData td : testCasData) {

@@ -231,8 +242,8 @@
           goldCas = goldCas.getView(viewCasName);

           // ** create TP, FP, FN annotations

           // ** collect results and gather eval data

-          evalLogicAndUpdateGUI(monitor, testPageView, debugPage, fScript, project, runCas,

-                  goldCas, td);

+          evalLogicAndUpdateGUI(monitor, testPageView, debugPage, fScript, project, runCas, goldCas,

+                  td);

           if (monitor.isCanceled()) {

             return Status.CANCEL_STATUS;

           }

@@ -258,8 +269,8 @@
      */

     private void runWithJVM(IProgressMonitor monitor, IFile scriptFile, IPath cleanInputPath,

             IPath runOutputPath) {

-      monitor.setTaskName(String.format("Processing script \"%s\" [w classpatch ext.].",

-              scriptFile.getName()));

+      monitor.setTaskName(

+              String.format("Processing script \"%s\" [w classpatch ext.].", scriptFile.getName()));

 

       IProject project = scriptFile.getProject();

 

@@ -281,15 +292,15 @@
 

       try {

         ClassLoader classLoader = RutaProjectUtils.getClassLoader(project);

-        IPath descriptorPath = RutaProjectUtils.getAnalysisEngineDescriptorPath(scriptFile.getLocation(),

-                project, classLoader);

+        IPath descriptorPath = RutaProjectUtils

+                .getAnalysisEngineDescriptorPath(scriptFile.getLocation(), project, classLoader);

         String descriptorAbsolutePath = descriptorPath.toFile().getAbsolutePath();

         ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();

         ILaunchConfigurationType type = mgr

                 .getLaunchConfigurationType(RutaLaunchConfigurationConstants.ID_RUTA_SCRIPT);

 

-        ILaunchConfigurationWorkingCopy copy = type.newInstance(null, scriptFile.getName()

-                + ".Testing");

+        ILaunchConfigurationWorkingCopy copy = type.newInstance(null,

+                scriptFile.getName() + ".Testing");

         // do not use RutaLaunchConstants.ARG_INPUT_FOLDER here

         copy.setAttribute(RutaLaunchConstants.INPUT_FOLDER, inputDirPath);

         // do not use RutaLaunchConstants.ARG_OUTPUT_FOLDER here

@@ -324,8 +335,8 @@
     private void clearFolder(final IProject project, final IPath folderPath) {

       FileUtils.deleteAllFiles(folderPath.toFile()); // clear folder

       try {

-        project.getFolder(folderPath.makeRelativeTo(project.getLocation())).refreshLocal(

-                IResource.DEPTH_INFINITE, new NullProgressMonitor());

+        project.getFolder(folderPath.makeRelativeTo(project.getLocation()))

+                .refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

       } catch (CoreException e1) {

         e1.printStackTrace();

       }

@@ -361,7 +372,9 @@
         // create CAS:

         XMLInputSource in = new XMLInputSource(tsDescriptorPath.toPortableString());

         TypeSystemDescription tsd = UIMAFramework.getXMLParser().parseTypeSystemDescription(in);

-

+        ClassLoader classLoader = RutaProjectUtils.getClassLoader(project);

+        ResourceManager resourceManager = new ResourceManager_impl(classLoader);

+        tsd.resolveImports(resourceManager);

         CAS cleanCas = getEmptyCas(tsd);

 

         for (TestCasData td : testCasData) {

@@ -393,8 +406,8 @@
         }

 

         cleanCas.release();

-        project.getFolder(cleanInputPath.makeRelativeTo(project.getLocation())).refreshLocal(

-                IResource.DEPTH_INFINITE, new NullProgressMonitor());

+        project.getFolder(cleanInputPath.makeRelativeTo(project.getLocation()))

+                .refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

       } catch (Exception e) {

         RutaAddonsPlugin.error(e);

       }

@@ -468,8 +481,8 @@
 

           // process run cas and evaluate it

           ae.process(runCas);

-          evalLogicAndUpdateGUI(monitor, testPageView, debugPage, fScript, project, runCas,

-                  testCas, td);

+          evalLogicAndUpdateGUI(monitor, testPageView, debugPage, fScript, project, runCas, testCas,

+                  td);

           if (monitor.isCanceled()) {

             ae.destroy();

             return Status.CANCEL_STATUS;

@@ -544,22 +557,22 @@
 

       monitor.setTaskName("Actually evaluating " + td.getPath().lastSegment());

 

-      IPath estimatedTestPath = project.getFullPath().append(

-              RutaProjectUtils.getDefaultTestLocation());

+      IPath estimatedTestPath = project.getFullPath()

+              .append(RutaProjectUtils.getDefaultTestLocation());

       IPath path2recource = fScript.getFullPath();

       IPath projectRelativePath2Script = path2recource.removeFirstSegments(2);

-      IPath estimatedTestFolderPath = estimatedTestPath.append(projectRelativePath2Script

-              .removeFileExtension());

+      IPath estimatedTestFolderPath = estimatedTestPath

+              .append(projectRelativePath2Script.removeFileExtension());

 

       IPath path2Result = path2Test.append(TestCasData.RESULT_FOLDER);

-      IPath path2ResultFile = path2Result.append(td.getPath().removeFileExtension().lastSegment()

-              + ".result.xmi");

+      IPath path2ResultFile = path2Result

+              .append(td.getPath().removeFileExtension().lastSegment() + ".result.xmi");

 

       if (!path2Test.toOSString().contains(estimatedTestFolderPath.toOSString())) {

         path2Result = project.getLocation().append(RutaProjectUtils.getDefaultTestLocation())

                 .append(RutaProjectUtils.getDefaultTempTestLocation());

-        path2ResultFile = path2Result.append(td.getPath().removeFileExtension().lastSegment()

-                + ".result.xmi");

+        path2ResultFile = path2Result

+                .append(td.getPath().removeFileExtension().lastSegment() + ".result.xmi");

       }

 

       File resultFile = new File(path2ResultFile.toPortableString());

@@ -571,20 +584,21 @@
       EvalDataProcessor.calculateEvaluatData(td, resultCas);

 

       testPageView.getDefaultPage().getControl().getDisplay().asyncExec(new Runnable() {

+        @Override

         public void run() {

           debugPage.getViewer().refresh();

         }

       });

       monitor.worked(1);

-      project.getFolder(path2Result.makeRelativeTo(project.getLocation())).refreshLocal(

-              IResource.DEPTH_INFINITE, new NullProgressMonitor());

+      project.getFolder(path2Result.makeRelativeTo(project.getLocation()))

+              .refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

       runCas.release();

       goldCas.release();

       resultCas.release();

     }

 

-    private CAS getEmptyCas(Object descriptor) throws ResourceInitializationException,

-            InvalidXMLException {

+    private CAS getEmptyCas(Object descriptor)

+            throws ResourceInitializationException, InvalidXMLException {

       CAS testCas = null;

       if (descriptor instanceof AnalysisEngineDescription) {

         testCas = CasCreationUtils.createCas((AnalysisEngineDescription) descriptor);

@@ -597,14 +611,17 @@
     }

   }

 

+  @Override

   public void addHandlerListener(IHandlerListener handlerListener) {

 

   }

 

+  @Override

   public void dispose() {

 

   }

 

+  @Override

   public Object execute(ExecutionEvent event) throws ExecutionException {

     TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);

     if (!(debugView.getCurrentPage() instanceof TestViewPage)) {

@@ -641,14 +658,17 @@
     }

   }

 

+  @Override

   public boolean isEnabled() {

     return true;

   }

 

+  @Override

   public boolean isHandled() {

     return true;

   }

 

+  @Override

   public void removeHandlerListener(IHandlerListener handlerListener) {

 

   }

@@ -687,7 +707,7 @@
       Type originalType = original.getType();

 

       if (map.containsKey(originalType.getName())) {

-        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());

+        TypeEvalData element = map.get(originalType.getName());

         int oldCount = element.getTruePositives();

         element.setTruePositives(oldCount + 1);

       } else {

@@ -705,7 +725,7 @@
       Type originalType = original.getType();

 

       if (map.containsKey(originalType.getName())) {

-        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());

+        TypeEvalData element = map.get(originalType.getName());

         int oldCount = element.getFalsePositives();

         element.setFalsePositives(oldCount + 1);

       } else {

@@ -723,7 +743,7 @@
       Type originalType = original.getType();

 

       if (map.containsKey(originalType.getName())) {

-        TypeEvalData element = (TypeEvalData) map.get(originalType.getName());

+        TypeEvalData element = map.get(originalType.getName());

         int oldCount = element.getFalseNegatives();

         element.setFalseNegatives(oldCount + 1);

       } else {

diff --git a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/LanguageCheckerVisitor.java b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/LanguageCheckerVisitor.java
index c7892ea..b8af235 100644
--- a/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/LanguageCheckerVisitor.java
+++ b/ruta-ep-ide-ui/src/main/java/org/apache/uima/ruta/ide/validator/LanguageCheckerVisitor.java
@@ -151,7 +151,7 @@
    * Name of each block
    */
   private final Stack<String> blocks;
-  
+
   /**
    * each (inlined) rules
    */
@@ -313,8 +313,8 @@
             if (file != null) {
               // script in other project? use that if the file was found in the workspace
               referredProject = file.getProject();
-              IPath typeSystemDescriptorPath = RutaProjectUtils
-                      .getTypeSystemDescriptorPath(file.getLocation(), referredProject, classLoader);
+              IPath typeSystemDescriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(
+                      file.getLocation(), referredProject, classLoader);
               TypeSystemDescription tsDesc = importCompleteTypeSystem(typeSystemDescriptorPath,
                       url);
 
@@ -444,7 +444,7 @@
       }
     }
     if (s instanceof RutaRule) {
-      if(rules.isEmpty()) {
+      if (rules.isEmpty()) {
         collectAllLabels((RutaRule) s);
       }
       rules.push((RutaRule) s);
@@ -566,7 +566,7 @@
       StringBuilder sb = new StringBuilder();
       Iterator<IFolder> iterator = folders.iterator();
       while (iterator.hasNext()) {
-        IFolder iFolder = (IFolder) iterator.next();
+        IFolder iFolder = iterator.next();
         sb.append(iFolder.getLocation().toPortableString());
         if (iterator.hasNext()) {
           sb.append(System.getProperty("path.separator"));
@@ -623,8 +623,9 @@
         return false;
       }
       RutaVariableReference ref = (RutaVariableReference) s;
-      if(ref.getType() == RutaTypeConstants.RUTA_TYPE_WT || ref.getType() == RutaTypeConstants.RUTA_TYPE_WL) {
-        if(StringUtils.isBlank(ref.getName())) {
+      if (ref.getType() == RutaTypeConstants.RUTA_TYPE_WT
+              || ref.getType() == RutaTypeConstants.RUTA_TYPE_WL) {
+        if (StringUtils.isBlank(ref.getName())) {
           // declaration with a string expression: do not check
           return false;
         }
@@ -643,12 +644,11 @@
           return false;
         }
         if (namespaces.keySet().contains(name) || namespaces.values().contains(name)
-                || allLongTypeNames.contains(name)
-                 ) {
+                || allLongTypeNames.contains(name)) {
           return false;
         }
         Integer variableType = getVariableType(name);
-        if(variableType != null && (variableType == RutaTypeConstants.RUTA_TYPE_AT
+        if (variableType != null && (variableType == RutaTypeConstants.RUTA_TYPE_AT
                 || variableType == RutaTypeConstants.RUTA_TYPE_UA
                 || variableType == RutaTypeConstants.RUTA_TYPE_UAL)) {
           return false;
@@ -802,8 +802,9 @@
       if (conditionName.equals("CONTAINS")) {
         List<?> args = cond.getChilds();
         boolean valid = checkContainsArguments(args);
-        if(!valid) {
-          IProblem problem = problemFactory.createWrongArgumentTypeProblem(cond, "different combination of arguments.");
+        if (!valid) {
+          IProblem problem = problemFactory.createWrongArgumentTypeProblem(cond,
+                  "different combination of arguments.");
           pr.reportProblem(problem);
         }
       }
@@ -882,7 +883,19 @@
   }
 
   private boolean isLabel(String name) {
-    return currentLabels.contains(name);
+
+    if (currentLabels.contains(name)) {
+      return true;
+    }
+
+    if (name.contains(".")) {
+      String[] split = name.split("[.]");
+      if (split.length > 0) {
+        return currentLabels.contains(split[0]);
+      }
+    }
+
+    return false;
   }
 
   private String expand(String shortName) {
@@ -912,8 +925,10 @@
     String match = isFeatureMatch(aref);
     Integer variableType1 = getVariableType(aref);
     Integer variableType2 = getVariableType(bref);
-    if (match == null && variableType1 != null && variableType2 != null && (variableType1 == RutaTypeConstants.RUTA_TYPE_AT
-            || variableType2 == RutaTypeConstants.RUTA_TYPE_AT|| variableType1 == RutaTypeConstants.RUTA_TYPE_UA)) {
+    if (match == null && variableType1 != null && variableType2 != null
+            && (variableType1 == RutaTypeConstants.RUTA_TYPE_AT
+                    || variableType2 == RutaTypeConstants.RUTA_TYPE_AT
+                    || variableType1 == RutaTypeConstants.RUTA_TYPE_UA)) {
       // do not check on variables!
       return;
     }
@@ -957,7 +972,7 @@
     if (s instanceof RutaDeclareDeclarationsStatement) {
       parentTypeInDeclaration = null;
     }
-    if(s instanceof ForEachBlock) {
+    if (s instanceof ForEachBlock) {
       knownLocalVariables.pop();
     }
     if (s instanceof RutaMacroDeclaration) {
@@ -968,7 +983,7 @@
     }
     if (s instanceof RutaRule) {
       rules.pop();
-      if(rules.isEmpty()) {
+      if (rules.isEmpty()) {
         currentLabels.clear();
       }
     }
@@ -991,7 +1006,7 @@
       RutaBlock b = (RutaBlock) s;
       String name = b.getName();
       HashMap<String, Integer> map = new HashMap<String, Integer>();
-      if(b instanceof ForEachBlock) {
+      if (b instanceof ForEachBlock) {
         map.put(name, RutaTypeConstants.RUTA_TYPE_UA);
       }
       knownLocalVariables.push(map);
@@ -1451,7 +1466,8 @@
   private TypeSystemDescription getTypeSystemOfScript()
           throws InvalidXMLException, IOException, CoreException {
     IPath descriptorPath = RutaProjectUtils.getTypeSystemDescriptorPath(
-            sourceModule.getResource().getLocation(), sourceModule.getScriptProject().getProject(), classLoader);
+            sourceModule.getResource().getLocation(), sourceModule.getScriptProject().getProject(),
+            classLoader);
     if (descriptorPath == null) {
       return null;
     }