How to use the @theia/core/lib/node/file-uri.FileUri.create 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 / node / dugite-git.ts View on Github external
private async getContainerRepository(repositoryPath: string): Promise {
        // Do not log an error if we are not contained in a Git repository. Treat exit code 128 as a success too.
        const options = { successExitCodes: new Set([0, 128]) };
        const result = await git(['rev-parse', '--show-toplevel'], repositoryPath, 'rev-parse', options);
        const out = result.stdout;
        if (out && out.length !== 0) {
            const localUri = FileUri.create(out.trim()).toString();
            return { localUri };
        }
        return undefined;
    }
github eclipse-theia / theia / packages / git / src / node / dugite-git.spec.ts View on Github external
it('modifying a staged file should result in two changes', async () => {

            // Init repository.
            const root = await createTestRepository(track.mkdirSync('status-test'));
            const localUri = FileUri.create(root).toString();
            const repository = { localUri };
            const git = await createGit();

            // // Check status. Expect empty.
            let status = await git.status(repository);
            expect(status.changes).to.be.empty;

            // Modify a file.
            const filePath = path.join(root, 'A.txt');
            const fileUri = FileUri.create(filePath).toString();
            fs.writeFileSync(filePath, 'new content');
            expect(fs.readFileSync(filePath, { encoding: 'utf8' })).to.be.equal('new content');
            await git.add(repository, fileUri);

            // Check the status again. Expect one single change.
            status = await git.status(repository);
            expect(status.changes).to.be.have.lengthOf(1);
            expect(status.changes[0].uri).to.be.equal(fileUri);
            expect(status.changes[0].staged).to.be.true;

            // Change the same file again.
            fs.writeFileSync(filePath, 'yet another new content');
            expect(fs.readFileSync(filePath, { encoding: 'utf8' })).to.be.equal('yet another new content');

            // We expect two changes; one is staged, the other is in the working directory.
            status = await git.status(repository);
github eclipse-theia / theia / packages / search-in-workspace / src / node / ripgrep-search-in-workspace-server.slow-spec.ts View on Github external
function compareSearchResults(expected: SearchInWorkspaceResult[], actual: SearchInWorkspaceResult[]): void {
    expect(actual.length).eq(expected.length);

    if (actual.length !== expected.length) {
        return;
    }

    for (let i = 0; i < actual.length; i++) {
        const e = expected[i];
        const lines = fileLines.get(e.fileUri);
        if (lines) {
            const line = lines[e.line - 1];
            e.lineText = line;
            e.fileUri = FileUri.create(path.join(getRootPathFromName(e.fileUri), e.fileUri)).toString();

            const a = actual.find(l => l.fileUri === e.fileUri && l.line === e.line && l.character === e.character);
            expect(a).deep.eq(e);
        } else {
            // We don't know this file...
            expect.fail();
        }
    }
}
github eclipse-theia / theia / packages / preferences / src / node / json-preference-server.spec.ts View on Github external
before(() => {
    chai.should();
    chai.use(chaiAsPromised);
    chai.config.showDiff = true;
    chai.config.includeStack = true;

    const rootUri = FileUri.create(track.mkdirSync());
    preferenceFileUri = rootUri.resolve(preferencePath);
    prefServer = helper.createJsonPrefServer(preferenceFileUri);
    fs.mkdirSync(FileUri.fsPath(rootUri.resolve('.theia')));
    fs.writeFileSync(FileUri.fsPath(preferenceFileUri), '{ "showLineNumbers": false }');
});
github eclipse-theia / theia / packages / mini-browser / src / node / mini-browser-endpoint.ts View on Github external
protected getUri(request: Request): MaybePromise {
        const decodedPath = request.path.substr(MiniBrowserEndpoint.HANDLE_PATH.length);
        return new URI(FileUri.create(decodedPath).toString(true)).toString(true);
    }
github eclipse-theia / theia / packages / git / src / node / dugite-git.ts View on Github external
private getUri(path: string): string {
        return FileUri.create(path).toString();
    }
github eclipse-theia / theia / packages / search-in-workspace / src / node / ripgrep-search-in-workspace-server.slow-spec.ts View on Github external
before(() => {
    rootDirA = track.mkdirSync();
    rootDirB = track.mkdirSync();
    rootSubdirA = track.mkdirSync({ dir: rootDirA });
    rootDirAUri = FileUri.create(rootDirA).toString();
    rootDirBUri = FileUri.create(rootDirB).toString();
    rootSubdirAUri = FileUri.create(rootSubdirA).toString();

    createTestFile('carrots', `\
This is a carrot.
Most carrots are orange, but some carrots are not.
Once capitalized, the word carrot looks like this: CARROT.
Carrot is a funny word.
`);
    createTestFile('potatoes', `\
Potatoes, unlike carrots, are generally not orange.  But sweet potatoes are,
it's very confusing.
`);

    createTestFile('pastas', 'pasta pasta');

    createTestFile('regexes', `\
github eclipse-theia / theia / packages / search-in-workspace / src / node / ripgrep-search-in-workspace-server.slow-spec.ts View on Github external
before(() => {
    rootDirA = track.mkdirSync();
    rootDirB = track.mkdirSync();
    rootSubdirA = track.mkdirSync({ dir: rootDirA });
    rootDirAUri = FileUri.create(rootDirA).toString();
    rootDirBUri = FileUri.create(rootDirB).toString();
    rootSubdirAUri = FileUri.create(rootSubdirA).toString();

    createTestFile('carrots', `\
This is a carrot.
Most carrots are orange, but some carrots are not.
Once capitalized, the word carrot looks like this: CARROT.
Carrot is a funny word.
`);
    createTestFile('potatoes', `\
Potatoes, unlike carrots, are generally not orange.  But sweet potatoes are,
it's very confusing.
`);

    createTestFile('pastas', 'pasta pasta');
github eclipse-theia / theia / packages / plugin-ext / src / hosted / node / scanners / scanner-theia.ts View on Github external
protected readThemes(pck: PluginPackage): ThemeContribution[] | undefined {
        if (!pck.contributes || !pck.contributes.themes) {
            return undefined;
        }
        const result: ThemeContribution[] = [];
        for (const contribution of pck.contributes.themes) {
            if (contribution.path) {
                result.push({
                    id: contribution.id,
                    uri: FileUri.create(path.join(pck.packagePath, contribution.path)).toString(),
                    description: contribution.description,
                    label: contribution.label,
                    uiTheme: contribution.uiTheme
                });
            }
        }
        return result;
    }