Package com.google.dart.engine.source

Examples of com.google.dart.engine.source.Source


   */
  protected AnalysisError getErrorForDuplicate(Element existing, Element duplicate) {
    // TODO(brianwilkerson) Customize the error message based on the types of elements that share
    // the same name.
    // TODO(jwren) There are 4 error codes for duplicate, but only 1 is being generated.
    Source source = duplicate.getSource();
    return new AnalysisError(
        source,
        duplicate.getNameOffset(),
        duplicate.getDisplayName().length(),
        CompileTimeErrorCode.DUPLICATE_DEFINITION,
View Full Code Here


   * @param directive the directive to be verified
   * @param errorListener the error listener to which errors should be reported
   */
  public static void validateReferencedSource(AnalysisContext context, Source librarySource,
      UriBasedDirective directive, AnalysisErrorListener errorListener) {
    Source source = directive.getSource();
    if (source != null) {
      if (context.exists(source)) {
        return;
      }
    } else {
View Full Code Here

    if (parentNodes.contains(node)) {
      return reportCircularity(node);
    }
    parentNodes.add(node);
    try {
      Source htmlSource = htmlElement.getSource();
      XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
      String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute.getText();
      if (node.getAttributeEnd().getType() == TokenType.GT && scriptSourcePath == null) {
        EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl(node);
        try {
          LibraryResolver resolver = new LibraryResolver(context);
          LibraryElementImpl library = (LibraryElementImpl) resolver.resolveEmbeddedLibrary(
              htmlSource,
              modificationStamp,
              node.getScript(),
              true);
          script.setScriptLibrary(library);
          resolvedLibraries.addAll(resolver.getResolvedLibraries());
          errorListener.addAll(resolver.getErrorListener());
        } catch (AnalysisException exception) {
          //TODO (danrubel): Handle or forward the exception
          AnalysisEngine.getInstance().getLogger().logError(
              "Could not resolve script tag",
              exception);
        }
        node.setScriptElement(script);
        scripts.add(script);
      } else {
        ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl(node);
        if (scriptSourcePath != null) {
          try {
            scriptSourcePath = UriUtilities.encode(scriptSourcePath);
            // Force an exception to be thrown if the URI is invalid so that we can report the
            // problem.
            new URI(scriptSourcePath);
            Source scriptSource = context.getSourceFactory().resolveUri(
                htmlSource,
                scriptSourcePath);
            script.setScriptSource(scriptSource);
            if (!context.exists(scriptSource)) {
              reportValueError(
View Full Code Here

    return source;
  }

  @Override
  protected String getTaskDescription() {
    Source librarySource = libraryElement.getSource();
    if (librarySource == null) {
      return "resolve unit null source";
    }
    return "resolve unit " + librarySource.getFullName();
  }
View Full Code Here

   */
  private static CompilationUnit getDartUnit(AnalysisContext context, HtmlUnit unit)
      throws AnalysisException {
    for (HtmlScriptElement script : unit.getElement().getScripts()) {
      if (script instanceof ExternalHtmlScriptElement) {
        Source scriptSource = ((ExternalHtmlScriptElement) script).getScriptSource();
        if (scriptSource != null) {
          return context.resolveCompilationUnit(scriptSource, scriptSource);
        }
      }
    }
View Full Code Here

        String templateUri = hasTemplate.getTemplateUri();
        if (templateUri == null) {
          continue;
        }
        try {
          Source templateSource = context.getSourceFactory().forUri(
              source.resolveRelativeUri(new URI(templateUri)));
          if (!context.exists(templateSource)) {
            templateSource = context.getSourceFactory().resolveUri(source, "package:" + templateUri);
            if (!context.exists(templateSource)) {
              errorListener.onError(new AnalysisError(
View Full Code Here

    CompilationUnitElement definingUnitElement = libraryElement.getDefiningCompilationUnit();
    if (definingUnitElement == null) {
      return false;
    }
    // prepare sources
    Source library = definingUnitElement.getSource();
    Source unit = unitElement.getSource();
    // special handling for the defining library unit
    if (unit.equals(library)) {
      // prepare new parts
      Set<Source> newParts = Sets.newHashSet();
      for (CompilationUnitElement part : libraryElement.getParts()) {
        newParts.add(part.getSource());
      }
View Full Code Here

    // may be already disposed in other thread
    if (context.isDisposed()) {
      return false;
    }
    // remove locations
    Source source = htmlElement.getSource();
    removeLocations(context, null, source);
    // remove keys
    {
      Map<Source2, Set<ElementRelationKey>> sourceToKeys = contextToSourceToKeys.get(context);
      if (sourceToKeys != null) {
View Full Code Here

    }
//    System.out.println(element + " " + relationship + " " + location);
    // prepare information
    AnalysisContext elementContext = element.getContext();
    AnalysisContext locationContext = location.getElement().getContext();
    Source elementSource = element.getSource();
    Source locationSource = location.getElement().getSource();
    Source elementLibrarySource = getLibrarySourceOrNull(element);
    Source locationLibrarySource = getLibrarySourceOrNull(location.getElement());
    // sanity check
    if (locationContext == null) {
      return;
    }
    if (locationSource == null) {
View Full Code Here

    // remove sources #1
    Map<Source2, Set<ElementRelationKey>> sourceToKeys = contextToSourceToKeys.get(context);
    if (sourceToKeys != null) {
      List<Source2> sources = Lists.newArrayList(sourceToKeys.keySet());
      for (Source2 source2 : sources) {
        Source source = source2.unitSource;
        if (container == null || container.contains(source)) {
          removeSource(context, source);
        }
      }
    }
    // remove sources #2
    Map<Source2, List<Location>> sourceToLocations = contextToSourceToLocations.get(context);
    if (sourceToLocations != null) {
      List<Source2> sources = Lists.newArrayList(sourceToLocations.keySet());
      for (Source2 source2 : sources) {
        Source source = source2.unitSource;
        if (container == null || container.contains(source)) {
          removeSource(context, source);
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.source.Source

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.