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


Java HintContext.getInfo方法代码示例

本文整理汇总了Java中org.netbeans.spi.java.hints.HintContext.getInfo方法的典型用法代码示例。如果您正苦于以下问题:Java HintContext.getInfo方法的具体用法?Java HintContext.getInfo怎么用?Java HintContext.getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.spi.java.hints.HintContext的用法示例。


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

示例1: translate

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
private static List<ErrorDescription> translate(HintContext ctx) {
    ExpressionVisitor v = new ExpressionVisitor(ctx.getInfo(), false,
        ctx.getPreferences().getInt(OPTION_COMPLEX_ARITHMETIC_LIMIT, DEFAULT_ARITHMETIC_COMPLEX_LIMIT)
    );
    v.scan(ctx.getPath(), null);
    List<TreePath> paths = v.getErrorPaths();
    if (paths.isEmpty()) {
        return null;
    }
    
    List<ErrorDescription> desc = new ArrayList<>(paths.size());
    for (TreePath tp : paths) {
        int count = v.getNodeOperands(tp);
        desc.add(ErrorDescriptionFactory.forTree(
                ctx, tp, TEXT_ArithmeticTooComplex(count)
        ));
    }
    return desc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ComplexArithmeticExpression.java

示例2: tooCoupledClass

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(
    displayName = "#DN_ClassTooCoupled",
    description = "#DESC_ClassTooCoupled",
    category = "metrics",
    options = { Hint.Options.HEAVY, Hint.Options.QUERY },
    enabled = false
)
@UseOptions({ OPTION_COUPLING_LIMIT, OPTION_COUPLING_IGNORE_JAVA })
@TriggerTreeKind(Tree.Kind.CLASS)
public static ErrorDescription tooCoupledClass(HintContext ctx) {
    ClassTree clazz = (ClassTree)ctx.getPath().getLeaf();
    DependencyCollector col = new DependencyCollector(ctx.getInfo());
    boolean ignoreJava = ctx.getPreferences().getBoolean(OPTION_COUPLING_IGNORE_JAVA, DEFAULT_COUPLING_IGNORE_JAVA);
    col.setIgnoreJavaLibraries(ignoreJava);
    col.scan(ctx.getPath(), null);
    
    int coupling = col.getSeenQNames().size();
    int limit = ctx.getPreferences().getInt(OPTION_COUPLING_LIMIT, DEFAULT_COUPLING_LIMIT);
    if (coupling > limit) {
        return ErrorDescriptionFactory.forName(ctx, 
                ctx.getPath(), 
                TEXT_ClassTooCoupled(clazz.getSimpleName().toString(), coupling));
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ClassMetrics.java

示例3: computeTreeKind

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind(Kind.METHOD_INVOCATION)
public static ErrorDescription computeTreeKind(HintContext ctx) {
    MethodInvocationTree mit = (MethodInvocationTree) ctx.getPath().getLeaf();

    if (!mit.getArguments().isEmpty() || !mit.getTypeArguments().isEmpty()) {
        return null;
    }

    CompilationInfo info = ctx.getInfo();
    Element e = info.getTrees().getElement(new TreePath(ctx.getPath(), mit.getMethodSelect()));

    if (e == null || e.getKind() != ElementKind.METHOD) {
        return null;
    }

    if (e.getSimpleName().contentEquals("toURL") && info.getElementUtilities().enclosingTypeElement(e).getQualifiedName().contentEquals("java.io.File")) {
        ErrorDescription w = ErrorDescriptionFactory.forName(ctx, mit, "Use of java.io.File.toURL()");

        return w;
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:FileToURL.java

示例4: computeAnnonymousToLambda

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPatterns({
    @TriggerPattern("new $clazz($params$) { $method; }") //NOI18N
})
@NbBundle.Messages("MSG_AnonymousConvertibleToLambda=This anonymous inner class creation can be turned into a lambda expression.")
public static ErrorDescription computeAnnonymousToLambda(HintContext ctx) {
    ClassTree clazz = ((NewClassTree) ctx.getPath().getLeaf()).getClassBody();
    ConvertToLambdaPreconditionChecker preconditionChecker =
            new ConvertToLambdaPreconditionChecker(ctx.getPath(), ctx.getInfo());
    if (!preconditionChecker.passesFatalPreconditions()) {
        return null;
    }

    FixImpl fix = new FixImpl(ctx.getInfo(), ctx.getPath(), false);
    if (ctx.getPreferences().getBoolean(KEY_PREFER_MEMBER_REFERENCES, DEF_PREFER_MEMBER_REFERENCES)
            && (preconditionChecker.foundMemberReferenceCandidate() || preconditionChecker.foundConstructorReferenceCandidate())) {
        return ErrorDescriptionFactory.forTree(ctx, ((NewClassTree) ctx.getPath().getLeaf()).getIdentifier(), Bundle.MSG_AnonymousConvertibleToLambda(),
                new FixImpl(ctx.getInfo(), ctx.getPath(), true).toEditorFix(), fix.toEditorFix());
    }
    return ErrorDescriptionFactory.forTree(ctx, ((NewClassTree) ctx.getPath().getLeaf()).getIdentifier(), 
            Bundle.MSG_AnonymousConvertibleToLambda(), fix.toEditorFix());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ConvertToLambda.java

示例5: checkSystemOut

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPatterns ({
        @TriggerPattern (value="System.out"),
        @TriggerPattern (value="System.err")
    })
    public static ErrorDescription checkSystemOut (HintContext ctx) {
        TreePath                treePath = ctx.getPath ();
        CompilationInfo         compilationInfo = ctx.getInfo ();
        return ErrorDescriptionFactory.forName (
            ctx,
            treePath,
            NbBundle.getMessage (SystemOut.class, "MSG_SystemOut"),
        new FixImpl (
NbBundle.getMessage (
LoggerNotStaticFinal.class,
"MSG_SystemOut_fix"
),
TreePathHandle.create (treePath, compilationInfo)
).toEditorFix()
        );
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SystemOut.java

示例6: utilityClass

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(id="org.netbeans.modules.java.hints.UtilityClass_1", displayName="#MSG_UtilityClass", description="#HINT_UtilityClass", category="api", enabled=false, severity=Severity.VERIFIER, suppressWarnings="UtilityClassWithoutPrivateConstructor")
@TriggerTreeKind(Kind.CLASS)
public static ErrorDescription utilityClass(HintContext ctx) {
    CompilationInfo compilationInfo = ctx.getInfo();
    TreePath treePath = ctx.getPath();
    Element e = compilationInfo.getTrees().getElement(treePath);
    if (e == null) {
        return null;
    }
    
    if (!isUtilityClass(compilationInfo, e)) return null;
    
    for (ExecutableElement c : ElementFilter.constructorsIn(e.getEnclosedElements())) {
        if (!compilationInfo.getElementUtilities().isSynthetic(c)) {
            return null;
        }
    }

    return ErrorDescriptionFactory.forName(ctx,
                                           treePath,
                                           NbBundle.getMessage(UtilityClass.class, "MSG_UtilityClass"),
                                           new FixImpl(true,
                                                       TreePathHandle.create(e, compilationInfo)
                                           ).toEditorFix());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:UtilityClass.java

示例7: errorHint

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(id = "error-in-javadoc", category = "JavaDoc", description = "#DESC_ERROR_IN_JAVADOC_HINT", displayName = "#DN_ERROR_IN_JAVADOC_HINT", hintKind = Hint.Kind.INSPECTION, severity = Severity.WARNING, customizerProvider = JavadocHint.CustomizerProviderImplError.class)
@TriggerTreeKind({Kind.METHOD, Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.VARIABLE})
public static List<ErrorDescription> errorHint(final HintContext ctx) {
    Preferences pref = ctx.getPreferences();
    boolean correctJavadocForNonPublic = pref.getBoolean(AVAILABILITY_KEY + false, false);

    CompilationInfo javac = ctx.getInfo();
    Boolean publiclyAccessible = AccessibilityQuery.isPubliclyAccessible(javac.getFileObject().getParent());
    boolean isPubliclyA11e = publiclyAccessible == null ? true : publiclyAccessible;

    if (!isPubliclyA11e && !correctJavadocForNonPublic) {
        return null;
    }

    if (javac.getElements().getTypeElement("java.lang.Object") == null) { // NOI18N
        // broken java platform
        return Collections.<ErrorDescription>emptyList();
    }

    TreePath path = ctx.getPath();
    {
        Document doc = null;
        try {
            doc = javac.getDocument();
        } catch (IOException e) {
            Exceptions.printStackTrace(e);
        }
        if (doc != null && isGuarded(path.getLeaf(), javac, doc)) {
            return null;
        }
    }
    
    Access access = Access.resolve(pref.get(SCOPE_KEY, SCOPE_DEFAULT));
    Analyzer a = new Analyzer(javac, path, access, ctx);
    return a.analyze();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:JavadocHint.java

示例8: clone

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPattern("$mods$ $type clone() throws $exc$ { $stmts$; }") // NOI18N
@Hint(category = "bugs",
      displayName = "#DN_CloneAndCloneable_cloneInNonCloneableClass", // NOI18N
      description = "#DESC_CloneAndCloneable_cloneInNonCloneableClass", // NOI18N
      suppressWarnings={"CloneInNonCloneableClass"},
      enabled = false
)
public static ErrorDescription cloneInNonCloneableClass(HintContext ctx) {
    final CompilationInfo info = ctx.getInfo();
    ExecutableElement cloneMethod = (ExecutableElement)info.getTrees().getElement(ctx.getPath());
    if (cloneMethod == null) {
        return null;
    }
    if (!cloneMethod.getModifiers().contains(Modifier.PUBLIC)) {
        return null;
    }
    // check if the enclosing subclass is not final
    TypeElement declaringClass = info.getElementUtilities().enclosingTypeElement(cloneMethod);
    if (declaringClass == null) {
        return null;
    }
    TypeElement cloneableIface = info.getElements().getTypeElement("java.lang.Cloneable"); // NOI18N
    if (cloneableIface == null) {
        return null;
    }
    if (info.getTypes().isSubtype(declaringClass.asType(), cloneableIface.asType())) {
        return null;
    }
    Fix fix = new CloneableInsertFix(info, info.getTrees().getPath(declaringClass)).toEditorFix();
    return ErrorDescriptionFactory.forName(
            ctx,
            info.getTrees().getTree(declaringClass), 
            TEXT_CloneWithoutCloneable(), fix);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:CloneAndCloneable.java

示例9: complexArithmeticField

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind(Tree.Kind.VARIABLE)
@UseOptions(ComplexArithmeticExpression.OPTION_COMPLEX_ARITHMETIC_LIMIT)
public static List<ErrorDescription> complexArithmeticField(HintContext ctx) {
    Tree parentTree = ctx.getPath().getParentPath().getLeaf();
    if (!(parentTree.getKind() == Tree.Kind.CLASS || parentTree.getKind() == Tree.Kind.ENUM ||
        parentTree.getKind() == Tree.Kind.INTERFACE)) {
        return null;
    }
    ExpressionVisitor v = new ExpressionVisitor(ctx.getInfo(), false,
        ctx.getPreferences().getInt(OPTION_COMPLEX_ARITHMETIC_LIMIT, DEFAULT_ARITHMETIC_COMPLEX_LIMIT)
    );
    return translate(ctx);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ComplexArithmeticExpression.java

示例10: tooComplexAnonymousClass

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(
    displayName = "#DN_ClassAnonymousTooComplex",
    description = "#DESC_ClassAnonymousTooComplex",
    category = "metrics",
    options = { Hint.Options.HEAVY, Hint.Options.QUERY },
    enabled = false
)
@UseOptions(OPTION_ANONYMOUS_COMPLEXITY_LIMIT)
@TriggerPatterns({
    @TriggerPattern("new $classname<$tparams$>($params$) { $members$; }"),
    @TriggerPattern("$expr.new $classname<$tparams$>($params$) { $members$; }"),
    @TriggerPattern("new $classname($params$) { $members$; }"),
    @TriggerPattern("$expr.new $classname($params$) { $members$; }"),
})
public static ErrorDescription tooComplexAnonymousClass(HintContext ctx) {
    CyclomaticComplexityVisitor v = new CyclomaticComplexityVisitor();
    v.scan(ctx.getPath(), null);
    
    int complexity = v.getComplexity();
    int limit = ctx.getPreferences().getInt(OPTION_ANONYMOUS_COMPLEXITY_LIMIT, 
            DEFAULT_ANONYMOUS_COMPLEXITY_LIMIT);
    if (complexity > limit) {
        CompilationInfo info = ctx.getInfo();
        SourcePositions pos = info.getTrees().getSourcePositions();
        NewClassTree nct = (NewClassTree)ctx.getPath().getLeaf();
        long start = pos.getStartPosition(info.getCompilationUnit(), nct);
        long mstart = pos.getStartPosition(info.getCompilationUnit(), nct.getClassBody());
        return ErrorDescriptionFactory.forSpan(ctx, 
                (int)start, (int)mstart,
                TEXT_ClassAnonymousTooComplex(complexity));
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ClassMetrics.java

示例11: broadCatch

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(
  displayName = "#DN_BroadCatch",
  description = "#DESC_BroadCatch",
  category = "rules15",
  customizerProvider = CF.class,
  suppressWarnings = { "BroadCatchBlock", "TooBroadCatch" },
  enabled = false
)
@TriggerPatterns({
    @TriggerPattern("try { $statements$; } catch $catches$"),
    @TriggerPattern("try { $statements$; } catch $catches$ finally { $handler$; }")
})
public static List<ErrorDescription> broadCatch(HintContext ctx) {
    if (ctx.getPath().getLeaf().getKind() != Tree.Kind.TRY) {
        return null;
    }
    TryTree tt = (TryTree)ctx.getPath().getLeaf();
    Set<TypeMirror> realExceptions = ctx.getInfo().getTreeUtilities().getUncaughtExceptions(
            new TreePath(ctx.getPath(), tt.getBlock()));
    
    CatchClauseProcessor processor = new CatchClauseProcessor(ctx.getInfo(), ctx, realExceptions);
    
    if (ctx.getPreferences().getBoolean(OPTION_EXCLUDE_COMMON, DEFAULT_EXCLUDE_COMMON)) {
        processor.excludeCommons();
    }
    if (ctx.getPreferences().getBoolean(OPTION_EXCLUDE_UMBRELLA, DEFAULT_EXCLUDE_UMBRELLA)) {
        processor.suppressUmbrellas(ctx.getPreferences().get(OPTION_UMBRELLA_LIST, DEFAULT_UMBRELLA_LIST));
    }

    processor.process(ctx.getMultiVariables().get("$catches$"));
    
    return processor.errors;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:BroadCatchBlock.java

示例12: run

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:InitializerCanBeStatic.java

示例13: tooManyDependencies

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(
    category = "metrics",
    displayName = "#DN_MethodCoupled",
    description = "#DESC_MethodCoupled",
    options = { Hint.Options.QUERY, Hint.Options.HEAVY },
    enabled = false
)
@TriggerTreeKind(Tree.Kind.METHOD)
@UseOptions({ OPTION_COUPLING_LIMIT, OPTION_COUPLING_IGNORE_JAVA })
public static ErrorDescription tooManyDependencies(HintContext ctx) {
    MethodTree m = (MethodTree)ctx.getPath().getLeaf();
    boolean ignoreJava = ctx.getPreferences().getBoolean(OPTION_COUPLING_IGNORE_JAVA, DEFAULT_COUPLING_IGNORE_JAVA);
    TypeElement outermost = ctx.getInfo().getElementUtilities().outermostTypeElement(ctx.getInfo().getTrees().getElement(ctx.getPath()));
    
    DependencyCollector col = new DependencyCollector(ctx.getInfo());
    col.setIgnoreJavaLibraries(ignoreJava);
    col.setOutermostClass(outermost);
    
    /*
     left for the case that superclass references should be excluded optionally
    ExecutableElement el = (ExecutableElement)ctx.getInfo().getTrees().getElement(ctx.getPath());
    Element parent = el.getEnclosingElement();
    while (parent != null && 
           (parent.getKind() == ElementKind.INTERFACE || parent.getKind() == ElementKind.CLASS || parent.getKind() == ElementKind.ENUM)) {
        
        Element p = parent;
        while (true) {
            TypeElement tel = (TypeElement)p;
            col.addIgnoredQName(tel.getQualifiedName());
            TypeMirror tm = tel.getSuperclass();
            if (tm.getKind() == TypeKind.DECLARED) {
                p = ctx.getInfo().getTypes().asElement(tm);
            } else {
                break;
            }
        } 
        parent = parent.getEnclosingElement();
    }*/
    
    col.scan(ctx.getPath(), null);
    
    int deps = col.getSeenQNames().size();
    int limit = ctx.getPreferences().getInt(OPTION_COUPLING_LIMIT, DEFAULT_COUPLING_LIMIT);
    if (deps > limit) {
        return ErrorDescriptionFactory.forName(ctx, m, TEXT_MethodTooCoupled(m.getName().toString(), deps));
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:MethodMetrics.java

示例14: checkTooManyMethods

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
private static ErrorDescription checkTooManyMethods(HintContext ctx, TreePath path, int limit, boolean anon) {
    ClassTree clazz = (ClassTree)path.getLeaf();
    boolean ignoreAccessors = ctx.getPreferences().getBoolean(OPTION_CLASS_METHODS_IGNORE_ACCESSORS, DEFAULT_CLASS_METHODS_IGNORE_ACCESSORS);
    boolean ignoreAbstract = ctx.getPreferences().getBoolean(OPTION_CLASS_METHODS_IGNORE_ABSTRACT, DEFAULT_CLASS_METHODS_IGNORE_ABSTRACT);
    int methodCount = 0;
    for (Tree member : clazz.getMembers()) {
        if (member.getKind() != Tree.Kind.METHOD) {
            continue;
        }
        MethodTree method = (MethodTree)member;
        if (method.getReturnType() == null) {
            // a constructor ?
            continue;
        }
        TreePath methodPath = new TreePath(path, method);
        if (ignoreAccessors && (isSimpleGetter(ctx.getInfo(), methodPath) ||
                isSimpleSetter(ctx.getInfo(), methodPath))) {
            continue;
        }
        if (ignoreAbstract) {
            ExecutableElement mel = (ExecutableElement)ctx.getInfo().getTrees().getElement(methodPath);
            ExecutableElement overriden = ctx.getInfo().getElementUtilities().getOverriddenMethod(mel);
            if (overriden != null && overriden.getModifiers().contains(Modifier.ABSTRACT)) {
                continue;
            }
        }
        methodCount++;
    }
    
    if (methodCount <= limit) {
        return null;
    }
    if (anon) {
        CompilationInfo info = ctx.getInfo();
        SourcePositions pos = info.getTrees().getSourcePositions();
        long start = pos.getStartPosition(info.getCompilationUnit(), path.getParentPath().getLeaf());
        long mstart = pos.getStartPosition(info.getCompilationUnit(), path.getLeaf());
        return ErrorDescriptionFactory.forSpan(ctx, (int)start, (int)mstart,
                TEXT_AnonClassManyMethods(methodCount));
    } else {
        return ErrorDescriptionFactory.forName(ctx, 
                path, 
                TEXT_ClassManyMethods(clazz.getSimpleName().toString(), methodCount));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:ClassMetrics.java

示例15: methodInvocation

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(displayName = "#DN_ThrowableMethodResultIgnored", description = "#DESC_ThrowableMethodResultIgnored",
        category = "bugs",
        enabled = true,
        suppressWarnings = { "ThrowableResultIgnored", "", "ThrowableResultOfMethodCallIgnored" })
@TriggerPatterns({
    @TriggerPattern(value = "$m($params$)")
})
public static ErrorDescription methodInvocation(HintContext ctx) {
    TreePath p = ctx.getPath();
    if (p.getLeaf().getKind() != Tree.Kind.METHOD_INVOCATION) {
        return null;
    }
    TypeMirror tm = ctx.getInfo().getTrees().getTypeMirror(p);
    Element el = ctx.getInfo().getElements().getTypeElement("java.lang.Throwable"); // NOI18N
    if (el == null || !Utilities.isValidType(tm)) {
        // bad JDK ?
        return null;
    }
    TypeMirror b = el.asType();
    if (!Utilities.isValidType(b) || !ctx.getInfo().getTypes().isAssignable(tm, b)) {
        // does not return Throwable
        return null;
    }

    ExecutableElement initCause = (ExecutableElement)ctx.getInfo().getElementUtilities().findElement("java.lang.Throwable.initCause(java.lang.Throwable)"); // NOI18N
    if (initCause != null) {
        Element e = ctx.getInfo().getTrees().getElement(ctx.getVariables().get("$m")); // NOI18N
        // #246279 possibly e will be an unresolved symbol == a ClassSymbol, which cannot be casted to ExElement.
        if (e == null || (e.getKind() != ElementKind.CONSTRUCTOR && e.getKind() != ElementKind.METHOD)) {
            return null;
        }
        ExecutableElement thisMethod = (ExecutableElement)e;
        if (thisMethod == initCause || ctx.getInfo().getElements().overrides(thisMethod, initCause, (TypeElement)el)) {
            return null;
        }
    }
    TreePath enclosingMethodPath = findEnclosingMethodPath(ctx.getPath());
    ThrowableTracer tracer = new ThrowableTracer(ctx.getInfo(), enclosingMethodPath);
    if (!tracer.traceThrowable(ctx.getPath())) {
        return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), 
                Bundle.TEXT_ThrowableValueNotThrown());
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:ThrowableNotThrown.java


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