Package org.eclipse.xtext.naming

Examples of org.eclipse.xtext.naming.QualifiedName


    if(descr == null)
      return; // give up - some sort of clean build
    EClass wantedType = PPTPPackage.Literals.TYPE_ARGUMENT;
    for(IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      for(IEObjectDescription objDesc : visibleContainer.getExportedObjects()) {
        QualifiedName q = objDesc.getQualifiedName();
        if("Type".equals(q.getFirstSegment())) {
          if(wantedType == objDesc.getEClass() || wantedType.isSuperTypeOf(objDesc.getEClass()))
            metaCache.put(q.getLastSegment(), objDesc);
        }
        else if(objDesc.getEClass() == PPTPPackage.Literals.META_VARIABLE) {
          metaVarCache.put(q.getLastSegment(), objDesc);
        }
      }
    }
  }
View Full Code Here


  }

  public SearchResult findDefinitions(EObject scopeDetermeningResource, PPImportedNamesAdapter importedNames) {
    // make all segments initial char lower case (if references is to the type itself - eg. 'File' instead of
    // 'file', or 'Aa::Bb' instead of 'aa::bb'
    QualifiedName fqn2 = QualifiedName.EMPTY;

    // TODO: Note that order is important, TYPE has higher precedence and should be used for linking
    // This used to work when list was iterated per type, not it is iterated once with type check
    // first - thus if a definition is found before a type, it is earlier in the list.
    return findExternal(scopeDetermeningResource, fqn2, importedNames, Match.STARTS_WITH, DEF_AND_TYPE);
View Full Code Here

  public SearchResult findDefinitions(EObject scopeDetermeningResource, String name,
      PPImportedNamesAdapter importedNames) {
    if(name == null)
      throw new IllegalArgumentException("name is null");
    QualifiedName fqn = converter.toQualifiedName(name);
    // make all segments initial char lower case (if references is to the type itself - eg. 'File' instead of
    // 'file', or 'Aa::Bb' instead of 'aa::bb'
    QualifiedName fqn2 = QualifiedName.EMPTY;
    for(int i = 0; i < fqn.getSegmentCount(); i++)
      fqn2 = fqn2.append(toInitialLowerCase(fqn.getSegment(i)));
    // fqn2 = fqn.skipLast(1).append(toInitialLowerCase(fqn.getLastSegment()));

    // TODO: Note that order is important, TYPE has higher precedence and should be used for linking
    // This used to work when list was iterated per type, not it is iterated once with type check
    // first - thus if a definition is found before a type, it is earlier in the list.
View Full Code Here

      IResourceDescription descr = descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI());

      // GIVE UP (the system is performing a build clean).
      if(descr == null)
        return new SearchResult(targets, targets);
      QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject);

      // for(IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      // for(EClass aClass : eClasses)
      for(IEObjectDescription objDesc : new NameInScopeFilter(matchingStrategy, getExportedObjects(
        descr, descriptionIndex),
      // visibleContainer.getExportedObjects(),
      fqn, nameOfScope, eClasses))
        targets.add(objDesc);
    }
    else {
      // This is lookup from the main resource perspective
      QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject);
      for(IEObjectDescription objDesc : new NameInScopeFilter(matchingStrategy, //
        matchingStrategy.matchStartsWith()
            ? exportedPerLastSegment.values()
            : exportedPerLastSegment.get(fqn.getLastSegment()), //
        fqn, nameOfScope, eClasses))
View Full Code Here

  public SearchResult 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'.
    if(fqn.getSegmentCount() == 0)
      return new SearchResult(); // can happen while editing
    fqn = fqn.skipLast(1).append(toInitialLowerCase(fqn.getLastSegment()));
    return findExternal(scopeDetermeningResource, fqn, importedNames, Match.EQUALS, CLASS_AND_TYPE);
  }
View Full Code Here

  private SearchResult findInherited(EObject scopeDetermeningObject, QualifiedName fqn,
      PPImportedNamesAdapter importedNames, List<QualifiedName> stack, SearchStrategy matchingStrategy,
      EClass[] classes) {
    // Protect against circular inheritance
    QualifiedName containerName = fqn.skipLast(1);
    if(stack.contains(containerName))
      return new SearchResult();
    stack.add(containerName);

    // find using the given name
    SearchResult searchResult = findExternal(scopeDetermeningObject, fqn, importedNames, matchingStrategy, classes);
    final List<IEObjectDescription> result = searchResult.getAdjusted();
    // Collect raw results to enable better error reporting on path errors
    List<IEObjectDescription> rawResult = Lists.newArrayList();
    rawResult.addAll(searchResult.getRaw());

    // Search up the inheritance chain if no match (on exact match), or if a prefix search
    if(result.isEmpty() || !matchingStrategy.isExists()) {
      // find the parent type
      if(containerName.getSegmentCount() > 0) {
        // there was a parent
        List<IEObjectDescription> parentResult = findExternal(
          scopeDetermeningObject, containerName, importedNames, Match.EQUALS, DEF_AND_TYPE).getAdjusted();
        if(!parentResult.isEmpty()) {
          IEObjectDescription firstFound = parentResult.get(0);
          String parentName = firstFound.getUserData(PPDSLConstants.PARENT_NAME_DATA);
          if(parentName != null && parentName.length() > 0) {
            // find attributes for parent

            QualifiedName attributeFqn = converter.toQualifiedName(parentName);
            attributeFqn = attributeFqn.append(fqn.getLastSegment());
            SearchResult inheritedSearchResult = findInherited(
              scopeDetermeningObject, attributeFqn, importedNames, stack, matchingStrategy, classes);
            result.addAll(inheritedSearchResult.getAdjusted());
            rawResult.addAll(inheritedSearchResult.getRaw());
          }
View Full Code Here

   * @return
   */
  public SearchResult findVariable(EObject scopeDetermeningResource, String name, PPImportedNamesAdapter importedNames) {
    if(name == null)
      throw new IllegalArgumentException("name is null");
    QualifiedName fqn = converter.toQualifiedName(name);
    return findVariables(scopeDetermeningResource, fqn, importedNames, Match.NO_OUTER_EXISTS);
  }
View Full Code Here

    }
    SearchResult result = findExternal(
      scopeDetermeningObject, fqn, importedNames, matchingStrategy, CLASSES_FOR_VARIABLES);
    if(result.getAdjusted().size() > 0 && matchingStrategy.isExists())
      return result;
    QualifiedName scopeName = getNameOfScope(scopeDetermeningObject);
    if(!scopeName.isEmpty()) {
      fqn = scopeName.append(fqn);
      return result.addAll(findInherited(
        scopeDetermeningObject, fqn, importedNames, Lists.<QualifiedName> newArrayList(), matchingStrategy,
        CLASSES_FOR_VARIABLES));
    }
    return result;
View Full Code Here

   */
  public SearchResult findVariables(EObject scopeDetermeningResource, String name,
      PPImportedNamesAdapter importedNames) {
    if(name == null)
      throw new IllegalArgumentException("name is null");
    QualifiedName fqn = converter.toQualifiedName(name);
    return findVariables(scopeDetermeningResource, fqn, importedNames, Match.NO_OUTER);
  }
View Full Code Here

   *
   * @param o
   * @return
   */
  public QualifiedName getNameOfScope(EObject o) {
    QualifiedName result = null;
    for(; o != null; o = o.eContainer()) {
      result = fqnProvider.getFullyQualifiedName(o);
      if(result != null)
        return result;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.naming.QualifiedName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.