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);
}
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);
}
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));
}
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());
}
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");
}
Aggregations