Skip to content

Commit

Permalink
fix: module and function ref path
Browse files Browse the repository at this point in the history
  • Loading branch information
erha19 committed Apr 6, 2022
1 parent 9a30017 commit e6def14
Show file tree
Hide file tree
Showing 101 changed files with 405 additions and 223 deletions.
6 changes: 3 additions & 3 deletions packages/core-common/__tests__/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

import * as path from '../src/path';
import { Path } from '../src/path';
import { isWindows } from '../src/platform';
import { path, isWindows } from '@opensumi/ide-core-common';

const { Path } = path;

describe('Paths (Node Implementation)', () => {
test('join', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/core-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export * from './theme';
export * from './env';
export * from './credential';
export * from './cryptr';
export * from './markdown';
export * from '@opensumi/ide-utils';
4 changes: 3 additions & 1 deletion packages/debug/src/browser/debug-schema-updater.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Injectable, Autowired } from '@opensumi/di';
import { deepClone, IJSONSchema, IJSONSchemaRegistry } from '@opensumi/ide-core-browser';
import { objects, IJSONSchema, IJSONSchemaRegistry } from '@opensumi/ide-core-browser';

import { launchSchemaUri } from '../common';
import { DebugServer, IDebugServer } from '../common/debug-service';

import { DebugConfigurationManager } from './debug-configuration-manager';

const { deepClone } = objects;

@Injectable()
export class DebugSchemaUpdater {
@Autowired(IDebugServer)
Expand Down
4 changes: 3 additions & 1 deletion packages/debug/src/browser/debugUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { equalsIgnoreCase } from '@opensumi/ide-core-browser';
import { strings } from '@opensumi/ide-core-browser';

import { DebugConfiguration } from '../common';

const { equalsIgnoreCase } = strings;

export function isExtensionHostDebugging(config: DebugConfiguration) {
return (
config.type &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Injectable, Autowired } from '@opensumi/di';
import { CancellationTokenSource, coalesce, IRange } from '@opensumi/ide-core-common';
import { CancellationTokenSource, arrays, IRange } from '@opensumi/ide-core-common';
import { ITextModel } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';

import { IEvaluatableExpressionService } from './evaluatable-expression';

const { coalesce } = arrays;

@Injectable()
export class DebugExpressionProvider {
Expand All @@ -30,10 +31,10 @@ export class DebugExpressionProvider {

const results = await Promise.all(promises).then(coalesce);
if (results.length > 0) {
matchingExpression = results[0].expression;
rng = results[0].range;
matchingExpression = results[0]?.expression;
rng = results[0]?.range;

if (!matchingExpression) {
if (!matchingExpression && rng) {
const lineContent = model.getLineContent(pos.lineNumber);
matchingExpression = lineContent.substring(rng.startColumn - 1, rng.endColumn - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import {
WatchEvent,
TreeNodeEvent,
} from '@opensumi/ide-components';
import { Emitter, Deferred, Event, DisposableCollection } from '@opensumi/ide-core-browser';
import { Path } from '@opensumi/ide-core-common/lib/path';
import { Emitter, Deferred, Event, DisposableCollection, path } from '@opensumi/ide-core-browser';

import { DebugVariable, ExpressionContainer, ExpressionNode } from '../tree/debug-tree-node.define';
import styles from '../view/variables/debug-variables.module.less';

import { DebugHoverModel } from './debug-hover-model';
import { ExpressionVariable, DebugHoverSource } from './debug-hover-source';

const { Path } = path;

export interface IDebugVariablesHandle extends IRecycleTreeHandle {
hasDirectFocus: () => boolean;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@opensumi/di';
import { Emitter, Event } from '@opensumi/ide-core-browser';
import * as strings from '@opensumi/ide-core-common';
import { Emitter, Event, strings } from '@opensumi/ide-core-browser';

import { matchAll } from '../../debugUtils';

import { DebugConsoleFilterModel } from './debug-console-filter.model';

const Ansi = require('anser');
const { convertSimple2RegExpPattern } = strings;

export interface IDebugConsoleFilter {
filter: (t: string) => boolean;
Expand Down Expand Up @@ -60,7 +60,7 @@ export class DebugConsoleFilterService implements IDebugConsoleFilter {
}

public findMatches(text: string): IFilterMatches[] {
const regexp = new RegExp(strings.convertSimple2RegExpPattern(this._filterText.toLowerCase()), 'g');
const regexp = new RegExp(convertSimple2RegExpPattern(this._filterText.toLowerCase()), 'g');
if (this._filterText.trim() === '') {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
Event,
DisposableCollection,
IClipboardService,
path,
} from '@opensumi/ide-core-browser';
import { AbstractContextMenuService, MenuId, ICtxMenuRenderer } from '@opensumi/ide-core-browser/lib/menu/next';
import { Path } from '@opensumi/ide-core-common/lib/path';

import { IDebugSessionManager } from '../../../common';
import { LinkDetector } from '../../debug-link-detector';
Expand All @@ -40,7 +40,7 @@ import { DebugConsoleTreeModel } from './debug-console-model';
import { DebugConsoleSession } from './debug-console-session';
import styles from './debug-console.module.less';


const { Path } = path;
export interface IDebugConsoleHandle extends IRecycleTreeHandle {
hasDirectFocus: () => boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
IClipboardService,
IContextKey,
IReporterService,
path,
} from '@opensumi/ide-core-browser';
import { AbstractContextMenuService, MenuId, ICtxMenuRenderer } from '@opensumi/ide-core-browser/lib/menu/next';
import { Path } from '@opensumi/ide-core-common/lib/path';

import { DebugSessionManager } from '../../debug-session-manager';
import { DebugWatch } from '../../model';
Expand All @@ -40,6 +40,7 @@ import { DebugVariableContainer, DebugVariable } from './../../tree/debug-tree-n
import { DebugWatchModel } from './debug-watch-model';
import styles from './debug-watch.module.less';

const { Path } = path;

export interface IDebugWatchHandle extends IRecycleTreeHandle {
hasDirectFocus: () => boolean;
Expand Down
5 changes: 3 additions & 2 deletions packages/editor/src/browser/fs-resource/fs-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
IApplicationService,
} from '@opensumi/ide-core-browser';
import { LabelService } from '@opensumi/ide-core-browser/lib/services';
import { FileChangeType } from '@opensumi/ide-core-common';
import { Path } from '@opensumi/ide-core-common/lib/path';
import { FileChangeType, path } from '@opensumi/ide-core-common';
import { IFileServiceClient, FileStat } from '@opensumi/ide-file-service/lib/common';
import { IDialogService } from '@opensumi/ide-overlay';

Expand All @@ -22,6 +21,8 @@ import { IEditorDocumentModelService } from '../doc-model/types';

import { FileTreeSet } from './file-tree-set';

const { Path } = path;

enum AskSaveResult {
REVERT = 1,
SAVE = 2,
Expand Down
5 changes: 3 additions & 2 deletions packages/extension-storage/src/browser/storage-path.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Injectable, Autowired } from '@opensumi/di';
import { AppConfig } from '@opensumi/ide-core-browser';
import { isWindows, URI, Deferred, StoragePaths } from '@opensumi/ide-core-common';
import { isWindows, URI, Deferred, StoragePaths, path } from '@opensumi/ide-core-common';
import { IHashCalculateService } from '@opensumi/ide-core-common/lib/hash-calculate/hash-calculate';
import { Path } from '@opensumi/ide-core-common/lib/path';
import { IFileServiceClient, FileStat } from '@opensumi/ide-file-service';
import { ILoggerManagerClient } from '@opensumi/ide-logs';
import {
Expand All @@ -13,6 +12,8 @@ import {

import { IExtensionStoragePathServer } from '../common';

const { Path } = path;

@Injectable()
export class ExtensionStoragePathServer implements IExtensionStoragePathServer {
private windowsDataFolders = [StoragePaths.WINDOWS_APP_DATA_DIR, StoragePaths.WINDOWS_ROAMING_DIR];
Expand Down
14 changes: 12 additions & 2 deletions packages/extension-storage/src/browser/storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Injectable, Autowired } from '@opensumi/di';
import { Deferred, URI, ILogger, StoragePaths, ThrottledDelayer, Throttler, Uri } from '@opensumi/ide-core-common';
import { Path } from '@opensumi/ide-core-common/lib/path';
import {
Deferred,
URI,
ILogger,
StoragePaths,
ThrottledDelayer,
Throttler,
Uri,
path,
} from '@opensumi/ide-core-common';
import { IFileServiceClient, FileStat } from '@opensumi/ide-file-service';

import {
Expand All @@ -13,6 +21,8 @@ import {
IExtensionStorageTask,
} from '../common/';

const { Path } = path;

@Injectable()
export class ExtensionStorageServer implements IExtensionStorageServer {
private static readonly DEFAULT_FLUSH_DELAY = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
Terminal,
} from '../../../../src/hosted/api/vscode/ext.host.terminal';


const emitterA = new Emitter<any>();
const emitterB = new Emitter<any>();

Expand Down Expand Up @@ -87,7 +86,7 @@ describe(__filename, () => {
getDefaultSystemShell() {
return '/bin/sh';
},
getOs() {
getOS() {
return OperatingSystem.Macintosh;
},
detectAvailableProfiles() {
Expand Down
5 changes: 3 additions & 2 deletions packages/extension/src/browser/extension-worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Injectable, Autowired, INJECTOR_TOKEN, Injector } from '@opensumi/di';
import { warning } from '@opensumi/ide-components/lib/utils';
import { IRPCProtocol, RPCProtocol } from '@opensumi/ide-connection/lib/common/rpcProtocol';
import { AppConfig, Deferred, Emitter, IExtensionProps, ILogger, URI } from '@opensumi/ide-core-browser';
import { Disposable, IDisposable, toDisposable } from '@opensumi/ide-core-common';
import { posix } from '@opensumi/ide-core-common/lib/path';
import { Disposable, IDisposable, toDisposable, path } from '@opensumi/ide-core-common';

import { IExtension, IExtensionWorkerHost, WorkerHostAPIIdentifier } from '../common';
import { ActivatedExtensionJSON } from '../common/activator';
Expand All @@ -13,6 +12,8 @@ import { getWorkerBootstrapUrl } from './loader';
import { initWorkerThreadAPIProxy } from './vscode/api/main.thread.api.impl';
import { startInsideIframe } from './workerHostIframe';

const { posix } = path;

@Injectable()
export class WorkerExtProcessService
extends Disposable
Expand Down
4 changes: 3 additions & 1 deletion packages/extension/src/browser/sumi-browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injector } from '@opensumi/di';
import { IRPCProtocol } from '@opensumi/ide-connection';
import { URI, localize, getIcon, IReporterService, format } from '@opensumi/ide-core-browser';
import { URI, localize, getIcon, IReporterService, strings } from '@opensumi/ide-core-browser';
import { ResizeHandleHorizontal, ResizeHandleVertical } from '@opensumi/ide-core-browser/lib/components';
import { EditorComponentRenderMode } from '@opensumi/ide-editor/lib/browser';
import { Scroll } from '@opensumi/ide-editor/lib/browser/component/scroll/scroll';
Expand All @@ -13,6 +13,8 @@ import { IExtension } from '../../common';
import { createBrowserCommandsApiFactory } from './commands';
import { createBrowserComponents } from './components';

const { format } = strings;

/**
* Browser 尽量只export视图相关的少量API
* 设计API时遵循以下原则:
Expand Down
5 changes: 2 additions & 3 deletions packages/extension/src/browser/sumi-browser/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ProxyIdentifier } from '@opensumi/ide-connection/lib/common/rpcProtocol';
import { IDisposable, Uri } from '@opensumi/ide-core-common';
import { Path } from '@opensumi/ide-core-common/lib/path';
import { IDisposable, Uri, path } from '@opensumi/ide-core-common';
import { EditorComponentRenderMode } from '@opensumi/ide-editor/lib/browser';
import { ToolBarPosition } from '@opensumi/ide-toolbar/lib/browser';
import { ContextKeyExpr } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -147,7 +146,7 @@ export interface IEditorViewContribution {
* 判断一个path是否要被处理
* @deprecated
*/
shouldPreview?: (path: Path) => boolean;
shouldPreview?: (path: path.Path) => boolean;

/**
* 判断一个uri是否要被处理(传入参数为vscode uri)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Injectable, Autowired, Optional } from '@opensumi/di';
import { IRPCProtocol } from '@opensumi/ide-connection';
import { CommandRegistry, ILogger, IContextKeyService, IDisposable } from '@opensumi/ide-core-browser';
import { URI, isNonEmptyArray, Disposable, IExtensionInfo } from '@opensumi/ide-core-common';
import { URI, arrays, Disposable, IExtensionInfo } from '@opensumi/ide-core-common';
import { ICommandServiceToken, IMonacoCommandService } from '@opensumi/ide-monaco/lib/browser/contrib/command';

import { ExtHostAPIIdentifier, IMainThreadCommands, IExtHostCommands, ArgumentProcessor } from '../../../common/vscode';

const { isNonEmptyArray } = arrays;

export interface IExtCommandHandler extends IDisposable {
execute: (...args: any[]) => Promise<any>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
MarkerManager,
REPORT_NAME,
URI,
path,
} from '@opensumi/ide-core-common';
import { extname } from '@opensumi/ide-core-common/lib/path';
import { IEvaluatableExpressionService } from '@opensumi/ide-debug/lib/browser/editor/evaluatable-expression';
import { InlineValuesProviderRegistry } from '@opensumi/ide-debug/lib/browser/editor/inline-values';
import { InlineValueContext, InlineValuesProvider, InlineValue } from '@opensumi/ide-debug/lib/common/inline-values';
Expand Down Expand Up @@ -70,6 +70,8 @@ import {
DocumentSemanticTokensProvider,
} from './semantic-tokens/semantic-token-provider';

const { extname } = path;

@Injectable({ multiple: true })
export class MainThreadLanguages implements IMainThreadLanguages {
private readonly proxy: IExtHostLanguages;
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/src/browser/vscode/api/main.thread.scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
IDisposable,
Disposable,
CancellationToken,
Sequence,
ISplice,
} from '@opensumi/ide-core-common';
import { Sequence, ISplice } from '@opensumi/ide-core-common/lib/sequence';
import {
ISCMRepository,
ISCMProvider,
Expand All @@ -31,7 +32,6 @@ import {
IMainThreadSCMShape,
} from '../../../common/vscode/scm';


class MainThreadSCMResourceGroup implements ISCMResourceGroup {
readonly elements: ISCMResource[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React = require('react');

import { Injectable, Autowired } from '@opensumi/di';
import { useInjectable, IEventBus } from '@opensumi/ide-core-browser';
import { CancellationTokenSource, Disposable, ILogger } from '@opensumi/ide-core-common';
import { CancellationTokenSource, Disposable, ILogger, match } from '@opensumi/ide-core-common';
import { EditorComponentRegistry, ReactEditorComponent } from '@opensumi/ide-editor/lib/browser';
import { IWebviewService } from '@opensumi/ide-webview';
import { WebviewMounter } from '@opensumi/ide-webview/lib/browser/editor-webview';
Expand All @@ -18,7 +18,6 @@ import {
CustomEditorShouldRevertEvent,
CustomEditorShouldEditEvent,
} from '../../../common/vscode/custom-editor';
import { match } from '../../../common/vscode/glob';
import { IActivationEventService } from '../../types';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Injectable, Autowired } from '@opensumi/di';
import { replaceLocalizePlaceholder } from '@opensumi/ide-core-browser';
import { IJSONSchema, IJSONSchemaSnippet, deepClone, localize, IJSONSchemaMap } from '@opensumi/ide-core-common';
import { IJSONSchema, IJSONSchemaSnippet, objects, localize, IJSONSchemaMap } from '@opensumi/ide-core-common';
import { IDebugService, IDebuggerContribution } from '@opensumi/ide-debug';
import { DebugConfigurationManager, DebugSchemaUpdater } from '@opensumi/ide-debug/lib/browser';

import { VSCodeContributePoint, Contributes } from '../../../common';

const { deepClone } = objects;

const INTERNAL_CONSOLE_OPTIONS_SCHEMA = {
enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'],
default: 'openOnFirstSessionStart',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
PreferenceService,
parseWithComments,
getLanguageId,
path,
} from '@opensumi/ide-core-browser';
import { Path } from '@opensumi/ide-core-common/lib/path';
import { IExtensionStoragePathServer } from '@opensumi/ide-extension-storage';
import { IFileServiceClient } from '@opensumi/ide-file-service/lib/common';

Expand All @@ -19,6 +19,8 @@ import {
} from '../../../common';
import { AbstractExtInstanceManagementService } from '../../types';

const { Path } = path;

export interface TranslationFormat {
id: string;
path: string;
Expand Down
Loading

0 comments on commit e6def14

Please sign in to comment.