Java Code Examples for javax.lang.model.element.NestingKind#MEMBER
The following examples show how to use
javax.lang.model.element.NestingKind#MEMBER .
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: InferredTypeElement.java From buck with Apache License 2.0 | 5 votes |
@Override public NestingKind getNestingKind() { // We'll never need to infer local or anonymous classes, so there are only two options left // and we can tell the difference: if (getEnclosingElement() instanceof InferredTypeElement) { return NestingKind.MEMBER; } return NestingKind.TOP_LEVEL; }
Example 2
Source File: InitializerCanBeStatic.java From netbeans with Apache License 2.0 | 5 votes |
@TriggerTreeKind(Tree.Kind.BLOCK) public static ErrorDescription run(HintContext ctx) { TreePath path = ctx.getPath(); if (((BlockTree)path.getLeaf()).isStatic()) { return null; } TreePath parentPath = path.getParentPath(); if (parentPath == null) { return null; } Tree l = parentPath.getLeaf(); if (!(l instanceof ClassTree)) { return null; } Element el = ctx.getInfo().getTrees().getElement(parentPath); if (el == null || !el.getKind().isClass()) { return null; } TypeElement tel = (TypeElement)el; // do not suggest for anonymous classes, local classes or members which are not static. if (tel.getNestingKind() != NestingKind.TOP_LEVEL && (tel.getNestingKind() != NestingKind.MEMBER || !tel.getModifiers().contains(Modifier.STATIC))) { return null; } InstanceRefFinder finder = new InstanceRefFinder(ctx.getInfo(), path); finder.process(); if (finder.containsInstanceReferences() || finder.containsReferencesToSuper()) { return null; } return ErrorDescriptionFactory.forTree(ctx, path, Bundle.TEXT_InitializerCanBeStatic(), new MakeInitStatic(TreePathHandle.create(path, ctx.getInfo())).toEditorFix()); }
Example 3
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
Example 4
Source File: ExternalDomainMetaFactory.java From doma with Apache License 2.0 | 5 votes |
private void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4280, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4278, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4279, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 5
Source File: InternalDomainMetaFactory.java From doma with Apache License 2.0 | 5 votes |
void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4277, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4275, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4276, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 6
Source File: DataTypeMetaFactory.java From doma with Apache License 2.0 | 5 votes |
void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4450, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4451, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4452, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 7
Source File: EntityMetaFactory.java From doma with Apache License 2.0 | 5 votes |
void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4317, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4315, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4316, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 8
Source File: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public NestingKind getNestingKind() { complete(); if (owner.kind == PCK) return NestingKind.TOP_LEVEL; else if (name.isEmpty()) return NestingKind.ANONYMOUS; else if (owner.kind == MTH) return NestingKind.LOCAL; else return NestingKind.MEMBER; }
Example 9
Source File: TypeElementImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public NestingKind getNestingKind() { ReferenceBinding refBinding = (ReferenceBinding)_binding; if (refBinding.isAnonymousType()) { return NestingKind.ANONYMOUS; } else if (refBinding.isLocalType()) { return NestingKind.LOCAL; } else if (refBinding.isMemberType()) { return NestingKind.MEMBER; } return NestingKind.TOP_LEVEL; }
Example 10
Source File: EmbeddableMetaFactory.java From doma with Apache License 2.0 | 5 votes |
void validateEnclosingElement(Element element) { TypeElement typeElement = ctx.getMoreElements().toTypeElement(element); if (typeElement == null) { return; } String simpleName = typeElement.getSimpleName().toString(); if (simpleName.contains(Constants.BINARY_NAME_DELIMITER) || simpleName.contains(Constants.TYPE_NAME_DELIMITER)) { throw new AptException( Message.DOMA4417, typeElement, new Object[] {typeElement.getQualifiedName()}); } NestingKind nestingKind = typeElement.getNestingKind(); if (nestingKind == NestingKind.TOP_LEVEL) { return; } else if (nestingKind == NestingKind.MEMBER) { Set<Modifier> modifiers = typeElement.getModifiers(); if (modifiers.containsAll(Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))) { validateEnclosingElement(typeElement.getEnclosingElement()); } else { throw new AptException( Message.DOMA4415, typeElement, new Object[] {typeElement.getQualifiedName()}); } } else { throw new AptException( Message.DOMA4416, typeElement, new Object[] {typeElement.getQualifiedName()}); } }
Example 11
Source File: InMemoryJavaFile.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public NestingKind getNestingKind() { return qualifiedName.isTopLevel() ? NestingKind.TOP_LEVEL : NestingKind.MEMBER; }
Example 12
Source File: MoreElements.java From buck with Apache License 2.0 | 4 votes |
public static boolean isInnerClass(TypeElement e) { return e.getNestingKind() == NestingKind.MEMBER && !e.getModifiers().contains(Modifier.STATIC); }
Example 13
Source File: CaptureInfo.java From j2objc with Apache License 2.0 | 4 votes |
private static boolean automaticOuterParam(TypeElement type) { return type.getNestingKind() == NestingKind.MEMBER && !ElementUtil.isStatic(type); }
Example 14
Source File: GenericElement.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public NestingKind getNestingKind() { return qualifiedName.isTopLevel() ? NestingKind.TOP_LEVEL : NestingKind.MEMBER; }
Example 15
Source File: ClassTypeImpl.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public NestingKind getNestingKind() { return (enclosingElement.getKind() == ElementKind.PACKAGE) ? NestingKind.TOP_LEVEL : NestingKind.MEMBER; }
Example 16
Source File: GenericTypeElementImpl.java From FreeBuilder with Apache License 2.0 | 4 votes |
@Override public NestingKind getNestingKind() { return (enclosingElement.getKind() == ElementKind.PACKAGE) ? NestingKind.TOP_LEVEL : NestingKind.MEMBER; }
Example 17
Source File: TurbineElement.java From turbine with Apache License 2.0 | 4 votes |
@Override public NestingKind getNestingKind() { TypeBoundClass info = info(); return (info != null && info.owner() != null) ? NestingKind.MEMBER : NestingKind.TOP_LEVEL; }
Example 18
Source File: JavaClassCompletor.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean isAccessibleClass(TypeElement te) { NestingKind nestingKind = te.getNestingKind(); return (nestingKind == NestingKind.TOP_LEVEL) || (nestingKind == NestingKind.MEMBER && te.getModifiers().contains(Modifier.STATIC)); }
Example 19
Source File: LazyTypeCompletionItem.java From netbeans with Apache License 2.0 | 4 votes |
private static boolean isAccessibleClass(TypeElement te) { NestingKind nestingKind = te.getNestingKind(); return (nestingKind == NestingKind.TOP_LEVEL) || (nestingKind == NestingKind.MEMBER && te.getModifiers().contains(Modifier.STATIC)); }