本文整理汇总了Java中com.intellij.lang.annotation.ExternalAnnotator类的典型用法代码示例。如果您正苦于以下问题:Java ExternalAnnotator类的具体用法?Java ExternalAnnotator怎么用?Java ExternalAnnotator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExternalAnnotator类属于com.intellij.lang.annotation包,在下文中一共展示了ExternalAnnotator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCollectInformation
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
@RequiredReadAction
@Override
public void doCollectInformation(@Nonnull ProgressIndicator progress) {
myDocumentChanged = false;
final FileViewProvider viewProvider = myFile.getViewProvider();
final Set<Language> relevantLanguages = viewProvider.getLanguages();
for (Language language : relevantLanguages) {
PsiFile psiRoot = viewProvider.getPsi(language);
if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot)) continue;
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
if (!externalAnnotators.isEmpty()) {
DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject);
boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument);
for(ExternalAnnotator externalAnnotator: externalAnnotators) {
final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor, errorFound);
if (collectedInfo != null) {
myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo));
}
}
}
}
}
示例2: allForFile
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
@NotNull
public static List<ExternalAnnotator> allForFile(@NotNull Language language, @NotNull final PsiFile file) {
List<ExternalAnnotator> annotators = INSTANCE.allForLanguage(language);
final ExternalAnnotatorsFilter[] filters = Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
return ContainerUtil.findAll(annotators, new Condition<ExternalAnnotator>() {
@Override
public boolean value(ExternalAnnotator annotator) {
for (ExternalAnnotatorsFilter filter : filters) {
if (filter.isProhibited(annotator, file)) {
return false;
}
}
return true;
}
});
}
示例3: checkFileWithExternalAnnotator
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
@NotNull
public static <Init,Result> ProblemDescriptor[] checkFileWithExternalAnnotator(@NotNull PsiFile file,
@NotNull InspectionManager manager,
boolean isOnTheFly,
@NotNull ExternalAnnotator<Init,Result> annotator) {
if (isOnTheFly) {
// ExternalAnnotator does this work
return ProblemDescriptor.EMPTY_ARRAY;
}
Init info = annotator.collectInformation(file);
if (info != null) {
Result annotationResult = annotator.doAnnotate(info);
if (annotationResult == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
AnnotationHolderImpl annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
annotator.apply(file, annotationResult, annotationHolder);
return convertToProblemDescriptors(annotationHolder, manager, file);
}
return ProblemDescriptor.EMPTY_ARRAY;
}
示例4: doCollectInformation
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
myDocumentChanged = false;
final FileViewProvider viewProvider = myFile.getViewProvider();
final Set<Language> relevantLanguages = viewProvider.getLanguages();
for (Language language : relevantLanguages) {
PsiFile psiRoot = viewProvider.getPsi(language);
if (!HighlightLevelUtil.shouldInspect(psiRoot)) continue;
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot);
if (!externalAnnotators.isEmpty()) {
boolean errorFound = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap().wasErrorFound(myDocument);
if (errorFound) return;
for(ExternalAnnotator externalAnnotator: externalAnnotators) {
externalAnnotator.annotate(psiRoot, myAnnotationHolder);
final Object collectedInfo = externalAnnotator.collectInformation(psiRoot, myEditor);
if (collectedInfo != null) {
myAnnotator2DataMap.put(externalAnnotator, new MyData(psiRoot, collectedInfo));
}
}
}
}
}
示例5: runXmlFileSchemaValidation
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));
final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
for (ExternalAnnotator<?, ?> annotator : annotators) {
processAnnotator(xmlFile, holder, annotator);
}
if (!holder.hasAnnotations()) return Collections.emptyMap();
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
for (final Annotation annotation : holder) {
final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;
final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
if (startElement == null || endElement == null) continue;
final ProblemDescriptor descriptor =
myInspectionManager.createProblemDescriptor(startElement, endElement, info.getDescription(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false);
final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR? HighlightDisplayLevel.ERROR: HighlightDisplayLevel.WARNING;
problemsMap.put(descriptor, level);
}
return problemsMap;
}
示例6: processAnnotator
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private static <X, Y> void processAnnotator(@NotNull XmlFile xmlFile, AnnotationHolderImpl holder, ExternalAnnotator<X, Y> annotator) {
X initial = annotator.collectInformation(xmlFile);
if (initial != null) {
Y result = annotator.doAnnotate(initial);
if (result != null) {
annotator.apply(xmlFile, result, holder);
}
}
}
示例7: applyRelevant
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private void applyRelevant() {
for (ExternalAnnotator annotator : myAnnotator2DataMap.keySet()) {
final MyData data = myAnnotator2DataMap.get(annotator);
if (data != null && data.myAnnotationResult != null) {
annotator.apply(data.myPsiRoot, data.myAnnotationResult, myAnnotationHolder);
}
}
}
示例8: doAnnotate
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private void doAnnotate() {
for (ExternalAnnotator annotator : DumbService.getInstance(myProject).filterByDumbAwareness(myAnnotator2DataMap.keySet())) {
final MyData data = myAnnotator2DataMap.get(annotator);
if (data != null) {
data.myAnnotationResult = annotator.doAnnotate(data.myCollectedInfo);
}
}
}
示例9: externalAnnotatorsDefined
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private static boolean externalAnnotatorsDefined(@NotNull PsiFile file) {
for (Language language : file.getViewProvider().getLanguages()) {
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, file);
if (!externalAnnotators.isEmpty()) {
return true;
}
}
return false;
}
示例10: runXmlFileSchemaValidation
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));
final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
for (ExternalAnnotator annotator : annotators) {
annotator.annotate(xmlFile, holder);
}
if (!holder.hasAnnotations()) return Collections.emptyMap();
Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
for (final Annotation annotation : holder) {
final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;
final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
if (startElement == null || endElement == null) continue;
final ProblemDescriptor descriptor =
myInspectionManager.createProblemDescriptor(startElement, endElement, info.getDescription(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
false);
final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR? HighlightDisplayLevel.ERROR: HighlightDisplayLevel.WARNING;
problemsMap.put(descriptor, level);
}
return problemsMap;
}
示例11: allForFile
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
public static List<ExternalAnnotator> allForFile(Language language, final PsiFile file) {
List<ExternalAnnotator> annotators = INSTANCE.allForLanguage(language);
final ExternalAnnotatorsFilter[] filters = Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
return ContainerUtil.findAll(annotators, new Condition<ExternalAnnotator>() {
@Override
public boolean value(ExternalAnnotator annotator) {
for (ExternalAnnotatorsFilter filter : filters) {
if (filter.isProhibited(annotator, file)) {
return false;
}
}
return true;
}
});
}
示例12: ExternalToolPass
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
public ExternalToolPass(@NotNull ExternalToolPassFactory externalToolPassFactory,
@NotNull PsiFile file,
@NotNull Editor editor,
int startOffset,
int endOffset) {
super(file.getProject(), editor.getDocument(), false);
myEditor = editor;
myFile = file;
myStartOffset = startOffset;
myEndOffset = endOffset;
myAnnotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
myAnnotator2DataMap = new HashMap<ExternalAnnotator, MyData>();
myExternalToolPassFactory = externalToolPassFactory;
}
示例13: collectHighlighters
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private void collectHighlighters() {
for (ExternalAnnotator annotator : myAnnotator2DataMap.keySet()) {
final MyData data = myAnnotator2DataMap.get(annotator);
if (data != null) {
annotator.apply(data.myPsiRoot, data.myAnnotationResult, myAnnotationHolder);
}
}
}
示例14: doAnnotate
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private void doAnnotate() {
for (ExternalAnnotator annotator : myAnnotator2DataMap.keySet()) {
final MyData data = myAnnotator2DataMap.get(annotator);
if (data != null) {
data.myAnnotationResult = annotator.doAnnotate(data.myCollectedInfo);
}
}
}
示例15: externalAnnotatorsDefined
import com.intellij.lang.annotation.ExternalAnnotator; //导入依赖的package包/类
private static boolean externalAnnotatorsDefined(PsiFile file) {
for (Language language : file.getViewProvider().getLanguages()) {
final List<ExternalAnnotator> externalAnnotators = ExternalLanguageAnnotators.allForFile(language, file);
if (!externalAnnotators.isEmpty()) {
return true;
}
}
return false;
}