use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testPsiToLombokConversion10.
public void testPsiToLombokConversion10() {
// Checks that annotations on variable declarations are preserved
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "import android.annotation.SuppressLint;\n" + "import android.annotation.TargetApi;\n" + "import android.os.Build;\n" + "\n" + "public class SuppressTest {\n" + " @SuppressLint(\"ResourceAsColor\")\n" + " @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n" + " private void test() {\n" + " @SuppressLint(\"SdCardPath\") String s = \"/sdcard/fyfaen\";\n" + " setTitleColor(android.R.color.black);\n" + " }\n" + "\n" + " private void setTitleColor(int color) {\n" + " //To change body of created methods use File | Settings | File Templates.\n" + " }\n" + "}\n";
PsiFile file = myFixture.addFileToProject("src/test/pkg/SuppressTest.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class InteractionManagerTest method testDragAndDrop.
public void testDragAndDrop() throws Exception {
// Drops a fragment (xmlFragment below) into the design surface (via drag & drop events) and verifies that
// the resulting document ends up modified as expected.
@Language("XML") String source = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"0dp\"\n" + " android:orientation=\"vertical\">\n" + "\n" + "</LinearLayout>\n";
XmlFile xmlFile = (XmlFile) myFixture.addFileToProject("res/layout/layout.xml", source);
DesignSurface surface = createSurface();
NlModel model = createModel(surface, myFacet, xmlFile);
ScreenView screenView = createScreen(surface, model, new SelectionModel());
DesignSurface designSurface = screenView.getSurface();
InteractionManager manager = createManager(designSurface);
@Language("XML") String xmlFragment = "" + "<TextView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Hello World\"\n" + "/>";
Transferable transferable = createTransferable(DataFlavor.stringFlavor, xmlFragment);
dragDrop(manager, 0, 0, 100, 100, transferable);
Disposer.dispose(model);
@Language("XML") String expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"0dp\"\n" + " android:orientation=\"vertical\">\n" + "\n" + " <TextView\n" + " android:id=\"@+id/textView\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Hello World\" />\n" + "</LinearLayout>\n";
assertEquals(expected, xmlFile.getText());
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class AndroidResolveHelperTest method testIntDefResolution.
public void testIntDefResolution() {
@Language("JAVA") String text = "package p1.p2;\n" + "\n" + "import java.lang.annotation.Retention;\n" + "import java.lang.annotation.RetentionPolicy;\n" + "\n" + "public class Foo {\n" + " public static final int INVISIBLE = 0x00000004;\n" + " public static final int VISIBLE = 0x00000000;\n" + " public static final int GONE = 0x00000008;\n" + "\n" + " @android.support.annotation.IntDef({VISIBLE, INVISIBLE, GONE})\n" + " @Retention(RetentionPolicy.SOURCE)\n" + " public @interface Visibility {}\n" + "\n" + " @Foo.Visibility\n" + " private int mVisibility; \n" + "\n" + " public void setVisibility(@Foo.Visibility int v) {\n" + " mVis<caret>ibility = v;\n" + " }\n" + "}\n";
PsiElement element = getPsiElement(text);
assertNotNull(element);
PsiAnnotation annotation = AndroidResolveHelper.getAnnotationForLocal(element, "v");
assertNotNull(annotation);
assertEquals(SdkConstants.INT_DEF_ANNOTATION, annotation.getQualifiedName());
AndroidResolveHelper.IntDefResolution result = AndroidResolveHelper.resolveIntDef(annotation);
assertFalse(result.canBeOred);
Map<Integer, String> map = result.valuesMap;
assertNotNull(map);
assertEquals(3, map.size());
assertEquals("INVISIBLE", map.get(4));
assertEquals("VISIBLE", map.get(0));
assertEquals("GONE", map.get(8));
}
use of org.intellij.lang.annotations.Language in project presto by prestodb.
the class TestHiveIntegrationSmokeTest method insertPartitionedTable.
private void insertPartitionedTable(Session session, HiveStorageFormat storageFormat) throws Exception {
@Language("SQL") String createTable = "" + "CREATE TABLE test_insert_partitioned_table " + "(" + " ORDER_KEY BIGINT," + " SHIP_PRIORITY INTEGER," + " ORDER_STATUS VARCHAR" + ") " + "WITH (" + "format = '" + storageFormat + "', " + "partitioned_by = ARRAY[ 'SHIP_PRIORITY', 'ORDER_STATUS' ]" + ") ";
assertUpdate(session, createTable);
TableMetadata tableMetadata = getTableMetadata(catalog, TPCH_SCHEMA, "test_insert_partitioned_table");
assertEquals(tableMetadata.getMetadata().getProperties().get(STORAGE_FORMAT_PROPERTY), storageFormat);
assertEquals(tableMetadata.getMetadata().getProperties().get(PARTITIONED_BY_PROPERTY), ImmutableList.of("ship_priority", "order_status"));
assertQuery(session, "SHOW PARTITIONS FROM test_insert_partitioned_table", "SELECT shippriority, orderstatus FROM orders LIMIT 0");
// Hive will reorder the partition keys, so we must insert into the table assuming the partition keys have been moved to the end
assertUpdate(session, "" + "INSERT INTO test_insert_partitioned_table " + "SELECT orderkey, shippriority, orderstatus " + "FROM tpch.tiny.orders", "SELECT count(*) from orders");
// verify the partitions
List<?> partitions = getPartitions("test_insert_partitioned_table");
assertEquals(partitions.size(), 3);
assertQuery(session, "SELECT * from test_insert_partitioned_table", "SELECT orderkey, shippriority, orderstatus FROM orders");
assertQuery(session, "SHOW PARTITIONS FROM test_insert_partitioned_table", "SELECT DISTINCT shippriority, orderstatus FROM orders");
assertQuery(session, "SHOW PARTITIONS FROM test_insert_partitioned_table ORDER BY order_status LIMIT 2", "SELECT DISTINCT shippriority, orderstatus FROM orders ORDER BY orderstatus LIMIT 2");
assertQuery(session, "SHOW PARTITIONS FROM test_insert_partitioned_table WHERE order_status = 'O'", "SELECT DISTINCT shippriority, orderstatus FROM orders WHERE orderstatus = 'O'");
assertUpdate(session, "DROP TABLE test_insert_partitioned_table");
assertFalse(getQueryRunner().tableExists(session, "test_insert_partitioned_table"));
}
use of org.intellij.lang.annotations.Language in project presto by prestodb.
the class TestHiveIntegrationSmokeTest method createPartitionedTableAs.
public void createPartitionedTableAs(Session session, HiveStorageFormat storageFormat) throws Exception {
@Language("SQL") String createTable = "" + "CREATE TABLE test_create_partitioned_table_as " + "WITH (" + "format = '" + storageFormat + "', " + "partitioned_by = ARRAY[ 'SHIP_PRIORITY', 'ORDER_STATUS' ]" + ") " + "AS " + "SELECT orderkey AS order_key, shippriority AS ship_priority, orderstatus AS order_status " + "FROM tpch.tiny.orders";
assertUpdate(session, createTable, "SELECT count(*) from orders");
TableMetadata tableMetadata = getTableMetadata(catalog, TPCH_SCHEMA, "test_create_partitioned_table_as");
assertEquals(tableMetadata.getMetadata().getProperties().get(STORAGE_FORMAT_PROPERTY), storageFormat);
assertEquals(tableMetadata.getMetadata().getProperties().get(PARTITIONED_BY_PROPERTY), ImmutableList.of("ship_priority", "order_status"));
List<?> partitions = getPartitions("test_create_partitioned_table_as");
assertEquals(partitions.size(), 3);
assertQuery(session, "SELECT * from test_create_partitioned_table_as", "SELECT orderkey, shippriority, orderstatus FROM orders");
assertUpdate(session, "DROP TABLE test_create_partitioned_table_as");
assertFalse(getQueryRunner().tableExists(session, "test_create_partitioned_table_as"));
}
Aggregations