Example #1
0
	startProc(cmd) {
		if (!this.child) {
			this.output.show(vscode.ViewColumn.Three);
			this.output.clear();
			vscode.workspace.saveAll(false);
			this.buildButton.hide();
			this.startButton.hide();
			Promise.all([this.workspaced.getConfiguration(), this.workspaced.getBuildType()]).then(values => {
				let args = [cmd, "--config=" + values[0], "--build=" + values[1]];
				this.output.appendLine("> dub " + args.join(" "));
				this.child = ChildProcess.spawn("dub", args, { cwd: vscode.workspace.rootPath, detached: true });
				this.child.stderr.on("data", this.handleData.bind(this));
				this.child.stdout.on("data", this.handleData.bind(this));
				this.child.once("close", (code) => {
					code = (code || 0);
					if (code === 0)
						this.output.appendLine(cmd + " succeeded");
					else
						this.output.appendLine("dub stopped with error code " + code);
					this.handleStop();
				});
				this.child.once("error", (err) => {
					this.output.appendLine("dub crashed:");
					this.output.appendLine(err.toString());
					this.handleStop();
				});

				this.stopButton.show();
			});
		}
	}
Example #2
0
	/* internal */ populateService(): void {
		this.currentDiagnostics.clear();
		this.syntaxDiagnostics = Object.create(null);
		// See https://github.com/Microsoft/TypeScript/issues/5530
		workspace.saveAll(false).then((value) => {
			this.bufferSyncSupports.forEach(support => {
				support.reOpenDocuments();
				support.requestAllDiagnostics();
			});
		});
	}
Example #3
0
 const runSbtCommand = (args: string[], cwd?: string) => {
   workspace.saveAll().then(() => {
     if (!cwd) {
       // tslint:disable-next-line:no-parameter-reassignment
       cwd = workspace.rootPath;
     }
     if (typeof window.createTerminal === 'function') {
       runCommandInIntegratedTerminal(args, cwd);
     }
   });
 };
Example #4
0
function runNpmCommand(args: string[], cwd?: string): void {
	workspace.saveAll().then(() => {
		if (!cwd) {
			cwd = workspace.rootPath;
		}

		if (useTerminal()) {
			runCommandInTerminal(args, cwd);
		} else {
			runCommandInOutputWindow(args, cwd);
		}
	});
}
Example #5
0
function runNpmCommand(args: string[], cwd?: string, alwaysRunInputWindow = false): void {
	if (runSilent()) {
		args.push('--silent');
	}
	workspace.saveAll().then(() => {
		if (!cwd) {
			cwd = workspace.rootPath;
		}

		if (useTerminal() && !alwaysRunInputWindow) {
			if (typeof window.createTerminal === 'function') {
				runCommandInIntegratedTerminal(args, cwd);
			} else {
				runCommandInTerminal(args, cwd);
			}
		} else {
			outputChannel.clear();
			runCommandInOutputWindow(args, cwd);
		}
	});
}
    let disposable = vscode.commands.registerCommand('lövelauncher.launch', () => {
        if(currentInstances.length < maxInstances || overWrite){
            var path : string = vscode.workspace.getConfiguration('lövelauncher').get('path').toString();
            var useConsoleSubsystem = vscode.workspace.getConfiguration('lövelauncher').get('useConsoleSubsystem');
            var saveAllonLaunch = vscode.workspace.getConfiguration('lövelauncher').get('saveAllonLaunch');

            if (saveAllonLaunch){
                vscode.workspace.saveAll();
            }

            if (overWrite){
                currentInstances.forEach(function(instance){
                    if (instance != undefined){
                        instance.kill();
                    }
                });
            }

            if(!useConsoleSubsystem){
                var process = exec(path, [vscode.workspace.rootPath], function(err, data) {

                });
                process.on('exit', on_exit.bind(null,process));
                currentInstances[process.pid] = process;
            }else{
                var process = exec(path, [vscode.workspace.rootPath, "--console"], function (err, data) {

                });
                process.on('exit', on_exit.bind(null,process));
                currentInstances[process.pid] = process;
            }
        }else{
            vscode.window.showErrorMessage("You have reached your max concurrent Löve instances. You can change this setting in your config.");
        }

    });
Example #7
0
	/* internal */ populateService(): void {
		// See https://github.com/Microsoft/TypeScript/issues/5530
		workspace.saveAll(false).then((value) => {
			Object.keys(this.languagePerId).forEach(key => this.languagePerId[key].reInitialize());
		});
	}
Example #8
0
 async execute(): Promise<void> {
   // TODO : overwrite readonly files when bang? == true
   await vscode.workspace.saveAll(false);
 }
 public provideRenameEdits(document: vscode.TextDocument, position: vscode.Position, newName: string, token: vscode.CancellationToken): Thenable<vscode.WorkspaceEdit> {
     return vscode.workspace.saveAll(false).then(() => {
         return this.doRename(document, position, newName, token);
     });
 }
Example #10
0
export function activate(context: vscode.ExtensionContext) {

    let riolog = new RioLog();
    context.subscriptions.push(riolog);

    let preferences: Preferences[] = [];

    let workspaces = vscode.workspace.workspaceFolders;

    if (workspaces === undefined) {
        vscode.window.showErrorMessage('WPILib does not support single file');
        return;
    }

    for (let w of workspaces) {
        preferences.push(new Preferences(w));
    }

    context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(() => {
        // Nuke and restart
        for (let p of preferences) {
            p.dispose();
        }
        let wp = vscode.workspace.workspaceFolders;

        if (wp === undefined) {
            return;
        }

        for (let w of wp) {
            preferences.push(new Preferences(w));
        }
    }));

    context.subscriptions.push(...preferences);

    let extensionResourceLocation = path.join(context.extensionPath, 'resources');

    let tools = new Array<IToolRunner>();
    let codeDeployers = new Array<ICodeDeployer>();
    let codeDebuggers = new Array<ICodeDeployer>();
    let languageChoices = new Array<string>();

    let api : IExternalAPI = {
        async startRioLog(teamNumber: number) : Promise<void> {
            riolog.connect(teamNumber, path.join(extensionResourceLocation, 'riolog'));
        },
        async startTool(): Promise<void> {
            if (tools.length <= 0) {
                vscode.window.showErrorMessage('No tools found. Please install some');
                return;
            }

            let toolNames = new Array<string>();
            for (let t of tools) {
                toolNames.push(t.getDisplayName());
            }

            let result = await vscode.window.showQuickPick(toolNames, { placeHolder: 'Pick a tool'});

            if (result === undefined) {
                vscode.window.showInformationMessage('Tool run canceled');
                return;
            }

            for (let t of tools) {
                if (t.getDisplayName() === result) {
                    await t.runTool();
                    return;
                }
            }

            vscode.window.showErrorMessage('Invalid tool entered');
            return;
        },
        addTool(tool: IToolRunner): void {
            tools.push(tool);
        },
        async deployCode(workspace: vscode.WorkspaceFolder): Promise<boolean> {
            if (codeDeployers.length <= 0) {
                vscode.window.showErrorMessage('No registered deployers');
                return false;
            }

            let prefs = await this.getPreferences(workspace);

            let availableDeployers = new Array<ICodeDeployer>();
            for (let d of codeDeployers) {
                if (await d.getIsCurrentlyValid(workspace)) {
                    availableDeployers.push(d);
                }
            }

            if (availableDeployers.length <= 0) {
                vscode.window.showErrorMessage('No registered deployers');
                return false;
            } else if (availableDeployers.length === 1) {
                if (prefs.getAutoSaveOnDeploy()) {
                    vscode.workspace.saveAll();
                }
                let teamNumber = await prefs.getTeamNumber();
                let ret = await availableDeployers[0].runDeployer(teamNumber, workspace);
                if (prefs.getAutoStartRioLog() && ret) {
                    await this.startRioLog(teamNumber);
                }
                return ret;
            } else {
                let names = new Array<string>();
                for (let d of availableDeployers) {
                    names.push(d.getDisplayName());
                }
                let result = await vscode.window.showQuickPick(names, {placeHolder: 'Pick a deploy language'});
                if (result === undefined) {
                    await vscode.window.showInformationMessage('Deploy exited');
                    return false;
                }

                for (let d of availableDeployers) {
                    if (d.getDisplayName() === result) {
                        if (prefs.getAutoSaveOnDeploy()) {
                            vscode.workspace.saveAll();
                        }
                        let teamNumber = await prefs.getTeamNumber();
                        let ret = await d.runDeployer(teamNumber, workspace);
                        if (prefs.getAutoStartRioLog() && ret) {
                            await this.startRioLog(teamNumber);
                        }
                        return ret;
                    }
                }

                await vscode.window.showInformationMessage('Deploy exited');
                return false;
            }
        },
        registerCodeDeploy(deployer: ICodeDeployer): void {
            codeDeployers.push(deployer);
        },
        async debugCode(workspace: vscode.WorkspaceFolder): Promise<boolean> {
            if (codeDebuggers.length <= 0) {
                vscode.window.showErrorMessage('No registered debuggers');
                return false;
            }

            let availableDebuggers = new Array<ICodeDeployer>();
            for (let d of codeDebuggers) {
                if (await d.getIsCurrentlyValid(workspace)) {
                    availableDebuggers.push(d);
                }
            }

            if (availableDebuggers.length <= 0) {
                vscode.window.showErrorMessage('No registered debuggers');
                return false;
            } else if (availableDebuggers.length === 1) {
                let prefs = this.getPreferences(workspace);
                if (prefs.getAutoSaveOnDeploy()) {
                    vscode.workspace.saveAll();
                }
                await availableDebuggers[0].runDeployer(await prefs.getTeamNumber(), workspace);
            } else {
                let names = new Array<string>();
                for (let d of availableDebuggers) {
                    names.push(d.getDisplayName());
                }
                let result = await vscode.window.showQuickPick(names, { placeHolder: 'Pick a debug language'});
                if (result === undefined) {
                    await vscode.window.showInformationMessage('Debug exited');
                    return false;
                }

                for (let d of availableDebuggers) {
                    if (d.getDisplayName() === result) {
                        let prefs = this.getPreferences(workspace);
                        if (prefs.getAutoSaveOnDeploy()) {
                            vscode.workspace.saveAll();
                        }
                        return await d.runDeployer(await prefs.getTeamNumber(), workspace);
                    }
                }

                await vscode.window.showInformationMessage('Debug exited');
                return false;
            }
            return false;
        },
        registerCodeDebug(deployer: ICodeDeployer): void {
            codeDebuggers.push(deployer);
        },
        getApiVersion(): number {
            return 1;
        },
        getPreferences(workspace: vscode.WorkspaceFolder): IPreferences {
            for (let p of preferences) {
                if (p.workspace.uri === workspace.uri) {
                    return p;
                }
            }
            return preferences[0];
        },
        addLanguageChoice(language: string): void {
            languageChoices.push(language);
        },
        async requestLanguageChoice(): Promise<string> {
            if (languageChoices.length <= 0) {
                return '';
            }
            let result = await vscode.window.showQuickPick(languageChoices, { placeHolder: 'Pick a language' } );
            if (result === undefined) {
                return '';
            }
            return result;
        },
        async getFirstOrSelectedWorkspace(): Promise<vscode.WorkspaceFolder | undefined> {
            let wp = vscode.workspace.workspaceFolders;
            if (wp === undefined) {
                return;
            }
            let workspace = wp[0];
            if (wp.length > 1) {
                let res = await vscode.window.showWorkspaceFolderPick();
                if (res !== undefined) {
                    workspace = res;
                }
            }
            return workspace;
        }
    };

    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated
    console.log('Congratulations, your extension "vscode-wpilib-core" is now active!');

    context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.startRioLog', async () =>{
        let workspace = await api.getFirstOrSelectedWorkspace();
        if (workspace === undefined) {
            return;
        }
        await api.startRioLog(await api.getPreferences(workspace).getTeamNumber());
    }));

    context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.setTeamNumber', async () =>{
        let workspace = await api.getFirstOrSelectedWorkspace();
        if (workspace === undefined) {
            return;
        }
        await api.getPreferences(workspace).setTeamNumber(await requestTeamNumber());
    }));

    context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.startTool', async () =>{
        await api.startTool();
    }));

    context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.deployCode', async () =>{
        let workspace = await api.getFirstOrSelectedWorkspace();
        if (workspace === undefined) {
            return;
        }
        await api.deployCode(workspace);
    }));

    context.subscriptions.push(vscode.commands.registerCommand('wpilibcore.debugCode', async () =>{
        let workspace = await api.getFirstOrSelectedWorkspace();
        if (workspace === undefined) {
            return;
        }
        await api.debugCode(workspace);
    }));

    return api;
}
 public provideReferences(document: vscode.TextDocument, position: vscode.Position, options: { includeDeclaration: boolean; }, token: vscode.CancellationToken): Thenable<vscode.Location[]> {
     return vscode.workspace.saveAll(false).then(() => {
         return this.doFindReferences(document, position, options, token);
     });
 }