当前位置: 首页>>代码示例>>Java>>正文


Java ElementKind.EXCEPTION_PARAMETER属性代码示例

本文整理汇总了Java中javax.lang.model.element.ElementKind.EXCEPTION_PARAMETER属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.EXCEPTION_PARAMETER属性的具体用法?Java ElementKind.EXCEPTION_PARAMETER怎么用?Java ElementKind.EXCEPTION_PARAMETER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.EXCEPTION_PARAMETER属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assignsTo

/**
 * Determines whether the catch exception parameter is assigned to.
 * 
 * @param ctx HintContext - for CompilationInfo
 * @param variable the inspected variable
 * @param statements statements that should be checked for assignment
 * @return true if 'variable' is assigned to within 'statements'
 */
public static boolean assignsTo(final HintContext ctx, TreePath variable, Iterable<? extends TreePath> statements) {
    final Element tEl = ctx.getInfo().getTrees().getElement(variable);

    if (tEl == null || tEl.getKind() != ElementKind.EXCEPTION_PARAMETER) return true;
    final boolean[] result = new boolean[1];

    for (TreePath tp : statements) {
        new ErrorAwareTreePathScanner<Void, Void>() {
            @Override
            public Void visitAssignment(AssignmentTree node, Void p) {
                if (tEl.equals(ctx.getInfo().getTrees().getElement(new TreePath(getCurrentPath(), node.getVariable())))) {
                    result[0] = true;
                }
                return super.visitAssignment(node, p);
            }
        }.scan(tp, null);
    }

    return result[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:UseSpecificCatch.java

示例2: assignmentToCatchBlockParameter

@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToCatchBlockParameter", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.assignmentToCatchBlockParameter", category = "assignment_issues", enabled = false, suppressWarnings = "AssignmentToCatchBlockParameter", options=Options.QUERY) //NOI18N
@TriggerTreeKind(Kind.CATCH)
public static List<ErrorDescription> assignmentToCatchBlockParameter(HintContext context) {
    final Trees trees = context.getInfo().getTrees();
    final TreePath catchPath = context.getPath();
    final Element param = trees.getElement(TreePath.getPath(catchPath, ((CatchTree) catchPath.getLeaf()).getParameter()));
    if (param == null || param.getKind() != ElementKind.EXCEPTION_PARAMETER) {
        return null;
    }
    final TreePath block = TreePath.getPath(catchPath, ((CatchTree) catchPath.getLeaf()).getBlock());
    final List<TreePath> paths = new LinkedList<TreePath>();
    new AssignmentFinder(trees, param).scan(block, paths);
    final List<ErrorDescription> ret = new ArrayList<ErrorDescription>(paths.size());
    for (TreePath path : paths) {
        ret.add(ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class, "MSG_AssignmentToCatchBlockParameter", param.getSimpleName()))); //NOI18N
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AssignmentIssues.java

示例3: getKind

@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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Symbol.java

示例4: getConstValue

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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Symbol.java

示例5: visitVariable

@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) {
            result.append(" in ");

            //short typename:
            result.append(getTypeName(info, enclosing.asType(), true));
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:GoToSupport.java

示例6: isLocalVariableClosure

private static boolean isLocalVariableClosure(Element el) {
    return el.getKind() == ElementKind.PARAMETER || el.getKind() == ElementKind.LOCAL_VARIABLE
            || el.getKind() == ElementKind.RESOURCE_VARIABLE || el.getKind() == ElementKind.EXCEPTION_PARAMETER;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:SemanticHighlighterBase.java

示例7: isExceptionParameter

public boolean isExceptionParameter() {
    return data == ElementKind.EXCEPTION_PARAMETER;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:3,代码来源:Symbol.java


注:本文中的javax.lang.model.element.ElementKind.EXCEPTION_PARAMETER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。