Search in sources :

Example 76 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 77 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 78 with Language

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"));
}
Also used : Language(org.intellij.lang.annotations.Language) Document(org.jdom.Document) JDOMUtil.loadDocument(com.intellij.openapi.util.JDOMUtil.loadDocument) ComponentVersionReader(com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader) Test(org.junit.Test)

Example 79 with Language

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
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Language(org.intellij.lang.annotations.Language) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Module(com.intellij.openapi.module.Module) GradleVersion(com.android.ide.common.repository.GradleVersion) GradleWrapper(com.android.tools.idea.gradle.util.GradleWrapper)

Example 80 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Aggregations

Language (org.intellij.lang.annotations.Language)111 TableMetadata (com.facebook.presto.metadata.TableMetadata)25 Test (org.testng.annotations.Test)24 MaterializedResult (com.facebook.presto.testing.MaterializedResult)19 PsiFile (com.intellij.psi.PsiFile)18 MaterializedRow (com.facebook.presto.testing.MaterializedRow)11 List (java.util.List)11 Optional (java.util.Optional)11 Test (org.junit.Test)11 ImmutableList (com.google.common.collect.ImmutableList)10 Session (com.facebook.presto.Session)9 Constraint (com.facebook.presto.spi.Constraint)9 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)9 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)8 ColumnConstraint (com.facebook.presto.sql.planner.planPrinter.IOPlanPrinter.ColumnConstraint)8 ImmutableMap (com.google.common.collect.ImmutableMap)8 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)7 ExpectedValueProvider (com.facebook.presto.sql.planner.assertions.ExpectedValueProvider)7 PlanMatchPattern (com.facebook.presto.sql.planner.assertions.PlanMatchPattern)7 SortOrder (com.facebook.presto.common.block.SortOrder)6