Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#isFunctionType()
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#isFunctionType() .
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: SourceAppenderWithTypeMapping.java From sarl with Apache License 2.0 | 6 votes |
@Override public ISourceAppender append(LightweightTypeReference typeRef) { if (typeRef.isFunctionType()) { final FunctionTypeReference functionReference = typeRef.getAsFunctionTypeReference(); this.source.append(this.keywords.getLeftParenthesisKeyword()); boolean first = true; for (final LightweightTypeReference parameter : functionReference.getParameterTypes()) { if (first) { first = false; } else { this.source.append(","); //$NON-NLS-1$ } append(parameter); } this.source.append(this.keywords.getRightParenthesisKeyword()); this.source.append(this.keywords.getEqualsSignGreaterThanSignKeyword()); append(functionReference.getReturnType()); return this; } this.source.append(typeRef); return this; }
Example 2
Source File: XbaseIdeCrossrefProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReferenceFactory getTypeConverter(XtextResource context) { return new LightweightTypeReferenceFactory(new StandardTypeReferenceOwner(typeComputationServices, context)) { @Override public LightweightTypeReference doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { LightweightTypeReference result = super.doVisitParameterizedTypeReference(reference); if (result.isFunctionType()) { return result.tryConvertToFunctionTypeReference(false); } return result; } }; }
Example 3
Source File: XtypeProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReferenceFactory getTypeConverter(XtextResource context) { return new LightweightTypeReferenceFactory(new StandardTypeReferenceOwner(services, context)) { @Override public LightweightTypeReference doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { LightweightTypeReference result = super.doVisitParameterizedTypeReference(reference); if (result.isFunctionType()) { FunctionTypeReference functionTypeReference = result.tryConvertToFunctionTypeReference(false); return functionTypeReference; } return result; } }; }
Example 4
Source File: XbaseIdeCrossrefProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected ProposalBracketInfo getProposalBracketInfo(IEObjectDescription proposedDescription, ContentAssistContext contentAssistContext) { ProposalBracketInfo info = new ProposalBracketInfo(); if (proposedDescription instanceof IIdentifiableElementDescription) { JvmIdentifiableElement jvmFeature = ((IIdentifiableElementDescription) proposedDescription) .getElementOrProxy(); if (jvmFeature instanceof JvmExecutable) { List<JvmFormalParameter> parameters = ((JvmExecutable) jvmFeature).getParameters(); if (((IIdentifiableElementDescription) proposedDescription).getNumberOfParameters() == 1) { if (((JvmExecutable) jvmFeature).getSimpleName().startsWith("set") && !((IIdentifiableElementDescription) proposedDescription).getName().getFirstSegment() .startsWith("set")) { info.brackets = " = value"; info.selectionOffset = -"value".length(); info.selectionLength = "value".length(); return info; } JvmTypeReference parameterType = IterableExtensions.<JvmFormalParameter>last(parameters) .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 { 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((IIdentifiableElementDescription) proposedDescription)) { info.brackets = "()"; info.selectionOffset = -1; } } return info; }
Example 5
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; }