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


Java HintContext.getPath方法代码示例

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


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

示例1: forIF

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(displayName = "#LBL_Empty_IF", description = "#DSC_Empty_IF", category = "empty", hintKind = Hint.Kind.INSPECTION, severity = Severity.VERIFIER, suppressWarnings = SUPPRESS_WARNINGS_KEY, id = "EmptyStatements_IF", enabled = false)
@TriggerTreeKind(Tree.Kind.EMPTY_STATEMENT)
public static ErrorDescription forIF(HintContext ctx) {
    final TreePath treePath = ctx.getPath();

    Tree parent = treePath.getParentPath().getLeaf();        
    if (!EnumSet.of(Kind.IF).contains(parent.getKind())) {
        return null;
    }
    
    TreePath treePathForWarning = treePath;
    IfTree it = (IfTree) parent;
    if (it.getThenStatement() != null
            && it.getThenStatement().getKind() == Tree.Kind.EMPTY_STATEMENT) {
        treePathForWarning = treePath.getParentPath();
            }
    if (it.getElseStatement() != null
            && it.getElseStatement().getKind() == Tree.Kind.EMPTY_STATEMENT) {
        treePathForWarning = treePath;
            }
    
    final List<Fix> fixes = new ArrayList<>();
    fixes.add(FixFactory.createSuppressWarningsFix(ctx.getInfo(), treePathForWarning, SUPPRESS_WARNINGS_KEY));
    
    return createErrorDescription(ctx, parent, fixes, parent.getKind());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:EmptyStatements.java

示例2: 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

示例3: 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

示例4: testElement

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
private static VariableElement testElement(HintContext ctx) {
    TreePath tp = ctx.getPath();
    Element el = ctx.getInfo().getTrees().getElement(tp);

    if (!isAcceptable(el)) return null;

    TypeMirror actualType = ctx.getInfo().getTrees().getTypeMirror(tp);

    if (actualType == null || actualType.getKind() != TypeKind.DECLARED) return null;

    if (testType(ctx.getInfo(), actualType, "java.util.Collection") || testType(ctx.getInfo(), actualType, "java.util.Map")) {
        return (VariableElement) el;
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Unbalanced.java

示例5: checkPrintStackTrace

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPattern(value="$t.printStackTrace ()",
                    [email protected](variable="$t", type="java.lang.Throwable"))
    public static ErrorDescription checkPrintStackTrace (HintContext ctx) {
        TreePath                treePath = ctx.getPath ();
        CompilationInfo         compilationInfo = ctx.getInfo ();
        return ErrorDescriptionFactory.forName (
            ctx,
            treePath,
            NbBundle.getMessage (PrintStackTrace.class, "MSG_PrintStackTrace"),
        new FixImpl (
NbBundle.getMessage (
LoggerNotStaticFinal.class,
"MSG_PrintStackTrace_fix"
),
TreePathHandle.create (treePath, compilationInfo)
).toEditorFix());
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PrintStackTrace.java

示例6: run

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind(Tree.Kind.ASSERT)
public static ErrorDescription run(HintContext ctx) {
    CompilationInfo ci = ctx.getInfo();
    AssertTree at = (AssertTree)ctx.getPath().getLeaf();
    TreePath condPath = new TreePath(ctx.getPath(), at.getCondition());
    if (ci.getTreeUtilities().isCompileTimeConstantExpression(condPath)) {
        return null;
    }
    
    SideEffectVisitor visitor = new SideEffectVisitor(ctx);
    Tree culprit;
    try {
        visitor.scan(new TreePath(ctx.getPath(), at.getCondition()), null);
        return null;
    } catch (StopProcessing stop) {
        culprit = stop.getValue();
    }
    return ErrorDescriptionFactory.forTree(ctx, culprit, TEXT_AssertWithSideEffects());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AssertWithSideEffects.java

示例7: nestedAssignment

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.nestedAssignment", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.nestedAssignment", category = "assignment_issues", enabled = false, suppressWarnings = "NestedAssignment", options=Options.QUERY) //NOI18N
@TriggerTreeKind({Kind.ASSIGNMENT, Kind.AND_ASSIGNMENT, Kind.DIVIDE_ASSIGNMENT,
    Kind.LEFT_SHIFT_ASSIGNMENT, Kind.MINUS_ASSIGNMENT, Kind.MULTIPLY_ASSIGNMENT,
    Kind.OR_ASSIGNMENT, Kind.PLUS_ASSIGNMENT, Kind.REMAINDER_ASSIGNMENT, Kind.RIGHT_SHIFT_ASSIGNMENT,
    Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT, Kind.XOR_ASSIGNMENT})
public static ErrorDescription nestedAssignment(HintContext context) {
    final TreePath path = context.getPath();
    final Kind parentKind = path.getParentPath().getLeaf().getKind();
    if (parentKind != Kind.EXPRESSION_STATEMENT && parentKind != Kind.ANNOTATION) {
        return ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class, "MSG_NestedAssignment", path.getLeaf())); //NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:AssignmentIssues.java

示例8: 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

示例9: checkIncompatibleMask2

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPatterns ({
    @TriggerPattern (value="($a | $b) == $c"),
    @TriggerPattern (value="$c == ($a | $b)")
})
public static ErrorDescription checkIncompatibleMask2 (HintContext ctx) {
    TreePath treePath = ctx.getPath ();
    Map<String,TreePath> variables = ctx.getVariables ();
    TreePath tree = variables.get ("$a");
    Long v1 = getConstant (tree, ctx);
    if (v1 == null) {
        tree = variables.get ("$b");
        v1 = getConstant (tree, ctx);
    }
    if (v1 == null)
        return null;
    tree = variables.get ("$c");
    Long v2 = getConstant (tree, ctx);
    if (v2 == null)
        return null;

    if ((v1 & v2) != v1)
        return ErrorDescriptionFactory.forName (
            ctx,
            treePath,
            MessageFormat.format (
                NbBundle.getMessage (IncompatibleMask.class, "MSG_IncompatibleMask"),
                treePath.getLeaf ().toString ()
            )
        );
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:IncompatibleMask.java

示例10: mathRandomCast

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerPatterns(value = {
    @TriggerPattern(value = "(int)java.lang.Math.random()"),
    @TriggerPattern(value = "(int)java.lang.StrictMath.random()"),
    @TriggerPattern(value = "(long)java.lang.Math.random()"),
    @TriggerPattern(value = "(long)java.lang.StrictMath.random()"),

    @TriggerPattern(value = "(java.lang.Integer)java.lang.Math.random()"),
    @TriggerPattern(value = "(java.lang.Integer)java.lang.StrictMath.random()"),
    @TriggerPattern(value = "(java.lang.Long)java.lang.Math.random()"),
    @TriggerPattern(value = "(java.lang.Long)java.lang.StrictMath.random()")
})
public static ErrorDescription mathRandomCast(HintContext ctx) {
    TreePath path = ctx.getPath();

    if (path.getLeaf().getKind() != Tree.Kind.TYPE_CAST) {
        return null;
    }
    
    // traverse up to the expression chain
    TreePath expr = path;
    for (TreePath parent = path.getParentPath(); parent != null && EXPRESSION_KINDS.contains(parent.getLeaf().getKind()); parent = parent.getParentPath()) {
        expr = parent;
    }
    Fix fix = null;
    
    // do not provide hints if the cast was immediately used in a method call, assignment etc
    if (expr != path) {
        fix = new FixImpl(
                TreePathHandle.create(ctx.getPath(), ctx.getInfo()),
                TreePathHandle.create(expr, ctx.getInfo())).toEditorFix();
    }
    return ErrorDescriptionFactory.forTree(ctx, ctx.getPath(), TEXT_MathRandomCastInt(), fix);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:MathRandomCast.java

示例11: incrementDecrementUsed

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@Hint(displayName = "#DN_org.netbeans.modules.java.hints.AssignmentIssues.incrementDecrementUsed", description = "#DESC_org.netbeans.modules.java.hints.AssignmentIssues.incrementDecrementUsed", category = "assignment_issues", enabled = false, suppressWarnings = "ValueOfIncrementOrDecrementUsed", options=Options.QUERY) //NOI18N
@TriggerTreeKind({Kind.PREFIX_INCREMENT, Kind.PREFIX_DECREMENT, Kind.POSTFIX_INCREMENT, Kind.POSTFIX_DECREMENT})
public static ErrorDescription incrementDecrementUsed(HintContext context) {
    final TreePath path = context.getPath();
    if (path.getParentPath().getLeaf().getKind() != Kind.EXPRESSION_STATEMENT) {
        final Kind kind = path.getLeaf().getKind();
        return ErrorDescriptionFactory.forTree(context, path, NbBundle.getMessage(AssignmentIssues.class,
                kind == Kind.PREFIX_INCREMENT || kind == Kind.POSTFIX_INCREMENT
                ? "MSG_IncrementUsedAsExpression" : "MSG_DecrementUsedAsExpression", path.getLeaf())); //NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AssignmentIssues.java

示例12: before

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind({Kind.IDENTIFIER, Kind.MEMBER_SELECT})
@TriggerOptions(TriggerOptions.PROCESS_GUARDED)
public static ErrorDescription before(HintContext ctx) {
    TreePath tp = ctx.getPath();
    VariableElement var = testElement(ctx);

    if (var == null) return null;

    if (tp.getParentPath().getLeaf().getKind() == Kind.MEMBER_SELECT && tp.getParentPath().getParentPath().getLeaf().getKind() == Kind.METHOD_INVOCATION) {
        String methodName = ((MemberSelectTree) tp.getParentPath().getLeaf()).getIdentifier().toString();
        if (READ_METHODS.contains(methodName)) {
            if (tp.getParentPath().getParentPath().getParentPath().getLeaf().getKind() != Kind.EXPRESSION_STATEMENT) {
                record(ctx.getInfo(), var, State.READ);
            }
            return null;
        } else if (WRITE_METHODS.contains(methodName)) {
            if (tp.getParentPath().getParentPath().getParentPath().getLeaf().getKind() != Kind.EXPRESSION_STATEMENT) {
                record(ctx.getInfo(), var, State.WRITE, State.READ);
            } else {
                record(ctx.getInfo(), var, State.WRITE);
            }
            return null;
        }
    }

    record(ctx.getInfo(), var, State.WRITE, State.READ);

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

示例13: computeWarning

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind(Tree.Kind.CLASS)
   @Messages("ERR_CreateTestClassHint=Create Test Class")
   public static ErrorDescription computeWarning(HintContext context) {
TreePath tp = context.getPath();
       ClassTree cls = (ClassTree) tp.getLeaf();
       CompilationInfo info = context.getInfo();
       SourcePositions sourcePositions = info.getTrees().getSourcePositions();
       int startPos = (int) sourcePositions.getStartPosition(tp.getCompilationUnit(), cls);
       int caret = context.getCaretLocation();
       String code = context.getInfo().getText();
if (startPos < 0 || caret < 0 || caret < startPos || caret >= code.length()) {
           return null;
       }

       String headerText = code.substring(startPos, caret);
       int idx = headerText.indexOf('{'); //NOI18N
       if (idx >= 0) {
           return null;
       }

       ClassPath cp = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
       FileObject fileObject = info.getFileObject();
       if(!fileObject.isValid()) { //File is probably deleted
           return null;
       }
       FileObject root = cp.findOwnerRoot(fileObject);
       if (root == null) { //File not part of any project
           return null;
       }

Collection<? extends TestCreatorProvider> providers = Lookup.getDefault().lookupAll(TestCreatorProvider.class);
       Map<Object, List<String>> validCombinations = Utils.getValidCombinations(info, null);
       if (validCombinations == null) { // no TestCreatorProvider found
           return null;
       }
       for (TestCreatorProvider provider : providers) {
           if (provider.enable(new FileObject[]{fileObject}) && !validCombinations.isEmpty()) {
               List<Fix> fixes = new ArrayList<Fix>();
               Fix fix;
               for (Entry<Object, List<String>> entrySet : validCombinations.entrySet()) {
                   Object location = entrySet.getKey();
                   for (String testingFramework : entrySet.getValue()) {
                       fix = new CreateTestClassFix(new FileObject[]{fileObject}, location, testingFramework);
                       fixes.add(fix);
                   }
               }
               validCombinations.clear();
               return ErrorDescriptionFactory.forTree(context, context.getPath(), Bundle.ERR_CreateTestClassHint(), fixes.toArray(new Fix[fixes.size()]));
           }
       }
       validCombinations.clear();
return null;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:CreateTestClassHint.java

示例14: initCause

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
private static ErrorDescription initCause(HintContext ctx, boolean toThrow) {
    TypeElement throwable = ctx.getInfo().getElements().getTypeElement("java.lang.Throwable");

    if (throwable == null) return null;

    TreePath exc = ctx.getVariables().get("$exc");
    TypeMirror excType = ctx.getInfo().getTrees().getTypeMirror(exc);
    Types t = ctx.getInfo().getTypes();

    if (!t.isSubtype(t.erasure(excType), t.erasure(throwable.asType()))) {
        return null;
    }

    Element el = t.asElement(excType);

    if (el == null || el.getKind() != ElementKind.CLASS) {
        //should not happen
        return null;
    }

    List<TypeMirror> constrParams = new LinkedList<TypeMirror>();
    TreePath str = ctx.getVariables().get("$str");
    String target;

    if (   (str != null && (   MatcherUtilities.matches(ctx, str, "$del.toString()")
                            || (    MatcherUtilities.matches(ctx, str, "$del.getMessage()")
                                && !ctx.getPreferences().getBoolean(STRICT_KEY, STRICT_DEFAULT))
                            || (    MatcherUtilities.matches(ctx, str, "$del.getLocalizedMessage()")
                                && !ctx.getPreferences().getBoolean(STRICT_KEY, STRICT_DEFAULT)))
        || (str == null && !ctx.getPreferences().getBoolean(STRICT_KEY, STRICT_DEFAULT)))) {
        target = "new $exc($del)";
    } else {
        TypeElement jlString = ctx.getInfo().getElements().getTypeElement("java.lang.String");

        if (jlString == null) return null;

        constrParams.add(jlString.asType());

        if (str != null) {
            target = "new $exc($str, $del)";
        } else {
            target = "new $exc(null, $del)"; //TODO: might lead to incompilable code (for overloaded constructors)
        }
    }

    if (toThrow) {
        target = "throw " + target + ";";
    }

    TreePath del = ctx.getVariables().get("$del");
    TypeMirror delType = ctx.getInfo().getTrees().getTypeMirror(del);

    constrParams.add(delType);

    if (!findConstructor(el, t, constrParams)) return null;

    String fixDisplayName = NbBundle.getMessage(ThrowableInitCause.class, "FIX_ThrowableInitCause");
    String displayName = NbBundle.getMessage(ThrowableInitCause.class, "ERR_ThrowableInitCause");
    TreePath toUnderline = ctx.getVariables().get("$excVar");

    if (toUnderline == null) {
        toUnderline = ctx.getPath();
    }

    return ErrorDescriptionFactory.forTree(ctx, toUnderline, displayName, JavaFixUtilities.rewriteFix(ctx, fixDisplayName, ctx.getPath(), target));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:ThrowableInitCause.java

示例15: hint

import org.netbeans.spi.java.hints.HintContext; //导入方法依赖的package包/类
@TriggerTreeKind({Kind.INT_LITERAL, Kind.LONG_LITERAL})
public static ErrorDescription hint(HintContext ctx) {
    TreePath tp = ctx.getPath();
    int end = (int) ctx.getInfo().getTrees().getSourcePositions().getEndPosition(tp.getCompilationUnit(), tp.getLeaf());
    int start = (int) ctx.getInfo().getTrees().getSourcePositions().getStartPosition(tp.getCompilationUnit(), tp.getLeaf());
    TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence();
    ts.move(end);
    if (!ts.movePrevious()) return null;
    String literal = ts.token().text().toString();
    StringBuilder tokenPrefix = new StringBuilder();
    
    while (ts.offset() > start) {
        if (!ts.movePrevious()) {
            break;
        }
        if (ts.offset() == start) {
            tokenPrefix.append(ts.token().text().toString());
            break;
        }
    }
    if (!isReplaceLiteralsWithUnderscores(ctx.getPreferences()) && literal.contains("_")) return null;
    RadixInfo info = radixInfo(literal);
    if (info.radix == 8) return null;//octals ignored for now
    String normalized = info.constant.replaceAll(Pattern.quote("_"), "");
    int separateCount = getSizeForRadix(ctx.getPreferences(), info.radix);
    StringBuilder split = new StringBuilder();
    int count = separateCount + 1;

    for (int i = normalized.length(); i > 0; i--) {
        if (--count == 0) {
            split.append("_");
            count = separateCount;
        }
        split.append(normalized.charAt(i - 1));
    }

    split.reverse();

    String result = info.prefix + split.toString() + info.suffix;

    if (result.equals(literal)) return null;

    String displayName = NbBundle.getMessage(AddUnderscores.class, "ERR_" + ID);
    Fix f = new FixImpl(ctx.getInfo(), tp, tokenPrefix.toString() + result).toEditorFix();

    return ErrorDescriptionFactory.forTree(ctx, tp, displayName, f);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:AddUnderscores.java


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