Package com.google.dart.engine.element

Examples of com.google.dart.engine.element.LibraryElement


  @Override
  public Void visitExportDirective(ExportDirective node) {
    String uri = getStringValue(node.getUri());
    if (uri != null) {
      LibraryElement library = enclosingUnit.getLibrary();
      ExportElement exportElement = findExport(
          library.getExports(),
          enclosingUnit.getContext().getSourceFactory().resolveUri(enclosingUnit.getSource(), uri));
      processElement(exportElement);
    }
    return super.visitExportDirective(node);
  }
View Full Code Here


  @Override
  public Void visitImportDirective(ImportDirective node) {
    String uri = getStringValue(node.getUri());
    if (uri != null) {
      LibraryElement library = enclosingUnit.getLibrary();
      ImportElement importElement = findImport(
          library.getImports(),
          enclosingUnit.getContext().getSourceFactory().resolveUri(enclosingUnit.getSource(), uri),
          node.getPrefix());
      processElement(importElement);
    }
    return super.visitImportDirective(node);
View Full Code Here

          // TODO(brianwilkerson) Report this error?
          element = resolver.getNameScope().lookup(identifier, definingLibrary);
          name.setStaticElement(element);
          return null;
        }
        LibraryElement library = element.getLibrary();
        if (library == null) {
          // TODO(brianwilkerson) We need to understand how the library could ever be null.
          AnalysisEngine.getInstance().getLogger().logError(
              "Found element with null library: " + element.getName());
        } else if (!library.equals(definingLibrary)) {
          // TODO(brianwilkerson) Report this error.
        }
        name.setStaticElement(element);
        if (node.getNewKeyword() == null) {
          if (element instanceof ClassElement) {
View Full Code Here

      }
    }
    ImportElement importElement = node.getElement();
    if (importElement != null) {
      // The element is null when the URI is invalid
      LibraryElement library = importElement.getImportedLibrary();
      if (library != null) {
        resolveCombinators(library, node.getCombinators());
      }
      setMetadata(importElement, node);
    }
View Full Code Here

    if (target == null) {
      staticElement = resolveInvokedElement(methodName);
      propagatedElement = null;
    } else if (methodName.getName().equals(FunctionElement.LOAD_LIBRARY_NAME)
        && isDeferredPrefix(target)) {
      LibraryElement importedLibrary = getImportedLibrary(target);
      methodName.setStaticElement(importedLibrary.getLoadLibraryFunction());
      return null;
    } else {
      staticType = getStaticType(target);
      propagatedType = getPropagatedType(target);
      //
View Full Code Here

    SimpleIdentifier identifier = node.getIdentifier();
    //
    // First, check the "lib.loadLibrary" case
    //
    if (identifier.getName().equals(FunctionElement.LOAD_LIBRARY_NAME) && isDeferredPrefix(prefix)) {
      LibraryElement importedLibrary = getImportedLibrary(prefix);
      identifier.setStaticElement(importedLibrary.getLoadLibraryFunction());
      return null;
    }
    //
    // Check to see whether the prefix is really a prefix.
    //
View Full Code Here

      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        throw new AnalysisException("Could not resolve dart:core");
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
View Full Code Here

      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        throw new AnalysisException("Could not resolve dart:core");
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
View Full Code Here

              importElement.setUriOffset(uriLiteral.getOffset());
              importElement.setUriEnd(uriLiteral.getEnd());
              importElement.setUri(uriContent);
              importElement.setDeferred(importDirective.getDeferredToken() != null);
              importElement.setCombinators(buildCombinators(importDirective));
              LibraryElement importedLibraryElement = importedLibrary.getLibraryElement();
              if (importedLibraryElement != null) {
                importElement.setImportedLibrary(importedLibraryElement);
              }
              SimpleIdentifier prefixNode = ((ImportDirective) directive).getPrefix();
              if (prefixNode != null) {
                importElement.setPrefixOffset(prefixNode.getOffset());
                String prefixName = prefixNode.getName();
                PrefixElementImpl prefix = nameToPrefixMap.get(prefixName);
                if (prefix == null) {
                  prefix = new PrefixElementImpl(prefixNode);
                  nameToPrefixMap.put(prefixName, prefix);
                }
                importElement.setPrefix(prefix);
                prefixNode.setStaticElement(prefix);
              }
              directive.setElement(importElement);
              imports.add(importElement);

              if (analysisContext.computeKindOf(importedSource) != SourceKind.LIBRARY) {
                ErrorCode errorCode = importElement.isDeferred()
                    ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
                    : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;
                errorListener.onError(new AnalysisError(
                    library.getLibrarySource(),
                    uriLiteral.getOffset(),
                    uriLiteral.getLength(),
                    errorCode,
                    uriLiteral.toSource()));
              }
            }
          }
        } else if (directive instanceof ExportDirective) {
          ExportDirective exportDirective = (ExportDirective) directive;
          Source exportedSource = exportDirective.getSource();
          if (exportedSource != null) {
            // The exported source will be null if the URI in the export directive was invalid.
            Library exportedLibrary = libraryMap.get(exportedSource);
            if (exportedLibrary != null) {
              ExportElementImpl exportElement = new ExportElementImpl();
              StringLiteral uriLiteral = exportDirective.getUri();
              exportElement.setUriOffset(uriLiteral.getOffset());
              exportElement.setUriEnd(uriLiteral.getEnd());
              exportElement.setUri(exportDirective.getUriContent());
              exportElement.setCombinators(buildCombinators(exportDirective));
              LibraryElement exportedLibraryElement = exportedLibrary.getLibraryElement();
              if (exportedLibraryElement != null) {
                exportElement.setExportedLibrary(exportedLibraryElement);
              }
              directive.setElement(exportElement);
              exports.add(exportElement);
View Full Code Here

      //    requires that we be able to compute the names visible in the libraries being resolved,
      //    which in turn requires that we have resolved the import directives.
      //
      buildElementModels();
      instrumentation.metric("buildElementModels", "complete");
      LibraryElement coreElement = coreLibrary.getLibraryElement();
      if (coreElement == null) {
        missingCoreLibrary(analysisContext, coreLibrarySource);
      }
      buildDirectiveModels();
      instrumentation.metric("buildDirectiveModels", "complete");
View Full Code Here

TOP

Related Classes of com.google.dart.engine.element.LibraryElement

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.