@Override
 public String getDisplayString(
     final EObject element, final String givenQualifiedNameAsString, final String shortName) {
   String qualifiedNameAsString = givenQualifiedNameAsString;
   boolean _equals = Objects.equal(qualifiedNameAsString, null);
   if (_equals) {
     qualifiedNameAsString = shortName;
   }
   boolean _equals_1 = Objects.equal(qualifiedNameAsString, null);
   if (_equals_1) {
     boolean _notEquals = (!Objects.equal(element, null));
     if (_notEquals) {
       ILabelProvider _labelProvider = this.getLabelProvider();
       String _text = _labelProvider.getText(element);
       qualifiedNameAsString = _text;
     } else {
       return null;
     }
   }
   if ((!(element instanceof MobaApplication))) {
     IQualifiedNameConverter _qualifiedNameConverter = this.getQualifiedNameConverter();
     final QualifiedName qualifiedName =
         _qualifiedNameConverter.toQualifiedName(qualifiedNameAsString);
     int _segmentCount = qualifiedName.getSegmentCount();
     boolean _greaterThan = (_segmentCount > 1);
     if (_greaterThan) {
       String _lastSegment = qualifiedName.getLastSegment();
       String _plus = (_lastSegment + " - ");
       return (_plus + qualifiedNameAsString);
     }
   }
   return qualifiedNameAsString;
 }
 /**
  * Create a new {@link ImportNormalizer} for the given namespace.
  *
  * @param namespace the namespace.
  * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
  * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be
  *     converted to a valid qualified name.
  */
 protected ImportNormalizer createImportedNamespaceResolver(
     final String namespace, boolean ignoreCase) {
   if (Strings.isEmpty(namespace)) return null;
   QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
   if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) {
     return null;
   }
   boolean hasWildcard =
       ignoreCase
           ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildcard())
           : importedNamespace.getLastSegment().equals(getWildcard());
   if (hasWildcard) {
     if (importedNamespace.getSegmentCount() <= 1) return null;
     return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
   } else {
     return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
   }
 }
 public static ImportNormalizer createNestedTypeAwareImportNormalizer(
     QualifiedName importedNamespace, boolean wildcard, boolean ignoreCase) {
   for (int i = 0; i < importedNamespace.getSegmentCount(); i++) {
     if (importedNamespace.getSegment(i).indexOf('$') >= 0) {
       return new NestedTypeAwareImportNormalizer(importedNamespace, wildcard, ignoreCase);
     }
   }
   return new NestedTypeAwareImportNormalizerWithDotSeparator(
       importedNamespace, wildcard, ignoreCase);
 }
Esempio n. 4
0
 @Override
 protected JvmType findNestedType(JvmType result, int index, QualifiedName name) {
   if (result.eContainer() instanceof JvmDeclaredType && name.getSegmentCount() == 1) {
     QualifiedName importName = importNames.get(index);
     if (importName != null && importName.getLastSegment().equals(name.getFirstSegment())) {
       return result;
     }
   }
   return super.findNestedType(result, index, name);
 }
 protected QualifiedName resolveWildcard(QualifiedName relativeName) {
   int segmentCount = relativeName.getSegmentCount();
   if (segmentCount == 1) {
     return getImportedNamespacePrefix().append(relativeName);
   }
   for (int i = 0; i < segmentCount; i++) {
     if (relativeName.getSegment(i).indexOf('$') != -1) {
       return null;
     }
   }
   return getImportedNamespacePrefix().append(relativeName.toString("$"));
 }
Esempio n. 6
0
  public List<IEObjectDescription> findDefinitions(
      EObject scopeDetermeningResource, String name, PPImportedNamesAdapter importedNames) {
    if (name == null) throw new IllegalArgumentException("name is null");
    QualifiedName fqn = converter.toQualifiedName(name);
    // make all segments initial char lower case (if references is to the type itself - eg. 'File'
    // instead of
    // 'file', or 'Aa::Bb' instead of 'aa::bb'
    QualifiedName fqn2 = QualifiedName.EMPTY;
    for (int i = 0; i < fqn.getSegmentCount(); i++)
      fqn2 = fqn2.append(toInitialLowerCase(fqn.getSegment(i)));
    // fqn2 = fqn.skipLast(1).append(toInitialLowerCase(fqn.getLastSegment()));

    // TODO: Note that order is important, TYPE has higher precedence and should be used for linking
    // This used to work when list was iterated per type, not it is iterated once with type check
    // first - thus if a definition is found before a type, it is earlier in the list.
    return findExternal(scopeDetermeningResource, fqn2, importedNames, false, DEF_AND_TYPE);
  }
 protected void addNameAndDescription(
     final ContentAssistEntry entry,
     final EObject element,
     final String qualifiedNameAsString,
     final String shortName) {
   IQualifiedNameConverter _qualifiedNameConverter = this.getQualifiedNameConverter();
   final QualifiedName qualifiedName =
       _qualifiedNameConverter.toQualifiedName(qualifiedNameAsString);
   int _segmentCount = qualifiedName.getSegmentCount();
   boolean _greaterThan = (_segmentCount > 1);
   if (_greaterThan) {
     String _lastSegment = qualifiedName.getLastSegment();
     entry.setLabel(_lastSegment);
     entry.setDescription(qualifiedNameAsString);
   } else {
     entry.setLabel(qualifiedNameAsString);
   }
 }
 protected JvmType findNestedType(JvmType result, int index, QualifiedName name) {
   List<String> segments =
       name.getSegmentCount() == 1
           ? Strings.split(name.getFirstSegment(), '$')
           : name.getSegments();
   for (int i = 1, size = segments.size(); i < size && result instanceof JvmDeclaredType; i++) {
     JvmDeclaredType declaredType = (JvmDeclaredType) result;
     String simpleName = segments.get(i);
     // TODO handle ambiguous types
     for (JvmMember member : declaredType.findAllNestedTypesByName(simpleName)) {
       result = (JvmType) member;
       break;
     }
     if (declaredType == result) {
       return null;
     }
   }
   return result;
 }
Esempio n. 9
0
  protected List<IEObjectDescription> findExternal(
      EObject scopeDetermeningObject,
      QualifiedName fqn,
      PPImportedNamesAdapter importedNames,
      boolean prefixMatch,
      EClass... eClasses) {
    if (scopeDetermeningObject == null)
      throw new IllegalArgumentException("scope determening object is null");
    if (fqn == null) throw new IllegalArgumentException("name is null");
    if (eClasses == null || eClasses.length < 1)
      throw new IllegalArgumentException("eClass is null or empty");

    if (fqn.getSegmentCount() == 1 && "".equals(fqn.getSegment(0)))
      throw new IllegalArgumentException("FQN has one empty segment");

    // Not meaningful to record the fact that an Absolute reference was used as nothing
    // is named with an absolute FQN (i.e. it is only used to do lookup).
    final boolean absoluteFQN = fqn.getSegmentCount() > 0 && "".equals(fqn.getSegment(0));
    if (importedNames != null) importedNames.add(absoluteFQN ? fqn.skipFirst(1) : fqn);

    List<IEObjectDescription> targets = Lists.newArrayList();
    Resource scopeDetermeningResource = scopeDetermeningObject.eResource();

    if (scopeDetermeningResource != resource) {
      // This is a lookup in the perspective of some other resource
      IResourceDescriptions descriptionIndex =
          indexProvider.getResourceDescriptions(scopeDetermeningResource);
      IResourceDescription descr =
          descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI());

      // GIVE UP (the system is performing a build clean).
      if (descr == null) return targets;
      QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject);

      // for(IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      // for(EClass aClass : eClasses)
      for (IEObjectDescription objDesc :
          new NameInScopeFilter(
              prefixMatch,
              getExportedObjects(descr, descriptionIndex),
              // visibleContainer.getExportedObjects(),
              fqn,
              nameOfScope,
              eClasses)) targets.add(objDesc);
    } else {
      // This is lookup from the main resource perspective
      QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject);
      for (IEObjectDescription objDesc :
          new NameInScopeFilter(
              prefixMatch, //
              prefixMatch
                  ? exportedPerLastSegment.values()
                  : exportedPerLastSegment.get(fqn.getLastSegment()), //
              fqn,
              nameOfScope,
              eClasses)) targets.add(objDesc);
    }
    if (tracer.isTracing()) {
      for (IEObjectDescription d : targets)
        tracer.trace("    : ", converter.toString(d.getName()), " in: ", d.getEObjectURI().path());
    }
    return searchPathAdjusted(targets);
  }
Esempio n. 10
0
 protected boolean isLegacyMatch(int index, QualifiedName relativeName) {
   QualifiedName importedName = importNames.get(index);
   return importedName != null
       && relativeName.getSegmentCount() == 1
       && importedName.getLastSegment().equals(relativeName.getFirstSegment());
 }