Skip to content

Commit

Permalink
testing: reduce /api imports
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Feb 4, 2022
1 parent 6c2f13a commit c1190e0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
14 changes: 3 additions & 11 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { SaveReason } from 'vs/workbench/common/editor';
import * as notebooks from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
import * as search from 'vs/workbench/contrib/search/common/search';
import { CoverageDetails, DetailType, ICoveredCount, IFileCoverage, ISerializedTestResults, ITestErrorMessage, ITestItem, ITestItemContext, ITestTag, SerializedTestErrorMessage, SerializedTestResultItem, TestMessageType } from 'vs/workbench/contrib/testing/common/testCollection';
import { CoverageDetails, denamespaceTestTag, DetailType, ICoveredCount, IFileCoverage, ISerializedTestResults, ITestErrorMessage, ITestItem, ITestItemContext, ITestTag, namespaceTestTag, SerializedTestErrorMessage, SerializedTestResultItem, TestMessageType } from 'vs/workbench/contrib/testing/common/testCollection';
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
Expand Down Expand Up @@ -1700,17 +1700,9 @@ export namespace TestMessage {
}

export namespace TestTag {
const enum Constants {
Delimiter = '\0',
}

export const namespace = (ctrlId: string, tagId: string) =>
ctrlId + Constants.Delimiter + tagId;
export const namespace = namespaceTestTag;

export const denamespace = (namespaced: string) => {
const index = namespaced.indexOf(Constants.Delimiter);
return { ctrlId: namespaced.slice(0, index), tagId: namespaced.slice(index + 1) };
};
export const denamespace = denamespaceTestTag;
}

export namespace TestItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
import { TestTag } from 'vs/workbench/api/common/extHostTypeConverters';
import { attachSuggestEnabledInputBoxStyler, ContextScopedSuggestEnabledInputWithHistory, SuggestEnabledInputWithHistory, SuggestResultsProvider } from 'vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput';
import { testingFilterIcon } from 'vs/workbench/contrib/testing/browser/icons';
import { Testing } from 'vs/workbench/contrib/testing/common/constants';
import { StoredValue } from 'vs/workbench/contrib/testing/common/storedValue';
import { denamespaceTestTag } from 'vs/workbench/contrib/testing/common/testCollection';
import { ITestExplorerFilterState, TestFilterTerm } from 'vs/workbench/contrib/testing/common/testExplorerFilterState';
import { ITestService } from 'vs/workbench/contrib/testing/common/testService';

Expand Down Expand Up @@ -74,7 +74,7 @@ export class TestingExplorerFilter extends BaseActionViewItem {
provideResults: () => [
...Object.entries(testFilterDescriptions).map(([label, detail]) => ({ label, detail })),
...Iterable.map(this.testService.collection.tags.values(), tag => {
const { ctrlId, tagId } = TestTag.denamespace(tag.id);
const { ctrlId, tagId } = denamespaceTestTag(tag.id);
const insertText = `@${ctrlId}:${tagId}`;
return ({
label: `@${ctrlId}:${tagId}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ProgressLocation, UnmanagedProgress } from 'vs/platform/progress/common/progress';
import { TestResultState } from 'vs/workbench/api/common/extHostTypes';
import { ViewContainerLocation } from 'vs/workbench/common/views';
import { AutoOpenTesting, getTestingConfiguration, TestingConfigKeys } from 'vs/workbench/contrib/testing/common/configuration';
import { Testing } from 'vs/workbench/contrib/testing/common/constants';
import { TestResultState } from 'vs/workbench/contrib/testing/common/testCollection';
import { isFailedState } from 'vs/workbench/contrib/testing/common/testingStates';
import { LiveTestResult, TestResultItemChangeReason, TestStateCount } from 'vs/workbench/contrib/testing/common/testResult';
import { ITestResultService } from 'vs/workbench/contrib/testing/common/testResultService';
Expand Down
16 changes: 13 additions & 3 deletions src/vs/workbench/contrib/testing/common/testCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MarshalledId } from 'vs/base/common/marshalling';
import { URI } from 'vs/base/common/uri';
import { IPosition } from 'vs/editor/common/core/position';
import { IRange, Range } from 'vs/editor/common/core/range';
import { ILocationDto } from 'vs/workbench/api/common/extHost.protocol';
import { Dto } from 'vs/workbench/services/extensions/common/proxyIdentifier';

export const enum TestResultState {
Unset = 0,
Expand Down Expand Up @@ -112,7 +112,7 @@ export interface ITestErrorMessage {
location: IRichLocation | undefined;
}

export type SerializedTestErrorMessage = Omit<ITestErrorMessage, 'location'> & { location?: ILocationDto };
export type SerializedTestErrorMessage = Omit<ITestErrorMessage, 'location'> & { location?: Dto<Location> };

export interface ITestOutputMessage {
message: string;
Expand All @@ -121,7 +121,7 @@ export interface ITestOutputMessage {
location: IRichLocation | undefined;
}

export type SerializedTestOutputMessage = Omit<ITestOutputMessage, 'location'> & { location?: ILocationDto };
export type SerializedTestOutputMessage = Omit<ITestOutputMessage, 'location'> & { location?: Dto<Location> };

export type SerializedTestMessage = SerializedTestErrorMessage | SerializedTestOutputMessage;

Expand All @@ -143,6 +143,16 @@ export interface ITestTag {
id: string;
}

const testTagDelimiter = '\0';

export const namespaceTestTag =
(ctrlId: string, tagId: string) => ctrlId + testTagDelimiter + tagId;

export const denamespaceTestTag = (namespaced: string) => {
const index = namespaced.indexOf(testTagDelimiter);
return { ctrlId: namespaced.slice(0, index), tagId: namespaced.slice(index + 1) };
};

export interface ITestTagDisplayInfo {
id: string;
ctrlLabel: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { Emitter, Event } from 'vs/base/common/event';
import { splitGlobAware } from 'vs/base/common/glob';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { TestTag } from 'vs/workbench/api/common/extHostTypeConverters';
import { IObservableValue, MutableObservableValue } from 'vs/workbench/contrib/testing/common/observableValue';
import { namespaceTestTag } from 'vs/workbench/contrib/testing/common/testCollection';

export interface ITestExplorerFilterState {
_serviceBrand: undefined;
Expand Down Expand Up @@ -134,9 +134,9 @@ export class TestExplorerFilterState implements ITestExplorerFilterState {
}

if (match[0].startsWith('!')) {
this.excludeTags.add(TestTag.namespace(match[1], tagId));
this.excludeTags.add(namespaceTestTag(match[1], tagId));
} else {
this.includeTags.add(TestTag.namespace(match[1], tagId));
this.includeTags.add(namespaceTestTag(match[1], tagId));
}
nextIndex++;
}
Expand Down

0 comments on commit c1190e0

Please sign in to comment.