Package com.google.dart.engine.element

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


                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 && analysisContext.exists(exportedSource)) {
            // The exported source will be null if the URI in the export directive was invalid.
            ResolvableLibrary exportedLibrary = libraryMap.get(exportedSource);
            if (exportedLibrary != null) {
              ExportElementImpl exportElement = new ExportElementImpl();
              StringLiteral uriLiteral = exportDirective.getUri();
              if (uriLiteral != null) {
                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


  public Void visitInstanceCreationExpression(InstanceCreationExpression node) {
    recordStaticType(node, node.getConstructorName().getType().getType());

    ConstructorElement element = node.getStaticElement();
    if (element != null && "Element".equals(element.getEnclosingElement().getName())) {
      LibraryElement library = element.getLibrary();
      if (isHtmlLibrary(library)) {
        String constructorName = element.getName();
        if ("tag".equals(constructorName)) {
          Type returnType = getFirstArgumentAsTypeWithMap(
              library,
View Full Code Here

      if (target != null) {
        Type targetType = target.getBestType();
        if (targetType instanceof InterfaceType
            && (targetType.getName().equals("HtmlDocument") || targetType.getName().equals(
                "Document"))) {
          LibraryElement library = targetType.getElement().getLibrary();
          if (isHtmlLibrary(library)) {
            Type returnType = getFirstArgumentAsType(library, node.getArgumentList());
            if (returnType != null) {
              recordPropagatedType(node, returnType);
              needPropagatedType = false;
            }
          }
        }
      }
    } else if (methodName.equals("query")) {
      Expression target = node.getRealTarget();
      if (target == null) {
        Element methodElement = methodNameNode.getBestElement();
        if (methodElement != null) {
          LibraryElement library = methodElement.getLibrary();
          if (isHtmlLibrary(library)) {
            Type returnType = getFirstArgumentAsQuery(library, node.getArgumentList());
            if (returnType != null) {
              recordPropagatedType(node, returnType);
              needPropagatedType = false;
            }
          }
        }
      } else {
        Type targetType = target.getBestType();
        if (targetType instanceof InterfaceType
            && (targetType.getName().equals("HtmlDocument") || targetType.getName().equals(
                "Document"))) {
          LibraryElement library = targetType.getElement().getLibrary();
          if (isHtmlLibrary(library)) {
            Type returnType = getFirstArgumentAsQuery(library, node.getArgumentList());
            if (returnType != null) {
              recordPropagatedType(node, returnType);
              needPropagatedType = false;
            }
          }
        }
      }
    } else if (methodName.equals("$dom_createElement")) {
      Expression target = node.getRealTarget();
      if (target != null) {
        Type targetType = target.getBestType();
        if (targetType instanceof InterfaceType
            && (targetType.getName().equals("HtmlDocument") || targetType.getName().equals(
                "Document"))) {
          LibraryElement library = targetType.getElement().getLibrary();
          if (isHtmlLibrary(library)) {
            Type returnType = getFirstArgumentAsQuery(library, node.getArgumentList());
            if (returnType != null) {
              recordPropagatedType(node, returnType);
              needPropagatedType = false;
View Full Code Here

  @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));
      node.setElement(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());
      node.setElement(importElement);
    }
    return super.visitImportDirective(node);
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.