Beispiel #1
0
  /**
   * From diagram URI get Apdl URI. set it to private field.
   *
   * @param diagramFileURI
   */
  public void setAPDLFileName(URI diagramFileURI) {
    IPreferenceStore store = BpwmeDiagramEditorPlugin.getInstance().getPreferenceStore();
    String dot = "\\.";
    String[] names = diagramFileURI.lastSegment().split(dot);
    if (names.length == 2) {
      apdlURI = diagramFileURI.trimFileExtension().appendFileExtension("xml");
      // apdlURI =
      // URI.createFileURI(store.getString(PreferenceConstants.P_APDL_DIR)+names[0]+".xml");
      store.setValue(PreferenceConstants.P_APDL_FILE, apdlURI.toFileString());

      File f = new File(apdlURI.toFileString());
      if (!f.exists()) {

        try {
          f.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      IPath location = new Path(f.getAbsolutePath());
      PathEditorInput input = new PathEditorInput(location);
      SimpleEditor.setEditorInput(input);

    } else {
      System.err.println("Error in MainControl.getFileName");
    }
  }
Beispiel #2
0
 public URI getFullURI(ITypeBinding typeBinding) {
   // The URIs for primitive types are cached and indexed by their one character key
   // representation.
   //
   if (typeBinding.isPrimitive()) {
     return PRIMITIVE_URIS[typeBinding.getKey().charAt(0) - 'B'];
   }
   if (typeBinding.isClass()
       || typeBinding.isInterface()
       || typeBinding.isAnnotation()
       || typeBinding.isEnum()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass == null) {
       // This special case handling for common case of top level types that avoids creating a
       // builder.
       //
       String qualifiedName = typeBinding.getErasure().getQualifiedName();
       URI uri = COMMON_URIS.get(qualifiedName);
       if (uri != null) {
         return uri;
       }
       uri = OBJECTS_URI.appendSegment(qualifiedName);
       return uri.appendFragment(uri.lastSegment());
     }
     SegmentSequence.Builder builder = SegmentSequence.newBuilder("");
     URI uri = getFullURI(declaringClass, builder);
     builder.append("$");
     builder.append(typeBinding.getName());
     return uri.appendFragment(builder.toString());
   }
   SegmentSequence.Builder builder = SegmentSequence.newBuilder("");
   URI uri = getFullURI(typeBinding, builder);
   return uri.appendFragment(builder.toString());
 }
 public String name(final Resource res) {
   URI _uRI = res.getURI();
   final String s = _uRI.lastSegment();
   int _length = s.length();
   int _length_1 = ".xbase".length();
   int _minus = (_length - _length_1);
   return s.substring(0, _minus);
 }
Beispiel #4
0
 /** @since 2.4 */
 protected URI getFullURI(ITypeBinding typeBinding, SegmentSequence.Builder builder) {
   if (typeBinding.isPrimitive()) {
     builder.append(PRIMITIVE_URIS[typeBinding.getKey().charAt(0) - 'B'].fragment());
     return PRIMITIVES_URI;
   }
   if (typeBinding.isClass()
       || typeBinding.isInterface()
       || typeBinding.isAnnotation()
       || typeBinding.isEnum()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass != null) {
       URI uri = getFullURI(declaringClass, builder);
       builder.append("$");
       builder.append(typeBinding.getName());
       return uri;
     }
     String qualifiedName = typeBinding.getErasure().getQualifiedName();
     URI uri = COMMON_URIS.get(qualifiedName);
     if (uri == null) {
       uri = OBJECTS_URI.appendSegment(qualifiedName);
     }
     builder.append(uri.lastSegment());
     return uri;
   }
   if (typeBinding.isArray()) {
     URI uri = getFullURI(typeBinding.getComponentType(), builder);
     builder.append("[]");
     return uri;
   }
   if (typeBinding.isTypeVariable()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass != null) {
       URI uri = getFullURI(declaringClass, builder);
       builder.append("/");
       builder.append(typeBinding.getName());
       return uri;
     }
     IMethodBinding declaringMethod = typeBinding.getDeclaringMethod();
     URI uri = getFullURI(declaringMethod.getDeclaringClass(), builder);
     builder.append(".");
     builder.append(declaringMethod.getName());
     builder.append("(");
     ITypeBinding[] parameterTypes = declaringMethod.getParameterTypes();
     for (int i = 0; i < parameterTypes.length; i++) {
       if (i != 0) {
         builder.append(",");
       }
       getQualifiedName(parameterTypes[i], builder);
     }
     builder.append(")");
     builder.append("/");
     builder.append(typeBinding.getName());
     return uri;
   }
   throw new IllegalStateException("Unexpected type: " + typeBinding);
 }
  /**
   * This method should be called within a workspace modify operation since it creates resources.
   *
   * @generated
   */
  public static Resource createDiagram(
      URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) {
    TransactionalEditingDomain editingDomain =
        GMFEditingDomainFactory.INSTANCE.createEditingDomain();
    progressMonitor.beginTask(Messages.UMLDiagramEditorUtil_CreateDiagramProgressTask, 3);
    final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
    final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
    final String diagramName = diagramURI.lastSegment();
    AbstractTransactionalCommand command =
        new AbstractTransactionalCommand(
            editingDomain,
            Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel,
            Collections.EMPTY_LIST) {

          protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
              throws ExecutionException {
            Package model = createInitialModel();
            attachModelToResource(model, modelResource);

            Diagram diagram =
                ViewService.createDiagram(
                    model,
                    PackageEditPart.MODEL_ID,
                    UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
            if (diagram != null) {
              diagramResource.getContents().add(diagram);
              diagram.setName(diagramName);
              diagram.setElement(model);
            }

            try {
              modelResource.save(
                  org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil
                      .getSaveOptions());
              diagramResource.save(
                  org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil
                      .getSaveOptions());
            } catch (IOException e) {

              UMLDiagramEditorPlugin.getInstance()
                  .logError("Unable to store model and diagram resources", e); // $NON-NLS-1$
            }
            return CommandResult.newOKCommandResult();
          }
        };
    try {
      OperationHistoryFactory.getOperationHistory()
          .execute(command, new SubProgressMonitor(progressMonitor, 1), null);
    } catch (ExecutionException e) {
      UMLDiagramEditorPlugin.getInstance()
          .logError("Unable to create model and diagram", e); // $NON-NLS-1$
    }
    setCharset(WorkspaceSynchronizer.getFile(modelResource));
    setCharset(WorkspaceSynchronizer.getFile(diagramResource));
    return diagramResource;
  }
 /** Set the uri as the default input. */
 private void initialize() {
   if (uri != null && uriText.getText().length() == 0) {
     uriText.setText(uri.toString());
   } else {
     final URI diffURI = ((ApplyWizard) getWizard()).getMPatch().eResource().getURI();
     uriText.setText(
         diffURI
             .toString()
             .substring(0, diffURI.toString().length() - diffURI.lastSegment().length()));
   }
 }
Beispiel #7
0
 /**
  * Returns the file name of this test
  *
  * @return The file name of this test
  */
 public String getFileName() {
   Resource eResource = eResource();
   String result = "File name unknown";
   if (eResource != null) {
     URI uri = eResource.getURI();
     try {
       result = URLDecoder.decode(uri.lastSegment(), "UTF-8");
     } catch (UnsupportedEncodingException e) {
     }
   }
   return result;
 }
  public static String createBuildPathRelativeReference(URI sourceURI, URI targetURI) {
    if (sourceURI == null || targetURI == null) throw new IllegalArgumentException();

    // BaseURI source = new BaseURI(sourceURI);
    // return source.getRelativeURI(targetURI);
    // TODO: this is probably bogus.
    if (targetURI.isFile()) {
      return targetURI.lastSegment();
    }
    String result = targetURI.deresolve(sourceURI, true, true, true).toFileString();
    // When absolute URLs
    return (result == null ? targetURI.toString() : result);
  }
 private void initializeResourceObjectFromFile(FileEditorInput input) {
   IFile inputFile = input.getFile();
   com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.mopp.RezeptNature.activate(
       inputFile.getProject());
   String path = inputFile.getFullPath().toString();
   URI uri = URI.createPlatformResourceURI(path, true);
   ResourceSet resourceSet = getResourceSet();
   com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource
       loadedResource =
           (com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource)
               resourceSet.getResource(uri, false);
   if (loadedResource == null) {
     try {
       Resource demandLoadedResource = null;
       // here we do not use getResource(), because 'resource' might be null, which is ok
       // when initializing the resource object
       com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource
           currentResource = this.resource;
       if (currentResource != null
           && !currentResource.getURI().fileExtension().equals(uri.fileExtension())) {
         // do not attempt to load if file extension has changed in a 'save as' operation
       } else {
         demandLoadedResource = resourceSet.getResource(uri, true);
       }
       if (demandLoadedResource
           instanceof
           com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource) {
         setResource(
             (com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.IRezeptTextResource)
                 demandLoadedResource);
       } else {
         // the resource was not loaded by an EMFText resource, but some other EMF resource
         com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.ui.RezeptUIPlugin
             .showErrorDialog(
                 "Invalid resource.",
                 "The file '"
                     + uri.lastSegment()
                     + "' of type '"
                     + uri.fileExtension()
                     + "' can not be handled by the RezeptEditor.");
         // close this editor because it can not present the resource
         close(false);
       }
     } catch (Exception e) {
       com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.ui.RezeptUIPlugin.logError(
           "Exception while loading resource in " + this.getClass().getSimpleName() + ".", e);
     }
   } else {
     setResource(loadedResource);
   }
 }
Beispiel #10
0
 public URI getFullURI(ITypeBinding typeBinding, String method) {
   SegmentSequence.Builder builder = SegmentSequence.newBuilder("");
   URI uri = getFullURI(typeBinding, builder);
   URI[] uris = COMMON_METHOD_URIS.get(uri.lastSegment());
   if (uris != null) {
     for (URI methodURI : uris) {
       String fragment = methodURI.fragment();
       if (fragment.startsWith(method, fragment.length() - method.length() - 2)) {
         return methodURI;
       }
     }
   }
   builder.append(".").append(method).append("()");
   return uri.appendFragment(builder.toString());
 }
  private static IEditorInput getEditorInput(EObject item) {
    Resource res = item.eResource();
    for (EObject content : res.getContents()) {
      if (content == item) {
        return new FileEditorInput(WorkspaceSynchronizer.getFile(res));
      }
      if (content instanceof HierarchicalNode) {
        break;
      }
    }

    URI uri = EcoreUtil.getURI(item);
    String name = uri.lastSegment() + '#' + item.eResource().getContents().indexOf(item);
    IEditorInput input = new URIEditorInput(uri, name);
    return input;
  }
 /** @generated */
 private static IEditorInput getEditorInput(Diagram diagram) {
   Resource diagramResource = diagram.eResource();
   for (EObject nextEObject : diagramResource.getContents()) {
     if (nextEObject == diagram) {
       return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource));
     }
     if (nextEObject instanceof Diagram) {
       break;
     }
   }
   URI uri = EcoreUtil.getURI(diagram);
   String editorName =
       uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
   IEditorInput editorInput = new URIEditorInput(uri, editorName);
   return editorInput;
 }
Beispiel #13
0
  /*
   * (non-Javadoc)
   *
   * @seeorg.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.
   * IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
   */
  @Override
  public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {

    // System.out.println("activateEditor: "+isDragActive);

    if (aSelection == null || aSelection.isEmpty()) {
      return;
    }

    Object obj = aSelection.getFirstElement();
    if (obj instanceof IOfsModelResource) {
      IOfsModelResource ofsResource = (IOfsModelResource) obj;
      URI uri = ofsResource.getURI();
      String extension = uri.fileExtension();
      if (extension != null
          && StringUtils.contains(PageConstants.PAGE_DESIGNER_FILE_EXTENSIONS, extension, true)) {
        // check if an editor is alread open for the given uri.
        String filename = uri.lastSegment();
        String id =
            PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(filename).getId();
        for (IEditorReference editor : aPage.getEditorReferences()) {
          if (editor.getId().equals(id)) {
            try {
              IEditorInput eInput = editor.getEditorInput();
              if (eInput instanceof FileEditorInput) {
                FileEditorInput fInput = (FileEditorInput) eInput;
                if (filename.equals(fInput.getName())) {
                  if (isDragActive) {
                    // an editor is already open, simply return
                    // to avoid the activation of this editor.
                    isDragActive = false;
                    return;
                  }
                }
              }
            } catch (PartInitException ex) {
              // silently ignore
            }
          }
        }
      }
    }

    // editor not found
    super.activateEditor(aPage, aSelection);
  }
Beispiel #14
0
 /** @generated */
 protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   try {
     Diagram diagram = getDiagramToOpen();
     if (diagram == null) {
       diagram = intializeNewDiagram();
     }
     URI uri = EcoreUtil.getURI(diagram);
     String editorName =
         uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram);
     IEditorInput editorInput = new URIEditorInput(uri, editorName);
     IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
     page.openEditor(editorInput, getEditorID());
     return CommandResult.newOKCommandResult();
   } catch (Exception ex) {
     throw new ExecutionException("Can't open diagram", ex);
   }
 }
 protected void _infer(
     final Script script,
     final IJvmDeclaredTypeAcceptor acceptor,
     final boolean isPreIndexingPhase) {
   Resource _eResource = script.eResource();
   URI _uRI = _eResource.getURI();
   URI _trimFileExtension = _uRI.trimFileExtension();
   final String className = _trimFileExtension.lastSegment();
   JvmGenericType _class = this._jvmTypesBuilder.toClass(script, className);
   IPostIndexingInitializing<JvmGenericType> _accept = acceptor.<JvmGenericType>accept(_class);
   final Procedure1<JvmGenericType> _function =
       new Procedure1<JvmGenericType>() {
         public void apply(final JvmGenericType it) {
           EList<JvmMember> _members = it.getMembers();
           JvmTypeReference _newTypeRef =
               ScriptingJvmModelInferrer.this._jvmTypesBuilder.newTypeRef(script, Void.TYPE);
           final Procedure1<JvmOperation> _function =
               new Procedure1<JvmOperation>() {
                 public void apply(final JvmOperation it) {
                   EList<JvmFormalParameter> _parameters = it.getParameters();
                   JvmTypeReference _newTypeRef =
                       ScriptingJvmModelInferrer.this._jvmTypesBuilder.newTypeRef(
                           script, String.class);
                   JvmTypeReference _addArrayTypeDimension =
                       ScriptingJvmModelInferrer.this._jvmTypesBuilder.addArrayTypeDimension(
                           _newTypeRef);
                   JvmFormalParameter _parameter =
                       ScriptingJvmModelInferrer.this._jvmTypesBuilder.toParameter(
                           script, "args", _addArrayTypeDimension);
                   ScriptingJvmModelInferrer.this._jvmTypesBuilder
                       .<JvmFormalParameter>operator_add(_parameters, _parameter);
                   it.setStatic(true);
                   ScriptingJvmModelInferrer.this._jvmTypesBuilder.setBody(it, script);
                 }
               };
           JvmOperation _method =
               ScriptingJvmModelInferrer.this._jvmTypesBuilder.toMethod(
                   script, "main", _newTypeRef, _function);
           ScriptingJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add(
               _members, _method);
         }
       };
   _accept.initializeLater(_function);
 }
  private static boolean isLocalResource(final String uri) {

    boolean found = false;
    try {
      final String uriName = URI.createURI(uri).lastSegment();
      final Resource[] systemModels =
          ModelerCore.getModelContainer().getResourceFinder().findByName(uriName, false, false);

      for (int i = 0; i != systemModels.length; ++i) {
        final URI resUri = systemModels[i].getURI();
        if (resUri.lastSegment().equalsIgnoreCase(uriName)) found = true;
      }

    } catch (final Exception e) {
      ModelerCore.Util.log(e);
    }

    return found;
  }
 protected boolean validate(final Resource resource) {
   URI _uRI = resource.getURI();
   IResourceServiceProvider _resourceServiceProvider =
       this.context.getResourceServiceProvider(_uRI);
   final IResourceValidator resourceValidator = _resourceServiceProvider.getResourceValidator();
   boolean _equals = Objects.equal(resourceValidator, null);
   if (_equals) {
     return true;
   }
   URI _uRI_1 = resource.getURI();
   String _lastSegment = _uRI_1.lastSegment();
   String _plus = ("Starting validation for input: \'" + _lastSegment);
   String _plus_1 = (_plus + "\'");
   IncrementalBuilder.InternalStatefulIncrementalBuilder.LOG.info(_plus_1);
   final List<Issue> validationResult =
       resourceValidator.validate(resource, CheckMode.ALL, null);
   BuildRequest.IPostValidationCallback _afterValidate = this.request.getAfterValidate();
   URI _uRI_2 = resource.getURI();
   return _afterValidate.afterValidate(_uRI_2, validationResult);
 }
Beispiel #18
0
 public static void dumpURI(URI uri, Logger logger) {
   logger.debug("URI: " + uri);
   logger.debug("authority: " + uri.authority());
   logger.debug("device: " + uri.device());
   logger.debug("devicePath: " + uri.devicePath());
   logger.debug("fileExtension: " + uri.fileExtension());
   logger.debug("fragment: " + uri.fragment());
   logger.debug("host: " + uri.host());
   logger.debug("lastSegment: " + uri.lastSegment());
   logger.debug("opaquePart: " + uri.opaquePart());
   logger.debug("path: " + uri.path());
   logger.debug("port: " + uri.port());
   logger.debug("query: " + uri.query());
   logger.debug("scheme: " + uri.scheme());
   logger.debug("segmentCount: " + uri.segmentCount());
   logger.debug("toFileString: " + uri.toFileString());
   logger.debug("userInfo: " + uri.userInfo());
   logger.debug("hasAbsolutePath: " + uri.hasAbsolutePath());
   logger.debug("schemehasAbsolutePath: " + uri.hasAbsolutePath());
   logger.debug("hasAuthority: " + uri.hasAuthority());
   logger.debug("hasDevice: " + uri.hasDevice());
   logger.debug("hasEmptyPath: " + uri.hasEmptyPath());
   logger.debug("hasFragment: " + uri.hasFragment());
   logger.debug("hasOpaquePart: " + uri.hasOpaquePart());
   logger.debug("hasPath: " + uri.hasPath());
   logger.debug("hasQuery: " + uri.hasQuery());
   logger.debug("hasRelativePath: " + uri.hasRelativePath());
   logger.debug("hasTrailingPathSeparator: " + uri.hasTrailingPathSeparator());
   logger.debug("isCurrentDocumentReference: " + uri.isCurrentDocumentReference());
   logger.debug("isEmpty: " + uri.isEmpty());
   logger.debug("isFile: " + uri.isFile());
   logger.debug("isHierarchical: " + uri.isHierarchical());
   logger.debug("isPrefix: " + uri.isPrefix());
   logger.debug("isRelative: " + uri.isRelative());
   logger.debug("segments: " + uri.segments());
 }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public static boolean openEditor(IWorkbench workbench, URI uri) {
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();

    IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null);
    if (editorDescriptor == null) {
      MessageDialog.openError(
          workbenchWindow.getShell(),
          getString("_UI_Error_title"),
          getString("_WARN_No_Editor", uri.lastSegment()));
      return false;
    } else {
      try {
        page.openEditor(new URIEditorInput(uri), editorDescriptor.getId());
      } catch (PartInitException exception) {
        MessageDialog.openError(
            workbenchWindow.getShell(),
            getString("_UI_OpenEditorError_label"),
            exception.getMessage());
        return false;
      }
    }
    return true;
  }
 @Override
 public String getTaskIdFromTaskUrl(String taskFullUrl) {
   URI uri = URI.createURI(taskFullUrl);
   return uri.lastSegment();
 }
Beispiel #21
0
 public String gitLink(final JvmIdentifiableElement ie) {
   String _xblockexpression = null;
   {
     String _switchResult = null;
     String _qualifiedName = ie.getQualifiedName();
     final String name = _qualifiedName;
     boolean _matched = false;
     if (!_matched) {
       if (Objects.equal(name, null)) {
         _matched = true;
         return ("broken-link in " + ie);
       }
     }
     if (!_matched) {
       boolean _startsWith = name.startsWith("org.eclipse.xtext.common.types.xtext.ui");
       if (_startsWith) {
         _matched = true;
         String _plus = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.common.types.ui/src/");
         _switchResult = _plus;
       }
     }
     if (!_matched) {
       boolean _and = false;
       boolean _startsWith_1 = name.startsWith("org.eclipse.xtext.common.types.");
       if (!_startsWith_1) {
         _and = false;
       } else {
         String _simpleName = ie.getSimpleName();
         boolean _contains = GitExtensions.JVM_EMF_CLASSES.contains(_simpleName);
         _and = (_startsWith_1 && _contains);
       }
       if (_and) {
         _matched = true;
         String _plus_1 =
             (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.common.types/emf-gen/");
         _switchResult = _plus_1;
       }
     }
     if (!_matched) {
       boolean _startsWith_2 = name.startsWith("org.eclipse.xtext.common.types.");
       if (_startsWith_2) {
         _matched = true;
         String _plus_2 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.common.types/src/");
         _switchResult = _plus_2;
       }
     }
     if (!_matched) {
       boolean _startsWith_3 = name.startsWith("org.eclipse.xtext.ui.shared.");
       if (_startsWith_3) {
         _matched = true;
         String _plus_3 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.ui.shared/src/");
         _switchResult = _plus_3;
       }
     }
     if (!_matched) {
       boolean _startsWith_4 = name.startsWith("org.eclipse.xtext.xtend2.lib.");
       if (_startsWith_4) {
         _matched = true;
         String _plus_4 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xtend2.lib/src/");
         _switchResult = _plus_4;
       }
     }
     if (!_matched) {
       boolean _startsWith_5 = name.startsWith("org.eclipse.xtext.xtend2.ui.");
       if (_startsWith_5) {
         _matched = true;
         String _plus_5 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xtend2.ui/src/");
         _switchResult = _plus_5;
       }
     }
     if (!_matched) {
       boolean _startsWith_6 = name.startsWith("org.eclipse.xtext.xtend2.");
       if (_startsWith_6) {
         _matched = true;
         String _plus_6 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xtend2/src/");
         _switchResult = _plus_6;
       }
     }
     if (!_matched) {
       boolean _startsWith_7 = name.startsWith("org.eclipse.xtext.xbase.ui.");
       if (_startsWith_7) {
         _matched = true;
         String _plus_7 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase.ui/src/");
         _switchResult = _plus_7;
       }
     }
     if (!_matched) {
       boolean _startsWith_8 = name.startsWith("org.eclipse.xtext.xbase.lib.");
       if (_startsWith_8) {
         _matched = true;
         String _plus_8 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase.lib/src/");
         _switchResult = _plus_8;
       }
     }
     if (!_matched) {
       boolean _and_1 = false;
       boolean _startsWith_9 = name.startsWith("org.eclipse.xtext.xbase.");
       if (!_startsWith_9) {
         _and_1 = false;
       } else {
         String _simpleName_1 = ie.getSimpleName();
         boolean _contains_1 = GitExtensions.XBASE_EMF_CLASSES.contains(_simpleName_1);
         _and_1 = (_startsWith_9 && _contains_1);
       }
       if (_and_1) {
         _matched = true;
         String _plus_9 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase/emf-gen/");
         _switchResult = _plus_9;
       }
     }
     if (!_matched) {
       boolean _startsWith_10 = name.startsWith("org.eclipse.xtext.xbase.");
       if (_startsWith_10) {
         _matched = true;
         String _plus_10 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase/src/");
         _switchResult = _plus_10;
       }
     }
     if (!_matched) {
       boolean _and_2 = false;
       boolean _or = false;
       boolean _startsWith_11 = name.startsWith("org.eclipse.xtext.generator.");
       if (_startsWith_11) {
         _or = true;
       } else {
         boolean _startsWith_12 = name.startsWith("org.eclipse.xtext.ui.generator.");
         _or = (_startsWith_11 || _startsWith_12);
       }
       if (!_or) {
         _and_2 = false;
       } else {
         String _simpleName_2 = ie.getSimpleName();
         boolean _notEquals = (!Objects.equal("IGenerator", _simpleName_2));
         _and_2 = (_or && _notEquals);
       }
       if (_and_2) {
         _matched = true;
         String _plus_11 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.generator/src/");
         _switchResult = _plus_11;
       }
     }
     if (!_matched) {
       boolean _startsWith_13 = name.startsWith("org.eclipse.xtext.ui.");
       if (_startsWith_13) {
         _matched = true;
         String _plus_12 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.ui/src/");
         _switchResult = _plus_12;
       }
     }
     if (!_matched) {
       boolean _startsWith_14 = name.startsWith("org.eclipse.xtext.junit4.");
       if (_startsWith_14) {
         _matched = true;
         String _plus_13 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.junit4/src/");
         _switchResult = _plus_13;
       }
     }
     if (!_matched) {
       boolean _startsWith_15 = name.startsWith("org.eclipse.xtext.junit.");
       if (_startsWith_15) {
         _matched = true;
         String _plus_14 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.junit/src/");
         _switchResult = _plus_14;
       }
     }
     if (!_matched) {
       boolean _startsWith_16 = name.startsWith("org.eclipse.xtext.ui.");
       if (_startsWith_16) {
         _matched = true;
         String _plus_15 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.ui/src/");
         _switchResult = _plus_15;
       }
     }
     if (!_matched) {
       boolean _startsWith_17 = name.startsWith("org.eclipse.xtext.util.");
       if (_startsWith_17) {
         _matched = true;
         String _plus_16 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.util/src/");
         _switchResult = _plus_16;
       }
     }
     if (!_matched) {
       boolean _and_3 = false;
       boolean _startsWith_18 = name.startsWith("org.eclipse.xtext.");
       if (!_startsWith_18) {
         _and_3 = false;
       } else {
         String _simpleName_3 = ie.getSimpleName();
         boolean _contains_2 = GitExtensions.XTEXT_EMF_CLASSES.contains(_simpleName_3);
         _and_3 = (_startsWith_18 && _contains_2);
       }
       if (_and_3) {
         _matched = true;
         String _plus_17 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext/emf-gen/");
         _switchResult = _plus_17;
       }
     }
     if (!_matched) {
       boolean _startsWith_19 = name.startsWith("org.eclipse.xtext.");
       if (_startsWith_19) {
         _matched = true;
         String _plus_18 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext/src/");
         _switchResult = _plus_18;
       }
     }
     if (!_matched) {
       boolean _startsWith_20 = name.startsWith("org.eclipse.emf.mwe.utils.");
       if (_startsWith_20) {
         _matched = true;
         String _plus_19 = (GitExtensions.MWE_BASE_DIR + "org.eclipse.emf.mwe.utils/src/");
         _switchResult = _plus_19;
       }
     }
     if (!_matched) {
       boolean _startsWith_21 = name.startsWith("org.eclipse.emf.mwe2.runtime.");
       if (_startsWith_21) {
         _matched = true;
         String _plus_20 = (GitExtensions.MWE_BASE_DIR + "org.eclipse.emf.mwe2.runtime/src/");
         _switchResult = _plus_20;
       }
     }
     if (!_matched) {
       boolean _startsWith_22 = name.startsWith("org.eclipse.emf.mwe2.launch.");
       if (_startsWith_22) {
         _matched = true;
         String _plus_21 = (GitExtensions.MWE_BASE_DIR + "org.eclipse.emf.mwe2.launch/src/");
         _switchResult = _plus_21;
       }
     }
     if (!_matched) {
       boolean _startsWith_23 = name.startsWith("org.eclipse.emf.common.");
       if (_startsWith_23) {
         _matched = true;
         String _plus_22 = (GitExtensions.EMF_BASE_DIR + "org.eclipse.emf.common/src/");
         _switchResult = _plus_22;
       }
     }
     if (!_matched) {
       boolean _startsWith_24 = name.startsWith("org.eclipse.emf.");
       if (_startsWith_24) {
         _matched = true;
         String _plus_23 = (GitExtensions.EMF_BASE_DIR + "org.eclipse.emf.ecore/src/");
         _switchResult = _plus_23;
       }
     }
     if (!_matched) {
       boolean _or_1 = false;
       boolean _startsWith_25 = name.startsWith("org.eclipse.xtext.xbase.lib.");
       if (_startsWith_25) {
         _or_1 = true;
       } else {
         boolean _startsWith_26 = name.startsWith("org.eclipse.xtend2.lib.");
         _or_1 = (_startsWith_25 || _startsWith_26);
       }
       if (_or_1) {
         _matched = true;
         String _plus_24 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase.lib/src/");
         _switchResult = _plus_24;
       }
     }
     if (!_matched) {
       boolean _startsWith_27 = name.startsWith("org.eclipse.xtext.xbase.ui.");
       if (_startsWith_27) {
         _matched = true;
         String _plus_25 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase.ui/src/");
         _switchResult = _plus_25;
       }
     }
     if (!_matched) {
       boolean _startsWith_28 = name.startsWith("org.eclipse.xtext.xbase.");
       if (_startsWith_28) {
         _matched = true;
         String _plus_26 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtext.xbase/src/");
         _switchResult = _plus_26;
       }
     }
     if (!_matched) {
       boolean _startsWith_29 = name.startsWith("org.eclipse.xtend.lib.");
       if (_startsWith_29) {
         _matched = true;
         String _plus_27 = (GitExtensions.XTEXT_BASE_DIR + "org.eclipse.xtend.lib/src/");
         _switchResult = _plus_27;
       }
     }
     if (!_matched) {
       boolean _startsWith_30 = name.startsWith("org.eclipse.xtend.ui.");
       if (_startsWith_30) {
         _matched = true;
         String _plus_28 = (GitExtensions.XTEND_BASE_DIR + "org.eclipse.xtend.ui/src/");
         _switchResult = _plus_28;
       }
     }
     if (!_matched) {
       boolean _startsWith_31 = name.startsWith("org.eclipse.xtend.core.");
       if (_startsWith_31) {
         _matched = true;
         String _plus_29 = (GitExtensions.XTEND_BASE_DIR + "org.eclipse.xtend.core/src/");
         _switchResult = _plus_29;
       }
     }
     if (!_matched) {
       boolean _startsWith_32 = name.startsWith("org.xtext.");
       if (_startsWith_32) {
         _matched = true;
         String _xblockexpression_1 = null;
         {
           String[] _split = name.split("\\.");
           final String languageID = _split[2];
           String[] _split_1 = name.split("\\.");
           final String pluginSuffix = _split_1[3];
           String _xifexpression = null;
           boolean _equals = Objects.equal(pluginSuffix, "examples");
           if (_equals) {
             _xifexpression = "examples";
           } else {
             _xifexpression = "languages";
           }
           final String subdir = _xifexpression;
           StringConcatenation _builder = new StringConcatenation();
           _builder.append(GitExtensions.SEVENLANGUAGES_BASEDIR, "");
           _builder.append(subdir, "");
           _builder.append("/org.xtext.");
           _builder.append(languageID, "");
           {
             boolean _contains_3 =
                 GitExtensions.SEVEN_LANGUAGE_PLUGIN_SUFFIXES.contains(pluginSuffix);
             if (_contains_3) {
               _builder.append(".");
               _builder.append(pluginSuffix, "");
             }
           }
           _builder.append("/src/");
           _xblockexpression_1 = (_builder.toString());
         }
         _switchResult = _xblockexpression_1;
       }
     }
     if (!_matched) {
       _switchResult = "";
     }
     final String prefix = _switchResult;
     String _xifexpression = null;
     int _length = prefix.length();
     boolean _notEquals_1 = (_length != 0);
     if (_notEquals_1) {
       String _switchResult_1 = null;
       Resource _eResource = null;
       if (ie != null) {
         _eResource = ie.eResource();
       }
       URI _uRI = null;
       if (_eResource != null) {
         _uRI = _eResource.getURI();
       }
       final URI uri = _uRI;
       boolean _matched_1 = false;
       if (!_matched_1) {
         String _scheme = uri.scheme();
         boolean _equals = Objects.equal(_scheme, "java");
         if (_equals) {
           _matched_1 = true;
           String _qualifiedName_1 = ie.getQualifiedName();
           String _replaceAll = _qualifiedName_1.replaceAll("\\.", "/");
           String _replaceAll_1 = _replaceAll.replaceAll("\\$.*$", "");
           String _plus_30 = (prefix + _replaceAll_1);
           String _plus_31 = (_plus_30 + ".");
           String _plus_32 = (_plus_31 + "java");
           _switchResult_1 = _plus_32;
         }
       }
       if (!_matched_1) {
         String _packageName = ((JvmDeclaredType) ie).getPackageName();
         String _replaceAll_2 = _packageName.replaceAll("\\.", "/");
         String _plus_33 = (prefix + _replaceAll_2);
         String _plus_34 = (_plus_33 + "/");
         String _lastSegment = uri.lastSegment();
         String _plus_35 = (_plus_34 + _lastSegment);
         _switchResult_1 = _plus_35;
       }
       _xifexpression = _switchResult_1;
     } else {
       _xifexpression = null;
     }
     _xblockexpression = (_xifexpression);
   }
   return _xblockexpression;
 }
 protected void setModelName(ModelFigure figure, URI uri) {
   figure.setName(uri == null ? null : uri.lastSegment());
   figure.setFullName(uri == null ? null : uri.toString());
   figure.setForegroundColor(
       uri == null ? AliveDashboardFigure.DASHBOARD_FG : AliveDashboardFigure.DASHBOARD_COMPLETED);
 }
 protected String fileName(final EObject eObject) {
   Resource _eResource = eObject.eResource();
   URI _uRI = _eResource.getURI();
   return _uRI.lastSegment();
 }
  /**
   * Check if controlled sub-packages can be correctly updated : - Check if controlled package is
   * loaded - Change the control strategy if necessary - Report error if the controlled package is
   * read-only
   *
   * @param controlledPackages the controlled sub-packages (may be updated if contains proxies)
   * @return true if can be updated
   */
  private boolean checkControlledPackagesUpdateable(Set<Package> controlledPackages) {
    boolean notLoadedPackages = false;
    StringBuffer notLoadedPackagesList = new StringBuffer();
    boolean readOnlyPackages = false;
    StringBuffer readOnlyPackagesList = new StringBuffer();
    // Check if controlled package is loaded
    for (Iterator<Package> iterator = controlledPackages.iterator(); iterator.hasNext(); ) {
      Package pack = iterator.next();
      EditingDomain domain = EditorUtils.getTransactionalEditingDomain();
      if (pack.eIsProxy()) {
        EObject loadedObject =
            domain.getResourceSet().getEObject(((InternalEObject) pack).eProxyURI(), true);
        if (loadedObject != null) {
          // pack has been reload, replace proxy;
          controlledPackages.remove(pack);
          pack = (Package) loadedObject;
          controlledPackages.add(pack);
        }
      }
      if (pack.eIsProxy()) {
        notLoadedPackages = true;
        URI uri = ((InternalEObject) pack).eProxyURI();
        String uriLastSeg = uri.lastSegment();
        String name =
            uriLastSeg.substring(0, uriLastSeg.length() - uri.fileExtension().length() - 1);
        String qualifName =
            EMFCoreUtil.getQualifiedName(pack.getOwner(), true)
                .concat("::")
                .concat(name); // $NON-NLS-1$
        notLoadedPackagesList.append(String.format(ENTRY_FORMAT, qualifName));
      } else {
        if (domain instanceof AdapterFactoryEditingDomain) {
          // reset read-only cache map
          ((AdapterFactoryEditingDomain) domain).getResourceToReadOnlyMap().clear();
        }
        if (domain.isReadOnly(pack.eResource())) {
          readOnlyPackages = true;
          String name = EMFCoreUtil.getQualifiedName(pack, true);
          readOnlyPackagesList.append(String.format(ENTRY_FORMAT, name));
        }
      }
    }
    // Report error if the controlled package is read-only
    if (readOnlyPackages) {
      String msg = NLS.bind(Messages.error_readonly, readOnlyPackagesList.toString());
      NotificationBuilder notifBuild = NotificationBuilder.createErrorPopup(msg);
      notifBuild.setHTML(true);
      notifBuild.run();
      return false;
    }
    // Change the control strategy if necessary
    if (notLoadedPackages) {
      String msg = NLS.bind(Messages.switch_loading_strategy, notLoadedPackagesList.toString());
      final BooleanResult stategyChanged = new BooleanResult();
      Runnable runStrategySwitch =
          new Runnable() {

            public void run() {
              StrategyChooser.setCurrentStrategy(LOAD_ALL_STRATEGY);
              stategyChanged.setValue(true);
            }
          };
      Runnable cancel =
          new Runnable() {

            public void run() {
              stategyChanged.setValue(false);
            }
          };
      NotificationBuilder notifBuild =
          NotificationBuilder.createYesNo(msg, runStrategySwitch, cancel);
      notifBuild.setHTML(true);
      notifBuild.setAsynchronous(false);
      notifBuild.run();
      if (stategyChanged.getValue()) {
        // refresh set controlledPackages
        return checkControlledPackagesUpdateable(controlledPackages);
      } else {
        return false;
      }
    }
    return true;
  }
 protected void _infer(
     final Model model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPrelinkingPhase) {
   Resource _eResource = model.eResource();
   URI _uRI = _eResource.getURI();
   URI _trimFileExtension = _uRI.trimFileExtension();
   final String postfix = _trimFileExtension.lastSegment();
   JvmGenericType _class =
       this._jvmTypesBuilder.toClass(model, (IModelQueryConstants.INFERRED_CLASS_NAME + postfix));
   final Procedure1<JvmGenericType> _function =
       (JvmGenericType it) -> {
         EList<JvmMember> _members = it.getMembers();
         JvmTypeReference _typeRef =
             this._typeReferenceBuilder.typeRef(IResourceDescriptions.class);
         JvmField _field =
             this._jvmTypesBuilder.toField(model, IModelQueryConstants.INDEX, _typeRef);
         this._jvmTypesBuilder.<JvmField>operator_add(_members, _field);
         EList<JvmMember> _members_1 = it.getMembers();
         JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IProject.class);
         JvmField _field_1 =
             this._jvmTypesBuilder.toField(model, IModelQueryConstants.PROJECT, _typeRef_1);
         this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field_1);
         EList<JvmMember> _members_2 = it.getMembers();
         JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(ResourceSet.class);
         JvmField _field_2 =
             this._jvmTypesBuilder.toField(model, IModelQueryConstants.RESOURCESET, _typeRef_2);
         this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2);
         EList<JvmMember> _members_3 = it.getMembers();
         JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Injector.class);
         JvmField _field_3 =
             this._jvmTypesBuilder.toField(model, IModelQueryConstants.INJECTOR, _typeRef_3);
         this._jvmTypesBuilder.<JvmField>operator_add(_members_3, _field_3);
         EList<JvmMember> _members_4 = it.getMembers();
         JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Void.TYPE);
         final Procedure1<JvmOperation> _function_1 =
             (JvmOperation it_1) -> {
               XBlockExpression _body = model.getBody();
               this._jvmTypesBuilder.setBody(it_1, _body);
               EList<JvmTypeReference> _exceptions = it_1.getExceptions();
               JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(Exception.class);
               this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef_5);
             };
         JvmOperation _method =
             this._jvmTypesBuilder.toMethod(model, "main", _typeRef_4, _function_1);
         this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method);
         EList<XMethodDeclaration> _methods = model.getMethods();
         for (final XMethodDeclaration op : _methods) {
           EList<JvmMember> _members_5 = it.getMembers();
           String _name = op.getName();
           JvmTypeReference _elvis = null;
           JvmTypeReference _type = op.getType();
           if (_type != null) {
             _elvis = _type;
           } else {
             JvmTypeReference _inferredType = this._jvmTypesBuilder.inferredType();
             _elvis = _inferredType;
           }
           final Procedure1<JvmOperation> _function_2 =
               (JvmOperation it_1) -> {
                 EList<JvmFormalParameter> _parameters = op.getParameters();
                 for (final JvmFormalParameter p : _parameters) {
                   EList<JvmFormalParameter> _parameters_1 = it_1.getParameters();
                   String _name_1 = p.getName();
                   JvmTypeReference _parameterType = p.getParameterType();
                   JvmFormalParameter _parameter =
                       this._jvmTypesBuilder.toParameter(p, _name_1, _parameterType);
                   this._jvmTypesBuilder.<JvmFormalParameter>operator_add(
                       _parameters_1, _parameter);
                 }
                 EList<JvmTypeParameter> _typeParameters = op.getTypeParameters();
                 this.copyAndFixTypeParameters(_typeParameters, it_1);
                 XExpression _body = op.getBody();
                 this._jvmTypesBuilder.setBody(it_1, _body);
               };
           JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(op, _name, _elvis, _function_2);
           this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_1);
         }
       };
   acceptor.<JvmGenericType>accept(_class, _function);
 }
  protected Resource findResourceByImport(final ModelImport theImport, final List eResources) {
    Resource result = null;
    if (theImport != null && eResources != null) {

      // A ModelImport that references an EResource instance
      // will have the UUID of that EResource
      final String uuidString = theImport.getUuid();
      if (!CoreStringUtil.isEmpty(uuidString)) {
        final ObjectID uuid = stringToObjectID(uuidString);
        if (uuid != null) {
          result = findResourceByUUID(uuid, eResources);
          if (result != null) {
            return result;
          }
        }
      }

      // A ModelImport that references a Resource instance will have
      // the relative path to that resource in its location
      final String modelLocation = theImport.getModelLocation();
      if (!CoreStringUtil.isEmpty(modelLocation) && theImport.eResource() != null) {
        // Defect 23340 - Simplifying this check.
        URI modelLocationURI = URI.createURI(modelLocation);
        if (modelLocationURI.isRelative()) {
          result = findByWorkspaceUri(modelLocationURI, theImport.eResource());
        } else {
          result = findByURI(modelLocationURI, true);
        }

        if (result != null && eResources.contains(result)) {
          return result;
        }
        result = null;
      }

      // A ModelImport that references an XSDResource instance
      // will have the name of that XSDResource in its path/location
      final String path = theImport.getPath();
      final String modelPath = (CoreStringUtil.isEmpty(path) ? modelLocation : path);
      if (!CoreStringUtil.isEmpty(modelPath)) {

        // Check if the path represents a logic URI that can be found
        final URI uri = URI.createURI(modelPath);
        result = findByURI(uri, true);
        if (result != null && eResources.contains(result)) {
          return result;
        }
        result = null;

        // Check if the resource name matches any resource in the list
        final String name = uri.lastSegment();
        final Collection results = findResourcesByName(name, true, eResources);
        if (results.size() == 1) {
          result = (Resource) results.iterator().next();
        } else if (results.size() > 1) {
          for (Iterator iter = eResources.iterator(); iter.hasNext(); ) {
            Resource rsrc = (Resource) iter.next();

            // jh Defect 23067: Changed 'toFileString()' to 'toString()'
            // so it will handle both files and urls correctly
            String uriString = rsrc.getURI().toString();
            if (uriString.endsWith(modelPath)) {
              return rsrc;
            }
          }
        }
      }
    }
    return result;
  }
  /**
   * This will be called if the parent {@link URIConverter} didn't know how to convert the given
   * URI.
   *
   * @param uri The uri we are to normalize.
   * @return The normalized form of <code>uri</code>.
   */
  private URI dynamicNormalize(URI uri) {
    URI normalized = getURIMap().get(uri);
    if (normalized == null && EMFPlugin.IS_ECLIPSE_RUNNING) {
      BundleURLConverter conv = new BundleURLConverter(uri.toString());
      if (conv.resolveBundle() != null) {
        normalized = URI.createURI(conv.resolveAsPlatformPlugin());
      }
    }
    if (normalized == null
        && (!IAcceleoConstants.EMTL_FILE_EXTENSION.equals(uri.fileExtension())
            || !"file".equals(uri.scheme()))) { // $NON-NLS-1$
      normalized = super.normalize(uri);
    }
    if (normalized != null) {
      getURIMap().put(uri, normalized);
      return normalized;
    }

    String moduleName = uri.lastSegment();
    moduleName = moduleName.substring(0, moduleName.lastIndexOf('.'));
    Set<URI> candidateURIs = new CompactLinkedHashSet<URI>();

    // Search matching module in the current generation context
    Set<Module> candidateModules = searchCurrentModuleForCandidateMatches(moduleName);
    for (Module candidateModule : candidateModules) {
      if (candidateModule.eResource() != null) {
        candidateURIs.add(candidateModule.eResource().getURI());
      }
    }
    // If there were no matching module, search in their ResourceSet(s)
    if (candidateURIs.size() == 0) {
      candidateURIs.addAll(searchResourceSetForMatches(moduleName));
    }
    if (candidateURIs.size() == 1) {
      normalized = candidateURIs.iterator().next();
    } else if (candidateURIs.size() > 0) {
      normalized = findBestMatchFor(uri, candidateURIs);
    }
    // There is a chance that our match should itself be normalized
    if ((normalized == null || "file".equals(normalized.scheme())) // $NON-NLS-1$
        && EMFPlugin.IS_ECLIPSE_RUNNING) {
      BundleURLConverter conv = new BundleURLConverter(uri.toString());
      if (conv.resolveBundle() != null) {
        normalized = URI.createURI(conv.resolveAsPlatformPlugin());
      } else {
        String uriToString = uri.toString();
        if (uriToString.indexOf('#') > 0) {
          uriToString = uriToString.substring(0, uriToString.indexOf('#'));
        }
        String resolvedPath = AcceleoWorkspaceUtil.resolveInBundles(uriToString);
        if (resolvedPath != null) {
          normalized = URI.createURI(resolvedPath);
        }
      }
    }
    if (normalized == null) {
      normalized = super.normalize(uri);
    }
    if (!uri.equals(normalized)) {
      getURIMap().put(uri, normalized);
    }
    return normalized;
  }