Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -7,20 +7,22 @@
import { PPromise, TPromise } from 'vs/base/common/winjs.base';
import uri from 'vs/base/common/uri';
import objects = require('vs/base/common/objects');
import scorer = require('vs/base/common/scorer');
import strings = require('vs/base/common/strings');
import { getNextTickChannel } from 'vs/base/parts/ipc/common/ipc';
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
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, IFolderSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService } from './search';
import { IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService, ITelemetryEvent } from './search';
import { ISearchChannel, SearchChannelClient } from './searchIpc';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IEnvironmentService, IDebugParams } from 'vs/platform/environment/common/environment';
import { ResourceMap } from 'vs/base/common/map';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Schemas } from 'vs/base/common/network';
export class SearchService implements ISearchService {
public _serviceBrand: any;
@@ -33,10 +35,12 @@ export class SearchService implements ISearchService {
@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);
this.diskSearch = new DiskSearch(!environmentService.isBuilt || environmentService.verbose, /*timeout=*/undefined, environmentService.debugSearch);
this.registerSearchResultProvider(this.diskSearch);
this.forwardTelemetry();
}
public registerSearchResultProvider(provider: ISearchResultProvider): IDisposable {
@@ -188,7 +192,7 @@ export class SearchService implements ISearchService {
return false; // if we match on file pattern, we have to ignore non file resources
}
if (!scorer.matches(resource.fsPath, strings.stripWildcards(query.filePattern).toLowerCase())) {
if (!strings.fuzzyContains(resource.fsPath, strings.stripWildcards(query.filePattern).toLowerCase())) {
return false;
}
}
@@ -206,31 +210,47 @@ export class SearchService implements ISearchService {
public clearCache(cacheKey: string): TPromise<void> {
return this.diskSearch.clearCache(cacheKey);
}
private forwardTelemetry() {
this.diskSearch.fetchTelemetry()
.then(null, onUnexpectedError, event => {
this.telemetryService.publicLog(event.eventName, event.data);
});
}
}
export class DiskSearch implements ISearchResultProvider {
private raw: IRawSearchService;
constructor(verboseLogging: boolean, timeout: number = 60 * 60 * 1000) {
constructor(verboseLogging: boolean, timeout: number = 60 * 60 * 1000, searchDebug?: IDebugParams) {
const opts: IIPCOptions = {
serverName: 'Search',
timeout: timeout,
args: ['--type=searchService'],
// See https://github.com/Microsoft/vscode/issues/27665
// Pass in fresh execArgv to the forked process such that it doesn't inherit them from `process.execArgv`.
// e.g. Launching the extension host process with `--inspect-brk=xxx` and then forking a process from the extension host
// results in the forked process inheriting `--inspect-brk=xxx`.
freshExecArgv: true,
env: {
AMD_ENTRYPOINT: 'vs/workbench/services/search/node/searchApp',
PIPE_LOGGING: 'true',
VERBOSE_LOGGING: verboseLogging
}
};
if (searchDebug) {
if (searchDebug.break && searchDebug.port) {
opts.debugBrk = searchDebug.port;
} else if (!searchDebug.break && searchDebug.port) {
opts.debug = searchDebug.port;
}
}
const client = new Client(
uri.parse(require.toUrl('bootstrap')).fsPath,
{
serverName: 'Search',
timeout: timeout,
args: ['--type=searchService'],
// See https://github.com/Microsoft/vscode/issues/27665
// Pass in fresh execArgv to the forked process such that it doesn't inherit them from `process.execArgv`.
// e.g. Launching the extension host process with `--inspect-brk=xxx` and then forking a process from the extension host
// results in the forked process inheriting `--inspect-brk=xxx`.
freshExecArgv: true,
env: {
AMD_ENTRYPOINT: 'vs/workbench/services/search/node/searchApp',
PIPE_LOGGING: 'true',
VERBOSE_LOGGING: verboseLogging
}
}
);
opts);
const channel = getNextTickChannel(client.getChannel<ISearchChannel>('search'));
this.raw = new SearchChannelClient(channel);
@@ -240,25 +260,42 @@ export class DiskSearch implements ISearchResultProvider {
let request: PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem>;
let rawSearch: IRawSearch = {
folderQueries: query.folderQueries ? query.folderQueries.map(q => {
return <IFolderSearch>{
excludePattern: q.excludePattern,
includePattern: q.includePattern,
fileEncoding: q.fileEncoding,
folder: q.folder.fsPath
};
}) : [],
extraFiles: query.extraFileResources ? query.extraFileResources.map(r => r.fsPath) : [],
folderQueries: [],
extraFiles: [],
filePattern: query.filePattern,
excludePattern: query.excludePattern,
includePattern: query.includePattern,
maxResults: query.maxResults,
exists: query.exists,
sortByScore: query.sortByScore,
cacheKey: query.cacheKey,
useRipgrep: query.useRipgrep,
disregardIgnoreFiles: query.disregardIgnoreFiles
disregardIgnoreFiles: query.disregardIgnoreFiles,
ignoreSymlinks: query.ignoreSymlinks
};
if (query.folderQueries) {
for (const q of query.folderQueries) {
if (q.folder.scheme === Schemas.file) {
rawSearch.folderQueries.push({
excludePattern: q.excludePattern,
includePattern: q.includePattern,
fileEncoding: q.fileEncoding,
disregardIgnoreFiles: q.disregardIgnoreFiles,
folder: q.folder.fsPath
});
}
}
}
if (query.extraFileResources) {
for (const r of query.extraFileResources) {
if (r.scheme === Schemas.file) {
rawSearch.extraFiles.push(r.fsPath);
}
}
}
if (query.type === QueryType.Text) {
rawSearch.contentPattern = query.contentPattern;
}
@@ -318,4 +355,8 @@ export class DiskSearch implements ISearchResultProvider {
public clearCache(cacheKey: string): TPromise<void> {
return this.raw.clearCache(cacheKey);
}
public fetchTelemetry(): PPromise<void, ITelemetryEvent> {
return this.raw.fetchTelemetry();
}
}