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


TypeScript polymer-analyzer.applyEdits函數代碼示例

本文整理匯總了TypeScript中polymer-analyzer.applyEdits函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript applyEdits函數的具體用法?TypeScript applyEdits怎麽用?TypeScript applyEdits使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了applyEdits函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

 test('applies automatic-safe fixes', async() => {
   const warnings = await linter.lint([`${ruleId}/before-fixes.html`]);
   const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
   const loader = makeParseLoader(analyzer, warnings.analysis);
   const result = await applyEdits(edits, loader);
   assert.deepEqual(
       result.editedFiles.get(`${ruleId}/before-fixes.html`),
       (await loader(`${ruleId}/after-fixes.html`)).contents);
 });
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:9,代碼來源:content-to-slot-declarations_test.ts

示例2: assertFileChanges

 async function assertFileChanges(inputFile: string, outputFile: string) {
   const warnings = await linter.lint([inputFile]);
   const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
   const loader = makeParseLoader(analyzer);
   const result = await applyEdits(edits, loader);
   const inputFileContent = result.editedFiles.get(inputFile)
   const outputFileContent = (await loader(outputFile)).contents;
   assert.deepEqual(inputFileContent, outputFileContent);
 }
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:9,代碼來源:paper-toolbar-v1-to-v2_test.ts

示例3: test

 test('adds missing import by inferring the base path', async() => {
   const warnings =
       await linter.lint([`${ruleId}/forgot-import-before-fixes.html`]);
   const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
   const loader = makeParseLoader(analyzer, warnings.analysis);
   const result = await applyEdits(edits, loader);
   assert.deepEqual(
       result.editedFiles.get(`${ruleId}/forgot-import-before-fixes.html`),
       (await loader(`${ruleId}/forgot-import-after-fixes.html`)).contents);
 });
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:10,代碼來源:iron-flex-layout-import_test.ts

示例4: assertExpectedFixes

export async function assertExpectedFixes(
    linter: Linter, analyzer: Analyzer, inputFile: string, goldenFile: string) {
  const {warnings} = await linter.lint([inputFile]);
  const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
  const loader = makeParseLoader(analyzer);
  const {editedFiles, incompatibleEdits} = await applyEdits(edits, loader);
  assert.deepEqual(incompatibleEdits, []);
  const inputFileContent = editedFiles.get(analyzer.resolveUrl(inputFile)!);
  const outputFileContent =
      (await loader(analyzer.resolveUrl(goldenFile)!)).contents;
  assert.deepEqual(inputFileContent, outputFileContent);
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:12,代碼來源:util.ts

示例5: test

 test('applies automatic-safe fixes', async() => {
   const warnings = await linter.lint(
       ['deprecated-css-custom-property-syntax/before-fixes.html']);
   const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
   const loader = makeParseLoader(analyzer, warnings.analysis);
   const result = await applyEdits(edits, loader);
   assert.deepEqual(
       result.editedFiles.get(
           'deprecated-css-custom-property-syntax/before-fixes.html'),
       (await loader('deprecated-css-custom-property-syntax/after-fixes.html'))
           .contents);
   assert.deepEqual(result.incompatibleEdits, []);
 });
開發者ID:asdfg9822,項目名稱:polymer-linter,代碼行數:13,代碼來源:deprecated-css-custom-property-syntax_test.ts

示例6: test

 test('applies fixes and edit actions', async () => {
   const {warnings, analysis} =
       await linter.lint([`${ruleId}/before-fixes.html`]);
   const edits = [];
   for (const warning of warnings) {
     if (warning.fix) {
       edits.push(warning.fix);
     }
     for (const action of warning.actions || []) {
       if (action.kind === 'edit') {
         edits.push(action.edit);
       }
     }
   }
   const loader = makeParseLoader(analyzer, analysis);
   const result = await applyEdits(edits, loader);
   await assertFileEdited(
       analyzer,
       result,
       `${ruleId}/before-fixes.html`,
       `${ruleId}/after-edits.html`);
 });
開發者ID:Polymer,項目名稱:tools,代碼行數:22,代碼來源:content-to-slot-declarations_test.ts


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