Java源码示例:com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl
示例1
@NotNull
private AnnotationHolderImpl getAnnotationsAtCaret(String filename, String content) {
PsiFile psiFile = myFixture.configureByText(filename, content);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
for (Annotator annotator : LanguageAnnotators.INSTANCE.allForLanguage(psiFile.getLanguage())) {
annotator.annotate(psiElement, annotations);
}
return annotations;
}
示例2
private GlobErrorAnnotator createAnnotator(PsiFile file) {
annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
return new GlobErrorAnnotator() {
@Override
protected AnnotationHolder getHolder() {
return annotationHolder;
}
};
}
示例3
private LoadStatementAnnotator createAnnotator(PsiFile file) {
annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
return new LoadStatementAnnotator() {
@Override
protected AnnotationHolder getHolder() {
return annotationHolder;
}
};
}
示例4
private BuiltInRuleAnnotator createAnnotator(PsiFile file) {
annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
return new BuiltInRuleAnnotator() {
@Override
protected AnnotationHolder getHolder() {
return annotationHolder;
}
};
}
示例5
private static void assertNoAnnotations(@Nullable PsiReference reference) {
assertThat(reference).isNotNull();
PsiElement element = reference.getElement();
AnnotationHolderImpl holder =
new AnnotationHolderImpl(new AnnotationSession(element.getContainingFile()));
new GoAnnotator().annotate(element, holder);
assertThat(holder).isEmpty();
}
示例6
@NotNull
private AnnotationHolderImpl getAnnotationsAtCaret(String filename, String content) {
PsiFile psiFile = myFixture.configureByText(filename, content);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
for (Annotator annotator : LanguageAnnotators.INSTANCE.allForLanguage(psiFile.getLanguage())) {
annotator.annotate(psiElement, annotations);
}
return annotations;
}
示例7
@NotNull
private AnnotationHolderImpl getAnnotationsAtCaret(String filename, String content) {
PsiFile psiFile = myFixture.configureByText(filename, content);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
for (Annotator annotator : LanguageAnnotators.INSTANCE.allForLanguage(psiFile.getLanguage())) {
annotator.annotate(psiElement, annotations);
}
return annotations;
}
示例8
/**
* @see TemplateAnnotationAnnotator#annotate
*/
public void testThatTemplateCreationAnnotationProvidesQuickfix() {
PsiFile psiFile = myFixture.configureByText("foobar.php", "<?php\n" +
"use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template;\n" +
"\n" +
"class Foobar\n" +
"{\n" +
" /**\n" +
" * @Temp<caret>late(\"foobar.html.twig\")\n" +
" */\n" +
" public function fooAction()\n" +
" {\n" +
" }\n" +
"}\n" +
""
);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
PsiElement phpDocTag = psiElement.getParent();
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
new TemplateAnnotationAnnotator().annotate(new PhpAnnotationDocTagAnnotatorParameter(
PhpIndex.getInstance(getProject()).getAnyByFQN(TwigUtil.TEMPLATE_ANNOTATION_CLASS).iterator().next(),
(PhpDocTag) phpDocTag,
annotations
));
assertNotNull(
annotations.stream().findFirst().filter(annotation -> annotation.getMessage().contains("Create Template"))
);
}
示例9
@NotNull
private AnnotationHolderImpl getAnnotationsAtCaret(String filename, String content) {
PsiFile psiFile = myFixture.configureByText(filename, content);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
for (Annotator annotator : LanguageAnnotators.INSTANCE.allForLanguage(psiFile.getLanguage())) {
annotator.annotate(psiElement, annotations);
}
return annotations;
}
示例10
public HaxeAnnotationHolder(AnnotationHolder underlyingHolder) {
assert(underlyingHolder instanceof AnnotationHolderImpl || underlyingHolder instanceof HaxeAnnotationHolder);
myInternalHolder = underlyingHolder instanceof HaxeAnnotationHolder
? ((HaxeAnnotationHolder)underlyingHolder).myInternalHolder
: (AnnotationHolderImpl)underlyingHolder;
}
示例11
/**
* @see TemplateAnnotationAnnotator#annotate
*/
public void testThatTemplateCreationForInvokeMethodProvidesQuickfix() {
myFixture.copyFileToProject("controller_method.php");
myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" +
"namespace FooBundle\\Controller;\n" +
"class FoobarController\n" +
"{\n" +
" public function __in<caret>voke() {}\n" +
"" +
"}\n"
);
PsiFile psiFile = myFixture.configureByText("foobar.php", "<?php\n" +
"use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template;\n" +
"\n" +
"class Foobar\n" +
"{\n" +
" /**\n" +
" * @Temp<caret>late()\n" +
" */\n" +
" public function __invoke()\n" +
" {\n" +
" }\n" +
"}\n" +
""
);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
PsiElement phpDocTag = psiElement.getParent();
AnnotationHolderImpl annotations = new AnnotationHolderImpl(new AnnotationSession(psiFile));
new TemplateAnnotationAnnotator().annotate(new PhpAnnotationDocTagAnnotatorParameter(
PhpIndex.getInstance(getProject()).getAnyByFQN(TwigUtil.TEMPLATE_ANNOTATION_CLASS).iterator().next(),
(PhpDocTag) phpDocTag,
annotations
));
assertNotNull(
annotations.stream().findFirst().filter(annotation -> annotation.getMessage().contains("Create Template"))
);
}