コード例 #1
0
 @Override
 public ContentAssistEntry createProposal(
     final IEObjectDescription candidate,
     final CrossReference crossRef,
     final ContentAssistContext context) {
   boolean _hasIdRule = this.hasIdRule(crossRef);
   if (_hasIdRule) {
     final XbaseIdeCrossrefProposalProvider.ProposalBracketInfo bracketInfo =
         this.getProposalBracketInfo(candidate, context);
     IQualifiedNameConverter _qualifiedNameConverter = this.getQualifiedNameConverter();
     QualifiedName _name = candidate.getName();
     String _string = _qualifiedNameConverter.toString(_name);
     final String proposalString = (_string + bracketInfo.brackets);
     int insignificantParameters = 0;
     if ((candidate instanceof IIdentifiableElementDescription)) {
       int _numberOfIrrelevantParameters =
           ((IIdentifiableElementDescription) candidate).getNumberOfIrrelevantParameters();
       insignificantParameters = _numberOfIrrelevantParameters;
     }
     XtextResource _resource = context.getResource();
     final LightweightTypeReferenceFactory converter = this.getTypeConverter(_resource);
     final EObject objectOrProxy = candidate.getEObjectOrProxy();
     ContentAssistEntry _contentAssistEntry = new ContentAssistEntry();
     final Procedure1<ContentAssistEntry> _function =
         new Procedure1<ContentAssistEntry>() {
           @Override
           public void apply(final ContentAssistEntry it) {
             String _prefix = context.getPrefix();
             it.setPrefix(_prefix);
             it.setProposal(proposalString);
           }
         };
     final ContentAssistEntry result =
         ObjectExtensions.<ContentAssistEntry>operator_doubleArrow(_contentAssistEntry, _function);
     if ((objectOrProxy instanceof JvmFeature)) {
       boolean _startsWith = bracketInfo.brackets.startsWith(" =");
       if (_startsWith) {
         IQualifiedNameConverter _qualifiedNameConverter_1 = this.getQualifiedNameConverter();
         QualifiedName _name_1 = candidate.getName();
         String _string_1 = _qualifiedNameConverter_1.toString(_name_1);
         String _plus = (_string_1 + bracketInfo.brackets);
         this.addNameAndDescription(
             result,
             ((JvmFeature) objectOrProxy),
             false,
             insignificantParameters,
             _plus,
             converter);
       } else {
         boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(bracketInfo.brackets);
         boolean _not = (!_isNullOrEmpty);
         IQualifiedNameConverter _qualifiedNameConverter_2 = this.getQualifiedNameConverter();
         QualifiedName _name_2 = candidate.getName();
         String _string_2 = _qualifiedNameConverter_2.toString(_name_2);
         this.addNameAndDescription(
             result,
             ((JvmFeature) objectOrProxy),
             _not,
             insignificantParameters,
             _string_2,
             converter);
       }
     } else {
       IQualifiedNameConverter _qualifiedNameConverter_3 = this.getQualifiedNameConverter();
       QualifiedName _qualifiedName = candidate.getQualifiedName();
       String _string_3 = _qualifiedNameConverter_3.toString(_qualifiedName);
       IQualifiedNameConverter _qualifiedNameConverter_4 = this.getQualifiedNameConverter();
       QualifiedName _name_3 = candidate.getName();
       String _string_4 = _qualifiedNameConverter_4.toString(_name_3);
       this.addNameAndDescription(result, objectOrProxy, _string_3, _string_4);
     }
     int _offset = context.getOffset();
     String _prefix = context.getPrefix();
     int _length = _prefix.length();
     int _minus = (_offset - _length);
     int _length_1 = proposalString.length();
     int offset = (_minus + _length_1);
     result.setEscapePosition(Integer.valueOf((offset + bracketInfo.caretOffset)));
     if ((bracketInfo.selectionOffset != 0)) {
       int _offset_1 = offset;
       offset = (_offset_1 + bracketInfo.selectionOffset);
       ArrayList<TextRegion> _editPositions = result.getEditPositions();
       TextRegion _textRegion = new TextRegion(offset, bracketInfo.selectionLength);
       _editPositions.add(_textRegion);
     }
     if ((objectOrProxy instanceof JvmExecutable)) {
       final StringBuilder parameterList = new StringBuilder();
       this.appendParameters(
           parameterList, ((JvmExecutable) objectOrProxy), insignificantParameters, converter);
     }
     return result;
   }
   return super.createProposal(candidate, crossRef, context);
 }
コード例 #2
0
 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;
 }