org.eclipse.xtend.lib.macro.declaration.InterfaceDeclaration Java Examples
The following examples show how to use
org.eclipse.xtend.lib.macro.declaration.InterfaceDeclaration.
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: JsonRpcDataTransformationContext.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
public TypeReference getRightType(final TypeReference typeReference) { final Type type = typeReference.getType(); Type _type = this.eitherType.getType(); boolean _tripleEquals = (type == _type); if (_tripleEquals) { return IterableExtensions.<TypeReference>last(typeReference.getActualTypeArguments()); } if ((type instanceof InterfaceDeclaration)) { final Function1<TypeReference, TypeReference> _function = (TypeReference it) -> { return this.getRightType(it); }; return IterableExtensions.<TypeReference>head(IterableExtensions.<TypeReference>filterNull(IterableExtensions.map(((InterfaceDeclaration)type).getExtendedInterfaces(), _function))); } return null; }
Example #2
Source File: JsonRpcDataTransformationContext.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
public TypeReference getLeftType(final TypeReference typeReference) { final Type type = typeReference.getType(); Type _type = this.eitherType.getType(); boolean _tripleEquals = (type == _type); if (_tripleEquals) { return IterableExtensions.<TypeReference>head(typeReference.getActualTypeArguments()); } if ((type instanceof InterfaceDeclaration)) { final Function1<TypeReference, TypeReference> _function = (TypeReference it) -> { return this.getLeftType(it); }; return IterableExtensions.<TypeReference>head(IterableExtensions.<TypeReference>filterNull(IterableExtensions.map(((InterfaceDeclaration)type).getExtendedInterfaces(), _function))); } return null; }
Example #3
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
public Set<TypeReference> getImplementedInterfaces(final TypeReference it) { Set<TypeReference> _xblockexpression = null; { final LinkedHashSet<TypeReference> seen = CollectionLiterals.<TypeReference>newLinkedHashSet(); this.collectAllSuperTypes(it, seen); final Function1<TypeReference, Boolean> _function = (TypeReference it_1) -> { Type _type = it_1.getType(); return Boolean.valueOf((_type instanceof InterfaceDeclaration)); }; _xblockexpression = IterableExtensions.<TypeReference>toSet(IterableExtensions.<TypeReference>filter(seen, _function)); } return _xblockexpression; }
Example #4
Source File: TypeLookupImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public InterfaceDeclaration findSourceInterface(final String qualifiedName) { final XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> type = this.findSourceType(qualifiedName); XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _switchResult = null; boolean _matched = false; if (type instanceof InterfaceDeclaration) { _matched=true; _switchResult = ((XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>)type); } return ((InterfaceDeclaration)_switchResult); }
Example #5
Source File: RegisterGlobalsContextImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public InterfaceDeclaration findSourceInterface(final String qualifiedName) { return this.getTypeLookup().findSourceInterface(qualifiedName); }
Example #6
Source File: MutableJvmInterfaceDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableInterfaceDeclaration> getDeclaredInterfaces() { Iterable<? extends InterfaceDeclaration> _declaredInterfaces = super.getDeclaredInterfaces(); return ((Iterable<? extends MutableInterfaceDeclaration>) _declaredInterfaces); }
Example #7
Source File: XtendTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends InterfaceDeclaration> getDeclaredInterfaces() { return Iterables.<InterfaceDeclaration>filter(this.getDeclaredMembers(), InterfaceDeclaration.class); }
Example #8
Source File: MutableJvmEnumerationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableInterfaceDeclaration> getDeclaredInterfaces() { Iterable<? extends InterfaceDeclaration> _declaredInterfaces = super.getDeclaredInterfaces(); return ((Iterable<? extends MutableInterfaceDeclaration>) _declaredInterfaces); }
Example #9
Source File: XtendMethodDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public boolean isDefault() { return (((!this.getDelegate().isStatic()) && (this.getDelegate().getExpression() != null)) && (this.getDeclaringType() instanceof InterfaceDeclaration)); }
Example #10
Source File: JvmTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public Iterable<? extends InterfaceDeclaration> getDeclaredInterfaces() { return Iterables.<InterfaceDeclaration>filter(this.getDeclaredMembers(), InterfaceDeclaration.class); }
Example #11
Source File: MutableJvmClassDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableInterfaceDeclaration> getDeclaredInterfaces() { Iterable<? extends InterfaceDeclaration> _declaredInterfaces = super.getDeclaredInterfaces(); return ((Iterable<? extends MutableInterfaceDeclaration>) _declaredInterfaces); }
Example #12
Source File: MutableJvmAnnotationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableInterfaceDeclaration> getDeclaredInterfaces() { Iterable<? extends InterfaceDeclaration> _declaredInterfaces = super.getDeclaredInterfaces(); return ((Iterable<? extends MutableInterfaceDeclaration>) _declaredInterfaces); }
Example #13
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testIsAssignable() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package foo"); _builder.newLine(); _builder.newLine(); _builder.append("class BaseClass implements InterfaceA {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("class SubType extends BaseClass implements InterfaceA {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("interface InterfaceA {}"); _builder.newLine(); _builder.append("interface InterfaceB {}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { TypeDeclaration _get = ((TypeDeclaration[])Conversions.unwrapArray(it.getSourceTypeDeclarations(), TypeDeclaration.class))[0]; final ClassDeclaration baseClass = ((ClassDeclaration) _get); final MutableClassDeclaration subClass = it.getTypeLookup().findClass("foo.SubType"); TypeDeclaration _get_1 = ((TypeDeclaration[])Conversions.unwrapArray(it.getSourceTypeDeclarations(), TypeDeclaration.class))[2]; final InterfaceDeclaration interfaceA = ((InterfaceDeclaration) _get_1); TypeDeclaration _get_2 = ((TypeDeclaration[])Conversions.unwrapArray(it.getSourceTypeDeclarations(), TypeDeclaration.class))[3]; final InterfaceDeclaration interfaceB = ((InterfaceDeclaration) _get_2); final Type object = it.getTypeReferenceProvider().getObject().getType(); Assert.assertTrue(object.isAssignableFrom(baseClass)); Assert.assertTrue(object.isAssignableFrom(subClass)); Assert.assertTrue(object.isAssignableFrom(interfaceA)); Assert.assertTrue(object.isAssignableFrom(interfaceB)); Assert.assertTrue(baseClass.isAssignableFrom(baseClass)); Assert.assertTrue(baseClass.isAssignableFrom(subClass)); Assert.assertFalse(baseClass.isAssignableFrom(interfaceB)); Assert.assertFalse(baseClass.isAssignableFrom(interfaceA)); Assert.assertFalse(baseClass.isAssignableFrom(object)); Assert.assertTrue(interfaceA.isAssignableFrom(baseClass)); Assert.assertTrue(interfaceA.isAssignableFrom(subClass)); Assert.assertTrue(interfaceA.isAssignableFrom(interfaceA)); Assert.assertFalse(interfaceA.isAssignableFrom(interfaceB)); Assert.assertFalse(interfaceA.isAssignableFrom(object)); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #14
Source File: CheckMutableInterfaceDeclarationProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public void doRegisterGlobals(final List<? extends InterfaceDeclaration> annotatedSourceElements, final RegisterGlobalsContext context) { }
Example #15
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testXtendInterfaceWithDefaultMethod() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package p"); _builder.newLine(); _builder.newLine(); _builder.append("interface MyIntf {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def String dflt() { \"\" }"); _builder.newLine(); _builder.append("\t"); _builder.append("def String abstrct()"); _builder.newLine(); _builder.append("\t"); _builder.append("def static String statc() { \"\" }"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { Assert.assertEquals("p", it.getPackageName()); TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations()); final InterfaceDeclaration intf = ((InterfaceDeclaration) _head); Assert.assertEquals("p.MyIntf", intf.getQualifiedName()); Assert.assertTrue(IterableExtensions.isEmpty(intf.getExtendedInterfaces())); Assert.assertEquals(3, IterableExtensions.size(intf.getDeclaredMembers())); final MethodDeclaration dflt = IterableExtensions.head(intf.getDeclaredMethods()); Assert.assertTrue(dflt.isDefault()); Assert.assertFalse(dflt.isAbstract()); final MethodDeclaration abstract_ = ((MethodDeclaration[])Conversions.unwrapArray(intf.getDeclaredMethods(), MethodDeclaration.class))[1]; Assert.assertFalse(abstract_.isDefault()); Assert.assertTrue(abstract_.isAbstract()); final MethodDeclaration static_ = ((MethodDeclaration[])Conversions.unwrapArray(intf.getDeclaredMethods(), MethodDeclaration.class))[2]; Assert.assertFalse(static_.isDefault()); Assert.assertFalse(static_.isAbstract()); Assert.assertTrue(static_.isStatic()); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #16
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
public void doValidate(List<? extends InterfaceDeclaration> annotatedInterfaces, @Extension ValidationContext context) { for (InterfaceDeclaration annotatedInterface : annotatedInterfaces) { doValidate(annotatedInterface, context); } }
Example #17
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
public void doGenerateCode(List<? extends InterfaceDeclaration> annotatedSourceElements, @Extension CodeGenerationContext context) { for (InterfaceDeclaration annotatedInterface : annotatedSourceElements) { doGenerateCode(annotatedInterface, context); } }
Example #18
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
public void doRegisterGlobals(List<? extends InterfaceDeclaration> annotatedInterfaces, @Extension RegisterGlobalsContext context) { for (InterfaceDeclaration annotatedInterface : annotatedInterfaces) { doRegisterGlobals(annotatedInterface, context); } }
Example #19
Source File: SourceTypeLookup.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * @param qualifiedName * the qualified name of the type to look up. Nested class delimiter is expected to be the '.' (dot). * @return the <code>InterfaceDeclaration</code> with given qualified * name, or <code>null</code> if no such interface declaration is * contained in the currently processed <code>CompilationUnit</code> */ InterfaceDeclaration findSourceInterface(String qualifiedName);
Example #20
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * Invoked by the validator * @param annotatedInterface the generated interface that should be validated * @param context * @see #doValidate(List, ValidationContext) * @since 2.7 */ public void doValidate(InterfaceDeclaration annotatedInterface, @Extension ValidationContext context) {}
Example #21
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * Called during code generation. * * @param annotatedInterface a source element annotated with the annotation this processor is responsible for. * @param context * @see CodeGenerationParticipant#doGenerateCode(List, CodeGenerationContext) */ public void doGenerateCode(InterfaceDeclaration annotatedInterface, @Extension CodeGenerationContext context) {}
Example #22
Source File: AbstractInterfaceProcessor.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * Called during global symbol collecting. * * @param annotatedInterface a source element annotated with the annotation this processor is responsible for. * @param context */ public void doRegisterGlobals(InterfaceDeclaration annotatedInterface, @Extension RegisterGlobalsContext context) {}