예제 #1
0
 public List<IEObjectDescription> findHostClasses(
     EObject scopeDetermeningResource, String name, PPImportedNamesAdapter importedNames) {
   if (name == null) throw new IllegalArgumentException("name is null");
   QualifiedName fqn = converter.toQualifiedName(name);
   // make last segments initial char lower case (for references to the type itself - eg. 'File'
   // instead of
   // 'file'.
   fqn = fqn.skipLast(1).append(toInitialLowerCase(fqn.getLastSegment()));
   return findExternal(scopeDetermeningResource, fqn, importedNames, false, CLASS_AND_TYPE);
 }
예제 #2
0
  protected List<IEObjectDescription> findAttributesWithGuard(
      EObject scopeDetermeningObject,
      QualifiedName fqn,
      PPImportedNamesAdapter importedNames,
      List<QualifiedName> stack,
      boolean prefixMatch) {
    // Protect against circular inheritance
    QualifiedName containerName = fqn.skipLast(1);
    if (stack.contains(containerName)) return Collections.emptyList();
    stack.add(containerName);

    // find a regular DefinitionArgument, Property or Parameter
    final List<IEObjectDescription> result =
        findExternal(
            scopeDetermeningObject, fqn, importedNames, prefixMatch, DEF_AND_TYPE_ARGUMENTS);

    // Search up the inheritance chain if no match (on exact match), or if a prefix search
    if (result.isEmpty() || prefixMatch) {
      // find the parent type
      List<IEObjectDescription> parentResult =
          findExternal(scopeDetermeningObject, fqn.skipLast(1), importedNames, false, DEF_AND_TYPE);
      if (!parentResult.isEmpty()) {
        IEObjectDescription firstFound = parentResult.get(0);
        String parentName = firstFound.getUserData(PPDSLConstants.PARENT_NAME_DATA);
        if (parentName != null && parentName.length() > 1) {
          // find attributes for parent

          QualifiedName attributeFqn = converter.toQualifiedName(parentName);
          attributeFqn = attributeFqn.append(fqn.getLastSegment());
          if (prefixMatch)
            result.addAll(
                findAttributesWithGuard(
                    scopeDetermeningObject, attributeFqn, importedNames, stack, prefixMatch));
          else
            return findAttributesWithGuard(
                scopeDetermeningObject, attributeFqn, importedNames, stack, prefixMatch);
        }
      }
    }
    return result;
  }
 /**
  * Create a new {@link ImportNormalizer} for the given namespace.
  *
  * @param namespace the namespace.
  * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
  * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be
  *     converted to a valid qualified name.
  */
 protected ImportNormalizer createImportedNamespaceResolver(
     final String namespace, boolean ignoreCase) {
   if (Strings.isEmpty(namespace)) return null;
   QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
   if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) {
     return null;
   }
   boolean hasWildcard =
       ignoreCase
           ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildcard())
           : importedNamespace.getLastSegment().equals(getWildcard());
   if (hasWildcard) {
     if (importedNamespace.getSegmentCount() <= 1) return null;
     return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
   } else {
     return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
   }
 }