Java Code Examples for org.eclipse.xtext.xtype.XImportDeclaration#getImportedType()
The following examples show how to use
org.eclipse.xtext.xtype.XImportDeclaration#getImportedType() .
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: RewritableImportSection.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public RewritableImportSection(XtextResource resource, IImportsConfiguration importsConfiguration, XImportSection originalImportSection, String lineSeparator, ImportSectionRegionUtil regionUtil, IValueConverter<String> nameConverter) { this.importsConfiguration = importsConfiguration; this.resource = resource; this.lineSeparator = lineSeparator; this.regionUtil = regionUtil; this.nameValueConverter = nameConverter; this.implicitlyImportedPackages = importsConfiguration.getImplicitlyImportedPackages(resource); this.importRegion = regionUtil.computeRegion(resource); if (originalImportSection != null) { for (XImportDeclaration originalImportDeclaration : originalImportSection.getImportDeclarations()) { this.originalImportDeclarations.add(originalImportDeclaration); JvmDeclaredType importedType = originalImportDeclaration.getImportedType(); if (originalImportDeclaration.isStatic()) { String memberName = originalImportDeclaration.getMemberName(); if (originalImportDeclaration.isExtension()) { Maps2.putIntoSetMap(importedType, memberName, staticExtensionImports); } else { Maps2.putIntoSetMap(importedType, memberName, staticImports); } } else if (importedType != null) { Maps2.putIntoListMap(importedType.getSimpleName(), importedType, plainImports); } } } }
Example 2
Source File: RewritableImportSection.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void appendImport(StringBuilder builder, XImportDeclaration newImportDeclaration) { builder.append("import "); if (newImportDeclaration.isStatic()) { builder.append("static "); if (newImportDeclaration.isExtension()) { builder.append("extension "); } } String qualifiedTypeName = newImportDeclaration.getImportedNamespace(); if (newImportDeclaration.getImportedType() != null) { qualifiedTypeName = serializeType(newImportDeclaration.getImportedType()); } String escapedTypeName = nameValueConverter.toString(qualifiedTypeName); builder.append(escapedTypeName); if (newImportDeclaration.isStatic()) { builder.append("."); if (newImportDeclaration.isWildcard()) { builder.append("*"); } else { builder.append(newImportDeclaration.getMemberName()); } } builder.append(lineSeparator); }
Example 3
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkDeprecated(XImportDeclaration decl) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmType jvmType = decl.getImportedType(); checkDeprecated( jvmType, decl, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE); } }
Example 4
Source File: RewritableImportSection.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XImportDeclaration> findOriginalImports(JvmDeclaredType type, String memberName, Collection<XImportDeclaration> list, boolean isStatic, boolean isExtension) { List<XImportDeclaration> result = newArrayList(); for (XImportDeclaration importDeclaration : list) { if (!(isStatic ^ importDeclaration.isStatic()) && !(isExtension ^ importDeclaration.isExtension()) && importDeclaration.getImportedType() == type && (memberName == null || memberName.equals(importDeclaration.getMemberName()))) { result.add(importDeclaration); } } return result; }
Example 5
Source File: StaticallyImportedMemberProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public Iterable<JvmFeature> findAllFeatures(XImportDeclaration it) { JvmDeclaredType importedType = it.getImportedType(); if (!it.isStatic() || importedType == null) { return Collections.emptyList(); } IVisibilityHelper visibilityHelper = getVisibilityHelper(it.eResource()); IResolvedFeatures resolvedFeatures = resolvedFeaturesProvider.getResolvedFeatures(importedType); return Iterables.filter(resolvedFeatures.getAllFeatures(), (JvmFeature feature) -> { return feature.isStatic() && visibilityHelper.isVisible(feature) && (it.getMemberName() == null || feature.getSimpleName().startsWith(it.getMemberName())); }); }
Example 6
Source File: XbaseUIValidator.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Check public void checkRestrictedType(XImportDeclaration importDeclaration){ if (isRestrictionCheckIgnored()) return; JvmType importedType = importDeclaration.getImportedType(); if(importedType instanceof JvmDeclaredType) checkRestrictedType(importDeclaration, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE, (JvmDeclaredType) importedType); }
Example 7
Source File: XtendImportedNamespaceScopeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
private AbstractScope getImportScope(XImportSection importSection, AbstractScope parent, RecordingTypeScope typeScope) { if (importSection == null) return parent; List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); if (importDeclarations.isEmpty()) { return parent; } List<ImportNormalizer> wildcardImports = null; List<JvmType> concreteImports = null; List<QualifiedName> importedNames = null; boolean hasLegacyImport = false; for(XImportDeclaration importDeclaration: importDeclarations) { if (!importDeclaration.isStatic()) { if (importDeclaration.isWildcard()) { if (wildcardImports == null) { wildcardImports = Lists.newArrayListWithCapacity(4); } String importedNamespace = importDeclaration.getImportedNamespace(); importedNamespace = importedNamespace.substring(0, importedNamespace.length() - 2); QualifiedName qualifiedImportedNamespace = qualifiedNameConverter.toQualifiedName(importedNamespace); wildcardImports.add(AbstractNestedTypeAwareImportNormalizer.createNestedTypeAwareImportNormalizer(qualifiedImportedNamespace, true, false)); } else { JvmDeclaredType importedType = importDeclaration.getImportedType(); if (importedType != null && !importedType.eIsProxy()) { if (concreteImports == null || importedNames == null /* to make JDT happy */) { concreteImports = Lists.newArrayListWithCapacity(10); importedNames = Lists.newArrayListWithCapacity(10); } concreteImports.add(importedType); if (importedType.eContainer() instanceof JvmDeclaredType) { String importSyntax = getImportsConfiguration().getLegacyImportSyntax(importDeclaration); if (importSyntax != null) { hasLegacyImport = true; importedNames.add(getQualifiedNameConverter().toQualifiedName(importSyntax)); } else importedNames.add(null); } else { importedNames.add(null); } } } } } return getImportScope(wildcardImports, concreteImports, hasLegacyImport ? importedNames : null, parent, typeScope); }
Example 8
Source File: PyValidator.java From sarl with Apache License 2.0 | 4 votes |
/** Check that import mapping are known. * * @param importDeclaration the declaration. */ @Check public void checkImportsMapping(XImportDeclaration importDeclaration) { final JvmDeclaredType type = importDeclaration.getImportedType(); doTypeMappingCheck(importDeclaration, type, this.typeErrorHandler1); }