Package com.google.dart.engine.element

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


    // Return if the '/' operator is not defined in core, or if we don't know its static or propagated type
    MethodElement methodElement = node.getBestElement();
    if (methodElement == null) {
      return false;
    }
    LibraryElement libraryElement = methodElement.getLibrary();
    if (libraryElement != null && !libraryElement.isDartCore()) {
      return false;
    }
    // Report error if the (x/y) has toInt() invoked on it
    if (node.getParent() instanceof ParenthesizedExpression) {
      ParenthesizedExpression parenthesizedExpression = wrapParenthesizedExpression((ParenthesizedExpression) node.getParent());
View Full Code Here


   * @param importElement the {@link ImportElement} retrieved from the node
   * @return {@code true} if and only if an error code is generated on the passed node
   * @see CompileTimeErrorCode#IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION
   */
  private boolean checkForLoadLibraryFunction(ImportDirective node, ImportElement importElement) {
    LibraryElement importedLibrary = importElement.getImportedLibrary();
    if (importedLibrary == null) {
      return false;
    }
    if (importedLibrary.hasLoadLibraryFunction()) {
      errorReporter.reportErrorForNode(
          HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
          node,
          importedLibrary.getName());
      return true;
    }
    return false;
  }
View Full Code Here

   */
  private String getLibraryName(Element element) {
    if (element == null) {
      return StringUtilities.EMPTY;
    }
    LibraryElement library = element.getLibrary();
    if (library == null) {
      return StringUtilities.EMPTY;
    }
    ImportElement[] imports = definingLibrary.getImports();
    int count = imports.length;
    for (int i = 0; i < count; i++) {
      if (imports[i].getImportedLibrary() == library) {
        return library.getDefiningCompilationUnit().getDisplayName();
      }
    }
    ArrayList<String> indirectSources = new ArrayList<String>();
    for (int i = 0; i < count; i++) {
      LibraryElement importedLibrary = imports[i].getImportedLibrary();
      for (LibraryElement exportedLibrary : importedLibrary.getExportedLibraries()) {
        if (exportedLibrary == library) {
          indirectSources.add(importedLibrary.getDefiningCompilationUnit().getDisplayName());
        }
      }
    }
    int indirectCount = indirectSources.size();
    StringBuilder builder = new StringBuilder();
View Full Code Here

  public static ImportElementInfo getImportElementInfo(SimpleIdentifier prefixNode) {
    ImportElementInfo info = new ImportElementInfo();
    // prepare environment
    AstNode parent = prefixNode.getParent();
    CompilationUnit unit = prefixNode.getAncestor(CompilationUnit.class);
    LibraryElement libraryElement = unit.getElement().getLibrary();
    // prepare used element
    Element usedElement = null;
    if (parent instanceof PrefixedIdentifier) {
      PrefixedIdentifier prefixed = (PrefixedIdentifier) parent;
      if (prefixed.getPrefix() == prefixNode) {
View Full Code Here

      return null;
    }
    if (!(usedElement.getEnclosingElement() instanceof CompilationUnitElement)) {
      return null;
    }
    LibraryElement usedLibrary = usedElement.getLibrary();
    // find ImportElement that imports used library with used prefix
    List<ImportElement> candidates = null;
    for (ImportElement importElement : libraryElement.getImports()) {
      // required library
      if (!Objects.equal(importElement.getImportedLibrary(), usedLibrary)) {
View Full Code Here

  @Override
  public Void visitExportDirective(ExportDirective node) {
    ExportElement element = node.getElement();
    if (element != null) {
      LibraryElement expLibrary = element.getExportedLibrary();
      recordLibraryReference(node, expLibrary);
    }
    return super.visitExportDirective(node);
  }
View Full Code Here

  @Override
  public Void visitImportDirective(ImportDirective node) {
    ImportElement element = node.getElement();
    if (element != null) {
      LibraryElement impLibrary = element.getImportedLibrary();
      recordLibraryReference(node, impLibrary);
    }
    return super.visitImportDirective(node);
  }
View Full Code Here

  private Scope scopeForCompilationUnit(CompilationUnit node) throws AnalysisException {
    CompilationUnitElement unitElement = node.getElement();
    if (unitElement == null) {
      throw new AnalysisException("Cannot create scope: compilation unit is not resolved");
    }
    LibraryElement libraryElement = unitElement.getLibrary();
    if (libraryElement == null) {
      throw new AnalysisException("Cannot create scope: compilation unit is not part of a library");
    }
    return new LibraryScope(libraryElement, errorListener);
  }
View Full Code Here

        addAngularElementsFromClass(angularElements, type);
      }
    }
    // handle imports
    for (ImportElement importElement : library.getImports()) {
      LibraryElement importedLibrary = importElement.getImportedLibrary();
      addAngularElementsFromLibrary(angularElements, importedLibrary, visited);
    }
  }
View Full Code Here

    CompilationUnit dartUnit = getDartUnit(context, unit);
    if (dartUnit == null) {
      return null;
    }
    // prepare accessible Angular elements
    LibraryElement libraryElement = dartUnit.getElement().getLibrary();
    Set<LibraryElement> libraries = Sets.newHashSet();
    AngularElement[] angularElements = getAngularElements(libraries, libraryElement);
    // resolve AngularComponentElement template URIs
    // TODO(scheglov) resolve to HtmlElement to allow F3 ?
    Set<Source> angularElementsSources = Sets.newHashSet();
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.