How to use the @theia/core/lib/common/uri function in @theia/core

To help you get started, we’ve selected a few @theia/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / git / src / browser / history / git-history-widget.tsx View on Github external
protected openFile(change: GitFileChange, commitSha: string): void {
        const uri: URI = new URI(change.uri);
        let fromURI = change.oldUri ? new URI(change.oldUri) : uri; // set oldUri on renamed and copied
        fromURI = fromURI.withScheme(GIT_RESOURCE_SCHEME).withQuery(commitSha + '~1');
        const toURI = uri.withScheme(GIT_RESOURCE_SCHEME).withQuery(commitSha);
        let uriToOpen = uri;
        if (change.status === GitFileStatus.Deleted) {
            uriToOpen = fromURI;
        } else if (change.status === GitFileStatus.New) {
            uriToOpen = toURI;
        } else {
            uriToOpen = DiffUris.encode(fromURI, toURI);
        }
        open(this.openerService, uriToOpen, { mode: 'reveal' });
    }
}
github eclipse-theia / theia / packages / debug / src / browser / breakpoint / breakpoint-manager.ts View on Github external
enableAllBreakpoints(enabled: boolean): void {
        for (const uriString of this.getUris()) {
            let didChange = false;
            const uri = new URI(uriString);
            const markers = this.findMarkers({ uri });
            for (const marker of markers) {
                if (marker.data.enabled !== enabled) {
                    marker.data.enabled = enabled;
                    didChange = true;
                }
            }
            if (didChange) {
                this.fireOnDidChangeMarkers(uri);
            }
        }
    }
github eclipse-theia / theia / packages / scm / src / browser / scm-contribution.ts View on Github external
protected updateStatusBar(): void {
        this.statusBarDisposable.dispose();
        const repository = this.scmService.selectedRepository;
        if (!repository) {
            return;
        }
        const name = this.labelProvider.getName(new URI(repository.provider.rootUri));
        if (this.scmService.repositories.length > 1) {
            this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
                text: `$(database) ${name}`,
                tooltip: name.toString(),
                command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
                alignment: StatusBarAlignment.LEFT,
                priority: 100
            });
        }
        const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
        this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
            text: value.title,
            tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
            command: value.command,
            arguments: value.arguments,
            alignment: StatusBarAlignment.LEFT,
github eclipse-theia / theia / packages / debug / src / browser / debug-monaco-contribution.ts View on Github external
provideDocumentSymbols(model: monaco.editor.ITextModel): monaco.languages.DocumentSymbol[] {
        if (new URI(model.uri.toString()).path.base !== 'launch.json') {
            return [];
        }
        const children: monaco.languages.DocumentSymbol[] = [];
        const result: monaco.languages.DocumentSymbol = {
            name: 'Launch Configurations',
            detail: '',
            kind: monaco.languages.SymbolKind.Object,
            range: new monaco.Range(0, 0, 0, 0),
            selectionRange: new monaco.Range(0, 0, 0, 0),
            children
        };
        let name: string = '';
        let lastProperty = '';
        let startOffset = 0;
        let depthInObjects = 0;
github eclipse-theia / theia / packages / plugin-ext / src / main / browser / plugin-icon-theme-service.ts View on Github external
return;
        }
        this.styleSheetContent = '';
        this.toUnload.push(Disposable.create(() => {
            this.styleSheetContent = undefined;
            this.hasFileIcons = undefined;
            this.hasFolderIcons = undefined;
            this.hidesExplorerArrows = undefined;
            this.icons.clear();
        }));

        const { content } = await this.fileSystem.resolveContent(this.uri);
        const json: RecursivePartial = jsoncparser.parse(content, undefined, { disallowComments: false });
        this.hidesExplorerArrows = !!json.hidesExplorerArrows;

        const uri = new URI(this.uri);
        const toUnwatch = await this.fsWatcher.watchFileChanges(uri);
        if (this.toUnload.disposed) {
            toUnwatch.dispose();
        } else {
            this.toUnload.push(toUnwatch);
            this.toUnload.push(this.fsWatcher.onFilesChanged(e => {
                if (FileChangeEvent.isChanged(e, uri)) {
                    this.reload();
                }
            }));
        }

        const iconDefinitions = json.iconDefinitions;
        if (!iconDefinitions) {
            return;
        }
github eclipse-theia / theia / packages / git / src / browser / blame / blame-manager.ts View on Github external
isBlameable(uri: string): boolean {
        return !!this.repositoryTracker.getPath(new URI(uri));
    }
github eclipse-theia / theia / packages / git / src / browser / git-widget.tsx View on Github external
protected async updateView(status: WorkingDirectoryStatus | undefined) {
        const stagedChanges = [];
        const unstagedChanges = [];
        const mergeChanges = [];
        if (status) {
            for (const change of status.changes) {
                const uri = new URI(change.uri);
                const repository = this.repositoryProvider.selectedRepository;
                const [icon, label, description] = await Promise.all([
                    this.labelProvider.getIcon(uri),
                    this.labelProvider.getName(uri),
                    repository ? Repository.relativePath(repository, uri.parent).toString() : this.labelProvider.getLongName(uri.parent)
                ]);
                if (GitFileStatus[GitFileStatus.Conflicted.valueOf()] !== GitFileStatus[change.status]) {
                    if (change.staged) {
                        stagedChanges.push({
                            icon, label, description,
                            ...change
                        });
                    } else {
                        unstagedChanges.push({
                            icon, label, description,
                            ...change
github eclipse-theia / theia / packages / workspace / src / browser / workspace-commands.ts View on Github external
workspaceService.root.then(root => {
            if (root) {
                this.rootUri = new URI(root.uri);
            }
        });
    }
github eclipse-theia / theia / packages / git / src / browser / diff / git-diff-widget.tsx View on Github external
protected renderPath(): React.ReactNode {
        if (this.options.uri) {
            const path = this.gitLabelProvider.relativePath(this.options.uri);
            if (path.length > 0) {
                return '/' + path;
            } else {
                return this.labelProvider.getLongName(new URI(this.options.uri));
            }
        }
        return null;
    }
github eclipse-theia / theia / packages / filesystem / src / common / filesystem-utils.ts View on Github external
        const children = !parent.children ? [] : parent.children!.map(child => new URI(child.uri));