protected IEObjectDescription doGetSingleElement(QualifiedName name) {
   String firstSegment = name.getFirstSegment();
   int dollar = firstSegment.indexOf('$');
   if (dollar > 0) {
     firstSegment = firstSegment.substring(0, dollar);
   }
   return doGetSingleElement(name, firstSegment, dollar);
 }
Example #2
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 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;
 }
Example #4
0
  protected void cacheMetaParameters(EObject scopeDetermeningObject) {
    // System.err.println("Computing meta cache");
    metaCache = Maps.newHashMap();
    Resource scopeDetermeningResource = scopeDetermeningObject.eResource();

    IResourceDescriptions descriptionIndex =
        indexProvider.getResourceDescriptions(scopeDetermeningResource);
    IResourceDescription descr =
        descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI());
    if (descr == null) return; // give up - some sort of clean build
    EClass wantedType = PPTPPackage.Literals.TYPE_ARGUMENT;
    for (IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      for (IEObjectDescription objDesc : visibleContainer.getExportedObjects()) {
        QualifiedName q = objDesc.getQualifiedName();
        if ("Type".equals(q.getFirstSegment())) {
          if (wantedType == objDesc.getEClass() || wantedType.isSuperTypeOf(objDesc.getEClass()))
            metaCache.put(q.getLastSegment(), objDesc);
        }
      }
    }
  }
Example #5
0
 protected boolean isLegacyMatch(int index, QualifiedName relativeName) {
   QualifiedName importedName = importNames.get(index);
   return importedName != null
       && relativeName.getSegmentCount() == 1
       && importedName.getLastSegment().equals(relativeName.getFirstSegment());
 }
 protected XbaseIdeCrossrefProposalProvider.ProposalBracketInfo getProposalBracketInfo(
     final IEObjectDescription proposedDescription,
     final ContentAssistContext contentAssistContext) {
   final XbaseIdeCrossrefProposalProvider.ProposalBracketInfo info =
       new XbaseIdeCrossrefProposalProvider.ProposalBracketInfo();
   if ((proposedDescription instanceof IIdentifiableElementDescription)) {
     final JvmIdentifiableElement jvmFeature =
         ((IIdentifiableElementDescription) proposedDescription).getElementOrProxy();
     if ((jvmFeature instanceof JvmExecutable)) {
       final EList<JvmFormalParameter> parameters = ((JvmExecutable) jvmFeature).getParameters();
       int _numberOfParameters =
           ((IIdentifiableElementDescription) proposedDescription).getNumberOfParameters();
       boolean _equals = (_numberOfParameters == 1);
       if (_equals) {
         boolean _and = false;
         String _simpleName = ((JvmExecutable) jvmFeature).getSimpleName();
         boolean _startsWith = _simpleName.startsWith("set");
         if (!_startsWith) {
           _and = false;
         } else {
           QualifiedName _name = ((IIdentifiableElementDescription) proposedDescription).getName();
           String _firstSegment = _name.getFirstSegment();
           boolean _startsWith_1 = _firstSegment.startsWith("set");
           boolean _not = (!_startsWith_1);
           _and = _not;
         }
         if (_and) {
           info.brackets = " = value";
           int _length = "value".length();
           int _minus = (-_length);
           info.selectionOffset = _minus;
           int _length_1 = "value".length();
           info.selectionLength = _length_1;
           return info;
         }
         JvmFormalParameter _last = IterableExtensions.<JvmFormalParameter>last(parameters);
         final JvmTypeReference parameterType = _last.getParameterType();
         XtextResource _resource = contentAssistContext.getResource();
         LightweightTypeReferenceFactory _typeConverter = this.getTypeConverter(_resource);
         final LightweightTypeReference light =
             _typeConverter.toLightweightReference(parameterType);
         boolean _isFunctionType = light.isFunctionType();
         if (_isFunctionType) {
           FunctionTypeReference _asFunctionTypeReference = light.getAsFunctionTypeReference();
           List<LightweightTypeReference> _parameterTypes =
               _asFunctionTypeReference.getParameterTypes();
           final int numParameters = _parameterTypes.size();
           if ((numParameters == 1)) {
             info.brackets = "[]";
             info.caretOffset = (-1);
             return info;
           } else {
             if ((numParameters == 0)) {
               info.brackets = "[|]";
               info.caretOffset = (-1);
               return info;
             } else {
               final StringBuilder b = new StringBuilder();
               for (int i = 0; (i < numParameters); i++) {
                 {
                   if ((i != 0)) {
                     b.append(", ");
                   }
                   b.append(("p" + Integer.valueOf((i + 1))));
                 }
               }
               String _string = b.toString();
               String _plus = ("[" + _string);
               String _plus_1 = (_plus + "|]");
               info.brackets = _plus_1;
               info.caretOffset = (-1);
               int _length_2 = b.length();
               int _minus_1 = (-_length_2);
               int _minus_2 = (_minus_1 - 2);
               info.selectionOffset = _minus_2;
               int _length_3 = b.length();
               info.selectionLength = _length_3;
               return info;
             }
           }
         }
       }
     }
     boolean _isExplicitOperationCall =
         this.isExplicitOperationCall(((IIdentifiableElementDescription) proposedDescription));
     if (_isExplicitOperationCall) {
       info.brackets = "()";
       info.selectionOffset = (-1);
     }
   }
   return info;
 }