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); } } } } } }
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); } } } }
public boolean removeImport(JvmDeclaredType type) { List<XImportDeclaration> addedImportDeclarationsToRemove = findOriginalImports(type, null, addedImportDeclarations, false, false); addedImportDeclarations.removeAll(addedImportDeclarationsToRemove); List<XImportDeclaration> originalImportDeclarationsToRemove = findOriginalImports(type, null, originalImportDeclarations, false, false); removedImportDeclarations.addAll(originalImportDeclarationsToRemove); for (Map.Entry<String, List<JvmDeclaredType>> entry : plainImports.entrySet()) { List<JvmDeclaredType> values = entry.getValue(); if (values.size() == 1) { if (values.get(0) == type) { plainImports.remove(type.getSimpleName()); return true; } } Iterator<JvmDeclaredType> iterator = values.iterator(); while (iterator.hasNext()) { JvmDeclaredType value = iterator.next(); if (value == type) { iterator.remove(); return true; } } } return false; }
public boolean addStaticImport(JvmDeclaredType type, String memberName) { if (hasStaticImport(staticImports, type, memberName)) { return false; } Maps2.putIntoSetMap(type, memberName, staticImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); importDeclaration.setStatic(true); if (memberName == null) { importDeclaration.setWildcard(true); } else { importDeclaration.setMemberName(memberName); } addedImportDeclarations.add(importDeclaration); return true; }
public boolean addStaticExtensionImport(JvmDeclaredType type, String memberName) { if (hasStaticImport(staticExtensionImports, type, memberName)) { return false; } Maps2.putIntoSetMap(type, memberName, staticExtensionImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); importDeclaration.setStatic(true); importDeclaration.setExtension(true); if (memberName == null) { importDeclaration.setWildcard(true); } else { importDeclaration.setMemberName(memberName); } addedImportDeclarations.add(importDeclaration); return true; }
public void update() { XImportSection importSection = importsConfiguration.getImportSection(resource); if (importSection == null && importsConfiguration instanceof IMutableImportsConfiguration) { importSection = XtypeFactory.eINSTANCE.createXImportSection(); IMutableImportsConfiguration mutableImportsConfiguration = (IMutableImportsConfiguration) importsConfiguration; mutableImportsConfiguration.setImportSection(resource, importSection); } if (importSection == null) { return; } removeObsoleteStaticImports(); List<XImportDeclaration> allImportDeclarations = newArrayList(); allImportDeclarations.addAll(originalImportDeclarations); allImportDeclarations.addAll(addedImportDeclarations); allImportDeclarations.removeAll(removedImportDeclarations); List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); importDeclarations.clear(); importDeclarations.addAll(allImportDeclarations); }
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); }
private boolean hasStaticImport(String typeName, String memberName, boolean extension) { for (String string : implicitlyImportedPackages) { if (typeName.startsWith(string)) { return typeName.substring(string.length()).lastIndexOf('.') == 0; } } Map<JvmDeclaredType, Set<String>> imports = staticImports; if (extension) { imports = staticExtensionImports; } for (JvmDeclaredType type : imports.keySet()) { if (typeName.equals(type.getIdentifier())) { Set<String> members = imports.get(type); return members != null && ((members.contains(memberName) || members.contains(null))); } } for (XImportDeclaration importDeclr : addedImportDeclarations) { String identifier = importDeclr.getImportedTypeName(); if (importDeclr.isStatic() && typeName.equals(identifier)) { if (Objects.equal(importDeclr.getMemberName(), memberName) || importDeclr.isWildcard() || "*".equals(importDeclr.getMemberName())) { return true; } } } return false; }
@Override public String getLegacyImportSyntax(XImportDeclaration importDeclaration) { List<INode> list = NodeModelUtils.findNodesForFeature(importDeclaration, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE); if (list.isEmpty()) { return null; } INode singleNode = list.get(0); if (singleNode.getText().indexOf('$') < 0) { return null; } StringBuilder sb = new StringBuilder(); for(ILeafNode node: singleNode.getLeafNodes()) { if (!node.isHidden()) { sb.append(node.getText().replace("^", "")); } } return sb.toString(); }
public Iterable<JvmFeature> findAllFeatures(final XImportDeclaration it) { Iterable<JvmFeature> _xblockexpression = null; { final JvmDeclaredType importedType = it.getImportedType(); if (((!it.isStatic()) || (importedType == null))) { return CollectionLiterals.<JvmFeature>emptyList(); } final IVisibilityHelper visibilityHelper = this.getVisibilityHelper(it.eResource()); final IResolvedFeatures resolvedFeatures = this._provider.getResolvedFeatures(importedType); final Function1<JvmFeature, Boolean> _function = (JvmFeature feature) -> { return Boolean.valueOf(((feature.isStatic() && visibilityHelper.isVisible(feature)) && ((it.getMemberName() == null) || feature.getSimpleName().startsWith(it.getMemberName())))); }; _xblockexpression = IterableExtensions.<JvmFeature>filter(resolvedFeatures.getAllFeatures(), _function); } return _xblockexpression; }
private boolean removeStaticImport(Map<String, List<XImportDeclaration>> staticImports, JvmMember member) { JvmDeclaredType declaringType = member.getDeclaringType(); String identifier = declaringType.getIdentifier(); List<XImportDeclaration> list = staticImports.get(identifier); if (list == null) { return false; } if (list.size() == 1) { staticImports.remove(identifier); return true; } int indexToRemove = -1; for (int i = 0; i < list.size(); i++) { XImportDeclaration staticImportDeclaration = list.get(i); if (staticImportDeclaration.isWildcard()) { if (indexToRemove == -1) { indexToRemove = i; } continue; } if (Objects.equal(member.getSimpleName(), staticImportDeclaration.getMemberName())) { indexToRemove = i; break; } } if (indexToRemove == -1) { indexToRemove = 0; } list.remove(indexToRemove); return true; }
private boolean removeTypeImport(Map<String, List<XImportDeclaration>> imports, JvmType declaringType) { String identifier = declaringType.getIdentifier(); List<XImportDeclaration> list = imports.get(identifier); if (list == null) { return false; } if (list.size() == 1) { imports.remove(identifier); return true; } list.remove(0); return true; }
protected void addImportUnusedIssues(final Map<String, List<XImportDeclaration>> imports) { for (List<XImportDeclaration> importDeclarations : imports.values()) { for (XImportDeclaration importDeclaration : importDeclarations) { addIssue("The import '" + importDeclaration.getImportedName() + "' is never used.", importDeclaration, IMPORT_UNUSED); } } }
@Check public void checkDeprecated(XImportDeclaration decl) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmType jvmType = decl.getImportedType(); checkDeprecated( jvmType, decl, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE); } }
protected IScope internalGetScope(IScope parent, IScope globalScope, EObject context, EReference reference) { if(context instanceof XImportDeclaration) { return globalScope; } IScope result = parent; if (context.eContainer() == null) { if (parent != globalScope) throw new IllegalStateException("the parent should be the global scope"); result = getResourceScope(globalScope, context.eResource(), reference); } else { result = internalGetScope(parent, globalScope, context.eContainer(), reference); } return getLocalElementsScope(result, globalScope, context, reference); }
protected List<ImportNormalizer> getImportedNamespaceResolvers(XImportSection importSection, boolean ignoreCase) { List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); List<ImportNormalizer> result = Lists.newArrayListWithExpectedSize(importDeclarations.size()); for (XImportDeclaration imp: importDeclarations) { if (!imp.isStatic()) { String value = imp.getImportedNamespace(); if(value == null) value = imp.getImportedTypeName(); ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase); if (resolver != null) result.add(resolver); } } return result; }
@Override public IFeatureScopeSession newSession(Resource context) { List<JvmType> literalClasses = implicitlyImportedFeatures.getStaticImportClasses(context); List<JvmType> extensionClasses = implicitlyImportedFeatures.getExtensionClasses(context); IFeatureScopeSession result = rootSession.addTypesToStaticScope(literalClasses, extensionClasses); if (context.getContents().isEmpty() || !(context instanceof XtextResource)) return result; final XImportSection importSection = importsConfig.getImportSection((XtextResource) context); if(importSection != null) { result = result.addImports(new ITypeImporter.Client() { @Override public void doAddImports(ITypeImporter importer) { List<XImportDeclaration> imports = importSection.getImportDeclarations(); for(XImportDeclaration _import: imports) { if (_import.isStatic()) { if (_import.isWildcard()) { if (_import.isExtension()) { importer.importStaticExtension(_import.getImportedType(), false); } else { importer.importStatic(_import.getImportedType()); } } else { if (_import.isExtension()) { importer.importStaticExtension(_import.getImportedType(), _import.getMemberName(), false); } else { importer.importStatic(_import.getImportedType(), _import.getMemberName()); } } } } } }); } return result; }
public boolean addImport(JvmDeclaredType type) { if (plainImports.containsKey(type.getSimpleName()) || !needsImport(type)) return false; Maps2.putIntoListMap(type.getSimpleName(), type, plainImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); addedImportDeclarations.add(importDeclaration); return true; }
protected XImportDeclaration createImport(String importedNamespace, final String member) { XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedNamespace(importedNamespace); if (member != null) { importDeclaration.setMemberName(member); } return importDeclaration; }
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; }
/** * @param typeFqn * The fully qualified name of the type to import. E.g. <code>java.util.List</code>. May not be * <code>null</code>. * @param member * member name to import. May not be <code>null</code>. For wildcard use <code>*</code> * */ public boolean addStaticImport(final String typeFqn, final String member) { if (typeFqn == null || member == null) { throw new IllegalArgumentException("Type name " + typeFqn + ". Member name: " + member); } if (hasStaticImport(typeFqn, member, false)) { return false; } XImportDeclaration importDecl = createImport(typeFqn, member); importDecl.setStatic(true); return addedImportDeclarations.add(importDecl); }
/** * @param typeFqn * The fully qualified name of the type to import. E.g. <code>java.util.List</code>. May not be * <code>null</code>. * @param member * member name to import. May not be <code>null</code>. For wildcard use <code>*</code> * */ public boolean addStaticExtensionImport(final String typeFqn, final String member) { if (typeFqn == null || member == null) { throw new IllegalArgumentException("Type name " + typeFqn + ". Member name: " + member); } if (hasStaticImport(typeFqn, member, true)) { return false; } XImportDeclaration importDecl = createImport(typeFqn, member); importDecl.setStatic(true); importDecl.setExtension(true); return addedImportDeclarations.add(importDecl); }
protected boolean removeStaticImport(Map<JvmDeclaredType, Set<String>> staticImports, JvmDeclaredType type, String memberName, boolean isStatic, boolean isExtension) { List<XImportDeclaration> originalImportDeclarationsToRemove = findOriginalImports(type, memberName, originalImportDeclarations, isStatic, isExtension); removedImportDeclarations.addAll(originalImportDeclarationsToRemove); List<XImportDeclaration> addedImportDeclarationsToRemove = findOriginalImports(type, memberName, addedImportDeclarations, isStatic, isExtension); addedImportDeclarations.removeAll(addedImportDeclarationsToRemove); Set<String> members = staticImports.get(type); return members != null && members.remove(memberName); }
public List<ReplaceRegion> rewrite() { removeObsoleteStaticImports(); final List<ReplaceRegion> replaceRegions = newArrayList(); if (isSort) { List<XImportDeclaration> allImportDeclarations = newArrayList(); allImportDeclarations.addAll(originalImportDeclarations); allImportDeclarations.addAll(addedImportDeclarations); allImportDeclarations.removeAll(removedImportDeclarations); String newImportSection = serializeImports(allImportDeclarations); importRegion = regionUtil.addLeadingWhitespace(importRegion, resource); importRegion = regionUtil.addTrailingWhitespace(importRegion, resource); return singletonList(new ReplaceRegion(importRegion, newImportSection)); } else { for (XImportDeclaration removedImportDeclaration : removedImportDeclarations) { ICompositeNode node = NodeModelUtils.findActualNodeFor(removedImportDeclaration); if (node != null) { ITextRegion textRegion = node.getTextRegion(); textRegion = regionUtil.addTrailingSingleWhitespace(textRegion, lineSeparator, resource); replaceRegions.add(new ReplaceRegion(textRegion, "")); } } addSectionToAppend(new IAcceptor<ReplaceRegion>() { @Override public void accept(ReplaceRegion t) { replaceRegions.add(t); } }); } return replaceRegions; }
protected StringBuilder getImportDeclarationsToAppend() { StringBuilder builder = new StringBuilder(); for (XImportDeclaration newImportDeclaration : addedImportDeclarations) { appendImport(builder, newImportDeclaration); } return builder; }
protected boolean appendSubsection(StringBuilder builder, Iterable<XImportDeclaration> subSection, boolean needsNewline) { if (!isEmpty(subSection)) { if (needsNewline) builder.append(lineSeparator); for (XImportDeclaration declaration : isSort() ? sort(subSection) : subSection) { appendImport(builder, declaration); } return true; } return needsNewline; }
protected List<XImportDeclaration> sort(Iterable<XImportDeclaration> declarations) { List<XImportDeclaration> sortMe = newArrayList(filter(declarations, new Predicate<XImportDeclaration>() { @Override public boolean apply(XImportDeclaration in) { return !isEmpty(in.getImportedTypeName()); } })); Collections.sort(sortMe, new Comparator<XImportDeclaration>() { @Override public int compare(XImportDeclaration o1, XImportDeclaration o2) { return o1.getImportedName().compareTo(o2.getImportedName()); } }); return sortMe; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<XImportDeclaration> getImportDeclarations() { if (importDeclarations == null) { importDeclarations = new EObjectContainmentEList<XImportDeclaration>(XImportDeclaration.class, this, XtypePackage.XIMPORT_SECTION__IMPORT_DECLARATIONS); } return importDeclarations; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case XtypePackage.XIMPORT_SECTION__IMPORT_DECLARATIONS: getImportDeclarations().clear(); getImportDeclarations().addAll((Collection<? extends XImportDeclaration>)newValue); return; } super.eSet(featureID, newValue); }
protected void _format(final XImportSection section, @Extension final IFormattableDocument format) { EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations(); for (final XImportDeclaration imp : _importDeclarations) { { format.<XImportDeclaration>format(imp); XImportDeclaration _last = IterableExtensions.<XImportDeclaration>last(section.getImportDeclarations()); boolean _notEquals = (!Objects.equal(imp, _last)); if (_notEquals) { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesBetweenImports); } else { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesAfterImports); } } } }
public void format(final Object ref, final IFormattableDocument document) { if (ref instanceof JvmTypeParameter) { _format((JvmTypeParameter)ref, document); return; } else if (ref instanceof XtextResource) { _format((XtextResource)ref, document); return; } else if (ref instanceof XFunctionTypeRef) { _format((XFunctionTypeRef)ref, document); return; } else if (ref instanceof JvmParameterizedTypeReference) { _format((JvmParameterizedTypeReference)ref, document); return; } else if (ref instanceof JvmWildcardTypeReference) { _format((JvmWildcardTypeReference)ref, document); return; } else if (ref instanceof XImportDeclaration) { _format((XImportDeclaration)ref, document); return; } else if (ref instanceof XImportSection) { _format((XImportSection)ref, document); return; } else if (ref instanceof EObject) { _format((EObject)ref, document); return; } else if (ref == null) { _format((Void)null, document); return; } else if (ref != null) { _format(ref, document); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(ref, document).toString()); } }
protected boolean isImportDeclarationRequired(final ITypeDescriptor typeDesc, final String qualifiedName, final ContentAssistContext context, final XImportSection importSection) { return ((!(typeDesc.getName().startsWith("java.lang") && (typeDesc.getName().lastIndexOf(".") == 9))) && ((importSection == null) || (!IterableExtensions.<XImportDeclaration>exists(importSection.getImportDeclarations(), ((Function1<XImportDeclaration, Boolean>) (XImportDeclaration it) -> { JvmDeclaredType _importedType = it.getImportedType(); String _qualifiedName = null; if (_importedType!=null) { _qualifiedName=_importedType.getQualifiedName(); } return Boolean.valueOf(Objects.equal(_qualifiedName, qualifiedName)); }))))); }
/** * A label for imports. Is missing in xbase super class, but present in XtendLabelProvider. * * @param context * the import * @return its label. */ @Override public String text(final XImportDeclaration context) { String namespace = context.getImportedNamespace(); if (namespace != null) { return namespace; } return context.getImportedTypeName(); }
protected ImageDescriptor imageDescriptor(final Object at) { if (at instanceof JvmConstructor) { return _imageDescriptor((JvmConstructor)at); } else if (at instanceof JvmOperation) { return _imageDescriptor((JvmOperation)at); } else if (at instanceof JvmAnnotationType) { return _imageDescriptor((JvmAnnotationType)at); } else if (at instanceof JvmEnumerationType) { return _imageDescriptor((JvmEnumerationType)at); } else if (at instanceof JvmField) { return _imageDescriptor((JvmField)at); } else if (at instanceof JvmGenericType) { return _imageDescriptor((JvmGenericType)at); } else if (at instanceof JvmTypeParameter) { return _imageDescriptor((JvmTypeParameter)at); } else if (at instanceof JvmFormalParameter) { return _imageDescriptor((JvmFormalParameter)at); } else if (at instanceof XVariableDeclaration) { return _imageDescriptor((XVariableDeclaration)at); } else if (at instanceof AlgorithmType) { return _imageDescriptor((AlgorithmType)at); } else if (at instanceof GraphPolicies) { return _imageDescriptor((GraphPolicies)at); } else if (at instanceof Model) { return _imageDescriptor((Model)at); } else if (at instanceof PathGeneratorStopCondition) { return _imageDescriptor((PathGeneratorStopCondition)at); } else if (at instanceof Policies) { return _imageDescriptor((Policies)at); } else if (at instanceof Severity) { return _imageDescriptor((Severity)at); } else if (at instanceof StopCondition) { return _imageDescriptor((StopCondition)at); } else if (at instanceof IResolvedConstructor) { return _imageDescriptor((IResolvedConstructor)at); } else if (at instanceof IResolvedOperation) { return _imageDescriptor((IResolvedOperation)at); } else if (at instanceof XImportDeclaration) { return _imageDescriptor((XImportDeclaration)at); } else if (at instanceof XImportSection) { return _imageDescriptor((XImportSection)at); } else if (at instanceof IResolvedField) { return _imageDescriptor((IResolvedField)at); } else if (at != null) { return _imageDescriptor(at); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(at).toString()); } }
@Override public void sequence(ISerializationContext context, EObject semanticObject) { EPackage epackage = semanticObject.eClass().getEPackage(); ParserRule rule = context.getParserRule(); Action action = context.getAssignedAction(); Set<Parameter> parameters = context.getEnabledBooleanParameters(); if (epackage == TypesPackage.eINSTANCE) switch (semanticObject.eClass().getClassifierID()) { case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE: sequence_JvmTypeReference(context, (JvmGenericArrayTypeReference) semanticObject); return; case TypesPackage.JVM_INNER_TYPE_REFERENCE: sequence_JvmParameterizedTypeReference(context, (JvmInnerTypeReference) semanticObject); return; case TypesPackage.JVM_LOWER_BOUND: if (rule == grammarAccess.getJvmLowerBoundAndedRule()) { sequence_JvmLowerBoundAnded(context, (JvmLowerBound) semanticObject); return; } else if (rule == grammarAccess.getJvmLowerBoundRule()) { sequence_JvmLowerBound(context, (JvmLowerBound) semanticObject); return; } else break; case TypesPackage.JVM_PARAMETERIZED_TYPE_REFERENCE: if (action == grammarAccess.getJvmParameterizedTypeReferenceAccess().getJvmInnerTypeReferenceOuterAction_1_4_0_0_0()) { sequence_JvmParameterizedTypeReference_JvmInnerTypeReference_1_4_0_0_0(context, (JvmParameterizedTypeReference) semanticObject); return; } else if (rule == grammarAccess.getJvmTypeReferenceRule() || action == grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0() || rule == grammarAccess.getJvmParameterizedTypeReferenceRule() || rule == grammarAccess.getJvmArgumentTypeReferenceRule()) { sequence_JvmParameterizedTypeReference(context, (JvmParameterizedTypeReference) semanticObject); return; } else break; case TypesPackage.JVM_TYPE_PARAMETER: sequence_JvmTypeParameter(context, (JvmTypeParameter) semanticObject); return; case TypesPackage.JVM_UPPER_BOUND: if (rule == grammarAccess.getJvmUpperBoundAndedRule()) { sequence_JvmUpperBoundAnded(context, (JvmUpperBound) semanticObject); return; } else if (rule == grammarAccess.getJvmUpperBoundRule()) { sequence_JvmUpperBound(context, (JvmUpperBound) semanticObject); return; } else break; case TypesPackage.JVM_WILDCARD_TYPE_REFERENCE: sequence_JvmWildcardTypeReference(context, (JvmWildcardTypeReference) semanticObject); return; } else if (epackage == XtypePackage.eINSTANCE) switch (semanticObject.eClass().getClassifierID()) { case XtypePackage.XFUNCTION_TYPE_REF: sequence_XFunctionTypeRef(context, (XFunctionTypeRef) semanticObject); return; case XtypePackage.XIMPORT_DECLARATION: sequence_XImportDeclaration(context, (XImportDeclaration) semanticObject); return; case XtypePackage.XIMPORT_SECTION: sequence_XImportSection(context, (XImportSection) semanticObject); return; } if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context)); }
@Deprecated protected void sequence_XImportDeclaration(EObject context, XImportDeclaration semanticObject) { sequence_XImportDeclaration(createContext(context, semanticObject), semanticObject); }
/** * Complete the initialization of the package and its meta-model. This * method is guarded to have no affect on any invocation but its first. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void initializePackageContents() { if (isInitialized) return; isInitialized = true; // Initialize package setName(eNAME); setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); // Obtain other dependent packages TypesPackage theTypesPackage = (TypesPackage)EPackage.Registry.INSTANCE.getEPackage(TypesPackage.eNS_URI); // Create type parameters // Set bounds for type parameters // Add supertypes to classes xFunctionTypeRefEClass.getESuperTypes().add(theTypesPackage.getJvmSpecializedTypeReference()); xComputedTypeReferenceEClass.getESuperTypes().add(theTypesPackage.getJvmSpecializedTypeReference()); // Initialize classes and features; add operations and parameters initEClass(xFunctionTypeRefEClass, XFunctionTypeRef.class, "XFunctionTypeRef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getXFunctionTypeRef_ParamTypes(), theTypesPackage.getJvmTypeReference(), null, "paramTypes", null, 0, -1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXFunctionTypeRef_ReturnType(), theTypesPackage.getJvmTypeReference(), null, "returnType", null, 0, 1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXFunctionTypeRef_Type(), theTypesPackage.getJvmType(), null, "type", null, 0, 1, XFunctionTypeRef.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getXFunctionTypeRef_InstanceContext(), ecorePackage.getEBoolean(), "instanceContext", null, 0, 1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xComputedTypeReferenceEClass, XComputedTypeReference.class, "XComputedTypeReference", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXComputedTypeReference_TypeProvider(), this.getIJvmTypeReferenceProvider(), "typeProvider", null, 0, 1, XComputedTypeReference.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xImportSectionEClass, XImportSection.class, "XImportSection", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getXImportSection_ImportDeclarations(), this.getXImportDeclaration(), null, "importDeclarations", null, 0, -1, XImportSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xImportDeclarationEClass, XImportDeclaration.class, "XImportDeclaration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXImportDeclaration_Wildcard(), ecorePackage.getEBoolean(), "wildcard", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_Extension(), ecorePackage.getEBoolean(), "extension", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_Static(), ecorePackage.getEBoolean(), "static", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXImportDeclaration_ImportedType(), theTypesPackage.getJvmDeclaredType(), null, "importedType", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_MemberName(), ecorePackage.getEString(), "memberName", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_ImportedNamespace(), ecorePackage.getEString(), "importedNamespace", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); addEOperation(xImportDeclarationEClass, ecorePackage.getEString(), "getImportedName", 0, 1, IS_UNIQUE, IS_ORDERED); addEOperation(xImportDeclarationEClass, ecorePackage.getEString(), "getImportedTypeName", 0, 1, IS_UNIQUE, IS_ORDERED); // Initialize data types initEDataType(iJvmTypeReferenceProviderEDataType, IJvmTypeReferenceProvider.class, "IJvmTypeReferenceProvider", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); // Create resource createResource(eNS_URI); }
public Iterable<JvmFeature> getAllFeatures(final XImportDeclaration it) { return this.getAllFeatures(it.eResource(), it.getImportedType(), it.isStatic(), it.isExtension(), it.getMemberName()); }
/** * @deprecated override {@link #highlightReferenceJvmType(IHighlightedPositionAcceptor, EObject, EReference, EObject)} * or {@link #highlightFeature(IHighlightedPositionAcceptor, EObject, org.eclipse.emf.ecore.EStructuralFeature, String...)} * in order to customize the coloring of references of {@link JvmType JvmTypes}. */ @Deprecated protected void highlightReferenceJvmType(IHighlightedPositionAcceptor acceptor, EObject referencer, EReference reference, EObject resolvedReferencedObject, String highlightingConfiguration) { highlightDeprecation(acceptor, referencer, reference, resolvedReferencedObject); final Object referencersContainingFeature = referencer.eContainingFeature(); if (resolvedReferencedObject instanceof JvmTypeParameter) { // may happen in cast expressions highlightFeature(acceptor, referencer, reference, TYPE_VARIABLE); } else if (referencer instanceof JvmParameterizedTypeReference && (referencersContainingFeature == TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__ARGUMENTS || referencersContainingFeature == TypesPackage.Literals.JVM_TYPE_CONSTRAINT__TYPE_REFERENCE || referencersContainingFeature == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__TYPE_ARGUMENTS || referencersContainingFeature == XbasePackage.Literals.XCONSTRUCTOR_CALL__TYPE_ARGUMENTS)) { // case 1: 'referencer' is a type reference within the arguments reference of another (parameterized) type reference // 'referencer' definitely is a type argument and to be colored as such // (if 'resolvedReferencedObject' is not a type parameter, which is tested above) // case 2: type reference is nested in a JvmWildcardTypeReference -> JvmTypeConstraint // case 3: the type reference is part of the type arguments of a method call if (resolvedReferencedObject instanceof JvmEnumerationType) { highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, ENUM); } else if (resolvedReferencedObject instanceof JvmGenericType) { highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, getStyle((JvmGenericType) resolvedReferencedObject)); } else if (resolvedReferencedObject instanceof JvmAnnotationType) { highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, highlightingConfiguration); } highlightFeature(acceptor, referencer, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, TYPE_ARGUMENT); } else if (resolvedReferencedObject instanceof JvmDeclaredType) { if (referencer instanceof XImportDeclaration) { // don't highlight import statements return; } else if (resolvedReferencedObject instanceof JvmEnumerationType) { highlightFeature(acceptor, referencer, reference, ENUM); } else if (resolvedReferencedObject instanceof JvmGenericType) { highlightFeature(acceptor, referencer, reference, getStyle((JvmGenericType) resolvedReferencedObject)); } else if (resolvedReferencedObject instanceof JvmAnnotationType) { highlightFeature(acceptor, referencer, reference, highlightingConfiguration); } } }
/** * Contexts: * XImportDeclaration returns XImportDeclaration * * Constraint: * ( * (static?='static' extension?='extension'? importedType=[JvmDeclaredType|QualifiedNameInStaticImport] (wildcard?='*' | memberName=ValidID)) | * importedType=[JvmDeclaredType|QualifiedName] | * importedNamespace=QualifiedNameWithWildcard * ) */ protected void sequence_XImportDeclaration(ISerializationContext context, XImportDeclaration semanticObject) { genericSequencer.createSequence(context, semanticObject); }