use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testAnnotation.
public void testAnnotation() {
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "import java.lang.annotation.Retention;\n" + "import java.lang.annotation.RetentionPolicy;\n" + "import java.lang.annotation.Target;\n" + "\n" + "import static java.lang.annotation.ElementType.ANNOTATION_TYPE;\n" + "import static java.lang.annotation.ElementType.FIELD;\n" + "import static java.lang.annotation.ElementType.METHOD;\n" + "import static java.lang.annotation.ElementType.PARAMETER;\n" + "import static java.lang.annotation.RetentionPolicy.CLASS;\n" + "import static java.lang.annotation.RetentionPolicy.SOURCE;\n" + "@Retention(CLASS)\n" + "@Target({ANNOTATION_TYPE})\n" + "public @interface R11 {\n" + " long[] value();\n" + " boolean flag();\n" + "}";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R11.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method test57783.
public void test57783() {
//noinspection UnusedAssignment
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "public final class R7 {\n" + " public void foo() {\n" + " int i = 0;\n" + " int j = 0;\n" + " for (i = 0; i < 10; i++)\n" + " i++;" + " for (i = 0, j = 0; i < 10; i++)\n" + " i++;" + " }\n" + "}";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R7.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class CompatibilityChecksMetadataTest method loadMetadata.
@Test
public void loadMetadata() throws Exception {
@Language("XML") String metadataText = "<compatibility version='1'>\n" + " <check failureType='error'>\n" + " <component name='gradle' version='[2.4, +)'>\n" + " <requires name='android-gradle-plugin' version='[1.5.0, +]'>\n" + " <failureMsg>\n" + " <![CDATA[\n" + "Please use Android Gradle plugin 1.5.0 or newer.\n" + "]]>\n" + " </failureMsg>\n" + " </requires>\n" + " </component>\n" + " </check>\n" + "</compatibility>";
Document document = loadDocument(metadataText);
CompatibilityChecksMetadata metadata = CompatibilityChecksMetadata.load(document.getRootElement());
List<CompatibilityCheck> compatibilityChecks = metadata.getCompatibilityChecks();
assertThat(compatibilityChecks).hasSize(1);
CompatibilityCheck compatibilityCheck = compatibilityChecks.get(0);
assertSame(ERROR, compatibilityCheck.getType());
Component component = compatibilityCheck.getComponent();
assertEquals("gradle", component.getName());
// @formatter:off
assertAbout(versionRange()).that(component.getVersionRange()).hasMinVersion("2.4").hasMaxVersion(null).isMinVersionInclusive(true).isMaxVersionInclusive(false);
// @formatter:on
List<Component> requirements = component.getRequirements();
assertThat(requirements).hasSize(1);
Component requirement = requirements.get(0);
assertEquals("android-gradle-plugin", requirement.getName());
// @formatter:off
assertAbout(versionRange()).that(requirement.getVersionRange()).hasMinVersion("1.5.0").hasMaxVersion(null).isMinVersionInclusive(true).isMaxVersionInclusive(true);
// @formatter:on
assertEquals("Please use Android Gradle plugin 1.5.0 or newer.", requirement.getFailureMessage());
Map<String, ComponentVersionReader> readers = metadata.getReadersByComponentName();
assertSame(GRADLE, readers.get("gradle"));
assertSame(ANDROID_GRADLE_PLUGIN, readers.get("android-gradle-plugin"));
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class VersionCompatibilityCheckerTest method testCheckAndReportComponentIncompatibilities.
public void testCheckAndReportComponentIncompatibilities() throws Exception {
loadSimpleApplication();
mySyncMessagesStub.clearReportedMessages();
GradleWrapper gradleWrapper = GradleWrapper.find(getProject());
assertNotNull(gradleWrapper);
String gradleVersion = gradleWrapper.getGradleVersion();
assertNotNull(gradleVersion);
Module appModule = myModules.getAppModule();
AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
assertNotNull(androidModel);
GradleVersion currentModelVersion = androidModel.getModelVersion();
assertNotNull(currentModelVersion);
String failureMessage = "Please use Android Gradle plugin 1.5.0 or newer.";
@Language("XML") String metadata = "<compatibility version='1'>\n" + " <check failureType='error'>\n" + " <component name='gradle' version='[" + gradleVersion + ", +)'>\n" + " <requires name='android-gradle-plugin' version='[100.0.0, +]'>\n" + " <failureMsg>\n" + " <![CDATA[\n" + failureMessage + "\n" + "]]>\n" + " </failureMsg>\n" + " </requires>\n" + " </component>\n" + " </check>\n" + "</compatibility>";
VersionCompatibilityChecker checker = VersionCompatibilityChecker.getInstance();
checker.reloadMetadataForTesting(metadata);
checker.checkAndReportComponentIncompatibilities(getProject());
SyncMessage message = mySyncMessagesStub.getFirstReportedMessage();
String firstLine = String.format("Gradle %1$s requires Android Gradle plugin 100.0.0 (or newer) but project is using version %2$s.", gradleVersion, currentModelVersion);
// @formatter:off
assertAbout(syncMessage()).that(message).hasGroup("Gradle Sync Issues").hasType(ERROR).hasMessageLine(firstLine, 0).hasMessageLine(failureMessage, 1);
// @formatter:on
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testPrivateEnum.
public void testPrivateEnum() {
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "import android.os.Bundle;\n" + "import android.app.Activity;\n" + "\n" + "public class R9 extends Activity {\n" + "\n" + " @Override\n" + " protected void onCreate(Bundle savedInstanceState) {\n" + " super.onCreate(savedInstanceState);\n" + " setContentView(R.layout.main);\n" + " }\n" + "\n" + " private enum IconGridSize {\n" + " NORMAL(R.layout.other);\n" + "\n" + " IconGridSize(int foo) {\n" + " }\n" + " }\n" + "}\n";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R9.java", testClass);
check(file, testClass);
}
Aggregations