org.eclipse.xtext.xbase.XAbstractFeatureCall Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.XAbstractFeatureCall.
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: NewFeatureNameUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected String getBaseName(XExpression expression) { if (expression instanceof XMemberFeatureCall || expression instanceof XFeatureCall) { String featureName = ((XAbstractFeatureCall) expression).getFeature().getSimpleName(); if (featureName.startsWith("get")) return featureName.substring(3); else if (featureName.startsWith("is")) return featureName.substring(2); else return featureName; } if(expression instanceof XClosure) return "function"; LightweightTypeReference type = batchTypeResolver.resolveTypes(expression).getActualType(expression); if (type != null) return type.getSimpleName(); return ""; }
Example #2
Source File: TypeProviderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testParameterizedExtension_03() throws Exception { XtendFile file = file( "package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C<T extends XtendFile> {\n" + " extension ParseHelper<T>\n" + " def m() {" + " parse('')\n" + " }\n" + "}\n"); XtendClass c = (XtendClass) file.getXtendTypes().get(0); XAbstractFeatureCall parse = findSingleFeatureCall(c); assertEquals("org.eclipse.xtext.testing.util.ParseHelper.parse(java.lang.CharSequence)", parse.getFeature().getIdentifier()); assertEquals("T", getType(parse).getSimpleName()); }
Example #3
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testImplicitFirstArgument_05() throws Exception { XtendClass clazz = clazz( "import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " withObject\n" + " }\n" + " extension String" + " def withObject(Object obj) { null }" + "}"); XtendFunction func= (XtendFunction) clazz.getMembers().get(0); XFeatureCall fifth = (XFeatureCall) ((XBlockExpression)func.getExpression()).getExpressions().get(0); JvmOperation fifthFeature = (JvmOperation) fifth.getFeature(); assertEquals("MyXtendClass.withObject(java.lang.Object)", fifthFeature.getIdentifier()); assertEquals(1, fifthFeature.getParameters().size()); assertNotNull(fifth.getImplicitFirstArgument()); assertEquals("it", ((XAbstractFeatureCall) fifth.getImplicitFirstArgument()).getFeature().getSimpleName()); XFeatureCall fifthReceiver = (XFeatureCall) fifth.getImplicitReceiver(); assertTrue(fifthReceiver.getFeature() instanceof JvmGenericType); assertNull(fifth.getInvalidFeatureIssueCode(), fifth.getInvalidFeatureIssueCode()); }
Example #4
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void checkIsValidConstructorArgument(XExpression argument, JvmType containerType) { TreeIterator<EObject> iterator = EcoreUtil2.eAll(argument); while(iterator.hasNext()) { EObject partOfArgumentExpression = iterator.next(); if (partOfArgumentExpression instanceof XFeatureCall || partOfArgumentExpression instanceof XMemberFeatureCall) { XAbstractFeatureCall featureCall = (XAbstractFeatureCall) partOfArgumentExpression; XExpression actualReceiver = featureCall.getActualReceiver(); if(actualReceiver instanceof XFeatureCall && ((XFeatureCall)actualReceiver).getFeature() == containerType) { JvmIdentifiableElement feature = featureCall.getFeature(); if (feature != null && !feature.eIsProxy()) { if (feature instanceof JvmField) { if (!((JvmField) feature).isStatic()) error("Cannot refer to an instance field " + feature.getSimpleName() + " while explicitly invoking a constructor", partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT); } else if (feature instanceof JvmOperation) { if (!((JvmOperation) feature).isStatic()) error("Cannot refer to an instance method while explicitly invoking a constructor", partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT); } } } } else if(isLocalClassSemantics(partOfArgumentExpression)) { iterator.prune(); } } }
Example #5
Source File: XtendHoverSerializer.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public String computeArguments(XAbstractFeatureCall featureCall) { StringBuilder stringBuilder = new StringBuilder("("); if (featureCall != null) { XExpression implicitFirstArgument = featureCall.getImplicitFirstArgument(); List<XExpression> arguments = featureCall.getActualArguments(); if (implicitFirstArgument != null) { XbaseSwitch<String> xbaseSwitch = new XtendHoverXbaseSwitch(); String doSwitch = xbaseSwitch.doSwitch(implicitFirstArgument).trim(); if (doSwitch != null) stringBuilder.append(doSwitch); } int start = implicitFirstArgument != null ? 1 : 0; for(int i = start; i < arguments.size(); i++) { if (i != 0) { stringBuilder.append(SEPARATOR); } XExpression expression = arguments.get(i); ICompositeNode node = NodeModelUtils.findActualNodeFor(expression); if (node != null) stringBuilder.append(node.getText().trim()); } } stringBuilder.append(")"); return stringBuilder.toString(); }
Example #6
Source File: FindReferencesTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testFindReferencesTypeLiteralTwice() throws Exception { createFile("find.references.test/src/Test." + fileExtension, "com.acme.OtherwiseUnused != com.acme.OtherwiseUnused"); waitForBuild(); XtextResourceSet set = get(XtextResourceSet.class); set.setClasspathURIContext(JavaCore.create(project)); Resource resource = set.getResource(URI.createPlatformResourceURI("find.references.test/src/Test." + fileExtension, true), true); // obtain reference to type XBinaryOperation expression = (XBinaryOperation) resource.getContents().get(0); JvmType lookup = (JvmType) ((XAbstractFeatureCall) expression.getLeftOperand()).getFeature(); final MockAcceptor mockAcceptor = new MockAcceptor(); mockAcceptor.expect(expression.getLeftOperand(), lookup, XABSTRACT_FEATURE_CALL__FEATURE); mockAcceptor.expect(expression.getRightOperand(), lookup, XABSTRACT_FEATURE_CALL__FEATURE); findReferencesTester.checkFindReferences(lookup, "Java References to com.acme.OtherwiseUnused", mockAcceptor); }
Example #7
Source File: LinkingShadowingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Test public void testLocalVariable_shadows_parameter() throws Exception { XtendClass clazz = clazz( "class SomeClass {\n" + " def method(String aString) {\n" + " val String aString = null\n" + " aString\n" + " }\n" + "}"); XAbstractFeatureCall featureCall = getFeatureCall(clazz, 1); assertNotNull("feature is available", featureCall.getFeature()); JvmIdentifiableElement linked = featureCall.getFeature(); assertFalse("is resolved", linked.eIsProxy()); assertEquals("aString", linked.getIdentifier()); assertTrue(XbasePackage.Literals.XVARIABLE_DECLARATION.isInstance(linked)); assertNull(featureCall.getInvalidFeatureIssueCode(), featureCall.getInvalidFeatureIssueCode()); }
Example #8
Source File: TypeLiteralLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public TypeLiteralLinkingCandidate( XAbstractFeatureCall featureCall, IIdentifiableElementDescription description, ITypeExpectation expectation, final ExpressionTypeComputationState state) { super(featureCall, description, expectation, state, new TypeLiteralLinkingCandidateResolver(featureCall) { @Override protected IFeatureLinkingCandidate getLinkingCandidate(XExpression target) { return state.getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) target); } }); if (featureCall.isExplicitOperationCallOrBuilderSyntax()) { throw new IllegalArgumentException("Cannot be a type literal: " + String.valueOf(featureCall)); } this.helper = new TypeLiteralHelper(state); }
Example #9
Source File: ConstantExpressionValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public boolean isConstant(final XExpression expression) { if (expression instanceof XAbstractFeatureCall) { return _isConstant((XAbstractFeatureCall)expression); } else if (expression instanceof XBooleanLiteral) { return _isConstant((XBooleanLiteral)expression); } else if (expression instanceof XCastedExpression) { return _isConstant((XCastedExpression)expression); } else if (expression instanceof XNumberLiteral) { return _isConstant((XNumberLiteral)expression); } else if (expression instanceof XStringLiteral) { return _isConstant((XStringLiteral)expression); } else if (expression instanceof XTypeLiteral) { return _isConstant((XTypeLiteral)expression); } else if (expression != null) { return _isConstant(expression); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(expression).toString()); } }
Example #10
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected boolean inlineCallNeedsParenthesis(XAbstractFeatureCall call, String formatString) { String trimmedFormatString = formatString.trim(); if (trimmedFormatString.startsWith("(")) { return false; } if (call.eContainer() instanceof XMemberFeatureCall && call.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) { XMemberFeatureCall mfc = (XMemberFeatureCall) call.eContainer(); JvmAnnotationReference inlineAnnotation = expressionHelper.findInlineAnnotation(mfc); if (inlineAnnotation != null) { return true; } if (mfc.isExtension()) { return false; } return !trimmedFormatString.endsWith(")"); } return false; }
Example #11
Source File: AbstractOverloadedStaticMethodTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void linksTo(final String invocation, final String method) { try { final XtendFile file = this.file(this.inMethodBody(invocation), false); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass c = ((XtendClass) _head); XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers()); final XtendFunction m = ((XtendFunction) _head_1); XExpression _expression = m.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions()); final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file); final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType()); final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester); Assert.assertEquals(method, resolved.getSimpleSignature()); Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty()); Assert.assertNull(featureCall.getImplicitReceiver()); Assert.assertNull(featureCall.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #12
Source File: Utils.java From sarl with Apache License 2.0 | 6 votes |
/** Replies the root feature call into a sequence of feature calls that has * not reference to elements declared within the container, and that are * not one of the container's parameters. * * @param featureCall the leaf feature call. * @param container the container of the feature call. * @param containerParameters the parameters of the container. * @return the root feature call, or {@code null} if there is no root feature call. * @since 0.8.6 * @see #getRootFeatureCall(XAbstractFeatureCall) */ public static XAbstractFeatureCall getRootFeatureCall(XAbstractFeatureCall featureCall, XExpression container, List<JvmFormalParameter> containerParameters) { if (hasLocalParameters(featureCall, container, containerParameters) || !(featureCall instanceof XMemberFeatureCall || featureCall instanceof XFeatureCall)) { return null; } XAbstractFeatureCall current = featureCall; EObject currentContainer = current.eContainer(); while (currentContainer != null) { if (currentContainer instanceof XMemberFeatureCall || currentContainer instanceof XFeatureCall) { final XAbstractFeatureCall c = (XAbstractFeatureCall) currentContainer; if (hasLocalParameters(c, container, containerParameters)) { return current; } current = c; currentContainer = current.eContainer(); } else { return current; } } return current; }
Example #13
Source File: CreateMemberQuickfixes.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected LightweightTypeReference getReceiverType(XAbstractFeatureCall featureCall) { XExpression actualReceiver = featureCall.getActualReceiver(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, featureCall); if (actualReceiver == null) { JvmDeclaredType callersType = getCallersType(featureCall); if (callersType != null) return owner.newParameterizedTypeReference(callersType); } else if (actualReceiver instanceof XAbstractFeatureCall && ((XAbstractFeatureCall) actualReceiver).isTypeLiteral()) { JvmType type = (JvmType) ((XAbstractFeatureCall) actualReceiver).getFeature(); ParameterizedTypeReference reference = owner.newParameterizedTypeReference(type); return reference; } else { LightweightTypeReference typeRef = typeResolver.resolveTypes(featureCall).getActualType(actualReceiver); if(typeRef != null && typeRef.getType() instanceof JvmDeclaredType) return typeRef; } return null; }
Example #14
Source File: FeatureLinkHelper.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public XExpression getSyntacticReceiver(XExpression expression) { if (expression instanceof XAbstractFeatureCall) { if (expression instanceof XFeatureCall) { return null; } if (expression instanceof XMemberFeatureCall) { return ((XMemberFeatureCall) expression).getMemberCallTarget(); } if (expression instanceof XAssignment) { return ((XAssignment) expression).getAssignable(); } if (expression instanceof XBinaryOperation) { return ((XBinaryOperation) expression).getLeftOperand(); } if (expression instanceof XUnaryOperation) { return ((XUnaryOperation) expression).getOperand(); } if (expression instanceof XPostfixOperation) { return ((XPostfixOperation) expression).getOperand(); } } return null; }
Example #15
Source File: TypeLiteralLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected void preApply() { XAbstractFeatureCall expression = getExpression(); JvmType type = getType(); if (expression instanceof XMemberFeatureCall) { if (type instanceof JvmDeclaredType) { JvmDeclaredType declaredType = (JvmDeclaredType) type; if (declaredType.getDeclaringType() == null) { helper.applyPackageFragment((XMemberFeatureCall) expression, declaredType); } else { String queriedName = description.getName().toString(); // may be Map$Entry String qualifiedName = declaredType.getIdentifier(); String packageName = Strings.emptyIfNull(declaredType.getPackageName()); if (packageName.length() + 1 + queriedName.length() == qualifiedName.length()) { helper.applyPackageFragment((XMemberFeatureCall) expression, declaredType); } } } } }
Example #16
Source File: XbaseIdeContentProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void createReceiverProposals(final XExpression receiver, final CrossReference crossReference, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) { final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(receiver); final LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver); if (((receiverType == null) || receiverType.isPrimitiveVoid())) { return; } final IExpressionScope expressionScope = resolvedTypes.getExpressionScope(receiver, IExpressionScope.Anchor.RECEIVER); IScope scope = null; final EObject currentModel = context.getCurrentModel(); if ((currentModel != receiver)) { if (((currentModel instanceof XMemberFeatureCall) && (((XMemberFeatureCall) currentModel).getMemberCallTarget() == receiver))) { scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(((XAbstractFeatureCall) currentModel)), crossReference); } else { scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(), crossReference); } } else { scope = this.syntaxFilteredScopes.create(expressionScope.getFeatureScope(), crossReference); } this.getCrossrefProposalProvider().lookupCrossReference(scope, crossReference, context, acceptor, this.featureDescriptionPredicate); }
Example #17
Source File: ResolvedTypeLiteral.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected ResolvedTypeLiteral( XAbstractFeatureCall featureCall, JvmIdentifiableElement resolvedElement, ITypeExpectation expectation, ExpressionTypeComputationState state) { super(featureCall, resolvedElement, expectation, state); this.helper = new TypeLiteralHelper(state); }
Example #18
Source File: FeatureLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isAssignmentOrMemberFeatureCall() { if (getImplicitReceiverType() != null) return true; XAbstractFeatureCall featureCall = getFeatureCall(); if (featureCall instanceof XAssignment) { return isSimpleAssignment((XAssignment) featureCall); } return featureCall instanceof XMemberFeatureCall; }
Example #19
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testImplicitThis_1() throws Exception { XBlockExpression bop = (XBlockExpression) expression( "{ " + " val this = new java.util.ArrayList<String>(); " + " size;" + "}"); final XFeatureCall xFeatureCall = (XFeatureCall)bop.getExpressions().get(1); assertEquals("java.util.ArrayList.size()",xFeatureCall.getFeature().getIdentifier()); assertSame(bop.getExpressions().get(0), ((XAbstractFeatureCall)xFeatureCall.getImplicitReceiver()).getFeature()); }
Example #20
Source File: FeatureLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private boolean isStaticWithDeclaringType(XExpression syntacticReceiver) { if (isStatic() && syntacticReceiver instanceof XAbstractFeatureCall && !isExtension()) { IFeatureLinkingCandidate candidate = getState().getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) syntacticReceiver); if (candidate != null && candidate.isTypeLiteral()) { return true; } } return false; }
Example #21
Source File: LinkingShadowingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testOperation_sugarImplicitArgumentOnExtension_shadows_sugarOnStaticExtension() throws Exception { XtendClass clazz = clazz( "import static extension testdata.LinkingStaticTypeEquallyNamed.*" + "class SomeClass {\n" + " def void method(Object it) {\n" + " withArgument2\n" + " }" + " extension testdata.LinkingType\n" + "}"); XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz); assertLinksTo("testdata.LinkingType.getWithArgument2(java.lang.Object)", featureCall); }
Example #22
Source File: ImportsCollector.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void visit(final EObject jvmType, final INode originNode, final ImportsAcceptor acceptor) { if (jvmType instanceof JvmGenericType) { _visit((JvmGenericType)jvmType, originNode, acceptor); return; } else if (jvmType instanceof JvmDeclaredType) { _visit((JvmDeclaredType)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XFeatureCall) { _visit((XFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XMemberFeatureCall) { _visit((XMemberFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XAbstractFeatureCall) { _visit((XAbstractFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XConstructorCall) { _visit((XConstructorCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XTypeLiteral) { _visit((XTypeLiteral)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XAnnotation) { _visit((XAnnotation)jvmType, originNode, acceptor); return; } else if (jvmType instanceof JvmTypeReference) { _visit((JvmTypeReference)jvmType, originNode, acceptor); return; } else if (jvmType != null) { _visit(jvmType, originNode, acceptor); return; } else if (jvmType == null) { _visit((Void)null, originNode, acceptor); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(jvmType, originNode, acceptor).toString()); } }
Example #23
Source File: CompoundReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public IFeatureLinkingCandidate getLinkingCandidate(/* @Nullable */ XAbstractFeatureCall featureCall) { if (featureCall == null) return null; IResolvedTypes delegate = getDelegate(featureCall); return delegate.getLinkingCandidate(featureCall); }
Example #24
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XExpression> getActualArguments(final XAbstractFeatureCall expr) { List<XExpression> actualArguments = expr.getActualArguments(); return Lists.transform(actualArguments, new Function<XExpression, XExpression>() { @Override public XExpression apply(XExpression e) { return normalizeBlockExpression(e); } }); }
Example #25
Source File: UnresolvableFeatureCall.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public List<LightweightTypeReference> getTypeArguments() { XAbstractFeatureCall featureCall = getFeatureCall(); List<JvmTypeReference> typeArguments = featureCall.getTypeArguments(); if (typeArguments.isEmpty()) return Collections.emptyList(); List<LightweightTypeReference> result = Lists.newArrayList(); for(JvmTypeReference typeArgument: typeArguments) { result.add(getState().getReferenceOwner().toLightweightTypeReference(typeArgument)); } return result; }
Example #26
Source File: TypeProviderTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testParameterizedExtension_07() throws Exception { XtendFile file = file( "package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C<F extends XtendFile> extends ParseHelper<F> {\n" + " def m() {" + " ''.parse\n" + " }\n" + "}\n"); XtendClass c = (XtendClass) file.getXtendTypes().get(0); XAbstractFeatureCall parse = findSingleFeatureCall(c); assertEquals("org.eclipse.xtext.testing.util.ParseHelper.parse(java.lang.CharSequence)", parse.getFeature().getIdentifier()); assertEquals("F", getType(parse).getSimpleName()); }
Example #27
Source File: LinkingShadowingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testField_noConflicts_protectedOnIt() throws Exception { XtendClass clazz = clazz( "class SomeClass {\n" + " def method(testdata.LinkingType it) {\n" + " protectedField\n" + " }\n" + "}"); XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz); assertLinksTo("testdata.LinkingType.protectedField", featureCall, true); }
Example #28
Source File: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected QualifiedName getOperator(XAbstractFeatureCall call, QualifiedName name) { QualifiedName operator = operatorMapping.getOperator(name); if (!(call instanceof XBinaryOperation)) { return operator; } XBinaryOperation binaryOperation = (XBinaryOperation) call; if (!binaryOperation.isReassignFirstArgument()) { return operator; } if (operatorMapping.getCompoundOperators().contains(operator)) { return operator; } return operatorMapping.getCompoundOperator(operator); }
Example #29
Source File: XExpressionHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public boolean hasSideEffects(XAbstractFeatureCall featureCall, boolean inspectContents) { if (featureCall instanceof XBinaryOperation) { XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; if (binaryOperation.isReassignFirstArgument()) { return true; } } if (featureCall instanceof XAssignment) { return true; } if (featureCall.isPackageFragment() || featureCall.isTypeLiteral()) { return false; } final JvmIdentifiableElement feature = featureCall.getFeature(); if (feature == null || feature.eIsProxy()) return true; // linking problems ... could be anything if (feature instanceof JvmConstructor) { //super() and this() return true; } if (feature instanceof JvmOperation) { JvmOperation jvmOperation = (JvmOperation) feature; if (findPureAnnotation(jvmOperation) == null) { return true; } else { if(inspectContents) { for (XExpression param : featureCall.getActualArguments()) { if (hasSideEffects(param)) return true; } } } } return false; }
Example #30
Source File: XtendHoverGenericsResolverTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testGenerics_1() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package testPackage"); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("def bar(){"); _builder.newLine(); _builder.append("\t\t"); _builder.append("newArrayList(\"sd\").something"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def <T> T something(Iterable<T> iterable)"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet()); final Iterable<XtendClass> clazz = Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class); XtendMember _get = IterableExtensions.<XtendClass>head(clazz).getMembers().get(0); final XtendFunction function = ((XtendFunction) _get); XExpression _expression = function.getExpression(); final XBlockExpression expression = ((XBlockExpression) _expression); XExpression _get_1 = expression.getExpressions().get(0); final XAbstractFeatureCall call = ((XAbstractFeatureCall) _get_1); final String resolvedSignature = this.signatureProvider.getSignature(call); Assert.assertEquals("<String> String Foo.something(Iterable<String> iterable)", resolvedSignature); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }