本文整理匯總了TypeScript中polymer-analyzer.Analysis.getFeatures方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Analysis.getFeatures方法的具體用法?TypeScript Analysis.getFeatures怎麽用?TypeScript Analysis.getFeatures使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polymer-analyzer.Analysis
的用法示例。
在下文中一共展示了Analysis.getFeatures方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
});
}