Skip to content

Commit 9397ddb

Browse files
authored
Code analysis refactor (#9402)
* Refactor code analysis code.
1 parent a5de3a5 commit 9397ddb

File tree

7 files changed

+570
-498
lines changed

7 files changed

+570
-498
lines changed

Extension/src/LanguageServer/Providers/codeActionProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import * as vscode from 'vscode';
66
import { Position, Range, RequestType, TextEdit } from 'vscode-languageclient';
77
import * as util from '../../common';
8+
import { DefaultClient } from '../client';
89
import { CodeActionCodeInfo, CodeActionDiagnosticInfo, codeAnalysisFileToCodeActions, codeAnalysisCodeToFixes,
9-
codeAnalysisAllFixes, DefaultClient } from '../client';
10+
codeAnalysisAllFixes } from '../codeAnalysis';
1011
import { makeVscodeRange } from '../utils';
1112
import { CppSettings } from '../settings';
1213

Extension/src/LanguageServer/client.ts

Lines changed: 16 additions & 484 deletions
Large diffs are not rendered by default.

Extension/src/LanguageServer/codeAnalysis.ts

Lines changed: 501 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All Rights Reserved.
3+
* See 'LICENSE' in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
'use strict';
6+
import { Range } from 'vscode-languageclient';
7+
8+
/** Differs from vscode.Location, which has a uri of type vscode.Uri. */
9+
export interface Location {
10+
uri: string;
11+
range: Range;
12+
}
13+
14+
export interface TextEdit {
15+
range: Range;
16+
newText: string;
17+
}
18+
19+
export interface WorkspaceEdit {
20+
changes: { [uri: string]: TextEdit[] };
21+
}

Extension/src/LanguageServer/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import * as util from '../common';
1212
import * as telemetry from '../telemetry';
1313
import { TreeNode, NodeType } from './referencesModel';
1414
import { UI, getUI } from './ui';
15-
import { Client, openFileVersions, CodeAnalysisDiagnosticIdentifiersAndUri, CodeActionDiagnosticInfo, codeAnalysisCodeToFixes,
16-
codeAnalysisFileToCodeActions, codeAnalysisAllFixes } from './client';
15+
import { Client, openFileVersions } from './client';
16+
import { CodeAnalysisDiagnosticIdentifiersAndUri, CodeActionDiagnosticInfo, codeAnalysisCodeToFixes,
17+
codeAnalysisFileToCodeActions, codeAnalysisAllFixes } from './codeAnalysis';
1718
import { makeCpptoolsRange, rangeEquals } from './utils';
1819
import { ClientCollection } from './clientCollection';
1920
import { CppSettings, OtherSettings } from './settings';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* --------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All Rights Reserved.
3+
* See 'LICENSE' in the project root for license information.
4+
* ------------------------------------------------------------------------------------------ */
5+
'use strict';
6+
7+
import { lookupString } from '../nativeStrings';
8+
9+
export interface LocalizeStringParams {
10+
text: string;
11+
stringId: number;
12+
stringArgs: string[];
13+
indentSpaces: number;
14+
}
15+
16+
export function getLocalizedString(params: LocalizeStringParams): string {
17+
let indent: string = "";
18+
if (params.indentSpaces) {
19+
indent = " ".repeat(params.indentSpaces);
20+
}
21+
let text: string = params.text;
22+
if (params.stringId !== 0) {
23+
text = lookupString(params.stringId, params.stringArgs);
24+
}
25+
return indent + text;
26+
}

Extension/src/LanguageServer/utils.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,7 @@
55
'use strict';
66
import * as vscode from 'vscode';
77
import { Range } from 'vscode-languageclient';
8-
9-
/** Differs from vscode.Location, which has a uri of type vscode.Uri. */
10-
export interface Location {
11-
uri: string;
12-
range: Range;
13-
}
14-
15-
export interface TextEdit {
16-
range: Range;
17-
newText: string;
18-
}
8+
import { Location, TextEdit } from './commonTypes';
199

2010
export function makeCpptoolsRange(vscRange: vscode.Range): Range {
2111
return { start: { line: vscRange.start.line, character: vscRange.start.character },

0 commit comments

Comments
 (0)