Java Code Examples for org.eclipse.xtext.xbase.scoping.batch.IIdentifiableElementDescription#getElementOrProxy()
The following examples show how to use
org.eclipse.xtext.xbase.scoping.batch.IIdentifiableElementDescription#getElementOrProxy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectAndPrimitiveBasedCastOperationCandidateSelector.java From sarl with Apache License 2.0 | 6 votes |
@Override public boolean isCastOperatorCandidate(IIdentifiableElementDescription description) { if (description instanceof ScopeProviderAccess.ErrorDescription || !description.isVisible()) { return false; } final JvmIdentifiableElement operatorFunction = description.getElementOrProxy(); if (!(operatorFunction instanceof JvmOperation)) { return false; } final JvmOperation executable = (JvmOperation) operatorFunction; final String objectTypeName = getValidClassSimpleName(executable.getSimpleName()); if (objectTypeName != null) { return validatePrototype(objectTypeName, executable); } final String primitiveTypeName = getValidPrimitiveSimpleName(executable.getSimpleName()); if (primitiveTypeName != null) { return validatePrototype(primitiveTypeName, executable); } return false; }
Example 2
Source File: ExpressionScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference getFirstParameterType(IIdentifiableElementDescription candidate) { JvmOperation operation = (JvmOperation) candidate.getElementOrProxy(); if (operation.getParameters().isEmpty()) { return null; } return getParameterType(operation.getParameters().get(0)); }
Example 3
Source File: ExpressionScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected String getExtensionSignature(IIdentifiableElementDescription desc) { JvmOperation operation = (JvmOperation) desc.getElementOrProxy(); StringBuilder builder = new StringBuilder(64).append(desc.getName()); String opName = operation.getSimpleName(); if (opName.length() - 3 == desc.getName().getFirstSegment().length() && opName.startsWith("set")) { builder.append("="); } appendParameters(operation, builder, desc.isExtension()); return builder.toString(); }
Example 4
Source File: ExpressionScope.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected String getSignature(IIdentifiableElementDescription desc) { String descName = desc.getName().getFirstSegment(); StringBuilder builder = new StringBuilder(64).append(descName); JvmIdentifiableElement elementOrProxy = desc.getElementOrProxy(); if (elementOrProxy instanceof JvmExecutable) { JvmExecutable executable = (JvmExecutable) desc.getElementOrProxy(); String opName = executable.getSimpleName(); if (opName.length() - 3 == descName.length() && opName.startsWith("set")) { builder.append("="); } appendParameters(executable, builder, desc.isExtension()); } return builder.toString(); }
Example 5
Source File: AbstractTypeComputationState.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IConstructorLinkingCandidate createCandidate(XConstructorCall constructorCall, IIdentifiableElementDescription description) { StackedResolvedTypes stackedResolvedTypes = resolvedTypes.pushTypes(constructorCall); ExpressionTypeComputationState state = createExpressionComputationState(constructorCall, stackedResolvedTypes); if (description instanceof ScopeProviderAccess.ErrorDescription) { return new UnresolvableConstructorCall(constructorCall, ((ScopeProviderAccess.ErrorDescription) description).getNode(), description.getName().toString(), state); } else if (description.getElementOrProxy() instanceof JvmType) { return new TypeInsteadOfConstructorLinkingCandidate(constructorCall, description, state); } else { return new ConstructorLinkingCandidate(constructorCall, description, getSingleExpectation(state), state); } }
Example 6
Source File: FeatureLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isValidAssignmentName(IIdentifiableElementDescription description) { JvmIdentifiableElement candidate = description.getElementOrProxy(); if (candidate.eClass() == TypesPackage.Literals.JVM_OPERATION) { if (candidate.getSimpleName().equals(description.getName().getFirstSegment())) { return false; } else if (!candidate.getSimpleName().startsWith("set")) { return false; } } return true; }
Example 7
Source File: XbaseReferenceProposalCreator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void apply(IIdentifiableElementDescription featureDescription, MultiNameDescriptions result) { JvmIdentifiableElement element = featureDescription.getElementOrProxy(); String firstSegment = featureDescription.getName().getFirstSegment(); if (element.getSimpleName().equals(firstSegment)) { result.others.add(featureDescription); } }
Example 8
Source File: ParameterContextInformationProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public void getContextInformation(ContentAssistContext context, IContextInformationAcceptor acceptor) { XExpression containerCall = getContainerCall(eObjectAtOffsetHelper.resolveContainedElementAt(context.getResource(), context.getOffset())); LightweightTypeReferenceFactory factory = proposalProvider.getTypeConverter(context.getResource()); if (containerCall != null) { ICompositeNode containerCallNode = NodeModelUtils.findActualNodeFor(containerCall); ITextRegion containerCallRegion = containerCallNode.getTextRegion(); if(containerCallRegion.getOffset() > context.getOffset() || containerCallRegion.getOffset() + containerCallRegion.getLength() < context.getOffset()) return; JvmIdentifiableElement calledFeature = getCalledFeature(containerCall); if (calledFeature instanceof JvmExecutable) { if(getParameterListOffset(containerCall) > context.getOffset()) return; ParameterData parameterData = new ParameterData(); IScope scope = getScope(containerCall); QualifiedName qualifiedName = QualifiedName.create(getCalledFeatureName(containerCall)); boolean candidatesFound = false; for (IEObjectDescription element : scope.getElements(qualifiedName)) { if (element instanceof IIdentifiableElementDescription) { IIdentifiableElementDescription featureDescription = (IIdentifiableElementDescription) element; JvmIdentifiableElement featureCandidate = featureDescription.getElementOrProxy(); if (featureCandidate instanceof JvmExecutable) { JvmExecutable executable = (JvmExecutable) featureCandidate; if(!executable.getParameters().isEmpty()) { StyledString styledString = new StyledString(); proposalProvider.appendParameters(styledString, executable, featureDescription.getNumberOfIrrelevantParameters(), factory); parameterData.addOverloaded(styledString.toString(), executable.isVarArgs()); candidatesFound = true; } } } } if (candidatesFound) { StyledString displayString = proposalProvider.getStyledDisplayString((JvmExecutable) calledFeature, true, 0, qualifiedNameConverter.toString(qualifiedNameProvider.getFullyQualifiedName(calledFeature)), calledFeature.getSimpleName(), factory); ParameterContextInformation parameterContextInformation = new ParameterContextInformation( parameterData, displayString.toString(), getParameterListOffset(containerCall), context.getOffset()); acceptor.accept(parameterContextInformation); } } } }
Example 9
Source File: XbaseProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected ProposalBracketInfo getProposalBracketInfo(IEObjectDescription proposedDescription, ContentAssistContext contentAssistContext) { ProposalBracketInfo info = new ProposalBracketInfo(); if (proposedDescription instanceof IIdentifiableElementDescription) { IIdentifiableElementDescription jvmFeatureDescription = (IIdentifiableElementDescription)proposedDescription; JvmIdentifiableElement jvmFeature = jvmFeatureDescription.getElementOrProxy(); if(jvmFeature instanceof JvmExecutable) { List<JvmFormalParameter> parameters = ((JvmExecutable) jvmFeature).getParameters(); if (jvmFeatureDescription.getNumberOfParameters() == 1) { if (jvmFeature.getSimpleName().startsWith("set") && !proposedDescription.getName().getFirstSegment().startsWith("set")) { info.brackets = " = value"; info.selectionOffset = -"value".length(); info.selectionLength = "value".length(); return info; } JvmTypeReference parameterType = parameters.get(parameters.size()-1).getParameterType(); LightweightTypeReference light = getTypeConverter(contentAssistContext.getResource()).toLightweightReference(parameterType); if(light.isFunctionType()) { int numParameters = light.getAsFunctionTypeReference().getParameterTypes().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"+ (i+1)); } info.brackets = "[" + b.toString() + "|]"; info.caretOffset = -1; info.selectionOffset = -b.length() - 2; info.selectionLength = b.length(); return info; } } } } if (isExplicitOperationCall(jvmFeatureDescription)) { info.brackets = "()"; info.selectionOffset = -1; } } return info; }