com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl Java Examples

The following examples show how to use com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTestCase.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@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;
}
 
Example #2
Source File: GlobValidationTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private GlobErrorAnnotator createAnnotator(PsiFile file) {
  annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
  return new GlobErrorAnnotator() {
    @Override
    protected AnnotationHolder getHolder() {
      return annotationHolder;
    }
  };
}
 
Example #3
Source File: LoadStatementAnnotatorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private LoadStatementAnnotator createAnnotator(PsiFile file) {
  annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
  return new LoadStatementAnnotator() {
    @Override
    protected AnnotationHolder getHolder() {
      return annotationHolder;
    }
  };
}
 
Example #4
Source File: BuiltInRuleAnnotatorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private BuiltInRuleAnnotator createAnnotator(PsiFile file) {
  annotationHolder = new AnnotationHolderImpl(new AnnotationSession(file));
  return new BuiltInRuleAnnotator() {
    @Override
    protected AnnotationHolder getHolder() {
      return annotationHolder;
    }
  };
}
 
Example #5
Source File: BlazeGoAnnotatorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #6
Source File: ShopwareLightCodeInsightFixtureTestCase.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
@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;
}
 
Example #7
Source File: DrupalLightCodeInsightFixtureTestCase.java    From idea-php-drupal-symfony2-bridge with MIT License 5 votes vote down vote up
@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;
}
 
Example #8
Source File: TemplateAnnotationAnnotatorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * @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"))
    );
}
 
Example #9
Source File: SymfonyLightCodeInsightFixtureTestCase.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@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;
}
 
Example #10
Source File: HaxeAnnotationHolder.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public HaxeAnnotationHolder(AnnotationHolder underlyingHolder) {
  assert(underlyingHolder instanceof AnnotationHolderImpl || underlyingHolder instanceof HaxeAnnotationHolder);
  myInternalHolder = underlyingHolder instanceof HaxeAnnotationHolder
                      ? ((HaxeAnnotationHolder)underlyingHolder).myInternalHolder
                      : (AnnotationHolderImpl)underlyingHolder;
}
 
Example #11
Source File: TemplateAnnotationAnnotatorTest.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
/**
 * @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"))
    );
}