本文整理匯總了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;
});
}