本文整理汇总了TypeScript中polymer-analyzer.Analysis类的典型用法代码示例。如果您正苦于以下问题:TypeScript Analysis类的具体用法?TypeScript Analysis怎么用?TypeScript Analysis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Analysis类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getDefinitionsForFeatureAtPosition
private async getDefinitionsForFeatureAtPosition(
url: string, position: SourcePosition,
analysis?: Analysis): Promise<SourceRange[]> {
analysis = analysis ||
await this.analyzer.analyze([url], {reason: 'get definitions'});
const featureResult =
await this.featureFinder.getFeatureAt(url, position, analysis);
if (!featureResult) {
return [];
}
const {feature} = featureResult;
if (feature instanceof CssCustomPropertyUse ||
feature instanceof CssCustomPropertyAssignment) {
const assignments = analysis.getFeatures({
kind: 'css-custom-property-assignment',
id: feature.name,
externalPackages: true
});
return [...assignments].map((a) => a.sourceRange);
}
if (feature instanceof DatabindingFeature) {
if (feature.property && feature.property.sourceRange) {
return [feature.property.sourceRange];
}
return [];
}
if (feature.sourceRange) {
return [feature.sourceRange];
}
return [];
}
示例2: getAnalysisDocument
export function getAnalysisDocument(analysis: Analysis, url: string): Document {
const result = analysis.getDocument(url);
if (result.successful) {
return result.value;
}
if (result.error) {
const message = `Unable to get document ${url}: ${result.error.message}`;
throw new Error(message);
}
throw new Error(`Unable to get document ${url}`);
}
示例3: getNamespaceNames
/**
* Get all namespace names for an analysis object.
*/
function getNamespaceNames(analysis: Analysis) {
return IterableX
.from(analysis.getFeatures(
{kind: 'namespace', externalPackages: true, imported: true}))
.map((n) => {
const name = n.name;
if (name.startsWith('window.')) {
return name.slice('window.'.length);
}
return name;
});
}