Package com.google.dart.engine.utilities.general.TimeCounter

Examples of com.google.dart.engine.utilities.general.TimeCounter.TimeCounterHandle


    return "generate errors and warnings for " + source.getFullName();
  }

  @Override
  protected void internalPerform() throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.errors.start();
    try {
      RecordingErrorListener errorListener = new RecordingErrorListener();
      ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
      TypeProvider typeProvider = getContext().getTypeProvider();
      //
      // Validate the directives
      //
      validateDirectives(getContext(), source, unit, errorListener);
      //
      // Use the ConstantVerifier to verify the use of constants. This needs to happen before using
      // the ErrorVerifier because some error codes need the computed constant values.
      //
      ConstantVerifier constantVerifier = new ConstantVerifier(
          errorReporter,
          libraryElement,
          typeProvider);
      unit.accept(constantVerifier);
      //
      // Use the ErrorVerifier to compute the rest of the errors.
      //
      ErrorVerifier errorVerifier = new ErrorVerifier(
          errorReporter,
          libraryElement,
          typeProvider,
          new InheritanceManager(libraryElement));
      unit.accept(errorVerifier);
      errors = errorListener.getErrorsForSource(source);
    } finally {
      timeCounter.stop();
    }
  }
View Full Code Here


   * @return the compilation unit element that was built
   * @throws AnalysisException if the analysis could not be performed
   */
  public CompilationUnitElementImpl buildCompilationUnit(Source source, CompilationUnit unit)
      throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.resolve.start();
    try {
      if (unit == null) {
        return null;
      }
      ElementHolder holder = new ElementHolder();
      ElementBuilder builder = new ElementBuilder(holder);
      unit.accept(builder);

      CompilationUnitElementImpl element = new CompilationUnitElementImpl(source.getShortName());
      element.setAccessors(holder.getAccessors());
      element.setEnums(holder.getEnums());
      element.setFunctions(holder.getFunctions());
      element.setSource(source);
      element.setTypeAliases(holder.getTypeAliases());
      element.setTypes(holder.getTypes());
      element.setTopLevelVariables(holder.getTopLevelVariables());
      unit.setElement(element);
      return element;
    } finally {
      timeCounter.stop();
    }
  }
View Full Code Here

    enableDart2JSHints = context.getAnalysisOptions().getDart2jsHint();
    manager = new InheritanceManager(compilationUnits[0].getElement().getLibrary());
  }

  public void generateForLibrary() throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.hints.start();
    try {
      for (int i = 0; i < compilationUnits.length; i++) {
        CompilationUnitElement element = compilationUnits[i].getElement();
        if (element != null) {
          if (i == 0) {
            importsVerifier.setInDefiningCompilationUnit(true);
            generateForCompilationUnit(compilationUnits[i], element.getSource());
            importsVerifier.setInDefiningCompilationUnit(false);
          } else {
            generateForCompilationUnit(compilationUnits[i], element.getSource());
          }
        }
      }
      ErrorReporter definingCompilationUnitErrorReporter = new ErrorReporter(
          errorListener,
          compilationUnits[0].getElement().getSource());
      importsVerifier.generateDuplicateImportHints(definingCompilationUnitErrorReporter);
      importsVerifier.generateUnusedImportHints(definingCompilationUnitErrorReporter);
    } finally {
      timeCounter.stop();
    }
  }
View Full Code Here

        errorListener);
    unit.accept(resolverVisitor);
    //
    // Perform additional error checking.
    //
    TimeCounterHandle counterHandleErrors = PerformanceStatistics.errors.start();
    try {
      ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
      ErrorVerifier errorVerifier = new ErrorVerifier(
          errorReporter,
          libraryElement,
          typeProvider,
          inheritanceManager);
      unit.accept(errorVerifier);

      ConstantVerifier constantVerifier = new ConstantVerifier(
          errorReporter,
          libraryElement,
          typeProvider);
      unit.accept(constantVerifier);
    } finally {
      counterHandleErrors.stop();
    }
    //
    // Capture the results.
    //
    resolvedUnit = unit;
View Full Code Here

  }

  @Override
  protected void internalPerform() throws AnalysisException {
    final RecordingErrorListener errorListener = new RecordingErrorListener();
    TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.start();
    try {
      Scanner scanner = new Scanner(source, new CharSequenceReader(content), errorListener);
      scanner.setPreserveComments(getContext().getAnalysisOptions().getPreserveComments());
      tokenStream = scanner.tokenize();
      lineInfo = new LineInfo(scanner.getLineStarts());
      errors = errorListener.getErrorsForSource(source);
    } catch (Exception exception) {
      throw new AnalysisException("Exception", exception);
    } finally {
      timeCounterScan.stop();
    }
  }
View Full Code Here

    return file.isFile();
  }

  @Override
  public TimestampedData<CharSequence> getContents() throws Exception {
    TimeCounterHandle handle = PerformanceStatistics.io.start();
    try {
      return getContentsFromFile();
    } finally {
      reportIfSlowIO(handle.stop());
    }
  }
View Full Code Here

  }

  @Override
  @DartOmit
  public void getContentsToReceiver(ContentReceiver receiver) throws Exception {
    TimeCounterHandle handle = PerformanceStatistics.io.start();
    try {
      getContentsFromFileToReceiver(receiver);
    } finally {
      reportIfSlowIO(handle.stop());
    }
  }
View Full Code Here

  @Override
  protected void internalPerform() throws AnalysisException {
    //
    // Then parse the token stream.
    //
    TimeCounterHandle timeCounterParse = PerformanceStatistics.parse.start();
    try {
      final RecordingErrorListener errorListener = new RecordingErrorListener();
      Parser parser = new Parser(source, errorListener);
      AnalysisOptions options = getContext().getAnalysisOptions();
      parser.setParseFunctionBodies(options.getAnalyzeFunctionBodies());
      parser.setParseAsync(options.getEnableAsync());
      parser.setParseDeferredLibraries(options.getEnableDeferredLoading());
      parser.setParseEnum(options.getEnableEnum());
      unit = parser.parseCompilationUnit(tokenStream);
      unit.setLineInfo(lineInfo);
      AnalysisContext analysisContext = getContext();
      for (Directive directive : unit.getDirectives()) {
        if (directive instanceof PartOfDirective) {
          containsPartOfDirective = true;
        } else {
          containsNonPartOfDirective = true;
          if (directive instanceof UriBasedDirective) {
            Source referencedSource = resolveDirective(
                analysisContext,
                source,
                (UriBasedDirective) directive,
                errorListener);
            if (referencedSource != null) {
              if (directive instanceof ExportDirective) {
                exportedSources.add(referencedSource);
              } else if (directive instanceof ImportDirective) {
                importedSources.add(referencedSource);
              } else if (directive instanceof PartDirective) {
                if (!referencedSource.equals(source)) {
                  includedSources.add(referencedSource);
                }
              } else {
                throw new AnalysisException(getClass().getSimpleName() + " failed to handle a "
                    + directive.getClass().getName());
              }
            }
          }
        }
      }
      errors = errorListener.getErrorsForSource(source);
    } finally {
      timeCounterParse.stop();
    }
  }
View Full Code Here

   * the rest of the element model has been built (when resolving the core library).
   *
   * @throws AnalysisException if any of the enum members could not be built
   */
  private void buildEnumMembers() throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.resolve.start();
    try {
      for (ResolvableLibrary library : librariesInCycle) {
        for (Source source : library.getCompilationUnitSources()) {
          EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider);
          library.getAST(source).accept(builder);
        }
      }
    } finally {
      timeCounter.stop();
    }
  }
View Full Code Here

   * cycle.
   *
   * @throws AnalysisException if any of the type hierarchies could not be resolved
   */
  private void buildTypeHierarchies() throws AnalysisException {
    TimeCounterHandle timeCounter = PerformanceStatistics.resolve.start();
    try {
      for (ResolvableLibrary library : librariesInCycle) {
        for (ResolvableCompilationUnit unit : library.getResolvableCompilationUnits()) {
          Source source = unit.getSource();
          CompilationUnit ast = unit.getCompilationUnit();
          TypeResolverVisitor visitor = new TypeResolverVisitor(library, source, typeProvider);
          ast.accept(visitor);
        }
      }
    } finally {
      timeCounter.stop();
    }
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.utilities.general.TimeCounter.TimeCounterHandle

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.