本文整理汇总了Java中org.netbeans.modules.csl.api.Error.getStartPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Error.getStartPosition方法的具体用法?Java Error.getStartPosition怎么用?Java Error.getStartPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.modules.csl.api.Error
的用法示例。
在下文中一共展示了Error.getStartPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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());
}
示例3: getErrorOffsetRange
import org.netbeans.modules.csl.api.Error; //导入方法依赖的package包/类
/** tweak the error position if close to embedding boundary */
public static OffsetRange getErrorOffsetRange(Error e, Snapshot snapshot) {
int astFrom = e.getStartPosition();
int astTo = e.getEndPosition();
return convertToDocumentOffsets(astFrom, astTo, snapshot);
}
示例4: createMethodHintFix
import org.netbeans.modules.csl.api.Error; //导入方法依赖的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);
}
示例5: proposeUsings
import org.netbeans.modules.csl.api.Error; //导入方法依赖的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);
}
}
}
示例6: computeErrors
import org.netbeans.modules.csl.api.Error; //导入方法依赖的package包/类
List<ErrorDescription> computeErrors(Document doc, ParserResult result, List<? extends Error> errors, List<ErrorDescription> descs) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "errors = " + errors);
}
for (Error d : errors) {
if (cancel.isCancelled()) {
return null;
}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "d = " + d);
//Map<String, List<ErrorRule>> code2Rules = RulesManager.getInstance().getErrors();
}
//Map<String, List<ErrorRule>> code2Rules = RulesManager.getInstance().getErrors();
//List<ErrorRule> rules = code2Rules.get(d.getKey());
//if (LOG.isLoggable(Level.FINE)) {
//LOG.log(Level.FINE, "code= " + d.getKey());
//LOG.log(Level.FINE, "rules = " + rules);
//}
//int position = (int)d.getPosition();
int astOffset = d.getStartPosition();
int astEndOffset = d.getEndPosition();
int position, endPosition;
position = result.getSnapshot().getOriginalOffset(astOffset);
if (position == -1) {
continue;
}
endPosition = position+(astEndOffset-astOffset);
LazyFixList ehm;
//if (rules != null) {
// ehm = new CreatorBasedLazyFixList(info.getFileObject(), d.getKey(), (int)getPrefferedPosition(info, d), rules, data);
//} else {
ehm = ErrorDescriptionFactory.lazyListForFixes(Collections.<Fix>emptyList());
//}
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "ehm=" + ehm);
}
final String desc = d.getDisplayName();
final Position[] range = getLine(d, doc, position, endPosition);
if (cancel.isCancelled()) {
return null;
}
if (range[0] == null || range[1] == null) {
continue;
}
descs.add(ErrorDescriptionFactory.createErrorDescription(errorKind2Severity.get(d.getSeverity()), desc, ehm, doc, range[0], range[1]));
}
if (cancel.isCancelled()) {
return null;
}
return descs;
}
示例7: run
import org.netbeans.modules.csl.api.Error; //导入方法依赖的package包/类
@Override
protected void run(HtmlRuleContext context, List<Hint> result) {
Snapshot snapshot = context.getSnapshot();
int snapshotLen = snapshot.getText().length();
List<? extends Error> diagnostics = context.getLeftDiagnostics();
ListIterator<? extends Error> itr = diagnostics.listIterator();
while (itr.hasNext()) {
Error e = itr.next();
if (!appliesTo(context, e)) {
continue;
}
itr.remove(); //remove the processed element so the other rules won't see it
OffsetRange errorOffsetRange = EmbeddingUtil.getErrorOffsetRange(e, snapshot); //document offset range
int from = e.getStartPosition(); //use the embedded offset!
boolean valid = from >= 0 && from < snapshotLen;
boolean isFirstHintForPosition = valid ? context.isFirstHintForPosition(from) : true;
List<HintFix> fixes = new ArrayList<>();
if(isFirstHintForPosition) {
fixes.addAll(context.getDefaultFixes());
}
fixes.addAll(getExtraHintFixes(e, context));
Hint h = new Hint(this,
getModifiedErrorMessage(e.getDescription()),
e.getFile(),
errorOffsetRange,
fixes,
20);
if (isEnabled) {
//if the rule is disabled it will just remove the processed error from the
//list but won't create a hint
result.add(h);
}
}
}