本文整理汇总了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
}
}
}
示例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);
}
示例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");
}
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例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());
}
}
}
示例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);
}
}
}
示例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());
}