コード例 #1
0
 /**
  * Check the '.emtl' file and report in the '.mtl' file some syntax errors when we use the
  * non-standard library.
  *
  * @param iFile is the '.mtl' file
  * @param oURI is the URI of the '.emtl' file
  */
 private void checkFullOMGCompliance(File iFile, URI oURI) {
   try {
     AcceleoSourceBuffer buffer = new AcceleoSourceBuffer(iFile);
     ResourceSet oResourceSet = new ResourceSetImpl();
     EObject oRoot = ModelUtils.load(oURI, oResourceSet);
     TreeIterator<EObject> oAllContents = oRoot.eAllContents();
     while (oAllContents.hasNext()) {
       EObject oNext = oAllContents.next();
       if (oNext instanceof OperationCallExp) {
         OperationCallExp oOperationCallExp = (OperationCallExp) oNext;
         if (oOperationCallExp.getReferredOperation() != null
             && oOperationCallExp.getReferredOperation().getEAnnotation("MTL non-standard")
                 != null) { //$NON-NLS-1$
           IFile workspaceFile =
               ResourcesPlugin.getWorkspace()
                   .getRoot()
                   .getFileForLocation(new Path(iFile.getAbsolutePath()));
           if (workspaceFile != null
               && workspaceFile.isAccessible()
               && oOperationCallExp.getStartPosition() > -1) {
             int line = buffer.getLineOfOffset(oOperationCallExp.getStartPosition());
             AcceleoMarkerUtils.createMarkerOnFile(
                 AcceleoMarkerUtils.PROBLEM_MARKER_ID,
                 workspaceFile,
                 line,
                 oOperationCallExp.getStartPosition(),
                 oOperationCallExp.getEndPosition(),
                 AcceleoUIMessages.getString(
                     "AcceleoCompileOperation.NotFullyCompliant",
                     oOperationCallExp //$NON-NLS-1$
                         .getReferredOperation()
                         .getName()));
           }
         }
       }
     }
   } catch (IOException e) {
     Status status = new Status(IStatus.WARNING, AcceleoUIActivator.PLUGIN_ID, e.getMessage(), e);
     AcceleoUIActivator.getDefault().getLog().log(status);
   } catch (CoreException e) {
     AcceleoUIActivator.getDefault().getLog().log(e.getStatus());
   }
 }