Package com.google.dart.engine.internal.scope

Examples of com.google.dart.engine.internal.scope.Namespace


    Source source = library.getDefiningCompilationUnit().getSource();
    DartEntry dartEntry = getReadableDartEntry(source);
    if (dartEntry == null) {
      return null;
    }
    Namespace namespace = null;
    if (dartEntry.getValue(DartEntry.ELEMENT) == library) {
      namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
    }
    if (namespace == null) {
      NamespaceBuilder builder = new NamespaceBuilder();
View Full Code Here


   *
   * @param importDirective the import directive used to compute the returned namespace
   * @return the computed or looked up {@link Namespace}
   */
  private Namespace computeNamespace(ImportDirective importDirective) {
    Namespace namespace = namespaceMap.get(importDirective);
    if (namespace == null) {
      // If the namespace isn't in the namespaceMap, then compute and put it in the map
      ImportElement importElement = importDirective.getElement();
      if (importElement != null) {
        NamespaceBuilder builder = new NamespaceBuilder();
View Full Code Here

      unusedImports.remove(usedImportDirective);
    } else {
      // Otherwise, for each of the imported directives, use the namespaceMap to
      for (ImportDirective importDirective : importsFromSameLibrary) {
        // Get the namespace for this import
        Namespace namespace = computeNamespace(importDirective);
        if (namespace != null && namespace.get(name) != null) {
          unusedImports.remove(importDirective);
        }
      }
    }
    return null;
View Full Code Here

    // ensure that each ImportElement has set of elements
    for (ImportElement importElement : candidates) {
      if (importElementsMap.containsKey(importElement)) {
        continue;
      }
      Namespace namespace = new NamespaceBuilder().createImportNamespaceForDirective(importElement);
      Set<Element> elements = Sets.newHashSet(namespace.getDefinedNames().values());
      importElementsMap.put(importElement, elements);
    }
    // use import namespace to choose correct one
    for (Entry<ImportElement, Set<Element>> entry : importElementsMap.entrySet()) {
      if (entry.getValue().contains(usedElement)) {
View Full Code Here

      LibraryElement exportedLibrary) {
    if (exportedLibrary == null) {
      return false;
    }
    // check exported names
    Namespace namespace = new NamespaceBuilder().createExportNamespaceForDirective(exportElement);
    Map<String, Element> definedNames = namespace.getDefinedNames();
    for (Entry<String, Element> definedEntry : definedNames.entrySet()) {
      String name = definedEntry.getKey();
      Element element = definedEntry.getValue();
      Element prevElement = exportedElements.get(name);
      if (element != null && prevElement != null && !prevElement.equals(element)) {
View Full Code Here

      }
      LibraryElementImpl libraryElement = library.getLibraryElement();
      libraryElement.setImports(imports.toArray(new ImportElement[imports.size()]));
      libraryElement.setExports(exports.toArray(new ExportElement[exports.size()]));
      if (libraryElement.getEntryPoint() == null) {
        Namespace namespace = new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
        Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
        if (element instanceof FunctionElement) {
          libraryElement.setEntryPoint((FunctionElement) element);
        }
      }
    }
View Full Code Here

      // The library will be null if the directive containing the combinators has a URI that is not
      // valid.
      //
      return;
    }
    Namespace namespace = new NamespaceBuilder().createExportNamespaceForLibrary(library);
    for (Combinator combinator : combinators) {
      NodeList<SimpleIdentifier> names;
      if (combinator instanceof HideCombinator) {
        names = ((HideCombinator) combinator).getHiddenNames();
      } else {
        names = ((ShowCombinator) combinator).getShownNames();
      }
      for (SimpleIdentifier name : names) {
        String nameStr = name.getName();
        Element element = namespace.get(nameStr);
        if (element == null) {
          element = namespace.get(nameStr + "=");
        }
        if (element != null) {
          // Ensure that the name always resolves to a top-level variable
          // rather than a getter or setter
          if (element instanceof PropertyAccessorElement) {
View Full Code Here

      }
      LibraryElementImpl libraryElement = library.getLibraryElement();
      libraryElement.setImports(imports.toArray(new ImportElement[imports.size()]));
      libraryElement.setExports(exports.toArray(new ExportElement[exports.size()]));
      if (libraryElement.getEntryPoint() == null) {
        Namespace namespace = new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
        Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
        if (element instanceof FunctionElement) {
          libraryElement.setEntryPoint((FunctionElement) element);
        }
      }
    }
View Full Code Here

   * Initialize the types provided by this type provider from the given library.
   *
   * @param library the library containing the definitions of the core types
   */
  private void initializeFrom(LibraryElement library) {
    Namespace namespace = new NamespaceBuilder().createPublicNamespaceForLibrary(library);
    boolType = getType(namespace, "bool");
    bottomType = BottomTypeImpl.getInstance();
    deprecatedType = getType(namespace, "Deprecated");
    doubleType = getType(namespace, "double");
    dynamicType = DynamicTypeImpl.getInstance();
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.scope.Namespace

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.