未验证 提交 14140d2a 编写于 作者: A Alex Dima

Revert "Merge pull request #109049 from digeff/searchView/context/extensionPoints"

This reverts commit a1bb5ac2, reversing
changes made to 9a08a107.
上级 31c03460
......@@ -62,7 +62,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { IExtHostDecorations } from 'vs/workbench/api/common/extHostDecorations';
import { IExtHostTask } from 'vs/workbench/api/common/extHostTask';
import { IExtHostDebugService } from 'vs/workbench/api/common/extHostDebugService';
import { ExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
import { IExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
import { ILogService } from 'vs/platform/log/common/log';
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
......@@ -123,11 +123,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostCommands = rpcProtocol.set(ExtHostContext.ExtHostCommands, accessor.get(IExtHostCommands));
const extHostTerminalService = rpcProtocol.set(ExtHostContext.ExtHostTerminalService, accessor.get(IExtHostTerminalService));
const extHostDebugService = rpcProtocol.set(ExtHostContext.ExtHostDebugService, accessor.get(IExtHostDebugService));
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, accessor.get(IExtHostSearch));
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, accessor.get(IExtHostTask));
const extHostOutputService = rpcProtocol.set(ExtHostContext.ExtHostOutputService, accessor.get(IExtHostOutputService));
// manually create and register addressable instances
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, new ExtHostSearch(rpcProtocol, uriTransformer, extHostLogService, extHostCommands));
const extHostUrls = rpcProtocol.set(ExtHostContext.ExtHostUrls, new ExtHostUrls(rpcProtocol));
const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors));
const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService));
......
......@@ -14,7 +14,6 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IRawFileQuery, ISearchCompleteStats, IFileQuery, IRawTextQuery, IRawQuery, ITextQuery, IFolderQuery } from 'vs/workbench/services/search/common/search';
import { URI, UriComponents } from 'vs/base/common/uri';
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
export interface IExtHostSearch extends ExtHostSearchShape {
registerTextSearchProvider(scheme: string, provider: vscode.TextSearchProvider): IDisposable;
......@@ -38,27 +37,8 @@ export class ExtHostSearch implements ExtHostSearchShape {
constructor(
@IExtHostRpcService private extHostRpc: IExtHostRpcService,
@IURITransformerService protected _uriTransformer: IURITransformerService,
@ILogService protected _logService: ILogService,
commands: ExtHostCommands,
) {
commands.registerArgumentProcessor({
processArgument: arg => {
if (arg && Array.isArray(arg)) {
return arg.map(matchContext => {
if (matchContext.$mid === 13 /* SearchViewContextMid */) {
const filteredProperties = { ...matchContext };
delete filteredProperties.renderableMatch;
return filteredProperties;
} else {
return matchContext;
}
});
} else {
return arg;
}
}
});
}
@ILogService protected _logService: ILogService
) { }
protected _transformScheme(scheme: string): string {
return this._uriTransformer.transformOutgoingScheme(scheme);
......
......@@ -176,11 +176,6 @@ const apiMenus: IAPIMenu[] = [
id: MenuId.TimelineItemContext,
description: localize('view.timelineContext', "The Timeline view item context menu")
},
{
key: 'search/context',
id: MenuId.SearchContext,
description: localize('menus.searchContext', "The search context menu")
},
];
namespace schema {
......
......@@ -19,7 +19,6 @@ import { ExtHostSearch, reviveQuery } from 'vs/workbench/api/common/extHostSearc
import { Schemas } from 'vs/base/common/network';
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
export class NativeExtHostSearch extends ExtHostSearch {
......@@ -33,9 +32,8 @@ export class NativeExtHostSearch extends ExtHostSearch {
@IExtHostInitDataService initData: IExtHostInitDataService,
@IURITransformerService _uriTransformer: IURITransformerService,
@ILogService _logService: ILogService,
commands: ExtHostCommands,
) {
super(extHostRpc, _uriTransformer, _logService, commands);
super(extHostRpc, _uriTransformer, _logService);
if (initData.remote.isRemote && initData.remote.authority) {
this._registerEHSearchProviders();
......
......@@ -15,7 +15,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { getSelectionKeyboardEvent, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { IFileMatchContext, IFolderMatchWithResourceContext, IRenderableMatchContext, SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import * as Constants from 'vs/workbench/contrib/search/common/constants';
import { IReplaceService } from 'vs/workbench/contrib/search/common/replace';
import { FolderMatch, FileMatch, FolderMatchWithResource, Match, RenderableMatch, searchMatchComparer, SearchResult } from 'vs/workbench/contrib/search/common/searchModel';
......@@ -776,8 +776,7 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
}
}
export const copyPathCommand: ICommandHandler = async (accessor, fileMatchArg: [IFileMatchContext | IFolderMatchWithResourceContext] | undefined) => {
let fileMatch = fileMatchArg ? fileMatchArg[0].renderableMatch : undefined; // For the time being we only support single-select
export const copyPathCommand: ICommandHandler = async (accessor, fileMatch: FileMatch | FolderMatchWithResource | undefined) => {
if (!fileMatch) {
const selection = getSelectedRow(accessor);
if (!(selection instanceof FileMatch || selection instanceof FolderMatchWithResource)) {
......@@ -853,8 +852,7 @@ function folderMatchToString(folderMatch: FolderMatchWithResource | FolderMatch,
}
const maxClipboardMatches = 1e4;
export const copyMatchCommand: ICommandHandler = async (accessor, matchArg: [IRenderableMatchContext] | undefined) => {
let match = matchArg ? matchArg[0].renderableMatch : undefined; // For the time being we only support single-select
export const copyMatchCommand: ICommandHandler = async (accessor, match: RenderableMatch | undefined) => {
if (!match) {
const selection = getSelectedRow(accessor);
if (!selection) {
......
......@@ -71,7 +71,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { searchDetailsIcon } from 'vs/workbench/contrib/search/browser/searchIcons';
import { Range } from 'vs/editor/common/core/range';
const $ = dom.$;
......@@ -86,90 +85,6 @@ export enum SearchViewPosition {
Panel
}
export type SearchViewContextMid = 13;
export const SearchViewContextMid = 13;
export interface IMatchContext {
/** Identifies which kind of match this is (text,file,folder) */
matchingKind: 'textMatch';
/** vscode id for this match */
id: string;
/** The text that was matched */
matchedText: string;
/** Text we would replace the matched text for, if we apply the match */
replacementText: string;
/** uri of the file were this match happened */
uri: URI;
/** location of where the matched text is inside the file */
matchRange: Range;
renderableMatch: Match;
$mid: SearchViewContextMid;
}
export interface IFileMatchContext {
/** Identifies which kind of match this is (text,file,folder) */
matchingKind: 'fileMatch';
/** uri of the file were all these matches happened */
uri: URI;
/** matches for this particular file */
matches: IMatchContext[];
renderableMatch: FileMatch;
$mid: SearchViewContextMid;
}
export interface IFolderMatchContext {
/** Identifies which kind of match this is (text,file,folder) */
matchingKind: 'folderMatch';
/** vscode id for this match */
id: string;
/** matches for this particular folder */
matches: IFileMatchContext[];
/** resource that might be associate with this match */
resource: URI | null;
renderableMatch: FolderMatch;
$mid: SearchViewContextMid;
}
export interface IFolderMatchWithResourceContext extends IFolderMatchContext {
resource: URI;
renderableMatch: FolderMatchWithResource;
}
export type IRenderableMatchContext = (IMatchContext | IFileMatchContext | IFolderMatchContext);
function toMatchContext(match: Match): IMatchContext {
return {
matchingKind: 'textMatch',
id: match.id(),
uri: URI.parse(match.parent().id()),
matchedText: match.fullMatchText(),
replacementText: match.replaceString,
matchRange: match.range(),
renderableMatch: match,
$mid: SearchViewContextMid
};
}
function toFileMatchContext(fileMatch: FileMatch): IFileMatchContext {
return {
matchingKind: 'fileMatch',
uri: URI.parse(fileMatch.id()),
matches: fileMatch.matches().map(toMatchContext),
renderableMatch: fileMatch,
$mid: SearchViewContextMid
};
}
function toFolderMatchContext<T extends IFolderMatchContext>(folderMatch: FolderMatch): T {
return {
matchingKind: 'folderMatch',
matches: folderMatch.matches().map(toFileMatchContext),
id: folderMatch.id(),
renderableMatch: folderMatch,
$mid: SearchViewContextMid
} as T;
}
const SEARCH_CANCELLED_MESSAGE = nls.localize('searchCanceled', "Search was canceled before any results could be found - ");
export class SearchView extends ViewPane {
......@@ -865,24 +780,13 @@ export class SearchView extends ViewPane {
e.browserEvent.preventDefault();
e.browserEvent.stopPropagation();
const match = e.element;
let context: IRenderableMatchContext | undefined = undefined;
if (match instanceof FileMatch) {
context = toFileMatchContext(match);
} else if (match instanceof Match) {
context = toMatchContext(match);
} else if (match instanceof FolderMatch) {
context = toFolderMatchContext(match);
context.resource = match.resource;
}
const actions: IAction[] = [];
const actionsDisposable = createAndFillInContextMenuActions(this.contextMenu, { shouldForwardArgs: true }, actions);
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor,
getActions: () => actions,
getActionsContext: () => [context],
getActionsContext: () => e.element,
onHide: () => dispose(actionsDisposable)
});
}
......
......@@ -158,10 +158,6 @@ export class Match {
getMatchString(): string {
return this._oneLinePreviewText.substring(this._rangeInPreviewText.startColumn - 1, this._rangeInPreviewText.endColumn - 1);
}
toJSON(): object {
return {}; // We send an IRenderableMatchContext to the extensions
}
}
export class FileMatch extends Disposable implements IFileMatch {
......@@ -449,10 +445,6 @@ export class FileMatch extends Disposable implements IFileMatch {
this._onDispose.fire();
super.dispose();
}
toJSON(): object {
return {}; // We send an IRenderableMatchContext to the extensions
}
}
export interface IChangeEvent {
......@@ -643,10 +635,6 @@ export class FolderMatch extends Disposable {
this._onDispose.fire();
super.dispose();
}
toJSON(): object {
return {}; // We send an IRenderableMatchContext to the extensions
}
}
/**
......
......@@ -23,7 +23,6 @@ import { mock } from 'vs/base/test/common/mock';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
let rpcProtocol: TestRPCProtocol;
let extHostSearch: NativeExtHostSearch;
......@@ -147,8 +146,7 @@ suite('ExtHostSearch', () => {
rpcProtocol,
new class extends mock<IExtHostInitDataService>() { remote = { isRemote: false, authority: undefined, connectionData: null }; },
new URITransformerService(null),
logService,
new ExtHostCommands(rpcProtocol, new NullLogService())
logService
);
this._pfs = mockPFS as any;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册