Java Code Examples for org.eclipse.xtext.common.types.JvmType#eResource()

The following examples show how to use org.eclipse.xtext.common.types.JvmType#eResource() . 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 File: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void checkConflicts(XImportSection importSection, final Map<String, List<XImportDeclaration>> imports,
		final Map<String, JvmType> importedNames) {
	for (JvmDeclaredType declaredType : importsConfiguration.getLocallyDefinedTypes((XtextResource)importSection.eResource())) {
		if(importedNames.containsKey(declaredType.getSimpleName())){
			JvmType importedType = importedNames.get(declaredType.getSimpleName());
			if (importedType != declaredType  && importedType.eResource() != importSection.eResource()) {
				List<XImportDeclaration> list = imports.get(importedType.getIdentifier());
				if (list != null) {
					for (XImportDeclaration importDeclaration: list ) {
						error("The import '" 
								+ importedType.getIdentifier() 
								+ "' conflicts with a type defined in the same file", 
								importDeclaration, null, IssueCodes.IMPORT_CONFLICT);
					}
				}
			}
		}
	}
}
 
Example 2
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedEnum_05() throws Exception {
	String typeName = ClassContainingEnum.InnerEnumWithInt.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmEnumerationType);
	assertTrue(((JvmEnumerationType) type).isFinal());
	assertTrue(((JvmEnumerationType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 3
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testHashMap_01() {
	String typeName = HashMap.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 4
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFindTypeByName_javaLangCharSequence_01() {
	String typeName = CharSequence.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmGenericType);
	assertEquals(typeName, type.getIdentifier());
	assertTrue(((JvmDeclaredType) type).isAbstract());
	assertFalse(((JvmDeclaredType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 5
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFindTypeByName_int_array_03() {
	String typeName = int[][][].class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmArrayType);
	assertEquals("int[][][]", type.getIdentifier());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 6
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testVarArgs_01() {
	String typeName = ClassWithVarArgs.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 7
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testFindTypeByName_int() {
	String typeName = "int";
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmPrimitiveType);
	assertEquals(typeName, type.getIdentifier());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 8
Source File: ReflectionTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBug337307() {
	String typeName = "ClassWithDefaultPackage";
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmGenericType);
	assertEquals(typeName, type.getIdentifier());
	assertEquals(typeName, type.getQualifiedName());
	assertEquals(typeName, type.getSimpleName());
	assertNull(((JvmDeclaredType) type).getPackageName());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 9
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testHashMap_01() {
	String typeName = HashMap.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 10
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnnotationType_03() throws Exception {
	String typeName = TestAnnotationWithDefaults.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 11
Source File: ClasspathTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testBug337307() {
	String typeName = "ClassWithDefaultPackage";
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmGenericType);
	assertEquals(typeName, type.getIdentifier());
	assertEquals(typeName, type.getQualifiedName());
	assertEquals(typeName, type.getSimpleName());
	assertNull(((JvmDeclaredType) type).getPackageName());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 12
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedEnum_01() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmEnumerationType);
	assertTrue(((JvmEnumerationType) type).isFinal());
	assertTrue(((JvmEnumerationType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 13
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedEnum_01() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmEnumerationType);
	assertTrue(((JvmEnumerationType) type).isFinal());
	assertTrue(((JvmEnumerationType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 14
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnnotationType_03() throws Exception {
	String typeName = TestAnnotationWithDefaults.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 15
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnnotationType_01() throws Exception {
	String typeName = TestAnnotation.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	assertTrue(((JvmDeclaredType) type).isAbstract());
	assertFalse(((JvmDeclaredType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 16
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnnotationType_01() throws Exception {
	String typeName = TestAnnotation.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	assertTrue(((JvmDeclaredType) type).isAbstract());
	assertFalse(((JvmDeclaredType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 17
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testEnum_01() throws Exception {
	String typeName = TestEnum.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmEnumerationType);
	assertTrue(((JvmEnumerationType) type).isFinal());
	assertFalse(((JvmEnumerationType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 18
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedAnnotationType_01() throws Exception {
	String typeName = TestAnnotation.NestedAnnotation.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	assertTrue(((JvmDeclaredType) type).isAbstract());
	assertTrue(((JvmDeclaredType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 19
Source File: AbstractTypeProviderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnnotationType_03() throws Exception {
	String typeName = TestAnnotationWithDefaults.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmAnnotationType);
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}
 
Example 20
Source File: AbstractTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testNestedEnum_05() throws Exception {
	String typeName = ClassContainingEnum.InnerEnumWithInt.class.getName();
	JvmType type = getTypeProvider().findTypeByName(typeName);
	assertNotNull(type);
	assertTrue(type instanceof JvmEnumerationType);
	assertTrue(((JvmEnumerationType) type).isFinal());
	assertTrue(((JvmEnumerationType) type).isStatic());
	diagnose(type);
	Resource resource = type.eResource();
	getAndResolveAllFragments(resource);
	recomputeAndCheckIdentifiers(resource);
}