Skip to content

Commit

Permalink
chore: inline testAnnotator wrapper method (#6677)
Browse files Browse the repository at this point in the history
It was required to provide backward compatiblity with 212
  • Loading branch information
tpasternak authored Aug 29, 2024
1 parent d63c6d5 commit 4c026ff
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
import com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression;
import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.sdkcompat.BaseSdkTestCompat;
import com.intellij.lang.annotation.Annotation;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;

import com.intellij.psi.PsiElement;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -339,9 +341,8 @@ private static void assertHasError(List<Annotation> annotations, String error) {
}

private List<Annotation> validateFile(BuildFile file) {
return BaseSdkTestCompat.testAnnotator(
new BuiltInRuleAnnotator(),
PsiUtils.findAllChildrenOfClassRecursive(file, FuncallExpression.class)
.toArray(FuncallExpression[]::new));
PsiElement[] elements = PsiUtils.findAllChildrenOfClassRecursive(file, FuncallExpression.class)
.toArray(FuncallExpression[]::new);
return CodeInsightTestUtil.testAnnotator(new BuiltInRuleAnnotator(), elements);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression;
import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.sdkcompat.BaseSdkTestCompat;
import com.intellij.lang.annotation.Annotation;
import java.util.List;
import java.util.stream.Collectors;

import com.intellij.psi.PsiElement;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -263,10 +265,9 @@ private void assertHasError(List<Annotation> annotations, String error) {
}

private List<Annotation> validateFile(BuildFile file) {
return BaseSdkTestCompat.testAnnotator(
new GlobErrorAnnotator(),
PsiUtils.findAllChildrenOfClassRecursive(file, GlobExpression.class)
.toArray(GlobExpression[]::new));
PsiElement[] elements = PsiUtils.findAllChildrenOfClassRecursive(file, GlobExpression.class)
.toArray(GlobExpression[]::new);
return CodeInsightTestUtil.testAnnotator(new GlobErrorAnnotator(), elements);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile;
import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.sdkcompat.BaseSdkTestCompat;
import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.HighlightSeverity;
import java.util.List;
import java.util.stream.Collectors;

import com.intellij.psi.PsiElement;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -105,9 +107,8 @@ private void assertHasAnnotation(BuildFile file, String message, HighlightSeveri
}

private List<Annotation> validateFile(BuildFile file) {
return BaseSdkTestCompat.testAnnotator(
new LoadStatementAnnotator(),
PsiUtils.findAllChildrenOfClassRecursive(file, BuildElement.class)
.toArray(BuildElement[]::new));
PsiElement[] elements = PsiUtils.findAllChildrenOfClassRecursive(file, BuildElement.class)
.toArray(BuildElement[]::new);
return CodeInsightTestUtil.testAnnotator(new LoadStatementAnnotator(), elements);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api212: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> key) {
((ComponentManagerImpl) componentManager.getPicoContainer()).unregisterComponent(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api212: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> key) {
((ComponentManagerImpl) componentManager).unregisterComponent(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api212: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> key) {
((ComponentManagerImpl) componentManager).unregisterComponent(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api223: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> componentKey) {
((ComponentManagerImpl) componentManager).unregisterComponent(componentKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api223: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> componentKey) {
((ComponentManagerImpl) componentManager).unregisterComponent(componentKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api223: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> componentKey) {
((ComponentManagerImpl) componentManager).unregisterComponent(componentKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api223: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> componentKey) {
((ComponentManagerImpl) componentManager).unregisterComponent(componentKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,12 @@
*/
package com.google.idea.sdkcompat;

import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.components.ComponentManager;
import com.intellij.psi.PsiElement;
import com.intellij.serviceContainer.ComponentManagerImpl;
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
import com.intellij.testFramework.UITestUtil;
import com.intellij.ui.IconManager;
import com.intellij.ui.icons.CoreIconManager;

import javax.swing.*;
import java.util.List;

/**
* Provides SDK compatibility shims for base plugin API classes, available to all IDEs during
Expand All @@ -38,11 +29,6 @@
public final class BaseSdkTestCompat {
private BaseSdkTestCompat() {}

/** #api212: inline into test cases */
public static List<Annotation> testAnnotator(Annotator annotator, PsiElement... elements) {
return CodeInsightTestUtil.testAnnotator(annotator, elements);
}

/** #api223: inline into ServiceHelper */
public static void unregisterComponent(ComponentManager componentManager, Class<?> componentKey) {
((ComponentManagerImpl) componentManager).unregisterComponent(componentKey);
Expand Down

0 comments on commit 4c026ff

Please sign in to comment.