@theia/search-in-workspace 1.34.2 → 1.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +641 -641
- package/README.md +40 -40
- package/lib/browser/components/search-in-workspace-input.d.ts +39 -39
- package/lib/browser/components/search-in-workspace-input.js +120 -120
- package/lib/browser/search-in-workspace-context-key-service.d.ts +23 -23
- package/lib/browser/search-in-workspace-context-key-service.js +90 -90
- package/lib/browser/search-in-workspace-factory.d.ts +10 -10
- package/lib/browser/search-in-workspace-factory.js +68 -68
- package/lib/browser/search-in-workspace-frontend-contribution.d.ts +53 -53
- package/lib/browser/search-in-workspace-frontend-contribution.js +410 -410
- package/lib/browser/search-in-workspace-frontend-module.d.ts +6 -6
- package/lib/browser/search-in-workspace-frontend-module.js +70 -70
- package/lib/browser/search-in-workspace-label-provider.d.ts +9 -9
- package/lib/browser/search-in-workspace-label-provider.js +57 -57
- package/lib/browser/search-in-workspace-preferences.d.ts +17 -17
- package/lib/browser/search-in-workspace-preferences.js +82 -82
- package/lib/browser/search-in-workspace-result-tree-widget.d.ts +253 -253
- package/lib/browser/search-in-workspace-result-tree-widget.js +1072 -1072
- package/lib/browser/search-in-workspace-service.d.ts +35 -35
- package/lib/browser/search-in-workspace-service.js +158 -158
- package/lib/browser/search-in-workspace-widget.d.ts +121 -121
- package/lib/browser/search-in-workspace-widget.js +602 -602
- package/lib/browser/search-layout-migrations.d.ts +5 -5
- package/lib/browser/search-layout-migrations.js +64 -64
- package/lib/common/search-in-workspace-interface.d.ts +112 -112
- package/lib/common/search-in-workspace-interface.js +35 -35
- package/lib/node/ripgrep-search-in-workspace-server.d.ts +94 -94
- package/lib/node/ripgrep-search-in-workspace-server.js +423 -423
- package/lib/node/ripgrep-search-in-workspace-server.slow-spec.d.ts +1 -1
- package/lib/node/ripgrep-search-in-workspace-server.slow-spec.js +899 -899
- package/lib/node/search-in-workspace-backend-module.d.ts +3 -3
- package/lib/node/search-in-workspace-backend-module.js +32 -32
- package/package.json +9 -9
- package/src/browser/components/search-in-workspace-input.tsx +139 -139
- package/src/browser/search-in-workspace-context-key-service.ts +93 -93
- package/src/browser/search-in-workspace-factory.ts +59 -59
- package/src/browser/search-in-workspace-frontend-contribution.ts +402 -402
- package/src/browser/search-in-workspace-frontend-module.ts +82 -82
- package/src/browser/search-in-workspace-label-provider.ts +48 -48
- package/src/browser/search-in-workspace-preferences.ts +91 -91
- package/src/browser/search-in-workspace-result-tree-widget.tsx +1225 -1225
- package/src/browser/search-in-workspace-service.ts +152 -152
- package/src/browser/search-in-workspace-widget.tsx +711 -711
- package/src/browser/search-layout-migrations.ts +53 -53
- package/src/browser/styles/index.css +367 -367
- package/src/browser/styles/search.svg +6 -6
- package/src/common/search-in-workspace-interface.ts +149 -149
- package/src/node/ripgrep-search-in-workspace-server.slow-spec.ts +1073 -1073
- package/src/node/ripgrep-search-in-workspace-server.ts +482 -482
- package/src/node/search-in-workspace-backend-module.ts +33 -33
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { SearchInWorkspaceServer, SearchInWorkspaceClient, SearchInWorkspaceResult, SearchInWorkspaceOptions } from '../common/search-in-workspace-interface';
|
|
2
|
-
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
3
|
-
import { ILogger } from '@theia/core';
|
|
4
|
-
/**
|
|
5
|
-
* Class that will receive the search results from the server. This is separate
|
|
6
|
-
* from the SearchInWorkspaceService class only to avoid a cycle in the
|
|
7
|
-
* dependency injection.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SearchInWorkspaceClientImpl implements SearchInWorkspaceClient {
|
|
10
|
-
private service;
|
|
11
|
-
onResult(searchId: number, result: SearchInWorkspaceResult): void;
|
|
12
|
-
onDone(searchId: number, error?: string): void;
|
|
13
|
-
setService(service: SearchInWorkspaceClient): void;
|
|
14
|
-
}
|
|
15
|
-
export declare type SearchInWorkspaceCallbacks = SearchInWorkspaceClient;
|
|
16
|
-
/**
|
|
17
|
-
* Service to search text in the workspace files.
|
|
18
|
-
*/
|
|
19
|
-
export declare class SearchInWorkspaceService implements SearchInWorkspaceClient {
|
|
20
|
-
private pendingSearches;
|
|
21
|
-
private pendingOnDones;
|
|
22
|
-
private lastKnownSearchId;
|
|
23
|
-
protected readonly searchServer: SearchInWorkspaceServer;
|
|
24
|
-
protected readonly client: SearchInWorkspaceClientImpl;
|
|
25
|
-
protected readonly workspaceService: WorkspaceService;
|
|
26
|
-
protected readonly logger: ILogger;
|
|
27
|
-
protected init(): void;
|
|
28
|
-
isEnabled(): boolean;
|
|
29
|
-
onResult(searchId: number, result: SearchInWorkspaceResult): void;
|
|
30
|
-
onDone(searchId: number, error?: string): void;
|
|
31
|
-
search(what: string, callbacks: SearchInWorkspaceCallbacks, opts?: SearchInWorkspaceOptions): Promise<number>;
|
|
32
|
-
protected doSearch(what: string, rootsUris: string[], callbacks: SearchInWorkspaceCallbacks, opts?: SearchInWorkspaceOptions): Promise<number>;
|
|
33
|
-
searchWithCallback(what: string, rootsUris: string[], callbacks: SearchInWorkspaceClient, opts?: SearchInWorkspaceOptions | undefined): Promise<number>;
|
|
34
|
-
cancel(searchId: number): void;
|
|
35
|
-
}
|
|
1
|
+
import { SearchInWorkspaceServer, SearchInWorkspaceClient, SearchInWorkspaceResult, SearchInWorkspaceOptions } from '../common/search-in-workspace-interface';
|
|
2
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
3
|
+
import { ILogger } from '@theia/core';
|
|
4
|
+
/**
|
|
5
|
+
* Class that will receive the search results from the server. This is separate
|
|
6
|
+
* from the SearchInWorkspaceService class only to avoid a cycle in the
|
|
7
|
+
* dependency injection.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SearchInWorkspaceClientImpl implements SearchInWorkspaceClient {
|
|
10
|
+
private service;
|
|
11
|
+
onResult(searchId: number, result: SearchInWorkspaceResult): void;
|
|
12
|
+
onDone(searchId: number, error?: string): void;
|
|
13
|
+
setService(service: SearchInWorkspaceClient): void;
|
|
14
|
+
}
|
|
15
|
+
export declare type SearchInWorkspaceCallbacks = SearchInWorkspaceClient;
|
|
16
|
+
/**
|
|
17
|
+
* Service to search text in the workspace files.
|
|
18
|
+
*/
|
|
19
|
+
export declare class SearchInWorkspaceService implements SearchInWorkspaceClient {
|
|
20
|
+
private pendingSearches;
|
|
21
|
+
private pendingOnDones;
|
|
22
|
+
private lastKnownSearchId;
|
|
23
|
+
protected readonly searchServer: SearchInWorkspaceServer;
|
|
24
|
+
protected readonly client: SearchInWorkspaceClientImpl;
|
|
25
|
+
protected readonly workspaceService: WorkspaceService;
|
|
26
|
+
protected readonly logger: ILogger;
|
|
27
|
+
protected init(): void;
|
|
28
|
+
isEnabled(): boolean;
|
|
29
|
+
onResult(searchId: number, result: SearchInWorkspaceResult): void;
|
|
30
|
+
onDone(searchId: number, error?: string): void;
|
|
31
|
+
search(what: string, callbacks: SearchInWorkspaceCallbacks, opts?: SearchInWorkspaceOptions): Promise<number>;
|
|
32
|
+
protected doSearch(what: string, rootsUris: string[], callbacks: SearchInWorkspaceCallbacks, opts?: SearchInWorkspaceOptions): Promise<number>;
|
|
33
|
+
searchWithCallback(what: string, rootsUris: string[], callbacks: SearchInWorkspaceClient, opts?: SearchInWorkspaceOptions | undefined): Promise<number>;
|
|
34
|
+
cancel(searchId: number): void;
|
|
35
|
+
}
|
|
36
36
|
//# sourceMappingURL=search-in-workspace-service.d.ts.map
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017-2018 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.SearchInWorkspaceService = exports.SearchInWorkspaceClientImpl = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const search_in_workspace_interface_1 = require("../common/search-in-workspace-interface");
|
|
30
|
-
const browser_1 = require("@theia/workspace/lib/browser");
|
|
31
|
-
const core_1 = require("@theia/core");
|
|
32
|
-
/**
|
|
33
|
-
* Class that will receive the search results from the server. This is separate
|
|
34
|
-
* from the SearchInWorkspaceService class only to avoid a cycle in the
|
|
35
|
-
* dependency injection.
|
|
36
|
-
*/
|
|
37
|
-
let SearchInWorkspaceClientImpl = class SearchInWorkspaceClientImpl {
|
|
38
|
-
onResult(searchId, result) {
|
|
39
|
-
this.service.onResult(searchId, result);
|
|
40
|
-
}
|
|
41
|
-
onDone(searchId, error) {
|
|
42
|
-
this.service.onDone(searchId, error);
|
|
43
|
-
}
|
|
44
|
-
setService(service) {
|
|
45
|
-
this.service = service;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
SearchInWorkspaceClientImpl = __decorate([
|
|
49
|
-
(0, inversify_1.injectable)()
|
|
50
|
-
], SearchInWorkspaceClientImpl);
|
|
51
|
-
exports.SearchInWorkspaceClientImpl = SearchInWorkspaceClientImpl;
|
|
52
|
-
/**
|
|
53
|
-
* Service to search text in the workspace files.
|
|
54
|
-
*/
|
|
55
|
-
let SearchInWorkspaceService = class SearchInWorkspaceService {
|
|
56
|
-
constructor() {
|
|
57
|
-
// All the searches that we have started, that are not done yet (onDone
|
|
58
|
-
// with that searchId has not been called).
|
|
59
|
-
this.pendingSearches = new Map();
|
|
60
|
-
// Due to the asynchronicity of the node backend, it's possible that we
|
|
61
|
-
// start a search, receive an event for that search, and then receive
|
|
62
|
-
// the search id for that search.We therefore need to keep those
|
|
63
|
-
// events until we get the search id and return it to the caller.
|
|
64
|
-
// Otherwise the caller would discard the event because it doesn't know
|
|
65
|
-
// the search id yet.
|
|
66
|
-
this.pendingOnDones = new Map();
|
|
67
|
-
this.lastKnownSearchId = -1;
|
|
68
|
-
}
|
|
69
|
-
init() {
|
|
70
|
-
this.client.setService(this);
|
|
71
|
-
}
|
|
72
|
-
isEnabled() {
|
|
73
|
-
return this.workspaceService.opened;
|
|
74
|
-
}
|
|
75
|
-
onResult(searchId, result) {
|
|
76
|
-
const callbacks = this.pendingSearches.get(searchId);
|
|
77
|
-
if (callbacks) {
|
|
78
|
-
callbacks.onResult(searchId, result);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
onDone(searchId, error) {
|
|
82
|
-
const callbacks = this.pendingSearches.get(searchId);
|
|
83
|
-
if (callbacks) {
|
|
84
|
-
this.pendingSearches.delete(searchId);
|
|
85
|
-
callbacks.onDone(searchId, error);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
if (searchId > this.lastKnownSearchId) {
|
|
89
|
-
this.logger.debug(`Got an onDone for a searchId we don't know about (${searchId}), stashing it for later with error = `, error);
|
|
90
|
-
this.pendingOnDones.set(searchId, error);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// It's possible to receive an onDone for a search we have cancelled. Just ignore it.
|
|
94
|
-
this.logger.debug(`Got an onDone for a searchId we don't know about (${searchId}), but it's probably an old one, error = `, error);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Start a search of the string "what" in the workspace.
|
|
99
|
-
async search(what, callbacks, opts) {
|
|
100
|
-
if (!this.workspaceService.opened) {
|
|
101
|
-
throw new Error('Search failed: no workspace root.');
|
|
102
|
-
}
|
|
103
|
-
const roots = await this.workspaceService.roots;
|
|
104
|
-
return this.doSearch(what, roots.map(r => r.resource.toString()), callbacks, opts);
|
|
105
|
-
}
|
|
106
|
-
async doSearch(what, rootsUris, callbacks, opts) {
|
|
107
|
-
const searchId = await this.searchServer.search(what, rootsUris, opts);
|
|
108
|
-
this.pendingSearches.set(searchId, callbacks);
|
|
109
|
-
this.lastKnownSearchId = searchId;
|
|
110
|
-
this.logger.debug('Service launched search ' + searchId);
|
|
111
|
-
// Check if we received an onDone before search() returned.
|
|
112
|
-
if (this.pendingOnDones.has(searchId)) {
|
|
113
|
-
this.logger.debug('Ohh, we have a stashed onDone for that searchId');
|
|
114
|
-
const error = this.pendingOnDones.get(searchId);
|
|
115
|
-
this.pendingOnDones.delete(searchId);
|
|
116
|
-
// Call the client's searchId, but first give it a
|
|
117
|
-
// chance to record the returned searchId.
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
this.onDone(searchId, error);
|
|
120
|
-
}, 0);
|
|
121
|
-
}
|
|
122
|
-
return searchId;
|
|
123
|
-
}
|
|
124
|
-
async searchWithCallback(what, rootsUris, callbacks, opts) {
|
|
125
|
-
return this.doSearch(what, rootsUris, callbacks, opts);
|
|
126
|
-
}
|
|
127
|
-
// Cancel an ongoing search.
|
|
128
|
-
cancel(searchId) {
|
|
129
|
-
this.pendingSearches.delete(searchId);
|
|
130
|
-
this.searchServer.cancel(searchId);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
__decorate([
|
|
134
|
-
(0, inversify_1.inject)(search_in_workspace_interface_1.SearchInWorkspaceServer),
|
|
135
|
-
__metadata("design:type", Object)
|
|
136
|
-
], SearchInWorkspaceService.prototype, "searchServer", void 0);
|
|
137
|
-
__decorate([
|
|
138
|
-
(0, inversify_1.inject)(SearchInWorkspaceClientImpl),
|
|
139
|
-
__metadata("design:type", SearchInWorkspaceClientImpl)
|
|
140
|
-
], SearchInWorkspaceService.prototype, "client", void 0);
|
|
141
|
-
__decorate([
|
|
142
|
-
(0, inversify_1.inject)(browser_1.WorkspaceService),
|
|
143
|
-
__metadata("design:type", browser_1.WorkspaceService)
|
|
144
|
-
], SearchInWorkspaceService.prototype, "workspaceService", void 0);
|
|
145
|
-
__decorate([
|
|
146
|
-
(0, inversify_1.inject)(core_1.ILogger),
|
|
147
|
-
__metadata("design:type", Object)
|
|
148
|
-
], SearchInWorkspaceService.prototype, "logger", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
(0, inversify_1.postConstruct)(),
|
|
151
|
-
__metadata("design:type", Function),
|
|
152
|
-
__metadata("design:paramtypes", []),
|
|
153
|
-
__metadata("design:returntype", void 0)
|
|
154
|
-
], SearchInWorkspaceService.prototype, "init", null);
|
|
155
|
-
SearchInWorkspaceService = __decorate([
|
|
156
|
-
(0, inversify_1.injectable)()
|
|
157
|
-
], SearchInWorkspaceService);
|
|
158
|
-
exports.SearchInWorkspaceService = SearchInWorkspaceService;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017-2018 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.SearchInWorkspaceService = exports.SearchInWorkspaceClientImpl = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const search_in_workspace_interface_1 = require("../common/search-in-workspace-interface");
|
|
30
|
+
const browser_1 = require("@theia/workspace/lib/browser");
|
|
31
|
+
const core_1 = require("@theia/core");
|
|
32
|
+
/**
|
|
33
|
+
* Class that will receive the search results from the server. This is separate
|
|
34
|
+
* from the SearchInWorkspaceService class only to avoid a cycle in the
|
|
35
|
+
* dependency injection.
|
|
36
|
+
*/
|
|
37
|
+
let SearchInWorkspaceClientImpl = class SearchInWorkspaceClientImpl {
|
|
38
|
+
onResult(searchId, result) {
|
|
39
|
+
this.service.onResult(searchId, result);
|
|
40
|
+
}
|
|
41
|
+
onDone(searchId, error) {
|
|
42
|
+
this.service.onDone(searchId, error);
|
|
43
|
+
}
|
|
44
|
+
setService(service) {
|
|
45
|
+
this.service = service;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
SearchInWorkspaceClientImpl = __decorate([
|
|
49
|
+
(0, inversify_1.injectable)()
|
|
50
|
+
], SearchInWorkspaceClientImpl);
|
|
51
|
+
exports.SearchInWorkspaceClientImpl = SearchInWorkspaceClientImpl;
|
|
52
|
+
/**
|
|
53
|
+
* Service to search text in the workspace files.
|
|
54
|
+
*/
|
|
55
|
+
let SearchInWorkspaceService = class SearchInWorkspaceService {
|
|
56
|
+
constructor() {
|
|
57
|
+
// All the searches that we have started, that are not done yet (onDone
|
|
58
|
+
// with that searchId has not been called).
|
|
59
|
+
this.pendingSearches = new Map();
|
|
60
|
+
// Due to the asynchronicity of the node backend, it's possible that we
|
|
61
|
+
// start a search, receive an event for that search, and then receive
|
|
62
|
+
// the search id for that search.We therefore need to keep those
|
|
63
|
+
// events until we get the search id and return it to the caller.
|
|
64
|
+
// Otherwise the caller would discard the event because it doesn't know
|
|
65
|
+
// the search id yet.
|
|
66
|
+
this.pendingOnDones = new Map();
|
|
67
|
+
this.lastKnownSearchId = -1;
|
|
68
|
+
}
|
|
69
|
+
init() {
|
|
70
|
+
this.client.setService(this);
|
|
71
|
+
}
|
|
72
|
+
isEnabled() {
|
|
73
|
+
return this.workspaceService.opened;
|
|
74
|
+
}
|
|
75
|
+
onResult(searchId, result) {
|
|
76
|
+
const callbacks = this.pendingSearches.get(searchId);
|
|
77
|
+
if (callbacks) {
|
|
78
|
+
callbacks.onResult(searchId, result);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
onDone(searchId, error) {
|
|
82
|
+
const callbacks = this.pendingSearches.get(searchId);
|
|
83
|
+
if (callbacks) {
|
|
84
|
+
this.pendingSearches.delete(searchId);
|
|
85
|
+
callbacks.onDone(searchId, error);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (searchId > this.lastKnownSearchId) {
|
|
89
|
+
this.logger.debug(`Got an onDone for a searchId we don't know about (${searchId}), stashing it for later with error = `, error);
|
|
90
|
+
this.pendingOnDones.set(searchId, error);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// It's possible to receive an onDone for a search we have cancelled. Just ignore it.
|
|
94
|
+
this.logger.debug(`Got an onDone for a searchId we don't know about (${searchId}), but it's probably an old one, error = `, error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Start a search of the string "what" in the workspace.
|
|
99
|
+
async search(what, callbacks, opts) {
|
|
100
|
+
if (!this.workspaceService.opened) {
|
|
101
|
+
throw new Error('Search failed: no workspace root.');
|
|
102
|
+
}
|
|
103
|
+
const roots = await this.workspaceService.roots;
|
|
104
|
+
return this.doSearch(what, roots.map(r => r.resource.toString()), callbacks, opts);
|
|
105
|
+
}
|
|
106
|
+
async doSearch(what, rootsUris, callbacks, opts) {
|
|
107
|
+
const searchId = await this.searchServer.search(what, rootsUris, opts);
|
|
108
|
+
this.pendingSearches.set(searchId, callbacks);
|
|
109
|
+
this.lastKnownSearchId = searchId;
|
|
110
|
+
this.logger.debug('Service launched search ' + searchId);
|
|
111
|
+
// Check if we received an onDone before search() returned.
|
|
112
|
+
if (this.pendingOnDones.has(searchId)) {
|
|
113
|
+
this.logger.debug('Ohh, we have a stashed onDone for that searchId');
|
|
114
|
+
const error = this.pendingOnDones.get(searchId);
|
|
115
|
+
this.pendingOnDones.delete(searchId);
|
|
116
|
+
// Call the client's searchId, but first give it a
|
|
117
|
+
// chance to record the returned searchId.
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
this.onDone(searchId, error);
|
|
120
|
+
}, 0);
|
|
121
|
+
}
|
|
122
|
+
return searchId;
|
|
123
|
+
}
|
|
124
|
+
async searchWithCallback(what, rootsUris, callbacks, opts) {
|
|
125
|
+
return this.doSearch(what, rootsUris, callbacks, opts);
|
|
126
|
+
}
|
|
127
|
+
// Cancel an ongoing search.
|
|
128
|
+
cancel(searchId) {
|
|
129
|
+
this.pendingSearches.delete(searchId);
|
|
130
|
+
this.searchServer.cancel(searchId);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, inversify_1.inject)(search_in_workspace_interface_1.SearchInWorkspaceServer),
|
|
135
|
+
__metadata("design:type", Object)
|
|
136
|
+
], SearchInWorkspaceService.prototype, "searchServer", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, inversify_1.inject)(SearchInWorkspaceClientImpl),
|
|
139
|
+
__metadata("design:type", SearchInWorkspaceClientImpl)
|
|
140
|
+
], SearchInWorkspaceService.prototype, "client", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
(0, inversify_1.inject)(browser_1.WorkspaceService),
|
|
143
|
+
__metadata("design:type", browser_1.WorkspaceService)
|
|
144
|
+
], SearchInWorkspaceService.prototype, "workspaceService", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, inversify_1.inject)(core_1.ILogger),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], SearchInWorkspaceService.prototype, "logger", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, inversify_1.postConstruct)(),
|
|
151
|
+
__metadata("design:type", Function),
|
|
152
|
+
__metadata("design:paramtypes", []),
|
|
153
|
+
__metadata("design:returntype", void 0)
|
|
154
|
+
], SearchInWorkspaceService.prototype, "init", null);
|
|
155
|
+
SearchInWorkspaceService = __decorate([
|
|
156
|
+
(0, inversify_1.injectable)()
|
|
157
|
+
], SearchInWorkspaceService);
|
|
158
|
+
exports.SearchInWorkspaceService = SearchInWorkspaceService;
|
|
159
159
|
//# sourceMappingURL=search-in-workspace-service.js.map
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Widget, Message, BaseWidget, StatefulWidget } from '@theia/core/lib/browser';
|
|
3
|
-
import { SearchInWorkspaceResultTreeWidget } from './search-in-workspace-result-tree-widget';
|
|
4
|
-
import { SearchInWorkspaceOptions } from '../common/search-in-workspace-interface';
|
|
5
|
-
import * as React from '@theia/core/shared/react';
|
|
6
|
-
import { Root } from '@theia/core/shared/react-dom/client';
|
|
7
|
-
import { Event, Emitter } from '@theia/core/lib/common';
|
|
8
|
-
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
9
|
-
import { SearchInWorkspaceContextKeyService } from './search-in-workspace-context-key-service';
|
|
10
|
-
import { CancellationTokenSource } from '@theia/core';
|
|
11
|
-
import { ProgressBarFactory } from '@theia/core/lib/browser/progress-bar-factory';
|
|
12
|
-
import { EditorManager } from '@theia/editor/lib/browser';
|
|
13
|
-
import { SearchInWorkspacePreferences } from './search-in-workspace-preferences';
|
|
14
|
-
export interface SearchFieldState {
|
|
15
|
-
className: string;
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
title: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidget {
|
|
20
|
-
static ID: string;
|
|
21
|
-
static LABEL: string;
|
|
22
|
-
protected matchCaseState: SearchFieldState;
|
|
23
|
-
protected wholeWordState: SearchFieldState;
|
|
24
|
-
protected regExpState: SearchFieldState;
|
|
25
|
-
protected includeIgnoredState: SearchFieldState;
|
|
26
|
-
protected showSearchDetails: boolean;
|
|
27
|
-
protected _hasResults: boolean;
|
|
28
|
-
protected get hasResults(): boolean;
|
|
29
|
-
protected set hasResults(hasResults: boolean);
|
|
30
|
-
protected resultNumber: number;
|
|
31
|
-
protected searchFieldContainerIsFocused: boolean;
|
|
32
|
-
protected searchInWorkspaceOptions: SearchInWorkspaceOptions;
|
|
33
|
-
protected searchTerm: string;
|
|
34
|
-
protected replaceTerm: string;
|
|
35
|
-
private searchRef;
|
|
36
|
-
private replaceRef;
|
|
37
|
-
private includeRef;
|
|
38
|
-
private excludeRef;
|
|
39
|
-
protected _showReplaceField: boolean;
|
|
40
|
-
protected get showReplaceField(): boolean;
|
|
41
|
-
protected set showReplaceField(showReplaceField: boolean);
|
|
42
|
-
protected contentNode: HTMLElement;
|
|
43
|
-
protected searchFormContainer: HTMLElement;
|
|
44
|
-
protected resultContainer: HTMLElement;
|
|
45
|
-
protected readonly onDidUpdateEmitter: Emitter<void>;
|
|
46
|
-
readonly onDidUpdate: Event<void>;
|
|
47
|
-
readonly resultTreeWidget: SearchInWorkspaceResultTreeWidget;
|
|
48
|
-
protected readonly workspaceService: WorkspaceService;
|
|
49
|
-
protected readonly contextKeyService: SearchInWorkspaceContextKeyService;
|
|
50
|
-
protected readonly progressBarFactory: ProgressBarFactory;
|
|
51
|
-
protected readonly editorManager: EditorManager;
|
|
52
|
-
protected readonly searchInWorkspacePreferences: SearchInWorkspacePreferences;
|
|
53
|
-
protected searchFormContainerRoot: Root;
|
|
54
|
-
protected init(): void;
|
|
55
|
-
storeState(): object;
|
|
56
|
-
restoreState(oldState: any): void;
|
|
57
|
-
findInFolder(uris: string[]): void;
|
|
58
|
-
/**
|
|
59
|
-
* Update the search term and input field.
|
|
60
|
-
* @param term the search term.
|
|
61
|
-
* @param showReplaceField controls if the replace field should be displayed.
|
|
62
|
-
*/
|
|
63
|
-
updateSearchTerm(term: string, showReplaceField?: boolean): void;
|
|
64
|
-
hasResultList(): boolean;
|
|
65
|
-
hasSearchTerm(): boolean;
|
|
66
|
-
refresh(): void;
|
|
67
|
-
getCancelIndicator(): CancellationTokenSource | undefined;
|
|
68
|
-
collapseAll(): void;
|
|
69
|
-
expandAll(): void;
|
|
70
|
-
areResultsCollapsed(): boolean;
|
|
71
|
-
clear(): void;
|
|
72
|
-
protected onAfterAttach(msg: Message): void;
|
|
73
|
-
protected onUpdateRequest(msg: Message): void;
|
|
74
|
-
protected onResize(msg: Widget.ResizeMessage): void;
|
|
75
|
-
protected onAfterShow(msg: Message): void;
|
|
76
|
-
protected onAfterHide(msg: Message): void;
|
|
77
|
-
protected onActivateRequest(msg: Message): void;
|
|
78
|
-
protected focusInputField(): void;
|
|
79
|
-
protected renderSearchHeader(): React.ReactNode;
|
|
80
|
-
protected renderSearchAndReplace(): React.ReactNode;
|
|
81
|
-
protected renderReplaceFieldToggle(): React.ReactNode;
|
|
82
|
-
protected renderNotification(): React.ReactNode;
|
|
83
|
-
protected readonly focusSearchFieldContainer: () => void;
|
|
84
|
-
protected doFocusSearchFieldContainer(): void;
|
|
85
|
-
protected readonly blurSearchFieldContainer: () => void;
|
|
86
|
-
protected doBlurSearchFieldContainer(): void;
|
|
87
|
-
private _searchTimeout;
|
|
88
|
-
protected readonly search: (e: React.KeyboardEvent) => void;
|
|
89
|
-
protected readonly onKeyDownSearch: (e: React.KeyboardEvent) => void;
|
|
90
|
-
protected doSearch(e: React.KeyboardEvent): void;
|
|
91
|
-
protected performSearch(): void;
|
|
92
|
-
protected shouldFollowSymlinks(): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Determine if search should be case sensitive.
|
|
95
|
-
*/
|
|
96
|
-
protected shouldMatchCase(): boolean;
|
|
97
|
-
protected renderSearchField(): React.ReactNode;
|
|
98
|
-
protected handleFocusSearchInputBox: () => void;
|
|
99
|
-
protected handleBlurSearchInputBox: () => void;
|
|
100
|
-
protected readonly updateReplaceTerm: (e: React.KeyboardEvent) => void;
|
|
101
|
-
protected doUpdateReplaceTerm(e: React.KeyboardEvent): void;
|
|
102
|
-
protected renderReplaceField(): React.ReactNode;
|
|
103
|
-
protected handleFocusReplaceInputBox: () => void;
|
|
104
|
-
protected handleBlurReplaceInputBox: () => void;
|
|
105
|
-
protected renderReplaceAllButtonContainer(): React.ReactNode;
|
|
106
|
-
protected renderOptionContainer(): React.ReactNode;
|
|
107
|
-
protected renderOptionElement(opt: SearchFieldState): React.ReactNode;
|
|
108
|
-
protected handleOptionClick(option: SearchFieldState): void;
|
|
109
|
-
protected updateSearchOptions(): void;
|
|
110
|
-
protected renderSearchDetails(): React.ReactNode;
|
|
111
|
-
protected renderGlobFieldContainer(): React.ReactNode;
|
|
112
|
-
protected renderExpandGlobFieldsButton(): React.ReactNode;
|
|
113
|
-
protected renderGlobField(kind: 'include' | 'exclude'): React.ReactNode;
|
|
114
|
-
protected handleFocusIncludesInputBox: () => void;
|
|
115
|
-
protected handleBlurIncludesInputBox: () => void;
|
|
116
|
-
protected handleFocusExcludesInputBox: () => void;
|
|
117
|
-
protected handleBlurExcludesInputBox: () => void;
|
|
118
|
-
protected splitOnComma(patterns: string): string[];
|
|
119
|
-
protected renderSearchInfo(): React.ReactNode;
|
|
120
|
-
protected getSearchResultMessage(): string | undefined;
|
|
121
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Widget, Message, BaseWidget, StatefulWidget } from '@theia/core/lib/browser';
|
|
3
|
+
import { SearchInWorkspaceResultTreeWidget } from './search-in-workspace-result-tree-widget';
|
|
4
|
+
import { SearchInWorkspaceOptions } from '../common/search-in-workspace-interface';
|
|
5
|
+
import * as React from '@theia/core/shared/react';
|
|
6
|
+
import { Root } from '@theia/core/shared/react-dom/client';
|
|
7
|
+
import { Event, Emitter } from '@theia/core/lib/common';
|
|
8
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
9
|
+
import { SearchInWorkspaceContextKeyService } from './search-in-workspace-context-key-service';
|
|
10
|
+
import { CancellationTokenSource } from '@theia/core';
|
|
11
|
+
import { ProgressBarFactory } from '@theia/core/lib/browser/progress-bar-factory';
|
|
12
|
+
import { EditorManager } from '@theia/editor/lib/browser';
|
|
13
|
+
import { SearchInWorkspacePreferences } from './search-in-workspace-preferences';
|
|
14
|
+
export interface SearchFieldState {
|
|
15
|
+
className: string;
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidget {
|
|
20
|
+
static ID: string;
|
|
21
|
+
static LABEL: string;
|
|
22
|
+
protected matchCaseState: SearchFieldState;
|
|
23
|
+
protected wholeWordState: SearchFieldState;
|
|
24
|
+
protected regExpState: SearchFieldState;
|
|
25
|
+
protected includeIgnoredState: SearchFieldState;
|
|
26
|
+
protected showSearchDetails: boolean;
|
|
27
|
+
protected _hasResults: boolean;
|
|
28
|
+
protected get hasResults(): boolean;
|
|
29
|
+
protected set hasResults(hasResults: boolean);
|
|
30
|
+
protected resultNumber: number;
|
|
31
|
+
protected searchFieldContainerIsFocused: boolean;
|
|
32
|
+
protected searchInWorkspaceOptions: SearchInWorkspaceOptions;
|
|
33
|
+
protected searchTerm: string;
|
|
34
|
+
protected replaceTerm: string;
|
|
35
|
+
private searchRef;
|
|
36
|
+
private replaceRef;
|
|
37
|
+
private includeRef;
|
|
38
|
+
private excludeRef;
|
|
39
|
+
protected _showReplaceField: boolean;
|
|
40
|
+
protected get showReplaceField(): boolean;
|
|
41
|
+
protected set showReplaceField(showReplaceField: boolean);
|
|
42
|
+
protected contentNode: HTMLElement;
|
|
43
|
+
protected searchFormContainer: HTMLElement;
|
|
44
|
+
protected resultContainer: HTMLElement;
|
|
45
|
+
protected readonly onDidUpdateEmitter: Emitter<void>;
|
|
46
|
+
readonly onDidUpdate: Event<void>;
|
|
47
|
+
readonly resultTreeWidget: SearchInWorkspaceResultTreeWidget;
|
|
48
|
+
protected readonly workspaceService: WorkspaceService;
|
|
49
|
+
protected readonly contextKeyService: SearchInWorkspaceContextKeyService;
|
|
50
|
+
protected readonly progressBarFactory: ProgressBarFactory;
|
|
51
|
+
protected readonly editorManager: EditorManager;
|
|
52
|
+
protected readonly searchInWorkspacePreferences: SearchInWorkspacePreferences;
|
|
53
|
+
protected searchFormContainerRoot: Root;
|
|
54
|
+
protected init(): void;
|
|
55
|
+
storeState(): object;
|
|
56
|
+
restoreState(oldState: any): void;
|
|
57
|
+
findInFolder(uris: string[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Update the search term and input field.
|
|
60
|
+
* @param term the search term.
|
|
61
|
+
* @param showReplaceField controls if the replace field should be displayed.
|
|
62
|
+
*/
|
|
63
|
+
updateSearchTerm(term: string, showReplaceField?: boolean): void;
|
|
64
|
+
hasResultList(): boolean;
|
|
65
|
+
hasSearchTerm(): boolean;
|
|
66
|
+
refresh(): void;
|
|
67
|
+
getCancelIndicator(): CancellationTokenSource | undefined;
|
|
68
|
+
collapseAll(): void;
|
|
69
|
+
expandAll(): void;
|
|
70
|
+
areResultsCollapsed(): boolean;
|
|
71
|
+
clear(): void;
|
|
72
|
+
protected onAfterAttach(msg: Message): void;
|
|
73
|
+
protected onUpdateRequest(msg: Message): void;
|
|
74
|
+
protected onResize(msg: Widget.ResizeMessage): void;
|
|
75
|
+
protected onAfterShow(msg: Message): void;
|
|
76
|
+
protected onAfterHide(msg: Message): void;
|
|
77
|
+
protected onActivateRequest(msg: Message): void;
|
|
78
|
+
protected focusInputField(): void;
|
|
79
|
+
protected renderSearchHeader(): React.ReactNode;
|
|
80
|
+
protected renderSearchAndReplace(): React.ReactNode;
|
|
81
|
+
protected renderReplaceFieldToggle(): React.ReactNode;
|
|
82
|
+
protected renderNotification(): React.ReactNode;
|
|
83
|
+
protected readonly focusSearchFieldContainer: () => void;
|
|
84
|
+
protected doFocusSearchFieldContainer(): void;
|
|
85
|
+
protected readonly blurSearchFieldContainer: () => void;
|
|
86
|
+
protected doBlurSearchFieldContainer(): void;
|
|
87
|
+
private _searchTimeout;
|
|
88
|
+
protected readonly search: (e: React.KeyboardEvent) => void;
|
|
89
|
+
protected readonly onKeyDownSearch: (e: React.KeyboardEvent) => void;
|
|
90
|
+
protected doSearch(e: React.KeyboardEvent): void;
|
|
91
|
+
protected performSearch(): void;
|
|
92
|
+
protected shouldFollowSymlinks(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Determine if search should be case sensitive.
|
|
95
|
+
*/
|
|
96
|
+
protected shouldMatchCase(): boolean;
|
|
97
|
+
protected renderSearchField(): React.ReactNode;
|
|
98
|
+
protected handleFocusSearchInputBox: () => void;
|
|
99
|
+
protected handleBlurSearchInputBox: () => void;
|
|
100
|
+
protected readonly updateReplaceTerm: (e: React.KeyboardEvent) => void;
|
|
101
|
+
protected doUpdateReplaceTerm(e: React.KeyboardEvent): void;
|
|
102
|
+
protected renderReplaceField(): React.ReactNode;
|
|
103
|
+
protected handleFocusReplaceInputBox: () => void;
|
|
104
|
+
protected handleBlurReplaceInputBox: () => void;
|
|
105
|
+
protected renderReplaceAllButtonContainer(): React.ReactNode;
|
|
106
|
+
protected renderOptionContainer(): React.ReactNode;
|
|
107
|
+
protected renderOptionElement(opt: SearchFieldState): React.ReactNode;
|
|
108
|
+
protected handleOptionClick(option: SearchFieldState): void;
|
|
109
|
+
protected updateSearchOptions(): void;
|
|
110
|
+
protected renderSearchDetails(): React.ReactNode;
|
|
111
|
+
protected renderGlobFieldContainer(): React.ReactNode;
|
|
112
|
+
protected renderExpandGlobFieldsButton(): React.ReactNode;
|
|
113
|
+
protected renderGlobField(kind: 'include' | 'exclude'): React.ReactNode;
|
|
114
|
+
protected handleFocusIncludesInputBox: () => void;
|
|
115
|
+
protected handleBlurIncludesInputBox: () => void;
|
|
116
|
+
protected handleFocusExcludesInputBox: () => void;
|
|
117
|
+
protected handleBlurExcludesInputBox: () => void;
|
|
118
|
+
protected splitOnComma(patterns: string): string[];
|
|
119
|
+
protected renderSearchInfo(): React.ReactNode;
|
|
120
|
+
protected getSearchResultMessage(): string | undefined;
|
|
121
|
+
}
|
|
122
122
|
//# sourceMappingURL=search-in-workspace-widget.d.ts.map
|