UNPKG

2.99 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import { SourceRange } from '../analysis-format/analysis-format';
15import { AnalysisContext } from '../core/analysis-context';
16import { Document } from './document';
17import { Feature } from './feature';
18import { AnalysisQuery as Query, AnalysisQueryWithKind as QueryWithKind, FeatureKind, FeatureKindMap, Queryable } from './queryable';
19import { ResolvedUrl } from './url';
20import { Warning } from './warning';
21/**
22 * Represents the result of a computation that may fail.
23 *
24 * This lets us represent errors in a type-safe way, as well as
25 * in a way that makes it clear to the caller that the computation
26 * may fail.
27 */
28export declare type Result<T, E> = {
29 successful: true;
30 value: T;
31} | {
32 successful: false;
33 error: E;
34};
35/**
36 * Represents a queryable interface over all documents in a package/project.
37 *
38 * Results of queries will include results from all documents in the package, as
39 * well as from external dependencies that are transitively imported by
40 * documents in the package.
41 */
42export declare class Analysis implements Queryable {
43 private readonly context;
44 private readonly _results;
45 private readonly _searchRoots;
46 static isExternal(path: string): boolean;
47 constructor(results: Map<ResolvedUrl, Document | Warning>, context: AnalysisContext);
48 getDocument(packageRelativeUrl: string): Result<Document, Warning | undefined>;
49 /**
50 * Get features in the package.
51 *
52 * Be default this includes features in all documents inside the package,
53 * but you can specify whether to also include features that are outside the
54 * package reachable by documents inside. See the documentation for Query for
55 * more details.
56 *
57 * You can also narrow by feature kind and identifier.
58 */
59 getFeatures<K extends FeatureKind>(query: QueryWithKind<K>): Set<FeatureKindMap[K]>;
60 getFeatures(query?: Query): Set<Feature>;
61 /**
62 * Get all warnings in the project.
63 */
64 getWarnings(options?: Query): Warning[];
65 /**
66 * Potentially narrow down the document that contains the sourceRange.
67 * For example, if a source range is inside a inlineDocument, this function
68 * will narrow down the document to the most specific inline document.
69 *
70 * @param sourceRange Source range to search for in a document
71 */
72 getDocumentContaining(sourceRange: SourceRange | undefined): Document | undefined;
73 private _getDocumentQuery;
74}