diff options
author | Scott Tran <scotttran506@yahoo.com> | 2023-02-05 17:48:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-05 18:48:20 -0500 |
commit | b31ee6a643c94fbbf71a421868129aa0b96b5d34 (patch) | |
tree | 5ced70ac4a4f7cc7b1670032cb051a6ee8604009 | |
parent | 604cce2098b057d61323dd6e21cef09f73a53213 (diff) | |
download | compiler-explorer-gh-6170.tar.gz compiler-explorer-gh-6170.zip |
Tsify clang-tidy-tool (#4695)gh-6170
-rw-r--r-- | lib/tooling/clang-tidy-tool.ts (renamed from lib/tooling/clang-tidy-tool.js) | 22 | ||||
-rw-r--r-- | types/tool.interfaces.ts | 2 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/tooling/clang-tidy-tool.js b/lib/tooling/clang-tidy-tool.ts index 6866db6b5..1fb51d2c4 100644 --- a/lib/tooling/clang-tidy-tool.js +++ b/lib/tooling/clang-tidy-tool.ts @@ -26,6 +26,7 @@ import path from 'path'; import fs from 'fs-extra'; +import {Library} from '../../types/libraries/libraries.interfaces'; import * as utils from '../utils'; import {BaseTool} from './base-tool'; @@ -41,14 +42,21 @@ export class ClangTidyTool extends BaseTool { this.addOptionsToToolArgs = false; } - async runTool(compilationInfo, inputFilepath, args, stdin, supportedLibraries) { + override async runTool( + compilationInfo: Record<any, any>, + inputFilepath: string, + args?: string[], + stdin?: string, + supportedLibraries?: Record<string, Library>, + ) { const sourcefile = inputFilepath; const options = compilationInfo.options; const dir = path.dirname(sourcefile); - const includeflags = super.getIncludeArguments(compilationInfo.libraries, supportedLibraries); - const libOptions = super.getLibraryOptions(compilationInfo.libraries, supportedLibraries); + const includeflags = super.getIncludeArguments(compilationInfo.libraries, supportedLibraries || {}); + const libOptions = super.getLibraryOptions(compilationInfo.libraries, supportedLibraries || {}); - let source; + let source = ''; + args = args || []; const wantsFix = args.find(option => option.includes('-fix')); if (wantsFix) { args = args.filter(option => !option.includes('-header-filter=')); @@ -79,10 +87,10 @@ export class ClangTidyTool extends BaseTool { if (wantsFix) { const data = await fs.readFile(sourcefile); - const newsource = data.toString(); - if (newsource !== source) { + const newSource = data.toString(); + if (newSource !== source) { result.sourcechanged = true; - result.newsource = newsource; + result.newsource = newSource; } } diff --git a/types/tool.interfaces.ts b/types/tool.interfaces.ts index a54f28e55..075d68a36 100644 --- a/types/tool.interfaces.ts +++ b/types/tool.interfaces.ts @@ -73,4 +73,6 @@ export type ToolResult = { stderr: ResultLine[]; stdout: ResultLine[]; artifact?: Artifact; + sourcechanged?: boolean; + newsource?: string; }; |