本文整理匯總了Java中com.intellij.lang.annotation.Annotation.getStartOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.getStartOffset方法的具體用法?Java Annotation.getStartOffset怎麽用?Java Annotation.getStartOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.annotation.Annotation
的用法示例。
在下文中一共展示了Annotation.getStartOffset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertToProblemDescriptors
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@NotNull
private static ProblemDescriptor[] convertToProblemDescriptors(@NotNull final List<Annotation> annotations,
@NotNull final InspectionManager manager,
@NotNull final PsiFile file) {
if (annotations.isEmpty()) {
return ProblemDescriptor.EMPTY_ARRAY;
}
List<ProblemDescriptor> problems = ContainerUtil.newArrayListWithCapacity(annotations.size());
IdentityHashMap<IntentionAction, LocalQuickFix> quickFixMappingCache = ContainerUtil.newIdentityHashMap();
for (Annotation annotation : annotations) {
if (annotation.getSeverity() == HighlightSeverity.INFORMATION ||
annotation.getStartOffset() == annotation.getEndOffset()) {
continue;
}
final PsiElement startElement = file.findElementAt(annotation.getStartOffset());
final PsiElement endElement = file.findElementAt(annotation.getEndOffset() - 1);
if (startElement == null || endElement == null) {
continue;
}
LocalQuickFix[] quickFixes = toLocalQuickFixes(annotation.getQuickFixes(), quickFixMappingCache);
ProblemDescriptor descriptor = manager.createProblemDescriptor(startElement,
endElement,
annotation.getMessage(),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false,
quickFixes);
problems.add(descriptor);
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
示例2: fromAnnotation
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@NotNull
static HighlightInfo fromAnnotation(@NotNull Annotation annotation, @Nullable TextRange fixedRange, boolean batchMode) {
final TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes();
TextAttributesKey key = annotation.getTextAttributes();
final TextAttributesKey forcedAttributesKey = forcedAttributes == null ? (key == HighlighterColors.NO_HIGHLIGHTING ? null : key) : null;
HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation),
fixedRange != null? fixedRange.getStartOffset() : annotation.getStartOffset(),
fixedRange != null? fixedRange.getEndOffset() : annotation.getEndOffset(),
annotation.getMessage(), annotation.getTooltip(),
annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(),
0, annotation.getProblemGroup(), annotation.getGutterIconRenderer());
appendFixes(fixedRange, info, batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes());
return info;
}