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); } }
@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); }
protected void addNameAndDescription( final ContentAssistEntry entry, final JvmFeature feature, final boolean withParents, final int insignificantParameters, final String shortName, final LightweightTypeReferenceFactory converter) { final StringBuilder labelBuilder = new StringBuilder(shortName); final StringBuilder descriptionBuilder = new StringBuilder(); if ((feature instanceof JvmOperation)) { if (withParents) { labelBuilder.append("("); this.appendParameters( labelBuilder, ((JvmExecutable) feature), insignificantParameters, converter); labelBuilder.append(")"); } final JvmTypeReference returnType = ((JvmOperation) feature).getReturnType(); boolean _and = false; boolean _notEquals = (!Objects.equal(returnType, null)); if (!_notEquals) { _and = false; } else { String _simpleName = returnType.getSimpleName(); boolean _notEquals_1 = (!Objects.equal(_simpleName, null)); _and = _notEquals_1; } if (_and) { labelBuilder.append(" : "); LightweightTypeReference _lightweightReference = converter.toLightweightReference(returnType); String _humanReadableName = _lightweightReference.getHumanReadableName(); labelBuilder.append(_humanReadableName); } JvmDeclaredType _declaringType = ((JvmOperation) feature).getDeclaringType(); LightweightTypeReference _plainTypeReference = converter.toPlainTypeReference(_declaringType); String _humanReadableName_1 = _plainTypeReference.getHumanReadableName(); descriptionBuilder.append(_humanReadableName_1); if ((!withParents)) { descriptionBuilder.append("."); String _simpleName_1 = ((JvmOperation) feature).getSimpleName(); descriptionBuilder.append(_simpleName_1); descriptionBuilder.append("()"); } } else { if ((feature instanceof JvmField)) { labelBuilder.append(" : "); JvmTypeReference _type = ((JvmField) feature).getType(); boolean _notEquals_2 = (!Objects.equal(_type, null)); if (_notEquals_2) { JvmTypeReference _type_1 = ((JvmField) feature).getType(); LightweightTypeReference _lightweightReference_1 = converter.toLightweightReference(_type_1); final String fieldType = _lightweightReference_1.getHumanReadableName(); boolean _notEquals_3 = (!Objects.equal(fieldType, null)); if (_notEquals_3) { labelBuilder.append(fieldType); } } JvmDeclaredType _declaringType_1 = ((JvmField) feature).getDeclaringType(); LightweightTypeReference _plainTypeReference_1 = converter.toPlainTypeReference(_declaringType_1); String _humanReadableName_2 = _plainTypeReference_1.getHumanReadableName(); descriptionBuilder.append(_humanReadableName_2); } else { if ((feature instanceof JvmConstructor)) { if (withParents) { labelBuilder.append("("); this.appendParameters( labelBuilder, ((JvmExecutable) feature), insignificantParameters, converter); labelBuilder.append(")"); } } } } String _string = labelBuilder.toString(); entry.setLabel(_string); String _string_1 = descriptionBuilder.toString(); entry.setDescription(_string_1); }