mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 03:28:33 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -26,6 +26,7 @@ import extfs = require('vs/base/node/extfs');
|
||||
import flow = require('vs/base/node/flow');
|
||||
import { IRawFileMatch, ISerializedSearchComplete, IRawSearch, ISearchEngine, IFolderSearch } from './search';
|
||||
import { spawnRipgrepCmd } from './ripgrepFileSearch';
|
||||
import { rgErrorMsgForDisplay } from './ripgrepTextSearch';
|
||||
|
||||
enum Traversal {
|
||||
Node = 1,
|
||||
@@ -189,8 +190,9 @@ export class FileWalker {
|
||||
rootFolderDone(undefined, undefined);
|
||||
}
|
||||
});
|
||||
}, (err, result) => {
|
||||
done(err ? err[0] : null, this.isLimitHit);
|
||||
}, (errors, result) => {
|
||||
const err = errors ? errors.filter(e => !!e)[0] : null;
|
||||
done(err, this.isLimitHit);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -389,13 +391,17 @@ export class FileWalker {
|
||||
this.forwardData(cmd.stdout, encoding, done);
|
||||
const stderr = this.collectData(cmd.stderr);
|
||||
|
||||
let gotData = false;
|
||||
cmd.stdout.once('data', () => gotData = true);
|
||||
|
||||
cmd.on('error', (err: Error) => {
|
||||
done(err);
|
||||
});
|
||||
|
||||
cmd.on('close', (code: number) => {
|
||||
// ripgrep returns code=1 when no results are found
|
||||
if (code !== 0 && (!isRipgrep || code !== 1)) {
|
||||
let stderrText, displayMsg: string;
|
||||
if (isRipgrep ? (!gotData && (stderrText = this.decodeData(stderr, encoding)) && (displayMsg = rgErrorMsgForDisplay(stderrText))) : code !== 0) {
|
||||
done(new Error(`command failed with error code ${code}: ${this.decodeData(stderr, encoding)}`));
|
||||
} else {
|
||||
if (isRipgrep && this.exists && code === 0) {
|
||||
@@ -493,7 +499,7 @@ export class FileWalker {
|
||||
if (self.isLimitHit) {
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
matchDirectory(rootEntries);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import objects = require('vs/base/common/objects');
|
||||
import strings = require('vs/base/common/strings');
|
||||
import { PPromise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { FileWalker, Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
|
||||
import { MAX_FILE_SIZE } from 'vs/platform/files/common/files';
|
||||
import { MAX_FILE_SIZE } from 'vs/platform/files/node/files';
|
||||
import { RipgrepEngine } from 'vs/workbench/services/search/node/ripgrepTextSearch';
|
||||
import { Engine as TextSearchEngine } from 'vs/workbench/services/search/node/textSearch';
|
||||
import { TextSearchWorkerProvider } from 'vs/workbench/services/search/node/textSearchWorkerProvider';
|
||||
@@ -27,7 +27,7 @@ import { compareItemsByScore, IItemAccessor, ScorerCache, prepareQuery } from 'v
|
||||
|
||||
export class SearchService implements IRawSearchService {
|
||||
|
||||
private static BATCH_SIZE = 512;
|
||||
private static readonly BATCH_SIZE = 512;
|
||||
|
||||
private caches: { [cacheKey: string]: Cache; } = Object.create(null);
|
||||
|
||||
@@ -443,10 +443,10 @@ interface CacheStats {
|
||||
* If the batch isn't filled within some time, the callback is also called.
|
||||
*/
|
||||
class BatchedCollector<T> {
|
||||
private static TIMEOUT = 4000;
|
||||
private static readonly TIMEOUT = 4000;
|
||||
|
||||
// After RUN_TIMEOUT_UNTIL_COUNT items have been collected, stop flushing on timeout
|
||||
private static START_BATCH_AFTER_COUNT = 50;
|
||||
private static readonly START_BATCH_AFTER_COUNT = 50;
|
||||
|
||||
private totalNumberCompleted = 0;
|
||||
private batch: T[] = [];
|
||||
|
||||
@@ -18,10 +18,10 @@ import * as paths from 'vs/base/common/paths';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import * as encoding from 'vs/base/node/encoding';
|
||||
import * as glob from 'vs/base/common/glob';
|
||||
import { ILineMatch, ISearchLog } from 'vs/platform/search/common/search';
|
||||
import { ISearchLog } from 'vs/platform/search/common/search';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
import { ISerializedFileMatch, ISerializedSearchComplete, IRawSearch, IFolderSearch } from './search';
|
||||
import { ISerializedFileMatch, ISerializedSearchComplete, IRawSearch, IFolderSearch, LineMatch, FileMatch } from './search';
|
||||
|
||||
export class RipgrepEngine {
|
||||
private isDone = false;
|
||||
@@ -121,7 +121,7 @@ export class RipgrepEngine {
|
||||
this.isDone = true;
|
||||
let displayMsg: string;
|
||||
process.removeListener('exit', this.killRgProcFn);
|
||||
if (stderr && !gotData && (displayMsg = this.rgErrorMsgForDisplay(stderr))) {
|
||||
if (stderr && !gotData && (displayMsg = rgErrorMsgForDisplay(stderr))) {
|
||||
done(new Error(displayMsg), {
|
||||
limitHit: false,
|
||||
stats: null
|
||||
@@ -136,35 +136,35 @@ export class RipgrepEngine {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the first line of stderr and return an error for display or undefined, based on a whitelist.
|
||||
* Ripgrep produces stderr output which is not from a fatal error, and we only want the search to be
|
||||
* "failed" when a fatal error was produced.
|
||||
*/
|
||||
private rgErrorMsgForDisplay(msg: string): string | undefined {
|
||||
const firstLine = msg.split('\n')[0];
|
||||
/**
|
||||
* Read the first line of stderr and return an error for display or undefined, based on a whitelist.
|
||||
* Ripgrep produces stderr output which is not from a fatal error, and we only want the search to be
|
||||
* "failed" when a fatal error was produced.
|
||||
*/
|
||||
export function rgErrorMsgForDisplay(msg: string): string | undefined {
|
||||
const firstLine = msg.split('\n')[0];
|
||||
|
||||
if (strings.startsWith(firstLine, 'Error parsing regex')) {
|
||||
return firstLine;
|
||||
}
|
||||
|
||||
if (strings.startsWith(firstLine, 'error parsing glob') ||
|
||||
strings.startsWith(firstLine, 'unsupported encoding')) {
|
||||
// Uppercase first letter
|
||||
return firstLine.charAt(0).toUpperCase() + firstLine.substr(1);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
if (strings.startsWith(firstLine, 'Error parsing regex')) {
|
||||
return firstLine;
|
||||
}
|
||||
|
||||
if (strings.startsWith(firstLine, 'error parsing glob') ||
|
||||
strings.startsWith(firstLine, 'unsupported encoding')) {
|
||||
// Uppercase first letter
|
||||
return firstLine.charAt(0).toUpperCase() + firstLine.substr(1);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export class RipgrepParser extends EventEmitter {
|
||||
private static RESULT_REGEX = /^\u001b\[m(\d+)\u001b\[m:(.*)(\r?)/;
|
||||
private static FILE_REGEX = /^\u001b\[m(.+)\u001b\[m$/;
|
||||
private static readonly RESULT_REGEX = /^\u001b\[m(\d+)\u001b\[m:(.*)(\r?)/;
|
||||
private static readonly FILE_REGEX = /^\u001b\[m(.+)\u001b\[m$/;
|
||||
|
||||
public static MATCH_START_MARKER = '\u001b[m\u001b[31m';
|
||||
public static MATCH_END_MARKER = '\u001b[m';
|
||||
public static readonly MATCH_START_MARKER = '\u001b[m\u001b[31m';
|
||||
public static readonly MATCH_END_MARKER = '\u001b[m';
|
||||
|
||||
private fileMatch: FileMatch;
|
||||
private remainder: string;
|
||||
@@ -328,74 +328,6 @@ export class RipgrepParser extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
export class FileMatch implements ISerializedFileMatch {
|
||||
path: string;
|
||||
lineMatches: LineMatch[];
|
||||
|
||||
constructor(path: string) {
|
||||
this.path = path;
|
||||
this.lineMatches = [];
|
||||
}
|
||||
|
||||
addMatch(lineMatch: LineMatch): void {
|
||||
this.lineMatches.push(lineMatch);
|
||||
}
|
||||
|
||||
isEmpty(): boolean {
|
||||
return this.lineMatches.length === 0;
|
||||
}
|
||||
|
||||
serialize(): ISerializedFileMatch {
|
||||
let lineMatches: ILineMatch[] = [];
|
||||
let numMatches = 0;
|
||||
|
||||
for (let i = 0; i < this.lineMatches.length; i++) {
|
||||
numMatches += this.lineMatches[i].offsetAndLengths.length;
|
||||
lineMatches.push(this.lineMatches[i].serialize());
|
||||
}
|
||||
|
||||
return {
|
||||
path: this.path,
|
||||
lineMatches,
|
||||
numMatches
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class LineMatch implements ILineMatch {
|
||||
preview: string;
|
||||
lineNumber: number;
|
||||
offsetAndLengths: number[][];
|
||||
|
||||
constructor(preview: string, lineNumber: number) {
|
||||
this.preview = preview.replace(/(\r|\n)*$/, '');
|
||||
this.lineNumber = lineNumber;
|
||||
this.offsetAndLengths = [];
|
||||
}
|
||||
|
||||
getText(): string {
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
getLineNumber(): number {
|
||||
return this.lineNumber;
|
||||
}
|
||||
|
||||
addMatch(offset: number, length: number): void {
|
||||
this.offsetAndLengths.push([offset, length]);
|
||||
}
|
||||
|
||||
serialize(): ILineMatch {
|
||||
const result = {
|
||||
preview: this.preview,
|
||||
lineNumber: this.lineNumber,
|
||||
offsetAndLengths: this.offsetAndLengths
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IRgGlobResult {
|
||||
globArgs: string[];
|
||||
siblingClauses: glob.IExpression;
|
||||
|
||||
@@ -72,4 +72,61 @@ export interface ISerializedFileMatch {
|
||||
|
||||
// Type of the possible values for progress calls from the engine
|
||||
export type ISerializedSearchProgressItem = ISerializedFileMatch | ISerializedFileMatch[] | IProgress | ISearchLog;
|
||||
export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgress;
|
||||
export type IFileSearchProgressItem = IRawFileMatch | IRawFileMatch[] | IProgress;
|
||||
|
||||
|
||||
export class FileMatch implements ISerializedFileMatch {
|
||||
path: string;
|
||||
lineMatches: LineMatch[];
|
||||
|
||||
constructor(path: string) {
|
||||
this.path = path;
|
||||
this.lineMatches = [];
|
||||
}
|
||||
|
||||
addMatch(lineMatch: LineMatch): void {
|
||||
this.lineMatches.push(lineMatch);
|
||||
}
|
||||
|
||||
serialize(): ISerializedFileMatch {
|
||||
let lineMatches: ILineMatch[] = [];
|
||||
let numMatches = 0;
|
||||
|
||||
for (let i = 0; i < this.lineMatches.length; i++) {
|
||||
numMatches += this.lineMatches[i].offsetAndLengths.length;
|
||||
lineMatches.push(this.lineMatches[i].serialize());
|
||||
}
|
||||
|
||||
return {
|
||||
path: this.path,
|
||||
lineMatches,
|
||||
numMatches
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class LineMatch implements ILineMatch {
|
||||
preview: string;
|
||||
lineNumber: number;
|
||||
offsetAndLengths: number[][];
|
||||
|
||||
constructor(preview: string, lineNumber: number) {
|
||||
this.preview = preview.replace(/(\r|\n)*$/, '');
|
||||
this.lineNumber = lineNumber;
|
||||
this.offsetAndLengths = [];
|
||||
}
|
||||
|
||||
addMatch(offset: number, length: number): void {
|
||||
this.offsetAndLengths.push([offset, length]);
|
||||
}
|
||||
|
||||
serialize(): ILineMatch {
|
||||
const result = {
|
||||
preview: this.preview,
|
||||
lineNumber: this.lineNumber,
|
||||
offsetAndLengths: this.offsetAndLengths
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import { Client, IIPCOptions } from 'vs/base/parts/ipc/node/ipc.cp';
|
||||
import { IProgress, LineMatch, FileMatch, ISearchComplete, ISearchProgressItem, QueryType, IFileMatch, ISearchQuery, ISearchConfiguration, ISearchService, pathIncludedInQuery, ISearchResultProvider } from 'vs/platform/search/common/search';
|
||||
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService, ITelemetryEvent } from './search';
|
||||
import { ISearchChannel, SearchChannelClient } from './searchIpc';
|
||||
@@ -29,18 +28,17 @@ export class SearchService implements ISearchService {
|
||||
|
||||
private diskSearch: DiskSearch;
|
||||
private readonly searchProvider: ISearchResultProvider[] = [];
|
||||
private forwardingTelemetry: PPromise<void, ITelemetryEvent>;
|
||||
|
||||
constructor(
|
||||
@IModelService private modelService: IModelService,
|
||||
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
this.diskSearch = new DiskSearch(!environmentService.isBuilt || environmentService.verbose, /*timeout=*/undefined, environmentService.debugSearch);
|
||||
this.registerSearchResultProvider(this.diskSearch);
|
||||
this.forwardTelemetry();
|
||||
}
|
||||
|
||||
public registerSearchResultProvider(provider: ISearchResultProvider): IDisposable {
|
||||
@@ -56,7 +54,7 @@ export class SearchService implements ISearchService {
|
||||
}
|
||||
|
||||
public extendQuery(query: ISearchQuery): void {
|
||||
const configuration = this.configurationService.getConfiguration<ISearchConfiguration>();
|
||||
const configuration = this.configurationService.getValue<ISearchConfiguration>();
|
||||
|
||||
// Configuration: Encoding
|
||||
if (!query.fileEncoding) {
|
||||
@@ -66,7 +64,7 @@ export class SearchService implements ISearchService {
|
||||
|
||||
// Configuration: File Excludes
|
||||
if (!query.disregardExcludeSettings) {
|
||||
const fileExcludes = configuration && configuration.files && configuration.files.exclude;
|
||||
const fileExcludes = objects.deepClone(configuration && configuration.files && configuration.files.exclude);
|
||||
if (fileExcludes) {
|
||||
if (!query.excludePattern) {
|
||||
query.excludePattern = fileExcludes;
|
||||
@@ -78,6 +76,7 @@ export class SearchService implements ISearchService {
|
||||
}
|
||||
|
||||
public search(query: ISearchQuery): PPromise<ISearchComplete, ISearchProgressItem> {
|
||||
this.forwardTelemetry();
|
||||
|
||||
let combinedPromise: TPromise<void>;
|
||||
|
||||
@@ -212,10 +211,12 @@ export class SearchService implements ISearchService {
|
||||
}
|
||||
|
||||
private forwardTelemetry() {
|
||||
this.diskSearch.fetchTelemetry()
|
||||
.then(null, onUnexpectedError, event => {
|
||||
this.telemetryService.publicLog(event.eventName, event.data);
|
||||
});
|
||||
if (!this.forwardingTelemetry) {
|
||||
this.forwardingTelemetry = this.diskSearch.fetchTelemetry()
|
||||
.then(null, onUnexpectedError, event => {
|
||||
this.telemetryService.publicLog(event.eventName, event.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ITextSearchWorkerProvider } from './textSearchWorkerProvider';
|
||||
|
||||
export class Engine implements ISearchEngine<ISerializedFileMatch[]> {
|
||||
|
||||
private static PROGRESS_FLUSH_CHUNK_SIZE = 50; // optimization: number of files to process before emitting progress event
|
||||
private static readonly PROGRESS_FLUSH_CHUNK_SIZE = 50; // optimization: number of files to process before emitting progress event
|
||||
|
||||
private config: IRawSearch;
|
||||
private walker: FileWalker;
|
||||
|
||||
@@ -12,9 +12,8 @@ gracefulFs.gracefulify(fs);
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ISerializedFileMatch } from '../search';
|
||||
import { LineMatch, FileMatch } from '../search';
|
||||
import * as baseMime from 'vs/base/common/mime';
|
||||
import { ILineMatch } from 'vs/platform/search/common/search';
|
||||
import { UTF16le, UTF16be, UTF8, UTF8_with_bom, encodingExists, decode, bomLength } from 'vs/base/node/encoding';
|
||||
import { detectMimeAndEncodingFromBuffer } from 'vs/base/node/mime';
|
||||
|
||||
@@ -299,71 +298,3 @@ export class SearchWorkerEngine {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class FileMatch implements ISerializedFileMatch {
|
||||
path: string;
|
||||
lineMatches: LineMatch[];
|
||||
|
||||
constructor(path: string) {
|
||||
this.path = path;
|
||||
this.lineMatches = [];
|
||||
}
|
||||
|
||||
addMatch(lineMatch: LineMatch): void {
|
||||
this.lineMatches.push(lineMatch);
|
||||
}
|
||||
|
||||
isEmpty(): boolean {
|
||||
return this.lineMatches.length === 0;
|
||||
}
|
||||
|
||||
serialize(): ISerializedFileMatch {
|
||||
let lineMatches: ILineMatch[] = [];
|
||||
let numMatches = 0;
|
||||
|
||||
for (let i = 0; i < this.lineMatches.length; i++) {
|
||||
numMatches += this.lineMatches[i].offsetAndLengths.length;
|
||||
lineMatches.push(this.lineMatches[i].serialize());
|
||||
}
|
||||
|
||||
return {
|
||||
path: this.path,
|
||||
lineMatches,
|
||||
numMatches
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class LineMatch implements ILineMatch {
|
||||
preview: string;
|
||||
lineNumber: number;
|
||||
offsetAndLengths: number[][];
|
||||
|
||||
constructor(preview: string, lineNumber: number) {
|
||||
this.preview = preview.replace(/(\r|\n)*$/, '');
|
||||
this.lineNumber = lineNumber;
|
||||
this.offsetAndLengths = [];
|
||||
}
|
||||
|
||||
getText(): string {
|
||||
return this.preview;
|
||||
}
|
||||
|
||||
getLineNumber(): number {
|
||||
return this.lineNumber;
|
||||
}
|
||||
|
||||
addMatch(offset: number, length: number): void {
|
||||
this.offsetAndLengths.push([offset, length]);
|
||||
}
|
||||
|
||||
serialize(): ILineMatch {
|
||||
const result = {
|
||||
preview: this.preview,
|
||||
lineNumber: this.lineNumber,
|
||||
offsetAndLengths: this.offsetAndLengths
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user