Java Code Examples for org.eclipse.xtext.xbase.XMemberFeatureCall#getFeature()
The following examples show how to use
org.eclipse.xtext.xbase.XMemberFeatureCall#getFeature() .
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: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_11() throws Exception { XtendFile file = file( "import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var Integer i = 0\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloadedInt(i)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(2); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloadedInt(java.lang.Integer)", overloaded.getIdentifier()); }
Example 2
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testExplicitTypeOverSugar_02() throws Exception { XtendFile file = file( "import static extension org.eclipse.emf.ecore.util.EcoreUtil.*\n" + "import org.eclipse.emf.ecore.EObject\n" + "import org.eclipse.emf.common.util.URI\n" + "\n" + "class C {\n" + " def m(EObject it) {\n" + " URI.appendFragment(\"someString\")\n" + " }\n" + "}"); XtendClass c = (XtendClass) file.getXtendTypes().get(0); XtendFunction m = (XtendFunction) c.getMembers().get(0); XBlockExpression body = (XBlockExpression) m.getExpression(); XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0); JvmIdentifiableElement method = featureCall.getFeature(); assertEquals("org.eclipse.emf.common.util.URI.appendFragment(java.lang.String)", method.getIdentifier()); assertFalse(featureCall.isStaticWithDeclaringType()); XFeatureCall target = (XFeatureCall) featureCall.getMemberCallTarget(); assertFalse(target.isTypeLiteral()); assertEquals("org.eclipse.emf.ecore.util.EcoreUtil.getURI(org.eclipse.emf.ecore.EObject)", target.getFeature().getIdentifier()); }
Example 3
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_15() throws Exception { XtendFile file = file( "import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<T> collection, Iterable<? extends T> elements) {\n" + " collection.addAll(elements)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0); JvmIdentifiableElement addAll = featureCall.getFeature(); assertNotNull(addAll); assertFalse(addAll.eIsProxy()); assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.addAll(java.util.Collection,java.lang.Iterable)", addAll.getIdentifier()); }
Example 4
Source File: OrderSensitivityTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void doTestClosureMethodAndExpect(final String declarator, final String expression, final String expectation) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("new "); _builder.append(declarator); _builder.append("().run [| "); _builder.append(expression); _builder.append(" ]"); XExpression _expression = this.expression(_builder); final XMemberFeatureCall featureCall = ((XMemberFeatureCall) _expression); final JvmIdentifiableElement feature = featureCall.getFeature(); Assert.assertNotNull("feature is not null", feature); Assert.assertFalse("feature is resolved", feature.eIsProxy()); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append(declarator); _builder_1.append(".run("); _builder_1.append(declarator); _builder_1.append("$"); _builder_1.append(expectation); _builder_1.append(")"); Assert.assertEquals(_builder_1.toString(), feature.getIdentifier()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 5
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_06() throws Exception { XtendFile file = file( "import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<CharSequence> chars = null\n" + " var List<String> strings = null\n" + " var testdata.OverloadedMethods<CharSequence> receiver = null\n" + " receiver.overloaded2(strings, chars)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(3); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded2(java.lang.Iterable,java.util.Collection)", overloaded.getIdentifier()); }
Example 6
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_12() throws Exception { XtendFile file = file( "import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<? super T> collection, Collection<T> elements) {\n" + " collection.addAll(elements)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0); JvmIdentifiableElement addAll = featureCall.getFeature(); assertNotNull(addAll); assertFalse(addAll.eIsProxy()); assertEquals("java.util.Collection.addAll(java.util.Collection)", addAll.getIdentifier()); }
Example 7
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_08() throws Exception { XtendFile file = file( "import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<? extends Object> objects = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded2(objects, objects)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(2); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded2(java.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier()); }
Example 8
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_20() throws Exception { XtendFile file = file( "import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<T> collection, T head) {\n" + " collection.addAll(head)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0); JvmIdentifiableElement addAll = featureCall.getFeature(); assertNotNull(addAll); assertFalse(addAll.eIsProxy()); assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.addAll(java.util.Collection,T[])", addAll.getIdentifier()); }
Example 9
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_21() throws Exception { XtendFile file = file( "import java.util.Collection\n" + "class X {\n" + " def <T> foo(Collection<T> collection, Iterable<? extends T> elements) {\n" + " val t = elements.head\n" + " collection.addAll(t)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(1); JvmIdentifiableElement addAll = featureCall.getFeature(); assertNotNull(addAll); assertFalse(addAll.eIsProxy()); assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.addAll(java.util.Collection,T[])", addAll.getIdentifier()); }
Example 10
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testExplicitTypeOverSugar_01() throws Exception { XtendFile file = file( "import static extension org.eclipse.emf.ecore.util.EcoreUtil.*\n" + "import org.eclipse.emf.ecore.EObject\n" + "import org.eclipse.emf.common.util.URI\n" + "\n" + "class C {\n" + " def m(EObject it) {\n" + " URI::createURI(\"someString\")\n" + " }\n" + "}"); XtendClass c = (XtendClass) file.getXtendTypes().get(0); XtendFunction m = (XtendFunction) c.getMembers().get(0); XBlockExpression body = (XBlockExpression) m.getExpression(); XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0); JvmIdentifiableElement method = featureCall.getFeature(); assertEquals("org.eclipse.emf.common.util.URI.createURI(java.lang.String)", method.getIdentifier()); assertTrue(featureCall.isStaticWithDeclaringType()); XFeatureCall target = (XFeatureCall) featureCall.getMemberCallTarget(); assertTrue(target.isTypeLiteral()); assertEquals("org.eclipse.emf.common.util.URI", target.getFeature().getIdentifier()); }
Example 11
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testOverloadedMethods_01() throws Exception { XtendFile file = file( "import java.util.List\n" + "class X {\n" + " def foo() {\n" + " var List<CharSequence> chars = null\n" + " var List<String> strings = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(chars, strings)\n" + " }\n" + "}"); XtendClass clazz = (XtendClass) file.getXtendTypes().get(0); XtendFunction func = (XtendFunction) clazz.getMembers().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(3); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded(java.util.Collection,java.lang.Iterable)", overloaded.getIdentifier()); }
Example 12
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverloadedMethods_05() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var java.util.List<?> any = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(any, any)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(2); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded(java.lang.Iterable,java.lang.Iterable)", overloaded.getIdentifier()); }
Example 13
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverloadedMethods_06() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var java.util.List<CharSequence> chars = null\n" + " var java.util.List<String> strings = null\n" + " var testdata.OverloadedMethods<CharSequence> receiver = null\n" + " receiver.overloaded2(chars, strings)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(3); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded2(java.util.Collection,java.lang.Iterable)", overloaded.getIdentifier()); }
Example 14
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkExplicitOperationCall(XMemberFeatureCall featureCall) { if (featureCall.getFeature() instanceof JvmOperation && !featureCall.isExplicitOperationCallOrBuilderSyntax() && featureCall.getFeature().getSimpleName().equals(featureCall.getConcreteSyntaxFeatureName())) { addIssue("Method call without parentheses", featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, OPERATION_WITHOUT_PARENTHESES); } }
Example 15
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverloadedMethods_08() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var java.util.List<String> strings = null\n" + " var testdata.OverloadedMethods<String> receiver = null\n" + " receiver.overloaded2(strings, strings)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(2); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded2(java.util.List,java.util.List)", overloaded.getIdentifier()); }
Example 16
Source File: LinkingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testExplicitStaticInvocation_01() throws Exception { XtendFile file = file( "class C {\n" + " static def void getFields() {\n" + " C::fields" + " }" + "}\n"); XtendClass c = (XtendClass) file.getXtendTypes().get(0); XtendFunction m = (XtendFunction) c.getMembers().get(0); XBlockExpression body = (XBlockExpression) m.getExpression(); XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0); JvmIdentifiableElement method = featureCall.getFeature(); assertEquals("C.getFields()", method.getIdentifier()); }
Example 17
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverloadedMethods_02() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var java.util.List<CharSequence> chars = null\n" + " var java.util.List<String> strings = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(strings, chars)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(3); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded(java.lang.Iterable,java.util.Collection)", overloaded.getIdentifier()); }
Example 18
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBoxingUnboxing_01() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var int i = 0\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloadedInt(i)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(2); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloadedInt(int)", overloaded.getIdentifier()); }
Example 19
Source File: AbstractXbaseLinkingTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverloadedMethods_01() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{\n" + " var java.util.List<CharSequence> chars = null\n" + " var java.util.List<String> strings = null\n" + " var testdata.OverloadedMethods<Object> receiver = null\n" + " receiver.overloaded(chars, strings)\n" + "}"); XMemberFeatureCall featureCall = (XMemberFeatureCall) block.getExpressions().get(3); JvmIdentifiableElement overloaded = featureCall.getFeature(); assertNotNull(overloaded); assertFalse(overloaded.eIsProxy()); assertEquals("testdata.OverloadedMethods.overloaded(java.util.Collection,java.lang.Iterable)", overloaded.getIdentifier()); }
Example 20
Source File: ResolvedOperationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public IResolvedOperation toOperation(final String expression) { try { XExpression _expression = this.expression(expression); final XMemberFeatureCall featureCall = ((XMemberFeatureCall) _expression); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(featureCall); final LightweightTypeReference receiverType = resolvedTypes.getActualType(featureCall.getMemberCallTarget()); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); Assert.assertFalse(operation.eIsProxy()); return new BottomResolvedOperation(operation, receiverType, this.overrideTester); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }