當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript polymer-analyzer.Analysis類代碼示例

本文整理匯總了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 [];
 }
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:31,代碼來源:definition-finder.ts

示例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}`);
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:11,代碼來源:analyzer-utils.ts

示例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;
      });
}
開發者ID:,項目名稱:,代碼行數:15,代碼來源:


注:本文中的polymer-analyzer.Analysis類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。