예제 #1
0
 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;
 }
예제 #2
0
 protected CharSequence _toHtml(final CodeRef it) {
   CharSequence _xblockexpression = null;
   {
     JvmDeclaredType _element = it.getElement();
     String _identifier = _element.getIdentifier();
     String _operator_plus = StringExtensions.operator_plus("TODO CodeRef to: ", _identifier);
     InputOutput.<String>println(_operator_plus);
     CharSequence _xifexpression = null;
     TextOrMarkup _altText = it.getAltText();
     boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_altText, null);
     if (_operator_notEquals) {
       TextOrMarkup _altText_1 = it.getAltText();
       CharSequence _html = this.toHtml(_altText_1);
       _xifexpression = _html;
     } else {
       JvmDeclaredType _element_1 = it.getElement();
       String _identifier_1 = _element_1.getIdentifier();
       String _operator_plus_1 =
           StringExtensions.operator_plus("<code class=\"prettyprint lang-java\">", _identifier_1);
       String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "</code>");
       _xifexpression = _operator_plus_2;
     }
     _xblockexpression = (_xifexpression);
   }
   return _xblockexpression;
 }
예제 #3
0
 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);
       }
     }
   }
 }
 protected IScope doGetTypeScope(XFeatureCall call, JvmType type) {
   if (call.isPackageFragment()) {
     if (type instanceof JvmDeclaredType) {
       String packageName = ((JvmDeclaredType) type).getPackageName();
       int dot = packageName.indexOf('.');
       if (dot == -1) {
         return new SingletonScope(EObjectDescription.create(packageName, type), IScope.NULLSCOPE);
       } else {
         String firstSegment = packageName.substring(0, dot);
         return new SingletonScope(
             EObjectDescription.create(firstSegment, type), IScope.NULLSCOPE);
       }
     }
     return IScope.NULLSCOPE;
   } else {
     if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() != null) {
       Resource resource = call.eResource();
       if (resource instanceof XtextResource) {
         XImportSection importSection =
             importsConfiguration.getImportSection((XtextResource) resource);
         if (importSection != null) {
           List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations();
           List<IEObjectDescription> descriptions = Lists.newArrayList();
           for (XImportDeclaration importDeclaration : importDeclarations) {
             if (!importDeclaration.isStatic()
                 && !importDeclaration.isWildcard()
                 && !importDeclaration.isExtension()) {
               JvmDeclaredType importedType = importDeclaration.getImportedType();
               if (importedType == type) {
                 String syntax = importsConfiguration.getLegacyImportSyntax(importDeclaration);
                 if (syntax != null /* no node model attached */
                     && syntax.equals(type.getQualifiedName())) {
                   String packageName = importedType.getPackageName();
                   descriptions.add(
                       EObjectDescription.create(
                           syntax.substring(packageName.length() + 1), type));
                 }
               }
               if (EcoreUtil.isAncestor(importedType, type)) {
                 String name = type.getSimpleName();
                 JvmType worker = type;
                 while (worker != importedType) {
                   worker = (JvmType) worker.eContainer();
                   name = worker.getSimpleName() + "$" + name;
                 }
                 descriptions.add(EObjectDescription.create(name, type));
               }
             }
           }
           return new SimpleScope(descriptions);
         }
       }
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     } else {
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     }
   }
 }
예제 #5
0
 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;
 }
 @Override
 protected String computeIdentifier() {
   if (simpleName == null) return null;
   JvmDeclaredType declaringType = internalGetDeclaringType();
   if (declaringType == null) {
     if (Strings.isEmpty(packageName)) return simpleName;
     return packageName + "." + simpleName;
   }
   String parentName = declaringType.getIdentifier();
   if (parentName == null) return null;
   return parentName + '$' + simpleName;
 }
 @Override
 public String getQualifiedName(char innerClassDelimiter) {
   if (simpleName == null) return null;
   JvmDeclaredType declaringType = getDeclaringType();
   if (declaringType == null) {
     if (Strings.isEmpty(packageName)) return simpleName;
     return packageName + "." + simpleName;
   }
   String parentName = declaringType.getQualifiedName(innerClassDelimiter);
   if (parentName == null) return null;
   return parentName + innerClassDelimiter + simpleName;
 }
예제 #8
0
 @Test
 public void testBug300216() {
   JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName("java.lang.Object");
   assertTrue(type.getSuperTypes().isEmpty());
   URI unresolveableType = URI.createURI("java:/Objects/Something#Something");
   JvmVoid proxy = TypesFactory.eINSTANCE.createJvmVoid();
   JvmParameterizedTypeReference typeReference =
       TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
   typeReference.setType(proxy);
   ((InternalEObject) proxy).eSetProxyURI(unresolveableType);
   type.getSuperTypes().add(typeReference);
   assertTrue(type.getSuperTypes().get(0).getType().eIsProxy());
   assertEquals(2, type.eResource().getResourceSet().getResources().size());
 }
 public String getHash(final JvmDeclaredType type) {
   if (type.eResource() instanceof TypeResource) {
     IMirror mirror = ((TypeResource) type.eResource()).getMirror();
     if (mirror instanceof IMirrorExtension && ((IMirrorExtension) mirror).isSealed())
       return type.getIdentifier();
   }
   return cache.get(
       Tuples.create(HASH_CACHE_KEY, type),
       type.eResource(),
       new Provider<String>() {
         public String get() {
           return signatureBuilderProvider.get().appendSignature(type).hash();
         }
       });
 }
예제 #10
0
  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;
  }
예제 #11
0
 protected IScope createLocalVarScopeForJvmDeclaredType(JvmDeclaredType type, IScope parentScope) {
   Iterator<JvmTypeReference> classes =
       filter(
               type.getSuperTypes(),
               new Predicate<JvmTypeReference>() {
                 public boolean apply(JvmTypeReference input) {
                   if (input.getType() instanceof JvmGenericType) {
                     return !((JvmGenericType) input.getType()).isInterface();
                   }
                   return false;
                 }
               })
           .iterator();
   JvmGenericType superType = null;
   if (classes.hasNext()) {
     superType = (JvmGenericType) classes.next().getType();
   }
   if (superType == null) {
     return new JvmFeatureScope(parentScope, "this", new LocalVarDescription(THIS, type));
   } else {
     return new JvmFeatureScope(
         parentScope,
         "this & super",
         newArrayList(
             new LocalVarDescription(THIS, type),
             new LocalVarDescription(QualifiedName.create("super"), superType)));
   }
 }
예제 #12
0
 protected JvmType findNestedType(JvmType result, int index, QualifiedName name) {
   List<String> segments =
       name.getSegmentCount() == 1
           ? Strings.split(name.getFirstSegment(), '$')
           : name.getSegments();
   for (int i = 1, size = segments.size(); i < size && result instanceof JvmDeclaredType; i++) {
     JvmDeclaredType declaredType = (JvmDeclaredType) result;
     String simpleName = segments.get(i);
     // TODO handle ambiguous types
     for (JvmMember member : declaredType.findAllNestedTypesByName(simpleName)) {
       result = (JvmType) member;
       break;
     }
     if (declaredType == result) {
       return null;
     }
   }
   return result;
 }
예제 #13
0
 public boolean hasImportedType(JvmDeclaredType type) {
   List<JvmDeclaredType> importedTypes = getImportedTypes(type.getSimpleName());
   if (importedTypes == null) {
     return false;
   }
   for (JvmDeclaredType importedType : importedTypes) {
     if (importedType == type) {
       return true;
     }
   }
   return false;
 }
예제 #14
0
 public Class<? extends Object> compile(final Resource res, final JvmDeclaredType type) {
   res.eSetDeliver(false);
   EList<EObject> _contents = res.getContents();
   this.builder.<JvmDeclaredType>operator_add(_contents, type);
   res.eSetDeliver(true);
   InMemoryFileSystemAccess _inMemoryFileSystemAccess = new InMemoryFileSystemAccess();
   final InMemoryFileSystemAccess fsa = _inMemoryFileSystemAccess;
   this.generator.doGenerate(res, fsa);
   Map<String, CharSequence> _files = fsa.getFiles();
   String _identifier = type.getIdentifier();
   String _replace = _identifier.replace(".", "/");
   String _plus = (IFileSystemAccess.DEFAULT_OUTPUT + _replace);
   String _plus_1 = (_plus + ".java");
   CharSequence _get = _files.get(_plus_1);
   final String code = _get.toString();
   String _identifier_1 = type.getIdentifier();
   final Class<? extends Object> compiledClass =
       this.javaCompiler.compileToClass(_identifier_1, code);
   EList<EObject> _contents_1 = res.getContents();
   EObject _head = IterableExtensions.<EObject>head(_contents_1);
   this.helper.assertNoErrors(_head);
   return compiledClass;
 }
 protected SignatureHashBuilder appendMemberSignatures(
     JvmDeclaredType type, boolean innerTypesOnly) {
   Iterable<? extends JvmMember> members = type.getMembers();
   if (innerTypesOnly) members = filter(members, JvmDeclaredType.class);
   for (JvmMember member : members) {
     if (member.getVisibility() != JvmVisibility.PRIVATE && member.getSimpleName() != null) {
       appendAnnotationReferences(member);
       if (member instanceof JvmOperation) appendSignature((JvmOperation) member);
       else if (member instanceof JvmConstructor) appendSignature((JvmConstructor) member);
       else if (member instanceof JvmField) appendSignature((JvmField) member);
       else if (member instanceof JvmDeclaredType) {
         append(member.getQualifiedName());
         appendMemberSignatures((JvmDeclaredType) member, true);
       }
       append("\n");
     }
   }
   return this;
 }
 public SignatureHashBuilder appendSignature(JvmDeclaredType type) {
   if (type.getVisibility() != JvmVisibility.PRIVATE) {
     appendAnnotationReferences(type);
     appendVisibility(type.getVisibility()).append(" ");
     if (type.isAbstract()) append("abstract ");
     if (type.isStatic()) append("static ");
     if (type.isFinal()) append("final ");
     append("class ").append(type.getIdentifier());
     if (type instanceof JvmTypeParameterDeclarator)
       appendTypeParameters((JvmTypeParameterDeclarator) type);
     append("\n").appendSuperTypeSignatures(type).appendMemberSignatures(type, false);
   }
   return this;
 }
  protected IScope getLocalElementsScope(
      IScope parent, IScope globalScope, EObject context, EReference reference) {
    IScope result = parent;
    QualifiedName name = getQualifiedNameOfLocalElement(context);
    boolean ignoreCase = isIgnoreCase(reference);
    ISelectable resourceOnlySelectable = getAllDescriptions(context.eResource());
    ISelectable globalScopeSelectable = new ScopeBasedSelectable(globalScope);

    // imports
    List<ImportNormalizer> explicitImports = getImportedNamespaceResolvers(context, ignoreCase);
    if (!explicitImports.isEmpty()) {
      result =
          createImportScope(
              result,
              explicitImports,
              globalScopeSelectable,
              reference.getEReferenceType(),
              ignoreCase);
    }

    // local element
    if (name != null) {
      ImportNormalizer localNormalizer = doCreateImportNormalizer(name, true, ignoreCase);
      result =
          createImportScope(
              result,
              singletonList(localNormalizer),
              resourceOnlySelectable,
              reference.getEReferenceType(),
              ignoreCase);
    }

    // scope for jvm elements
    Set<EObject> elements = associations.getJvmElements(context);
    for (EObject derivedJvmElement : elements) {
      // scope for JvmDeclaredTypes
      if (derivedJvmElement instanceof JvmDeclaredType) {
        JvmDeclaredType declaredType = (JvmDeclaredType) derivedJvmElement;
        QualifiedName jvmTypeName = getQualifiedNameOfLocalElement(declaredType);
        if (declaredType.getDeclaringType() == null
            && !Strings.isEmpty(declaredType.getPackageName())) {
          QualifiedName packageName =
              this.qualifiedNameConverter.toQualifiedName(declaredType.getPackageName());
          ImportNormalizer normalizer = doCreateImportNormalizer(packageName, true, ignoreCase);
          result =
              createImportScope(
                  result,
                  singletonList(normalizer),
                  globalScopeSelectable,
                  reference.getEReferenceType(),
                  ignoreCase);
        }
        if (jvmTypeName != null && !jvmTypeName.equals(name)) {
          ImportNormalizer localNormalizer =
              doCreateImportNormalizer(jvmTypeName, true, ignoreCase);
          result =
              createImportScope(
                  result,
                  singletonList(localNormalizer),
                  resourceOnlySelectable,
                  reference.getEReferenceType(),
                  ignoreCase);
        }
      }
      // scope for JvmTypeParameterDeclarator
      if (derivedJvmElement instanceof JvmTypeParameterDeclarator) {
        JvmTypeParameterDeclarator parameterDeclarator =
            (JvmTypeParameterDeclarator) derivedJvmElement;
        List<IEObjectDescription> descriptions = null;
        for (JvmTypeParameter param : parameterDeclarator.getTypeParameters()) {
          if (param.getSimpleName() != null) {
            if (descriptions == null) descriptions = Lists.newArrayList();
            QualifiedName paramName = QualifiedName.create(param.getSimpleName());
            descriptions.add(EObjectDescription.create(paramName, param));
          }
        }
        if (descriptions != null && !descriptions.isEmpty())
          result = MapBasedScope.createScope(result, descriptions);
      }
    }
    return result;
  }
예제 #18
0
 /**
  * We cannot rely on JvmType#getIdentifier as it is cached and does not pick up changed
  * simpleNames, e.g. in rename refactoring.
  */
 protected String serializeType(JvmDeclaredType type) {
   return type.getQualifiedName('.');
 }
예제 #19
0
 public void generateBodyAnnotations(final XPackage pack) {
   final HashSet<ETypedElement> processed = CollectionLiterals.<ETypedElement>newHashSet();
   EList<XClassifier> _classifiers = pack.getClassifiers();
   for (final XClassifier xClassifier : _classifiers) {
     if ((xClassifier instanceof XDataType)) {
       final XDataType xDataType = ((XDataType) xClassifier);
       XDataTypeMapping _mapping = this.mappings.getMapping(xDataType);
       final EDataType eDataType = _mapping.getEDataType();
       final XBlockExpression createBody = xDataType.getCreateBody();
       XDataTypeMapping _mapping_1 = this.mappings.getMapping(xDataType);
       final JvmOperation creator = _mapping_1.getCreator();
       boolean _and = false;
       boolean _notEquals = (!Objects.equal(createBody, null));
       if (!_notEquals) {
         _and = false;
       } else {
         boolean _notEquals_1 = (!Objects.equal(creator, null));
         _and = (_notEquals && _notEquals_1);
       }
       if (_and) {
         final XcoreAppendable appendable = this.createAppendable();
         EList<JvmFormalParameter> _parameters = creator.getParameters();
         JvmFormalParameter _get = _parameters.get(0);
         appendable.declareVariable(_get, "it");
         JvmTypeReference _returnType = creator.getReturnType();
         Set<JvmTypeReference> _emptySet = Collections.<JvmTypeReference>emptySet();
         this.compiler.compile(createBody, appendable, _returnType, _emptySet);
         String _string = appendable.toString();
         String _extractBody = this.extractBody(_string);
         EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "create", _extractBody);
       }
       final XBlockExpression convertBody = xDataType.getConvertBody();
       XDataTypeMapping _mapping_2 = this.mappings.getMapping(xDataType);
       final JvmOperation converter = _mapping_2.getConverter();
       boolean _and_1 = false;
       boolean _notEquals_2 = (!Objects.equal(convertBody, null));
       if (!_notEquals_2) {
         _and_1 = false;
       } else {
         boolean _notEquals_3 = (!Objects.equal(converter, null));
         _and_1 = (_notEquals_2 && _notEquals_3);
       }
       if (_and_1) {
         final XcoreAppendable appendable_1 = this.createAppendable();
         EList<JvmFormalParameter> _parameters_1 = converter.getParameters();
         JvmFormalParameter _get_1 = _parameters_1.get(0);
         appendable_1.declareVariable(_get_1, "it");
         JvmTypeReference _returnType_1 = converter.getReturnType();
         Set<JvmTypeReference> _emptySet_1 = Collections.<JvmTypeReference>emptySet();
         this.compiler.compile(convertBody, appendable_1, _returnType_1, _emptySet_1);
         String _string_1 = appendable_1.toString();
         String _extractBody_1 = this.extractBody(_string_1);
         EcoreUtil.setAnnotation(eDataType, GenModelPackage.eNS_URI, "convert", _extractBody_1);
       }
     } else {
       final XClass xClass = ((XClass) xClassifier);
       XClassMapping _mapping_3 = this.mappings.getMapping(xClass);
       final EClass eClass = _mapping_3.getEClass();
       EList<EStructuralFeature> _eAllStructuralFeatures = eClass.getEAllStructuralFeatures();
       for (final EStructuralFeature eStructuralFeature : _eAllStructuralFeatures) {
         boolean _add = processed.add(eStructuralFeature);
         if (_add) {
           final XStructuralFeature xFeature = this.mappings.getXFeature(eStructuralFeature);
           boolean _notEquals_4 = (!Objects.equal(xFeature, null));
           if (_notEquals_4) {
             final XBlockExpression getBody = xFeature.getGetBody();
             boolean _notEquals_5 = (!Objects.equal(getBody, null));
             if (_notEquals_5) {
               XFeatureMapping _mapping_4 = this.mappings.getMapping(xFeature);
               final JvmOperation getter = _mapping_4.getGetter();
               final XcoreAppendable appendable_2 = this.createAppendable();
               JvmTypeReference _returnType_2 = getter.getReturnType();
               Set<JvmTypeReference> _emptySet_2 = Collections.<JvmTypeReference>emptySet();
               this.compiler.compile(getBody, appendable_2, _returnType_2, _emptySet_2);
               String _string_2 = appendable_2.toString();
               String _extractBody_2 = this.extractBody(_string_2);
               EcoreUtil.setAnnotation(
                   eStructuralFeature, GenModelPackage.eNS_URI, "get", _extractBody_2);
             }
           }
         }
       }
       EList<EOperation> _eAllOperations = eClass.getEAllOperations();
       for (final EOperation eOperation : _eAllOperations) {
         boolean _add_1 = processed.add(eOperation);
         if (_add_1) {
           final XOperation xOperation = this.mappings.getXOperation(eOperation);
           boolean _notEquals_6 = (!Objects.equal(xOperation, null));
           if (_notEquals_6) {
             final XBlockExpression body = xOperation.getBody();
             boolean _notEquals_7 = (!Objects.equal(body, null));
             if (_notEquals_7) {
               XOperationMapping _mapping_5 = this.mappings.getMapping(xOperation);
               final JvmOperation jvmOperation = _mapping_5.getJvmOperation();
               boolean _notEquals_8 = (!Objects.equal(jvmOperation, null));
               if (_notEquals_8) {
                 final XcoreAppendable appendable_3 = this.createAppendable();
                 JvmDeclaredType _declaringType = jvmOperation.getDeclaringType();
                 appendable_3.declareVariable(_declaringType, "this");
                 JvmDeclaredType _declaringType_1 = jvmOperation.getDeclaringType();
                 EList<JvmTypeReference> _superTypes = _declaringType_1.getSuperTypes();
                 final JvmTypeReference superType =
                     IterableExtensions.<JvmTypeReference>head(_superTypes);
                 boolean _notEquals_9 = (!Objects.equal(superType, null));
                 if (_notEquals_9) {
                   JvmType _type = superType.getType();
                   appendable_3.declareVariable(_type, "super");
                 }
                 EList<JvmFormalParameter> _parameters_2 = jvmOperation.getParameters();
                 for (final JvmFormalParameter parameter : _parameters_2) {
                   String _name = parameter.getName();
                   appendable_3.declareVariable(parameter, _name);
                 }
                 JvmTypeReference _returnType_3 = jvmOperation.getReturnType();
                 EList<JvmTypeReference> _exceptions = jvmOperation.getExceptions();
                 HashSet<JvmTypeReference> _hashSet = new HashSet<JvmTypeReference>(_exceptions);
                 this.compiler.compile(body, appendable_3, _returnType_3, _hashSet);
                 String _string_3 = appendable_3.toString();
                 String _extractBody_3 = this.extractBody(_string_3);
                 EcoreUtil.setAnnotation(
                     eOperation, GenModelPackage.eNS_URI, "body", _extractBody_3);
               }
             }
           }
         }
       }
     }
   }
 }
예제 #20
0
 public boolean needsImport(JvmDeclaredType type) {
   if (type.getDeclaringType() != null) return true;
   String packageName = type.getPackageName();
   return packageName != null && !(implicitlyImportedPackages.contains(packageName));
 }
예제 #21
0
 protected void createFeatureNodesForType(
     IOutlineNode parentNode,
     XtendTypeDeclaration xtendType,
     JvmDeclaredType inferredType,
     final JvmDeclaredType baseType,
     Set<JvmFeature> processedFeatures,
     int inheritanceDepth) {
   if (xtendType instanceof XtendClass) {
     for (JvmOperation operation : inferredType.getDeclaredOperations()) {
       if (dispatchHelper.isDispatcherFunction(operation)) {
         JvmOperation dispatcher = operation;
         XtendFeatureNode dispatcherNode =
             createNodeForFeature(parentNode, baseType, dispatcher, dispatcher, inheritanceDepth);
         if (dispatcherNode != null) {
           dispatcherNode.setDispatch(true);
           processedFeatures.add(dispatcher);
           boolean inheritsDispatchCases = false;
           Iterable<JvmOperation> dispatchCases;
           if (getCurrentMode() == SHOW_INHERITED_MODE)
             dispatchCases = dispatchHelper.getAllDispatchCases(dispatcher);
           else {
             dispatchCases = newArrayList(dispatchHelper.getLocalDispatchCases(dispatcher));
             sort(
                 (List<JvmOperation>) dispatchCases,
                 new Comparator<JvmOperation>() {
                   public int compare(JvmOperation o1, JvmOperation o2) {
                     return baseType.getMembers().indexOf(o1) - baseType.getMembers().indexOf(o2);
                   }
                 });
           }
           for (JvmOperation dispatchCase : dispatchCases) {
             inheritsDispatchCases |= dispatchCase.getDeclaringType() != baseType;
             XtendFunction xtendFunction = associations.getXtendFunction(dispatchCase);
             if (xtendFunction == null) {
               createNodeForFeature(
                   dispatcherNode, baseType, dispatchCase, dispatchCase, inheritanceDepth);
             } else {
               createNodeForFeature(
                   dispatcherNode, baseType, dispatchCase, xtendFunction, inheritanceDepth);
             }
             processedFeatures.add(dispatchCase);
           }
           if (inheritsDispatchCases)
             dispatcherNode.setImageDescriptor(
                 images.forDispatcherFunction(
                     dispatcher.getVisibility(),
                     adornments.get(dispatcher) | JavaElementImageDescriptor.OVERRIDES));
         }
       }
     }
   }
   for (JvmFeature feature : filter(inferredType.getMembers(), JvmFeature.class)) {
     if (!processedFeatures.contains(feature)) {
       EObject primarySourceElement = associations.getPrimarySourceElement(feature);
       createNodeForFeature(
           parentNode,
           baseType,
           feature,
           primarySourceElement != null ? primarySourceElement : feature,
           inheritanceDepth);
     }
   }
   if (getCurrentMode() == SHOW_INHERITED_MODE) {
     if (inferredType instanceof JvmGenericType) {
       JvmTypeReference extendedClass = ((JvmGenericType) inferredType).getExtendedClass();
       if (extendedClass != null)
         createInheritedFeatureNodes(
             parentNode, baseType, processedFeatures, inheritanceDepth, extendedClass);
       for (JvmTypeReference extendedInterface :
           ((JvmGenericType) inferredType).getExtendedInterfaces()) {
         createInheritedFeatureNodes(
             parentNode, baseType, processedFeatures, inheritanceDepth, extendedInterface);
       }
     }
   }
 }
예제 #22
0
 protected void setNameAndAssociate(
     final XtendFile file, final XtendTypeDeclaration xtendType, final JvmDeclaredType javaType) {
   super.setNameAndAssociate(file, xtendType, javaType);
   String _javaClassName = this._jnarioNameProvider.toJavaClassName(xtendType);
   javaType.setSimpleName(_javaClassName);
 }
 @Override
 public String getPackageName() {
   JvmDeclaredType declaringType = internalGetDeclaringType();
   if (declaringType != null) return declaringType.getPackageName();
   return packageName;
 }