Java Code Examples for javax.lang.model.element.ElementKind#RESOURCE_VARIABLE
The following examples show how to use
javax.lang.model.element.ElementKind#RESOURCE_VARIABLE .
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: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public ElementKind getKind() { long flags = flags(); if ((flags & PARAMETER) != 0) { if (isExceptionParameter()) return ElementKind.EXCEPTION_PARAMETER; else return ElementKind.PARAMETER; } else if ((flags & ENUM) != 0) { return ElementKind.ENUM_CONSTANT; } else if (owner.kind == TYP || owner.kind == ERR) { return ElementKind.FIELD; } else if (isResourceVariable()) { return ElementKind.RESOURCE_VARIABLE; } else { return ElementKind.LOCAL_VARIABLE; } }
Example 2
Source File: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Object getConstValue() { // TODO: Consider if getConstValue and getConstantValue can be collapsed if (data == ElementKind.EXCEPTION_PARAMETER || data == ElementKind.RESOURCE_VARIABLE) { return null; } else if (data instanceof Callable<?>) { // In this case, this is a final variable, with an as // yet unevaluated initializer. Callable<?> eval = (Callable<?>)data; data = null; // to make sure we don't evaluate this twice. try { data = eval.call(); } catch (Exception ex) { throw new AssertionError(ex); } } return data; }
Example 3
Source File: ConvertVarToExplicitType.java From netbeans with Apache License 2.0 | 6 votes |
protected static boolean isVariableValidForVarHint(HintContext ctx) { CompilationInfo info = ctx.getInfo(); TreePath treePath = ctx.getPath(); // hint will be enable only for JDK-10 or above. if (info.getSourceVersion().compareTo(SourceVersion.RELEASE_9) < 1) { return false; } if (treePath.getLeaf().getKind() == Tree.Kind.ENHANCED_FOR_LOOP) { EnhancedForLoopTree efl = (EnhancedForLoopTree) treePath.getLeaf(); TypeMirror expressionType = ctx.getInfo().getTrees().getTypeMirror(new TreePath(treePath, efl.getExpression())); if (!Utilities.isValidType(expressionType)) { return false; } } else { Element treePathELement = info.getTrees().getElement(treePath); // should be local variable if (treePathELement != null && (treePathELement.getKind() != ElementKind.LOCAL_VARIABLE && treePathELement.getKind() != ElementKind.RESOURCE_VARIABLE)) { return false; } } return true; }
Example 4
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public ElementKind getKind() { long flags = flags(); if ((flags & PARAMETER) != 0) { if (isExceptionParameter()) return ElementKind.EXCEPTION_PARAMETER; else return ElementKind.PARAMETER; } else if ((flags & ENUM) != 0) { return ElementKind.ENUM_CONSTANT; } else if (owner.kind == TYP || owner.kind == ERR) { return ElementKind.FIELD; } else if (isResourceVariable()) { return ElementKind.RESOURCE_VARIABLE; } else { return ElementKind.LOCAL_VARIABLE; } }
Example 5
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public Object getConstValue() { // TODO: Consider if getConstValue and getConstantValue can be collapsed if (data == ElementKind.EXCEPTION_PARAMETER || data == ElementKind.RESOURCE_VARIABLE) { return null; } else if (data instanceof Callable<?>) { // In this case, this is a final variable, with an as // yet unevaluated initializer. Callable<?> eval = (Callable<?>)data; data = null; // to make sure we don't evaluate this twice. try { data = eval.call(); } catch (Exception ex) { throw new AssertionError(ex); } } return data; }
Example 6
Source File: GoToSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Void visitVariable(VariableElement e, Boolean highlightName) { modifier(e.getModifiers()); result.append(getTypeName(info, e.asType(), true)); result.append(' '); boldStartCheck(highlightName); result.append(e.getSimpleName()); boldStopCheck(highlightName); if (highlightName) { if (e.getConstantValue() != null) { result.append(" = "); result.append(StringEscapeUtils.escapeHtml(e.getConstantValue().toString())); } Element enclosing = e.getEnclosingElement(); if (e.getKind() != ElementKind.PARAMETER && e.getKind() != ElementKind.LOCAL_VARIABLE && e.getKind() != ElementKind.RESOURCE_VARIABLE && e.getKind() != ElementKind.EXCEPTION_PARAMETER && !TreeShims.BINDING_VARIABLE.equals(e.getKind().name())) { result.append(" in "); //short typename: result.append(getTypeName(info, enclosing.asType(), true)); } } return null; }
Example 7
Source File: CompilationUnitBuilder.java From j2cl with Apache License 2.0 | 5 votes |
private Expression convertIdent(JCIdent identifier) { if (isThisExpression(identifier)) { return new ThisReference(getCurrentType().getTypeDescriptor()); } if (isSuperExpression(identifier)) { return new SuperReference(getCurrentType().getTypeDescriptor()); } Symbol symbol = identifier.sym; if (symbol instanceof ClassSymbol) { return new JavaScriptConstructorReference( environment.createDeclarationForType((ClassSymbol) identifier.sym)); } if (symbol instanceof MethodSymbol) { return NullLiteral.get().withComment(identifier.toString()); } VarSymbol varSymbol = (VarSymbol) symbol; if (symbol.getKind() == ElementKind.LOCAL_VARIABLE || symbol.getKind() == ElementKind.RESOURCE_VARIABLE || symbol.getKind() == ElementKind.PARAMETER || symbol.getKind() == ElementKind.EXCEPTION_PARAMETER) { Variable variable = variableByVariableElement.get(symbol); return resolveVariableReference(variable); } FieldDescriptor fieldDescriptor = environment.createFieldDescriptor(varSymbol, identifier.type); Expression qualifier = fieldDescriptor.isStatic() ? null : resolveOuterClassReference(fieldDescriptor.getEnclosingTypeDescriptor(), false); return FieldAccess.newBuilder() .setQualifier(qualifier) .setTargetFieldDescriptor(fieldDescriptor) .build(); }
Example 8
Source File: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public boolean isResourceVariable() { return data == ElementKind.RESOURCE_VARIABLE; }
Example 9
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public boolean isResourceVariable() { return data == ElementKind.RESOURCE_VARIABLE; }
Example 10
Source File: ElementUtil.java From j2objc with Apache License 2.0 | 4 votes |
public static boolean isVariable(Element element) { ElementKind kind = element.getKind(); return kind == ElementKind.FIELD || kind == ElementKind.LOCAL_VARIABLE || kind == ElementKind.PARAMETER || kind == ElementKind.EXCEPTION_PARAMETER || kind == ElementKind.RESOURCE_VARIABLE || kind == ElementKind.ENUM_CONSTANT; }