本文整理汇总了Java中org.netbeans.modules.csl.api.Error类的典型用法代码示例。如果您正苦于以下问题:Java Error类的具体用法?Java Error怎么用?Java Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Error类属于org.netbeans.modules.csl.api包,在下文中一共展示了Error类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLine
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
private Position[] getLine(final Error d, final Document doc, final int startOffset, final int endOffset) {
if (doc == null) {
return new Position[2];
}
final Position[][] ret = new Position[][] { new Position[2] };
// line nunmber conversion + getText from the line should happen
// under the document read-lock.
doc.render(new Runnable() {
public void run() {
if (cancel.isCancelled()) {
return;
}
ret[0] = getLine0(d, doc, startOffset, endOffset);
}
});
return ret[0];
}
示例2: checkErrors
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
protected void checkErrors(final String relFilePath) throws Exception {
Source testSource = getTestSource(getTestFile(relFilePath));
ParserManager.parse(Collections.singleton(testSource), new UserTask() {
public @Override void run(ResultIterator resultIterator) throws Exception {
Parser.Result r = resultIterator.getParserResult();
assertNotNull(r);
assertTrue(r instanceof ParserResult);
ParserResult pr = (ParserResult) r;
List<? extends Error> diagnostics = pr.getDiagnostics();
String annotatedSource = annotateErrors(diagnostics);
assertDescriptionMatches(relFilePath, annotatedSource, false, ".errors");
}
});
}
示例3: parse
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
/**
* Called by infrastructure when Source is changed, and a new Snapshot has been created for it.
*
* @param snapshot A snapshot that should be parsed.
* @param task A task asking for parsing result.
* @param event A scheduler event
*/
@Override
public void parse(Snapshot snapshot, Task task, SourceModificationEvent event) {
this.snapshot = snapshot;
Reader reader = new StringReader(snapshot.getText().toString());
apexParser = new ApexParser(reader);
apexParser.setTreeFactory(new ApexTreeFactory());
try {
if (snapshot.getMimeType().equalsIgnoreCase(ApexLanguageHierarchy.APEX_MIME_TYPE)) {
compilationUnit = apexParser.CompilationUnit();
} else if (snapshot.getMimeType().equalsIgnoreCase(ApexLanguageHierarchy.APEX_TRIGGER_MIME_TYPE)){
compilationUnit = apexParser.TriggerCompilationUnit();
}
} catch (org.fundacionjala.oblivion.apex.grammar.jcclexer.ParseException ex) {
apexParser.contextErrorRecover(ex);
} catch (java.lang.Error error){
error.printStackTrace();
}
}
示例4: getResult
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
@Override
public Result getResult(Task task) throws ParseException {
return new ParserResult(snapshot) {
@Override
public List<? extends Error> getDiagnostics() {
Document document = snapshot.getSource().getDocument(false);
if (document != null) {
return RoutesValidator.validateFile(document);
} else {
return Collections.EMPTY_LIST;
}
}
@Override
protected void invalidate() {
}
};
}
示例5: run
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
@Override
public void run(ParserResult result, SchedulerEvent event) {
List<? extends Error> listDiagnostics = result.getDiagnostics();
Document document = result.getSnapshot().getSource().getDocument(false);
List<ErrorDescription> errors = new ArrayList<>();
listDiagnostics.stream().forEach((error) -> {
try {
ErrorDescription errorDescription = ErrorDescriptionFactory
.createErrorDescription(
Severity.ERROR,
"",
document,
document.createPosition(error.getStartPosition()),
document.createPosition(error.getEndPosition()));
errors.add(errorDescription);
} catch (BadLocationException ex) {
ExceptionManager.logException(ex);
}
});
HintsController.setErrors(document, "idontknow", errors);
}
示例6: run
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
@Override
public void run(ParserResult result, SchedulerEvent event) {
Document document = result.getSnapshot().getSource().getDocument(false);
ScalaTemplateValidator scalaTemplateValidator = new ScalaTemplateValidator();
List<? extends Error> listDiagnostics = scalaTemplateValidator.validateFile(document);
List<ErrorDescription> errors = new ArrayList<>();
listDiagnostics.stream().forEach((error) -> {
try {
ErrorDescription errorDescription = ErrorDescriptionFactory
.createErrorDescription(
Severity.ERROR,
error.getDisplayName(),
document,
document.createPosition(error.getStartPosition()),
document.createPosition(error.getEndPosition()));
errors.add(errorDescription);
} catch (BadLocationException ex) {
ExceptionManager.logException(ex);
}
});
HintsController.setErrors(document, "idontknow", errors);
}
示例7: proposeCreateType
import org.netbeans.modules.csl.api.Error; //导入依赖的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);
}
示例8: processErrors
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
void processErrors(final Snapshot snapshot, final ParserResult result,
Document doc,
final List<ErrorDescription> descriptions,
Snapshot topLevelSnapshot) throws ParseException {
if (doc == null) {
doc = getDocument();
}
Language language = LanguageRegistry.getInstance().getLanguageByMimeType(snapshot.getMimeType());
if (language == null) {
return;
}
if(!(result instanceof ParserResult)) {
return ;
}
ParserResult r = (ParserResult)result;
List<? extends Error> errors = r.getDiagnostics();
List<ErrorDescription> desc = new ArrayList<ErrorDescription>();
List<Error> unhandled = processProviderErrors(descriptions, topLevelSnapshot, r, language);
if (unhandled != null) {
errors = unhandled;
}
// Process errors without codes
desc = computeErrors(doc, r, errors, desc);
if (desc == null) {
//meaning: cancelled
return;
}
descriptions.addAll(desc);
}
示例9: createDefaultError
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
public static Error createDefaultError(@NullAllowed String key,
@NonNull String displayName,
@NullAllowed String description,
@NonNull FileObject file,
@NonNull int start,
@NonNull int end,
boolean lineError,
@NonNull Severity severity) {
return new DefaultError(key, displayName, description, file, start, end, lineError, severity);
}
示例10: simplify
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
private static SimpleError simplify(Error error, int pos) {
return new SimpleError(error.getDisplayName(),
error.getDescription(),
pos == -1 ? error.getStartPosition() : pos,
error.getSeverity(),
error instanceof Badging && ((Badging) error).showExplorerBadge());
}
示例11: assertResult
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
protected CssParserResult assertResult(CssParserResult result, int problems) {
assertNotNull(result);
assertNotNull(result.getParseTree());
if (problems != result.getDiagnostics().size()) {
TestUtil.dumpResult(result);
}
int foundProblemsCount = result.getDiagnostics().size();
if(problems != foundProblemsCount) {
StringBuilder sb = new StringBuilder();
sb.append("Unexpected error(s):\n");
for(Error e : result.getDiagnostics()) {
sb.append(e.toString());
}
assertEquals(sb.toString(), problems, foundProblemsCount);
}
if (foundProblemsCount == 0) {
//Check whether the parse tree covers the whole file only if it is not broken.
//This doesn't mean an errorneous file should not produce parse tree
//fully covering the source. Just there're some cases where it doesn't work now.
//TODO: enable the parse tree tokens consistency check for all parse result, not just for the errorneous ones.
assertNoTokenNodeLost(result);
}
return result;
}
示例12: filter
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
@Override
public List<? extends Error> filter(ParserResult parserResult) {
if(parserResult instanceof CssParserResult) {
List<? extends FilterableError> extendedDiagnostics = ((CssParserResult)parserResult).getDiagnostics();
List<Error> kept = new ArrayList<>();
for(FilterableError fe : extendedDiagnostics) {
if(!fe.isFiltered()) {
kept.add(fe);
}
}
return kept;
}
return parserResult.getDiagnostics();
}
示例13: assertCssCode
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
protected void assertCssCode(String code) throws ParseException {
Source source = Source.create(getDocument(code));
ParserManager.parse(Collections.singleton(source), new UserTask() {
@Override
public void run(ResultIterator resultIterator) throws Exception {
Result result = resultIterator.getParserResult();
assertNotNull(result);
assertTrue(result instanceof CssParserResult);
CssParserResult cssresult = (CssParserResult) result;
Collection<? extends Error> errors = cssresult.getDiagnostics();
if(errors.size() > 0) {
StringBuilder sb = new StringBuilder();
for(Iterator<? extends Error> itr = errors.iterator(); itr.hasNext(); ) {
Error e = itr.next();
sb.append(e.getSeverity());
sb.append(" at ");
sb.append(e.getStartPosition());
sb.append(':');
sb.append(e.getDescription());
if(itr.hasNext()) {
sb.append(", ");
}
}
assertEquals(String.format("Unexpected errors found: %s.", sb), 0, errors.size());
}
}
});
}
示例14: computeErrors
import org.netbeans.modules.csl.api.Error; //导入依赖的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));
}
示例15: getExtraHintFixes
import org.netbeans.modules.csl.api.Error; //导入依赖的package包/类
@Override
protected List<HintFix> getExtraHintFixes(Error e, HtmlRuleContext context) {
if (matched_pattern_index == UNKNOWN_ELEMENT_PATTERN_INDEX) {
//the "Element .*? not allowed as child of element .*? in this context." pattern
List<HintFix> fixes = new ArrayList<>();
fixes.addAll(super.getExtraHintFixes(e, context));
fixes.addAll(getSPIHintFixes(e, context));
return fixes;
} else {
return super.getExtraHintFixes(e, context);
}
}