Java Code Examples for org.eclipse.xtext.common.types.JvmGenericType#setPackageName()
The following examples show how to use
org.eclipse.xtext.common.types.JvmGenericType#setPackageName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 6 votes |
@Test public void testJvmTypeSimple_Issue145() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("SimpleName"); expected.setPackageName("package.name"); resource.getContents().add(expected); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName"); assertEquals(expected, actual); resource.getContents().remove(expected); ((InternalEObject)expected).eSetProxyURI(EcoreUtil.getURI(expected)); JvmGenericType expected2 = TypesFactory.eINSTANCE.createJvmGenericType(); expected2.setSimpleName("SimpleName"); expected2.setPackageName("package.name"); resource.getContents().add(expected2); JvmType actual2 = getTypeProvider().findTypeByName("package.name.SimpleName"); assertEquals(expected2, actual2); }
Example 2
Source Project: xtext-extras File: JvmTypesBuilder.java License: Eclipse Public License 2.0 | 5 votes |
protected JvmGenericType createJvmGenericType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name) { if (sourceElement == null || name == null) return null; Pair<String, String> fullName = splitQualifiedName(name); final JvmGenericType result = typesFactory.createJvmGenericType(); result.setSimpleName(fullName.getSecond()); if (fullName.getFirst() != null) result.setPackageName(fullName.getFirst()); result.setVisibility(JvmVisibility.PUBLIC); return result; }
Example 3
Source Project: xtext-extras File: AbstractConstructorScopeTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testGetElementByInstance_01() { JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType(); type.setPackageName("java.lang"); type.setSimpleName("Object"); constructor.setSimpleName("Object"); type.getMembers().add(constructor); IEObjectDescription element = getConstructorScope().getSingleElement(constructor); assertNotNull(element); assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getName()); assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getQualifiedName()); }
Example 4
Source Project: xtext-extras File: ReflectionTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeSimple() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("SimpleName"); expected.setPackageName("package.name"); resource.getContents().add(expected); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName"); assertEquals(expected, actual); }
Example 5
Source Project: xtext-extras File: ReflectionTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClass() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName$Child"); assertEquals(expected, actual); }
Example 6
Source Project: xtext-extras File: ReflectionTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClassWithDot_01() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName.Child", false); assertEquals(expected, actual); }
Example 7
Source Project: xtext-extras File: ReflectionTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClassWithDot_02() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName.Child", true); assertNull(actual); }
Example 8
Source Project: xtext-extras File: ReflectionTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeArray() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("SimpleName"); expected.setPackageName("package.name"); resource.getContents().add(expected); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName[]"); assertTrue(actual instanceof JvmArrayType); assertEquals(expected, ((JvmArrayType) actual).getComponentType()); }
Example 9
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeSimple() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("SimpleName"); expected.setPackageName("package.name"); resource.getContents().add(expected); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName"); assertEquals(expected, actual); }
Example 10
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClass() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName$Child"); assertEquals(expected, actual); }
Example 11
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClassWithDot_01() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName.Child", false); assertEquals(expected, actual); }
Example 12
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeNestedClassWithDot_02() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType container = TypesFactory.eINSTANCE.createJvmGenericType(); container.setSimpleName("SimpleName"); container.setPackageName("package.name"); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("Child"); container.getMembers().add(expected); resource.getContents().add(container); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName.Child", true); assertNull(actual); }
Example 13
Source Project: xtext-extras File: ClasspathTypeProviderTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testJvmTypeArray() { Resource resource = resourceSet.createResource(URI.createURI("foo.typesRefactoring")); JvmGenericType expected = TypesFactory.eINSTANCE.createJvmGenericType(); expected.setSimpleName("SimpleName"); expected.setPackageName("package.name"); resource.getContents().add(expected); JvmType actual = getTypeProvider().findTypeByName("package.name.SimpleName[]"); assertTrue(actual instanceof JvmArrayType); assertEquals(expected, ((JvmArrayType) actual).getComponentType()); }
Example 14
Source Project: xtext-extras File: XbaseResourceDescriptionStrategyTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testInterfaceDescription_01() { JvmGenericType interfaceType = TypesFactory.eINSTANCE.createJvmGenericType(); interfaceType.setInterface(true); interfaceType.setPackageName("foo"); interfaceType.setSimpleName("MyType"); List<IEObjectDescription> list = new ArrayList<>(); descriptionStrategy.createEObjectDescriptions(interfaceType, it -> list.add(it)); Assert.assertTrue( list.stream().anyMatch(it -> "true".equals(it.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE)))); }
Example 15
Source Project: xtext-extras File: XbaseResourceDescriptionStrategyTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testInterfaceDescription_02() { JvmGenericType interfaceType = TypesFactory.eINSTANCE.createJvmGenericType(); interfaceType.setInterface(false); interfaceType.setPackageName("foo"); interfaceType.setSimpleName("MyType"); List<IEObjectDescription> list = new ArrayList<>(); descriptionStrategy.createEObjectDescriptions(interfaceType, it -> list.add(it)); Assert.assertFalse(list.stream().anyMatch( it -> "true".equals(it.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE)))); }
Example 16
Source Project: xtext-eclipse File: AbstractConstructorScopeTest.java License: Eclipse Public License 2.0 | 5 votes |
@Test public void testGetElementByInstance_01() { JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor(); JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType(); type.setPackageName("java.lang"); type.setSimpleName("Object"); constructor.setSimpleName("Object"); type.getMembers().add(constructor); IEObjectDescription element = getConstructorScope().getSingleElement(constructor); assertNotNull(element); assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getName()); assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getQualifiedName()); }
Example 17
Source Project: sarl File: PyGenerator.java License: Apache License 2.0 | 5 votes |
/** Create a JvmType for a Python type. * * @param pythonName the python type name. * @return the type. */ @SuppressWarnings("static-method") protected JvmType newType(String pythonName) { final JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType(); final int index = pythonName.indexOf("."); //$NON-NLS-1$ if (index <= 0) { type.setSimpleName(pythonName); } else { type.setPackageName(pythonName.substring(0, index - 1)); type.setSimpleName(pythonName.substring(index + 1)); } return type; }
Example 18
Source Project: sarl File: Bug92Test.java License: Apache License 2.0 | 4 votes |
protected static JvmType createType(Class<?> t) { JvmGenericType result = TypesFactory.eINSTANCE.createJvmGenericType(); result.setSimpleName(t.getSimpleName()); result.setPackageName(t.getPackage().getName()); return result; }