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


Java Hint类代码示例

本文整理汇总了Java中org.netbeans.modules.csl.api.Hint的典型用法代码示例。如果您正苦于以下问题:Java Hint类的具体用法?Java Hint怎么用?Java Hint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: computeSuggestions

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
@Override
public void computeSuggestions(HintsProvider.HintsManager manager, RuleContext context, List<Hint> hints, int caretOffset) {
    HtmlParserResult result = (HtmlParserResult) context.parserResult;
    Node root = result.root(SyntaxAnalyzerResult.FILTERED_CODE_NAMESPACE);
    Snapshot snapshot = result.getSnapshot();
    int embeddedCaretOffset = snapshot.getEmbeddedOffset(caretOffset);
    Element found = ElementUtils.findByPhysicalRange(root, embeddedCaretOffset, false);
    if (found != null) {
        switch (found.type()) {
            case OPEN_TAG:
            case CLOSE_TAG:
                Named named = (Named) found;
                String elementName = named.name().toString();
                Configuration conf = Configuration.get(snapshot.getSource().getFileObject());
                if (conf.getTagsNames().contains(elementName)) {
                    //custom element
                    hints.add(new CustomElementHint(elementName, context, new OffsetRange(snapshot.getOriginalOffset(found.from()), snapshot.getOriginalOffset(found.to()))));

                }

            //TODO add check + fix for missing required attributes
        }
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CustomHtmlExtension.java

示例2: proposeCreateType

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
private void proposeCreateType(Error error, RuleContext ctx, List<Hint> hints)
{
    FanParserTask result = (FanParserTask) ctx.parserResult;
    String type = null;
    try
    {
        type = result.getDocument().getText(error.getStartPosition(), error.getEndPosition() - error.getStartPosition());
    } catch (BadLocationException e)
    {
        return;
    }
    List<HintFix> fixes = new ArrayList<HintFix>();
    fixes.add(new FanCreateTypeFix(ctx, type));
    Hint hint = new Hint(new FanHintRule(), "", result.getSourceFile(),
            new OffsetRange(error.getStartPosition(), error.getEndPosition()), fixes, 25);
    hints.add(hint);
}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:18,代码来源:FanHintsProvider.java

示例3: findHints

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
protected void findHints(NbTestCase test, Rule hint, String relFilePath, FileObject fileObject, String caretLine) throws Exception {
    ComputedHints r = getHints(test, hint, relFilePath, fileObject, caretLine);
    ParserResult info = r.info;
    List<Hint> result = r.hints;
    int caretOffset = r.caretOffset;

    String annotatedSource = annotateHints((BaseDocument) info.getSnapshot().getSource().getDocument(true), result, caretOffset);

    if (fileObject != null) {
        assertDescriptionMatches(fileObject, annotatedSource, true, getGoldenFileSuffix() + ".hints");
    } else {
        assertDescriptionMatches(relFilePath, annotatedSource, true, getGoldenFileSuffix() + ".hints");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CslTestBase.java

示例4: findApplicableFix

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
private HintFix findApplicableFix(ComputedHints r, String text) {
    boolean substringMatch = true;
    if (text.endsWith("\n")) {
        text = text.substring(0, text.length()-1);
        substringMatch = false;
    }
    int caretOffset = r.caretOffset;
    for (Hint desc : r.hints) {
        int start = desc.getRange().getStart();
        int end = desc.getRange().getEnd();
        OffsetRange range = new OffsetRange(start, end);
        if (range.containsInclusive(caretOffset) || caretOffset == range.getEnd()+1) { // special case for wrong JRuby offsets
            // Optionally make sure the text is the one we're after such that
            // tests can disambiguate among multiple fixes
            // special case for wrong JRuby offsets
            // Optionally make sure the text is the one we're after such that
            // tests can disambiguate among multiple fixes
            List<HintFix> list = desc.getFixes();
            assertNotNull(list);
            for (HintFix fix : list) {
                if (text == null ||
                        (substringMatch && fix.getDescription().indexOf(text) != -1) ||
                        (!substringMatch && fix.getDescription().equals(text))) {
                    return fix;
                }
            }
        }
    }

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

示例5: getChecker

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
public static ElementVisitor getChecker(RuleContext context, Configuration conf, Snapshot snapshot, List<Hint> hints) {
    Collection<ElementVisitor> visitors = new ArrayList<>();
    visitors.add(new UnknownAttributesChecker(context, conf, snapshot, hints));
    visitors.add(new MissingRequiredAttributeChecker(context, conf, snapshot, hints));
    
    return new AggregatedVisitor(visitors);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:CheckerElementVisitor.java

示例6: computeErrors

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
@Override
public void computeErrors(HintsProvider.HintsManager manager, final RuleContext context, final List<Hint> hints, List<Error> unhandled) {
    HtmlParserResult result = (HtmlParserResult) context.parserResult;
    Node root = result.root(SyntaxAnalyzerResult.FILTERED_CODE_NAMESPACE);
    final Snapshot snapshot = result.getSnapshot();
    final Configuration conf = Configuration.get(snapshot.getSource().getFileObject());
    ElementUtils.visitChildren(root, CheckerElementVisitor.getChecker(context, conf, snapshot, hints));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CustomHtmlExtension.java

示例7: run

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
@Override
protected void run(HtmlRuleContext context, List<Hint> result) {
    try {
        HtmlParserResult parserResult = context.getHtmlParserResult();
        if(context.getCssIndex() != null) { //test if we can get the index, if not we can check nothing (typically css out of a project)
            CssClassesVisitor visitor = new CssClassesVisitor(this, context, result);
            ElementUtils.visitChildren(parserResult.root(), visitor, ElementType.OPEN_TAG);
        }
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MissingClassRule.java

示例8: CssClassesVisitor

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
public CssClassesVisitor(Rule rule, HtmlRuleContext context, List<Hint> hints) throws IOException {
    this.context = context;
    this.hints = hints;
    this.rule = rule;
    
    referredFiles = context.getCssDependenciesGraph().getAllReferedFiles();
    classes = context.getCssIndex().findAllClassDeclarations();
    classes2files = createReversedMap(classes);
    allStylesheets = context.getCssIndex().getAllIndexedFiles();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CssClassesVisitor.java

示例9: CssIdsVisitor

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
public CssIdsVisitor(Rule rule, HtmlRuleContext context, List<Hint> hints) throws IOException {
    this.context = context;
    this.hints = hints;
    this.rule = rule;
    
    referredFiles = context.getCssDependenciesGraph().getAllReferedFiles();
    ids = context.getCssIndex().findAllIdDeclarations();
    ids2files = createReversedMap(ids);
    allStylesheets = context.getCssIndex().getAllIndexedFiles();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CssIdsVisitor.java

示例10: run

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
@Override
protected void run(HtmlRuleContext context, List<Hint> result) {
    try {
        HtmlParserResult parserResult = context.getHtmlParserResult();
        CssIdsVisitor visitor = new CssIdsVisitor(this, context, result);
        ElementUtils.visitChildren(parserResult.root(), visitor, ElementType.OPEN_TAG);
    } catch(IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:MissingIdRule.java

示例11: createMethodHintFix

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
private void createMethodHintFix(RuleContext ctx, List<Hint> hints, Error error) {
    ParserResult parserResult = ctx.parserResult;
    List<HintFix> listFixes = new ArrayList<>();
    listFixes.add(new CreateMethodHintFix(ctx, error));

    Hint hint = new Hint(new RoutesHintRule(), "",
            parserResult.getSnapshot().getSource().getFileObject(),
            new OffsetRange(error.getStartPosition(), error.getEndPosition()),
            listFixes, 50);

    hints.add(hint);
}
 
开发者ID:pedrohidalgo,项目名称:pleasure,代码行数:13,代码来源:RoutesHintsProvider.java

示例12: computeErrors

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
public void computeErrors(HintsManager manager, RuleContext ctx, List<Hint> hints, List<Error> errors)
{
    FanParserTask result = (FanParserTask) ctx.parserResult;
    if (result != null)
    {
        errors.addAll(result.getDiagnostics());
    }

    provideHints(ctx, hints, errors);
}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:11,代码来源:FanHintsProvider.java

示例13: provideHints

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
/**
 * Provide hints for some of the errors
 * @param ctx
 * @param hints
 */
private void provideHints(RuleContext ctx, List<Hint> hints, List<Error> errors)
{
    //FanParserTask result = (FanParserTask) ctx.parserResult;
    for (Error error : errors)
    {
        FanParserErrorKey key;
        try
        {
            key = FanParserErrorKey.valueOf(error.getKey());
        } catch (IllegalArgumentException e)
        {
            return;
        }
        switch (key)
        {
            case UNKNOWN_TYPE:
                proposeUsings(error, ctx, hints);
                proposeCreateType(error, ctx, hints);
                // TODO: propose to create type in The current file ?
                break;
            case UNKNOWN_ITEM:
                proposeVar(error, ctx, hints);
                break;
            /*case UNKNOWN_SLOT:
            fixes.add(new FanAddUsingFix(ctx));
            hint = new Hint(new FanHintRule(), "", result.getSourceFile(),
            new OffsetRange(error.getStartPosition(), error.getEndPosition()), fixes, 25);
            break;
             */
            default:
                //System.err.println("Unknown key: " + key.name());
        }
    }

}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:41,代码来源:FanHintsProvider.java

示例14: proposeUsings

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
private void proposeUsings(Error error, RuleContext ctx, List<Hint> hints)
{
    FanParserTask result = (FanParserTask) ctx.parserResult;
    String type = null;
    try
    {
        type = result.getDocument().getText(error.getStartPosition(), error.getEndPosition() - error.getStartPosition());
    } catch (BadLocationException e)
    {
    }
    if (type != null)
    {
        Collection<FanType> types = FanType.findTypes(type);
        List<HintFix> fixes = new ArrayList<HintFix>();
        for (FanType t : types)
        {
            // propose adding this specific type
            String qn = t.getQualifiedName();
            fixes.add(new FanAddUsingFix(ctx, qn));
            // also propose adding the whole pod
            String pod = t.getPod();
            if (pod != null && pod.length() > 0 && !t.isJava())
            {
                fixes.add(new FanAddUsingFix(ctx, pod));
            }
        }
        if (!fixes.isEmpty())
        {
            Hint hint = new Hint(new FanHintRule(), "", result.getSourceFile(),
                    new OffsetRange(error.getStartPosition(), error.getEndPosition()), fixes, 25);
            hints.add(hint);
        }
    }
}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:35,代码来源:FanHintsProvider.java

示例15: createDescription

import org.netbeans.modules.csl.api.Hint; //导入依赖的package包/类
public final ErrorDescription createDescription(Hint desc, RuleContext context, boolean allowDisableEmpty, boolean last) {
    Rule rule = desc.getRule();
    HintSeverity severity;
    if (rule instanceof UserConfigurableRule) {
        severity = HintsSettings.getSeverity(this, (UserConfigurableRule)rule);
    } else {
        severity = rule.getDefaultSeverity();
    }
    OffsetRange range = desc.getRange();
    List<org.netbeans.spi.editor.hints.Fix> fixList;
    ParserResult info = context.parserResult;
    
    if (desc.getFixes() != null && desc.getFixes().size() > 0) {
        fixList = new ArrayList<org.netbeans.spi.editor.hints.Fix>(desc.getFixes().size());
        
        // TODO print out priority with left flushed 0's here
        // this is just a hack
        String sortText = Integer.toString(10000+desc.getPriority());
        
        for (org.netbeans.modules.csl.api.HintFix fix : desc.getFixes()) {
            fixList.add(new FixWrapper(fix, sortText));
            
            if (fix instanceof PreviewableFix) {
                PreviewableFix previewFix = (PreviewableFix)fix;
                if (previewFix.canPreview() && !isTest) {
                    fixList.add(new PreviewHintFix(info, previewFix, sortText));
                }
            }
        }
        
        if (last && rule instanceof UserConfigurableRule && !isTest) {
            // Add a hint for opening options dialog
            fixList.add(new DisableHintFix(this, context));
        }
    } else if (last && allowDisableEmpty && rule instanceof UserConfigurableRule && !isTest) {
        // Add a hint for openening options dialog
        fixList = Collections.<org.netbeans.spi.editor.hints.Fix>singletonList(new DisableHintFix(this, context));
    } else {
        fixList = Collections.emptyList();
    }
    return ErrorDescriptionFactory.createErrorDescription(
            severity.toEditorSeverity(), 
            desc.getDescription(), fixList, desc.getFile(), range.getStart(), range.getEnd());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:GsfHintsManager.java


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