com.intellij.lang.annotation.AnnotationSession Java Examples

The following examples show how to use com.intellij.lang.annotation.AnnotationSession. 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: 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 #2
Source File: ExternalToolPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ExternalToolPass(@Nonnull ExternalToolPassFactory externalToolPassFactory,
                        @Nonnull PsiFile file,
                        @Nonnull 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;
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: HaxeAnnotationHolder.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public AnnotationSession getCurrentAnnotationSession() {
  return myInternalHolder.getCurrentAnnotationSession();
}
 
Example #12
Source File: TestHolder.java    From litho with Apache License 2.0 4 votes vote down vote up
@Override
public AnnotationSession getCurrentAnnotationSession() {
  return null;
}
 
Example #13
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"))
    );
}
 
Example #14
Source File: AnnotationHolderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public AnnotationHolderImpl(@Nonnull AnnotationSession session) {
  this(session, false);
}
 
Example #15
Source File: AnnotationHolderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public AnnotationHolderImpl(@Nonnull AnnotationSession session, boolean batchMode) {
  myAnnotationSession = session;
  myBatchMode = batchMode;
}
 
Example #16
Source File: AnnotationHolderImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AnnotationSession getCurrentAnnotationSession() {
  return myAnnotationSession;
}
 
Example #17
Source File: CheckLevelHighlightInfoHolder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AnnotationSession getAnnotationSession() {
  return myHolder.getAnnotationSession();
}
 
Example #18
Source File: HighlightInfoHolder.java    From consulo with Apache License 2.0 4 votes vote down vote up
public HighlightInfoHolder(@Nonnull PsiFile contextFile, @Nonnull HighlightInfoFilter... filters) {
  myContextFile = contextFile;
  myAnnotationSession = new AnnotationSession(contextFile);
  myFilters = filters;
}
 
Example #19
Source File: HighlightInfoHolder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public AnnotationSession getAnnotationSession() {
  return myAnnotationSession;
}