///
/**
* @license
* Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
import { AnalysisContext } from './core/analysis-context';
import { Document, Package } from './model/model';
import { Parser } from './parser/parser';
import { Scanner } from './scanning/scanner';
import { UrlLoader } from './url-loader/url-loader';
import { UrlResolver } from './url-loader/url-resolver';
export interface Options {
urlLoader: UrlLoader;
urlResolver?: UrlResolver;
parsers?: Map>;
scanners?: ScannerTable;
lazyEdges?: LazyEdgeMap;
}
/**
* These are the options available to the `_fork` method. Currently, only the
* `urlLoader` override is implemented.
*/
export interface ForkOptions {
urlLoader?: UrlLoader;
}
export declare class NoKnownParserError extends Error {
}
export declare type ScannerTable = Map[]>;
export declare type LazyEdgeMap = Map;
/**
* A static analyzer for web projects.
*
* An Analyzer can load and parse documents of various types, and extract
* arbitrary information from the documents, and transitively load
* dependencies. An Analyzer instance is configured with parsers, and scanners
* which do the actual work of understanding different file types.
*/
export declare class Analyzer {
private _context;
constructor(options: Options | AnalysisContext);
/**
* Loads, parses and analyzes the root document of a dependency graph and its
* transitive dependencies.
*
* Note: The analyzer only supports analyzing a single root for now. This
* is because each analyzed document in the dependency graph has a single
* root. This mean that we can't properly analyze app-shell-style, lazy
* loading apps.
*
* @param contents Optional contents of the file when it is known without
* reading it from disk. Clears the caches so that the news contents is used
* and reanalyzed. Useful for editors that want to re-analyze changed files.
*/
analyze(url: string, contents?: string): Promise;
analyzePackage(): Promise;
/**
* Clear all cached information from this analyzer instance.
*
* Note: if at all possible, instead tell the analyzer about the specific
* files that changed rather than clearing caches like this. Caching provides
* large performance gains.
*/
clearCaches(): void;
/**
* Returns a copy of the analyzer. If options are given, the AnalysisContext
* is also forked and individual properties are overridden by the options.
* is forked with the given options.
*
* When the analysis context is forked, its cache is preserved, so you will
* see a mixture of pre-fork and post-fork contents when you analyze with a
* forked analyzer.
*
* Note: this feature is experimental.
*/
_fork(options?: ForkOptions): Analyzer;
/**
* Loads the content at the provided resolved URL.
*
* Currently does no caching. If the provided contents are given then they
* are used instead of hitting the UrlLoader (e.g. when you have in-memory
* contents that should override disk).
*/
load(resolvedUrl: string, providedContents?: string): Promise;
canResolveUrl(url: string): boolean;
resolveUrl(url: string): string;
}