Search in sources :

Example 66 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class XmlBuilderTest method toStringEmptyElementNotLayout.

@Test
public void toStringEmptyElementNotLayout() {
    @Language("XML") String expected = "<TabWidget />\n";
    String actual = new XmlBuilder().startTag("TabWidget").endTag("TabWidget").toString();
    assertEquals(expected, actual);
}
Also used : Language(org.intellij.lang.annotations.Language) XmlBuilder(com.android.tools.idea.XmlBuilder) Test(org.junit.Test)

Example 67 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class InstantRunNotificationTask method showNotification.

public static void showNotification(@NotNull Project project, @Nullable InstantRunContext context, @NotNull String notificationText) {
    if (!InstantRunSettings.isShowNotificationsEnabled()) {
        return;
    }
    @Language("HTML") String message = String.format("<html>%1$s<br>(<a href=\"mute\">Don't show again</a>)</html>", notificationText);
    NotificationListener l = (notification, event) -> {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            String description = event.getDescription();
            if (description != null && description.startsWith("http")) {
                BrowserUtil.browse(description, project);
            } else if ("mute".equals(description)) {
                InstantRunSettings.setShowStatusNotifications(false);
            } else if ("configure".equals(description)) {
                InstantRunConfigurable configurable = new InstantRunConfigurable();
                ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
            } else if ("restart".equals(description)) {
                assert context != null : "Notifications that include a restart activity option need to have a valid instant run context";
                RestartActivityAction.restartActivity(project, context);
            } else if ("learnmore".equals(description)) {
                BrowserUtil.browse("http://developer.android.com/r/studio-ui/instant-run.html", project);
            } else if ("updategradle".equals(description)) {
                InstantRunConfigurable.updateProjectToInstantRunTools(project, null);
            }
        }
    };
    InstantRunManager.NOTIFICATION_GROUP.createNotification("", message, NotificationType.INFORMATION, l).notify(project);
}
Also used : AndroidBundle(org.jetbrains.android.util.AndroidBundle) LaunchStatus(com.android.tools.idea.run.util.LaunchStatus) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) HyperlinkEvent(javax.swing.event.HyperlinkEvent) IDevice(com.android.ddmlib.IDevice) Language(org.intellij.lang.annotations.Language) HashSet(com.intellij.util.containers.HashSet) Set(java.util.Set) BrowserUtil(com.intellij.ide.BrowserUtil) com.android.tools.idea.fd(com.android.tools.idea.fd) ConsolePrinter(com.android.tools.idea.run.ConsolePrinter) NotificationListener(com.intellij.notification.NotificationListener) NotificationType(com.intellij.notification.NotificationType) Nullable(org.jetbrains.annotations.Nullable) GuardedBy(com.android.annotations.concurrency.GuardedBy) RestartActivityAction(com.android.tools.idea.fd.actions.RestartActivityAction) Project(com.intellij.openapi.project.Project) NotNull(org.jetbrains.annotations.NotNull) Language(org.intellij.lang.annotations.Language) NotificationListener(com.intellij.notification.NotificationListener)

Example 68 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class ConvertToConstraintLayoutTest method testConvert.

@Ignore("http://b.android.com/211200")
@Test
public void testConvert() throws Exception {
    guiTest.importSimpleApplication();
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/main/res/layout/absolute.xml", EditorFixture.Tab.DESIGN);
    NlEditorFixture layout = editor.getLayoutEditor(false);
    layout.waitForRenderToFinish();
    // Find and click the first button
    NlComponentFixture button = layout.findView("Button", 0);
    button.invokeContextMenuAction("Convert AbsoluteLayout to ConstraintLayout");
    // Confirm dialog
    DialogFixture quickFixDialog = WindowFinder.findDialog(Matchers.byTitle(Dialog.class, "Convert to ConstraintLayout")).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(guiTest.robot());
    // Press OK
    JButtonFixture finish = quickFixDialog.button(withText("OK"));
    finish.click();
    // Check that we've converted to what we expected
    layout.waitForRenderToFinish();
    editor.selectEditorTab(EditorFixture.Tab.EDITOR);
    waitForScout();
    editor.invokeAction(EditorFixture.EditorAction.FORMAT);
    @Language("XML") String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + "    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n" + "    xmlns:tools=\"http://schemas.android.com/tools\"\n" + "    android:id=\"@+id/constraintLayout\"\n" + "    android:layout_width=\"match_parent\"\n" + "    android:layout_height=\"match_parent\"\n" + "    tools:layout_editor_absoluteX=\"<test>\"\n" + "    tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:layout_marginTop=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button2\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/button\"\n" + "        app:layout_constraintTop_toBottomOf=\"@+id/button\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <EditText\n" + "        android:id=\"@+id/editText\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginBottom=\"<test>\"\n" + "        android:layout_marginEnd=\"<test>\"\n" + "        android:layout_marginTop=\"<test>\"\n" + "        android:ems=\"10\"\n" + "        android:inputType=\"textPersonName\"\n" + "        android:text=\"Name\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button6\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button3\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginStart=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button5\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/button5\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button5\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginBottom=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintLeft_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "    <Button\n" + "        android:id=\"@+id/button6\"\n" + "        android:layout_width=\"wrap_content\"\n" + "        android:layout_height=\"wrap_content\"\n" + "        android:layout_marginEnd=\"<test>\"\n" + "        android:text=\"Button\"\n" + "        app:layout_constraintBottom_toBottomOf=\"@+id/button5\"\n" + "        app:layout_constraintRight_toRightOf=\"@+id/constraintLayout\"\n" + "        app:layout_constraintTop_toTopOf=\"@+id/button5\"\n" + "        tools:layout_constraintBottom_creator=\"1\"\n" + "        tools:layout_constraintRight_creator=\"1\"\n" + "        tools:layout_constraintTop_creator=\"1\"\n" + "        tools:layout_editor_absoluteX=\"<test>\"\n" + "        tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + "</android.support.constraint.ConstraintLayout>\n" + "\n";
    assertThat(wipeDimensions(editor.getCurrentFileContents())).isEqualTo(wipeDimensions(xml));
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) DialogFixture(org.fest.swing.fixture.DialogFixture) Language(org.intellij.lang.annotations.Language) NlComponentFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 69 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class AndroidResolveHelperTest method testColorInt.

public void testColorInt() {
    @Language("JAVA") String text = "package p1.p2;\n" + "\n" + "public class Foo {\n" + "    @android.support.annotation.ColorInt int mColor;\n" + "    \n" + "    public void setColor(@android.support.annotation.ColorInt int c) {\n" + "        mColor = <caret>c;\n" + "    }\n" + "}\n";
    PsiElement element = getPsiElement(text);
    assertNotNull(element);
    PsiAnnotation annotation = AndroidResolveHelper.getAnnotationForLocal(element, "c");
    assertNotNull(annotation);
    assertEquals(ResourceEvaluator.COLOR_INT_ANNOTATION, annotation.getQualifiedName());
    annotation = AndroidResolveHelper.getAnnotationForField(element, "p1.p2.Foo", "mColor");
    assertNotNull(annotation);
    assertEquals(ResourceEvaluator.COLOR_INT_ANNOTATION, annotation.getQualifiedName());
}
Also used : Language(org.intellij.lang.annotations.Language) PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiElement(com.intellij.psi.PsiElement)

Example 70 with Language

use of org.intellij.lang.annotations.Language in project android by JetBrains.

the class JCenterRepositoryTest method testParse.

@Test
public void testParse() {
    @Language("JSON") String response = "[\n" + "  {\n" + "    \"name\": \"com.atlassian.guava:guava\",\n" + "    \"repo\": \"jcenter\",\n" + "    \"owner\": \"bintray\",\n" + "    \"desc\": null,\n" + "    \"system_ids\": [\n" + "      \"com.atlassian.guava:guava\"\n" + "    ],\n" + "    \"versions\": [\n" + "      \"15.0\"\n" + "    ],\n" + "    \"latest_version\": \"15.0\"\n" + "  },\n" + "  {\n" + "    \"name\": \"com.atlassian.bundles:guava\",\n" + "    \"repo\": \"jcenter\",\n" + "    \"owner\": \"bintray\",\n" + "    \"desc\": null,\n" + "    \"system_ids\": [\n" + "      \"com.atlassian.bundles:guava\"\n" + "    ],\n" + "    \"versions\": [\n" + "      \"8.1\"\n" + "    ],\n" + "    \"latest_version\": \"8.1\"\n" + "  },\n" + "  {\n" + "    \"name\": \"io.janusproject.guava:guava\",\n" + "    \"repo\": \"jcenter\",\n" + "    \"owner\": \"bintray\",\n" + "    \"desc\": null,\n" + "    \"system_ids\": [\n" + "      \"io.janusproject.guava:guava\"\n" + "    ],\n" + "    \"versions\": [\n" + "      \"19.0.0\"\n" + "    ],\n" + "    \"latest_version\": \"19.0.0\"\n" + "  },\n" + "  {\n" + "    \"name\": \"com.google.guava:guava\",\n" + "    \"repo\": \"jcenter\",\n" + "    \"owner\": \"bintray\",\n" + "    \"desc\": \"Guava is a suite of core and expanded libraries that include\\n    utility classes, google's collections, io classes, and much\\n    much more.\\n\\n    Guava has two code dependencies - javax.annotation\\n    per the JSR-305 spec and javax.inject per the JSR-330 spec.\",\n" + "    \"system_ids\": [\n" + "      \"com.google.guava:guava\"\n" + "    ],\n" + "    \"versions\": [\n" + "      \"19.0\",\n" + "      \"18.0\",\n" + "      \"17.0\",\n" + "      \"16.0\",\n" + "      \"15.0\",\n" + "      \"14.0\",\n" + "      \"13.0\"\n" + "    ],\n" + "    \"latest_version\": \"19.0\"\n" + "  },\n" + "  {\n" + "    \"name\": \"de.weltraumschaf.commons:guava\",\n" + "    \"repo\": \"jcenter\",\n" + "    \"owner\": \"bintray\",\n" + "    \"desc\": null,\n" + "    \"system_ids\": [\n" + "      \"de.weltraumschaf.commons:guava\"\n" + "    ],\n" + "    \"versions\": [\n" + "      \"2.1.0\"\n" + "    ],\n" + "    \"latest_version\": \"2.1.0\"\n" + "  }\n" + "]";
    Reader responseReader = new StringReader(response);
    SearchResult result = new JCenterRepository().parse(responseReader);
    assertEquals(5, result.getTotalFound());
    List<String> coordinates = result.getArtifactCoordinates();
    assertThat(coordinates).containsExactly("com.atlassian.guava:guava:15.0", "com.atlassian.bundles:guava:8.1", "io.janusproject.guava:guava:19.0.0", "com.google.guava:guava:19.0", "com.google.guava:guava:18.0", "com.google.guava:guava:17.0", "com.google.guava:guava:16.0", "com.google.guava:guava:15.0", "com.google.guava:guava:14.0", "com.google.guava:guava:13.0", "de.weltraumschaf.commons:guava:2.1.0");
}
Also used : Language(org.intellij.lang.annotations.Language) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) Test(org.junit.Test)

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