Skip to content
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 @@ -3,7 +3,7 @@
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as vscode from 'vscode';
import { DefaultClient, LocalizeDocumentSymbol, GetDocumentSymbolRequestParams, GetDocumentSymbolRequest } from '../client';
import { DefaultClient, LocalizeDocumentSymbol, GetDocumentSymbolRequestParams, GetDocumentSymbolRequest, SymbolScope } from '../client';
import * as util from '../../common';
import { processDelayedDidOpen } from '../extension';

Expand All @@ -16,7 +16,20 @@ export class DocumentSymbolProvider implements vscode.DocumentSymbolProvider {
const documentSymbols: vscode.DocumentSymbol[] = [];
if (symbols) {
symbols.forEach((symbol) => {
const detail: string = util.getLocalizedString(symbol.detail);
let detail: string = util.getLocalizedString(symbol.detail);
if (symbol.scope === SymbolScope.Private) {
if (detail.length === 0) {
detail = "private";
} else {
detail = util.getLocalizedSymbolScope("private", detail);
}
} else if (symbol.scope === SymbolScope.Protected) {
if (detail.length === 0) {
detail = "protected";
} else {
detail = util.getLocalizedSymbolScope("protected", detail);
}
}
const r: vscode.Range = new vscode.Range(symbol.range.start.line, symbol.range.start.character, symbol.range.end.line, symbol.range.end.character);
const sr: vscode.Range = new vscode.Range(symbol.selectionRange.start.line, symbol.selectionRange.start.character, symbol.selectionRange.end.line, symbol.selectionRange.end.character);
const vscodeSymbol: vscode.DocumentSymbol = new vscode.DocumentSymbol(symbol.name, detail, symbol.kind, r, sr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as vscode from 'vscode';
import { DefaultClient, GetSymbolInfoRequest, WorkspaceSymbolParams, LocalizeSymbolInformation } from '../client';
import { DefaultClient, GetSymbolInfoRequest, WorkspaceSymbolParams, LocalizeSymbolInformation, SymbolScope } from '../client';
import * as util from '../../common';

export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {
Expand All @@ -22,10 +22,21 @@ export class WorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider {

// Convert to vscode.Command array
symbols.forEach((symbol) => {
const suffix: string = util.getLocalizedString(symbol.suffix);
let suffix: string = util.getLocalizedString(symbol.suffix);
let name: string = symbol.name;
if (suffix.length) {
if (symbol.scope === SymbolScope.Private) {
suffix = util.getLocalizedSymbolScope("private", suffix);
} else if (symbol.scope === SymbolScope.Protected) {
suffix = util.getLocalizedSymbolScope("protected", suffix);
}
name = name + ' (' + suffix + ')';
} else {
if (symbol.scope === SymbolScope.Private) {
name = name + " (private)";
} else if (symbol.scope === SymbolScope.Protected) {
name = name + " (protected)";
}
}
const range: vscode.Range = new vscode.Range(symbol.location.range.start.line, symbol.location.range.start.character, symbol.location.range.end.line, symbol.location.range.end.character);
const uri: vscode.Uri = vscode.Uri.parse(symbol.location.uri.toString());
Expand Down
8 changes: 8 additions & 0 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,17 @@ export interface WorkspaceSymbolParams extends WorkspaceFolderParams {
query: string;
}

export enum SymbolScope {
Public = 0,
Protected = 1,
Private = 2
}

export interface LocalizeDocumentSymbol {
name: string;
detail: LocalizeStringParams;
kind: vscode.SymbolKind;
scope: SymbolScope;
range: Range;
selectionRange: Range;
children: LocalizeDocumentSymbol[];
Expand All @@ -315,6 +322,7 @@ interface Location {
export interface LocalizeSymbolInformation {
name: string;
kind: vscode.SymbolKind;
scope: SymbolScope;
location: Location;
containerName: string;
suffix: LocalizeStringParams;
Expand Down
24 changes: 16 additions & 8 deletions Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,19 @@ export function isUri(input: any): input is vscode.Uri {
}

export function isString(input: any): input is string {
return typeof(input) === "string";
return typeof (input) === "string";
}

export function isNumber(input: any): input is number {
return typeof(input) === "number";
return typeof (input) === "number";
}

export function isBoolean(input: any): input is boolean {
return typeof(input) === "boolean";
return typeof (input) === "boolean";
}

export function isObject(input: any): input is object {
return typeof(input) === "object";
return typeof (input) === "object";
}

export function isArray(input: any): input is any[] {
Expand All @@ -288,7 +288,7 @@ export function isOptionalArrayOfString(input: any): input is string[] | undefin
return input === undefined || isArrayOfString(input);
}

export function resolveCachePath(input: string | undefined, additionalEnvironment: {[key: string]: string | string[]}): string {
export function resolveCachePath(input: string | undefined, additionalEnvironment: { [key: string]: string | string[] }): string {
let resolvedPath: string = "";
if (!input) {
// If no path is set, return empty string to language service process, where it will set the default path as
Expand All @@ -301,7 +301,7 @@ export function resolveCachePath(input: string | undefined, additionalEnvironmen
return resolvedPath;
}

export function resolveVariables(input: string | undefined, additionalEnvironment?: {[key: string]: string | string[]}): string {
export function resolveVariables(input: string | undefined, additionalEnvironment?: { [key: string]: string | string[] }): string {
if (!input) {
return "";
}
Expand Down Expand Up @@ -981,7 +981,8 @@ export function extractCompilerPathAndArgs(inputCompilerPath?: string, inputComp

if (compilerPath) {
if (compilerPathLowercase?.endsWith("\\cl.exe") || compilerPathLowercase?.endsWith("/cl.exe") || (compilerPathLowercase === "cl.exe")
|| compilerPathLowercase?.endsWith("\\cl") || compilerPathLowercase?.endsWith("/cl") || (compilerPathLowercase === "cl")) { compilerName = path.basename(compilerPath);
|| compilerPathLowercase?.endsWith("\\cl") || compilerPathLowercase?.endsWith("/cl") || (compilerPathLowercase === "cl")) {
compilerName = path.basename(compilerPath);
} else if (compilerPath.startsWith("\"")) {
// Input has quotes around compiler path
const endQuote: number = compilerPath.substr(1).search("\"") + 1;
Expand Down Expand Up @@ -1049,7 +1050,7 @@ export function escapeForSquiggles(s: string): string {
newResults += "\\";
}
lastWasBackslash = false;
lastBackslashWasEscaped = false;
lastBackslashWasEscaped = false;
newResults += s[i];
}
}
Expand Down Expand Up @@ -1142,6 +1143,13 @@ export function getLocalizedString(params: LocalizeStringParams): string {
return indent + text;
}

export function getLocalizedSymbolScope(scope: string, detail: string): string {
return localize({
key: "c.cpp.symbolscope.separator", comment:
["{0} is an untranslated C++ keyword (e.g. \"private\") and {1} is either another keyword (e.g. \"typedef\") or a localized property (e.g. a localized verison of \"declaration\""]
}, "{0}, {1}", scope, detail);
}

function decodeUCS16(input: string): number[] {
const output: number[] = [];
let counter: number = 0;
Expand Down