import { ForkOptions, Options } from '../analyzer'; import { Document, Package, ScannedDocument } from '../model/model'; import { AnalysisCache } from './analysis-cache'; /** * An analysis of a set of files at a specific point-in-time with respect to * updates to those files. New files can be added to an existing context, but * updates to files will cause a fork of the context with new analysis results. * * All file contents and analysis results are consistent within a single * anaysis context. A context is forked via either the fileChanged or * clearCaches methods. * * For almost all purposes this is an entirely internal implementation detail. * An Analyzer instance has a reference to its current context, so it will * appear to be statefull with respect to file updates. */ export declare class AnalysisContext { private _parsers; private _languageAnalyzers; /** A map from import url to urls that document lazily depends on. */ private _lazyEdges; private _scanners; private _loader; private _resolver; private _cache; private _generation; private static _getDefaultScanners(lazyEdges); constructor(options: Options); /** * Returns a copy of this cache context with proper cache invalidation. */ filesChanged(urls: string[]): AnalysisContext; /** * Implements Analyzer#analyze, see its docs. */ analyze(url: string, contents?: string): Promise; private _analyzeOrWarning(url); analyzePackage(): Promise; /** * Gets an analyzed Document from the document cache. This is only useful for * Analyzer plugins. You almost certainly want to use `analyze()` instead. * * If a document has been analyzed, it returns the analyzed Document. If not * the scanned document cache is used and a new analyzed Document is returned. * If a file is in neither cache, it returns `undefined`. */ _getDocument(url: string): Document | undefined; /** * This is only useful for Analyzer plugins. * * If a url has been scanned, returns the ScannedDocument. */ _getScannedDocument(url: string): ScannedDocument | undefined; /** * 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(): AnalysisContext; /** * Returns a copy of the context but with optional replacements of cache or * constructor options. * * Note: this feature is experimental. */ _fork(cache?: AnalysisCache, options?: ForkOptions): AnalysisContext; /** * Scans a file locally, that is for features that do not depend * on this files imports. Local features can be cached even when * imports are invalidated. This method does not trigger transitive * scanning, _scan() does that. * * TODO(justinfagnani): consider renaming this to something like * _preScan, since about the only useful things it can find are * imports, exports and other syntactic structures. */ private _scanLocal(resolvedUrl, contents?); /** * Scan a toplevel document and all of its transitive dependencies. */ scan(resolvedUrl: string, contents?: string): Promise; /** * Scans a ParsedDocument. */ private _scanDocument(document, maybeAttachedComment?); private _getScannedFeatures(document); private _scanInlineDocuments(containingDocument); /** * 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; /** * Caching + loading wrapper around _parseContents. */ private _parse(resolvedUrl, providedContents?); /** * Parse the given string into the Abstract Syntax Tree (AST) corresponding * to its type. */ private _parseContents(type, contents, url, inlineInfo?); /** * Returns true if the url given is resovable by the Analyzer's `UrlResolver`. */ canResolveUrl(url: string): boolean; /** * Resolves a URL with this Analyzer's `UrlResolver` or returns the given * URL if it can not be resolved. */ resolveUrl(url: string): string; }