Skip to content

Code analysis refactor #9402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import * as vscode from 'vscode';
import { Position, Range, RequestType, TextEdit } from 'vscode-languageclient';
import * as util from '../../common';
import { DefaultClient } from '../client';
import { CodeActionCodeInfo, CodeActionDiagnosticInfo, codeAnalysisFileToCodeActions, codeAnalysisCodeToFixes,
codeAnalysisAllFixes, DefaultClient } from '../client';
codeAnalysisAllFixes } from '../codeAnalysis';
import { makeVscodeRange } from '../utils';
import { CppSettings } from '../settings';

Expand Down
500 changes: 16 additions & 484 deletions Extension/src/LanguageServer/client.ts

Large diffs are not rendered by default.

501 changes: 501 additions & 0 deletions Extension/src/LanguageServer/codeAnalysis.ts

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Extension/src/LanguageServer/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { Range } from 'vscode-languageclient';

/** Differs from vscode.Location, which has a uri of type vscode.Uri. */
export interface Location {
uri: string;
range: Range;
}

export interface TextEdit {
range: Range;
newText: string;
}

export interface WorkspaceEdit {
changes: { [uri: string]: TextEdit[] };
}
5 changes: 3 additions & 2 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import * as util from '../common';
import * as telemetry from '../telemetry';
import { TreeNode, NodeType } from './referencesModel';
import { UI, getUI } from './ui';
import { Client, openFileVersions, CodeAnalysisDiagnosticIdentifiersAndUri, CodeActionDiagnosticInfo, codeAnalysisCodeToFixes,
codeAnalysisFileToCodeActions, codeAnalysisAllFixes } from './client';
import { Client, openFileVersions } from './client';
import { CodeAnalysisDiagnosticIdentifiersAndUri, CodeActionDiagnosticInfo, codeAnalysisCodeToFixes,
codeAnalysisFileToCodeActions, codeAnalysisAllFixes } from './codeAnalysis';
import { makeCpptoolsRange, rangeEquals } from './utils';
import { ClientCollection } from './clientCollection';
import { CppSettings, OtherSettings } from './settings';
Expand Down
26 changes: 26 additions & 0 deletions Extension/src/LanguageServer/localization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';

import { lookupString } from '../nativeStrings';

export interface LocalizeStringParams {
text: string;
stringId: number;
stringArgs: string[];
indentSpaces: number;
}

export function getLocalizedString(params: LocalizeStringParams): string {
let indent: string = "";
if (params.indentSpaces) {
indent = " ".repeat(params.indentSpaces);
}
let text: string = params.text;
if (params.stringId !== 0) {
text = lookupString(params.stringId, params.stringArgs);
}
return indent + text;
}
12 changes: 1 addition & 11 deletions Extension/src/LanguageServer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@
'use strict';
import * as vscode from 'vscode';
import { Range } from 'vscode-languageclient';

/** Differs from vscode.Location, which has a uri of type vscode.Uri. */
export interface Location {
uri: string;
range: Range;
}

export interface TextEdit {
range: Range;
newText: string;
}
import { Location, TextEdit } from './commonTypes';

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