Commit 65ab1c00 authored by Timon Stampfli's avatar Timon Stampfli

removing distracting startup messages

parent a21ea039
Pipeline #5635 passed with stages
in 1 minute and 14 seconds
......@@ -24,18 +24,6 @@
"js-tokens": "^4.0.0"
}
},
"@sgarciac/bombadil": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/@sgarciac/bombadil/-/bombadil-0.0.7.tgz",
"integrity": "sha1-/9lSGfg2XQFNwq84ED/Dn9KP8zY=",
"requires": {
"chevrotain": "^0.28.3",
"lodash.every": "^4.6.0",
"lodash.includes": "^4.3.0",
"lodash.last": "^3.0.0",
"moment": "^2.18.1"
}
},
"@types/events": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
......@@ -892,11 +880,6 @@
"parse5": "^3.0.1"
}
},
"chevrotain": {
"version": "0.28.3",
"resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-0.28.3.tgz",
"integrity": "sha1-nj7WCkzduPPPjvlNm8aYs/W5fcM="
},
"chokidar": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
......@@ -3393,21 +3376,6 @@
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true
},
"lodash.every": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.every/-/lodash.every-4.6.0.tgz",
"integrity": "sha1-64mYS+vENkJ5uzrvu9HKGb+mxqc="
},
"lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8="
},
"lodash.last": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/lodash.last/-/lodash.last-3.0.0.tgz",
"integrity": "sha1-JC9mMRLdTG5jcoxgo8kJ0b2tvUw="
},
"log-symbols": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz",
......@@ -3703,11 +3671,6 @@
}
}
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
......
......@@ -285,7 +285,6 @@
},
"dependencies": {
"fs-extra": "^7.0.0",
"@sgarciac/bombadil": "0.0.7",
"node-fetch": "^2.1.2",
"request-light": "^0.2.2",
"vscode-json-languageservice": "^3.1.0",
......
{
"properties": {
"foo": { "type": "string" },
"bar": { "type": "number", "maximum": 3 }
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString, CompletionItemKind, CompletionItem } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let globProperties: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('assocLabelFile', "Files with Extension"), insertText: '"*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionFile', "Map all files matching the glob pattern in their filename to the language with the given identifier.") },
{ kind: CompletionItemKind.Value, label: localize('assocLabelPath', "Files with Path"), insertText: '"/{{path to file}}/*.{{extension}}": "{{language}}"', documentation: localize('assocDescriptionPath', "Map all files matching the absolute path glob pattern in their path to the language with the given identifier.") }
];
export class FileAssociationContribution implements JSONWorkerContribution {
private languageIds: string[] = [];
constructor() {
}
public setLanguageIds(ids: string[]): void {
this.languageIds = ids;
}
private isSettingsFile(resource: string): boolean {
return Strings.endsWith(resource, '/settings.json');
}
public async collectDefaultCompletions(resource: string, result: CompletionsCollector): Promise<any> {
return null;
}
public async collectPropertyCompletions(resource: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Promise<any> {
if (this.isSettingsFile(resource) && location.length === 1 && location[0] === 'files.associations') {
globProperties.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
return null;
}
public async collectValueCompletions(resource: string, location: JSONPath, currentKey: string, result: CompletionsCollector): Promise<any> {
if (this.isSettingsFile(resource) && location.length === 1 && location[0] === 'files.associations') {
this.languageIds.forEach(l => {
result.add({
kind: CompletionItemKind.Value,
label: l,
insertText: JSON.stringify('{{' + l + '}}'),
filterText: JSON.stringify(l)
});
});
}
return null;
}
public async getInfoContribution(resource: string, location: JSONPath): Promise<MarkedString[]> {
return [];
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { MarkedString, CompletionItemKind, CompletionItem } from 'vscode-languageserver';
import Strings = require('../utils/strings');
import { JSONWorkerContribution, JSONPath, CompletionsCollector } from 'vscode-json-languageservice';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
let globProperties: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('fileLabel', "Files by Extension"), insertText: '"**/*.{{extension}}": true', documentation: localize('fileDescription', "Match all files of a specific file extension.") },
{ kind: CompletionItemKind.Value, label: localize('filesLabel', "Files with Multiple Extensions"), insertText: '"**/*.{ext1,ext2,ext3}": true', documentation: localize('filesDescription', "Match all files with any of the file extensions.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: '"**/*.{{source-extension}}": { "when": "$(basename).{{target-extension}}" }', documentation: localize('derivedDescription', "Match files that have siblings with the same name but a different extension.") },
{ kind: CompletionItemKind.Value, label: localize('topFolderLabel', "Folder by Name (Top Level)"), insertText: '"{{name}}": true', documentation: localize('topFolderDescription', "Match a top level folder with a specific name.") },
{ kind: CompletionItemKind.Value, label: localize('topFoldersLabel', "Folders with Multiple Names (Top Level)"), insertText: '"{folder1,folder2,folder3}": true', documentation: localize('topFoldersDescription', "Match multiple top level folders.") },
{ kind: CompletionItemKind.Value, label: localize('folderLabel', "Folder by Name (Any Location)"), insertText: '"**/{{name}}": true', documentation: localize('folderDescription', "Match a folder with a specific name in any location.") },
];
let globValues: CompletionItem[] = [
{ kind: CompletionItemKind.Value, label: localize('trueLabel', "true"), insertText: 'true', documentation: localize('trueDescription', "Enable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('falseLabel', "false"), insertText: 'false', documentation: localize('falseDescription', "Disable the pattern.") },
{ kind: CompletionItemKind.Value, label: localize('derivedLabel', "Files with Siblings by Name"), insertText: '{ "when": "$(basename).{{extension}}" }', documentation: localize('siblingsDescription', "Match files that have siblings with the same name but a different extension.") }
];
export class GlobPatternContribution implements JSONWorkerContribution {
constructor() {
}
private isSettingsFile(resource: string): boolean {
return Strings.endsWith(resource, '/settings.json');
}
public async collectDefaultCompletions(resource: string, result: CompletionsCollector): Promise<any> {
return null;
}
public async collectPropertyCompletions(resource: string, location: JSONPath, currentWord: string, addValue: boolean, isLast: boolean, result: CompletionsCollector): Promise<any> {
if (this.isSettingsFile(resource) && location.length === 1 && ((location[0] === 'files.exclude') || (location[0] === 'search.exclude'))) {
globProperties.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
return null;
}
public async collectValueCompletions(resource: string, location: JSONPath, currentKey: string, result: CompletionsCollector): Promise<any> {
if (this.isSettingsFile(resource) && location.length === 1 && ((location[0] === 'files.exclude') || (location[0] === 'search.exclude'))) {
globValues.forEach(e => {
e.filterText = e.insertText;
result.add(e);
});
}
return null;
}
public async getInfoContribution(resource: string, location: JSONPath): Promise<MarkedString[]> {
return [];
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TextDocument } from 'vscode-languageserver';
export interface LanguageModelCache<T> {
get(document: TextDocument): T;
onDocumentRemoved(document: TextDocument): void;
dispose(): void;
}
export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T): LanguageModelCache<T> {
let languageModels: { [uri: string]: { version: number, languageId: string, cTime: number, languageModel: T } } = {};
let nModels = 0;
let cleanupInterval: NodeJS.Timeout | undefined = void 0;
if (cleanupIntervalTimeInSec > 0) {
cleanupInterval = setInterval(() => {
let cutoffTime = Date.now() - cleanupIntervalTimeInSec * 1000;
let uris = Object.keys(languageModels);
for (let uri of uris) {
let languageModelInfo = languageModels[uri];
if (languageModelInfo.cTime < cutoffTime) {
delete languageModels[uri];
nModels--;
}
}
}, cleanupIntervalTimeInSec * 1000);
}
return {
get(document: TextDocument): T {
let version = document.version;
let languageId = document.languageId;
let languageModelInfo = languageModels[document.uri];
if (languageModelInfo && languageModelInfo.version === version && languageModelInfo.languageId === languageId) {
languageModelInfo.cTime = Date.now();
return languageModelInfo.languageModel;
}
let languageModel = parse(document);
languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now() };
if (!languageModelInfo) {
nModels++;
}
if (nModels === maxEntries) {
let oldestTime = Number.MAX_VALUE;
let oldestUri = null;
for (let uri in languageModels) {
let languageModelInfo = languageModels[uri];
if (languageModelInfo.cTime < oldestTime) {
oldestUri = uri;
oldestTime = languageModelInfo.cTime;
}
}
if (oldestUri) {
delete languageModels[oldestUri];
nModels--;
}
}
return languageModel;
},
onDocumentRemoved(document: TextDocument) {
let uri = document.uri;
if (languageModels[uri]) {
delete languageModels[uri];
nModels--;
}
},
dispose() {
if (typeof cleanupInterval !== 'undefined') {
clearInterval(cleanupInterval);
cleanupInterval = void 0;
languageModels = {};
nModels = 0;
}
}
};
}
\ No newline at end of file
This diff is collapsed.
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
export function startsWith(haystack: string, needle: string): boolean {
if (haystack.length < needle.length) {
return false;
}
for (let i = 0; i < needle.length; i++) {
if (haystack[i] !== needle[i]) {
return false;
}
}
return true;
}
/**
* Determines if haystack ends with needle.
*/
export function endsWith(haystack: string, needle: string): boolean {
let diff = haystack.length - needle.length;
if (diff > 0) {
return haystack.lastIndexOf(needle) === diff;
} else if (diff === 0) {
return haystack === needle;
} else {
return false;
}
}
export function convertSimple2RegExpPattern(pattern: string): string {
return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
}
This diff is collapsed.
"use strict";
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as path from "path";
import * as vscode from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind
} from "vscode-languageclient";
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
// The server is implemented in node
let serverModule = context.asAbsolutePath(
path.join("dist", "better-stoml", "server", "tomlServerMain.js")
);
// The debug options for the server
let debugOptions = { execArgv: ["--nolazy", "--inspect=6004"] };
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions
}
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: ["stoml"],
synchronize: {
// Synchronize the setting section 'toml' and 'http' to the server
configurationSection: [
"stoml.schemas",
"http.proxy",
"http.proxyStrictSSL"
],
// Notify the server about file changes to '.toml files contain in the workspace
fileEvents: vscode.workspace.createFileSystemWatcher("**/*.soitask")
}
};
// Create the language client and start the client.
let disposable = new LanguageClient(
"STOML Language Server",
serverOptions,
clientOptions
).start();
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
export function deactivate() {}
declare module "ct" {
export interface IRecognizerContext {
/**
* A copy of the parser's rule stack at the "time" the RecognitionException occurred.
* This can be used to help debug parsing errors (How did we get here?).
*/
ruleStack: string[]
/**
* A copy of the parser's rule occurrence stack at the "time" the RecognitionException occurred.
* This can be used to help debug parsing errors (How did we get here?).
*/
ruleOccurrenceStack: number[]
}
export interface IRecognitionException {
name: string
message: string
/**
* The token which caused the parser error.
*/
token: Token
/**
* Additional tokens which have been re-synced in error recovery due to the original error.
* This information can be used the calculate the whole text area which has been skipped due to an error.
* For example for displaying with a red underline in a text editor.
*/
resyncedTokens: Token[]
context: IRecognizerContext
}
export interface ILexingError {
offset: number
line: number
column: number
length: number
message: string
}
export interface Token {
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ import {
import { Runner } from "./runner";
import { Store } from "./store";
import { activate as activate_stoml } from "./better-stoml/src/extension";
import { HelperBinaryResultReceiver } from "./helperBinaryResultReceiver";
import { gotoSample } from "./sample";
import { downloadCompilerBundle } from "./helperBinary";
......@@ -123,8 +122,6 @@ export async function activate(context: vscode.ExtensionContext) {
store.emitFsChange();
activate_stoml(context);
// await downloadHelperBinary(store);
await downloadCompilerBundle(store);
......
......@@ -22,30 +22,7 @@ export const emptyWorkspaceState: WorkspaceState = "NoFolderOpen";
async function determineWorkspaceFolder(): Promise<string | null> {
let dirs = vscode.workspace.workspaceFolders;
if (dirs === undefined || dirs.length <= 0) {
let response = await vscode.window.showErrorMessage(
"There needs to be a open workspace",
"Open folder",
"Cancel"
);
if (response === "Open folder") {
await vscode.commands.executeCommand(
"workbench.action.files.openLocalFolder"
);
}
return null;
}
if (dirs.length > 1) {
let response = await vscode.window.showErrorMessage(
"Multiroot workspaces are not supported",
"Open one folder",
"Cancel"
);
if (response === "Open one folder") {
await vscode.commands.executeCommand(
"workbench.action.files.openLocalFolder"
);
}
if (dirs === undefined || dirs.length <= 0 || dirs.length > 1) {
return null;
}
return dirs[0].uri.fsPath;
......@@ -56,40 +33,17 @@ async function determineWorkspaceSettingsFileContent(
workspace: string
): Promise<string | null> {
let workspaceSettings = await vscode.workspace.findFiles("soiworkspace.json");
if (
workspaceSettings.length >= 2 ||
workspaceSettings.length < 0 ||
workspaceSettings.length === undefined
) {
if (workspaceSettings.length >= 2 || workspaceSettings.length < 0) {
// Todo: Replace with assert
throw new Error("This is impossible");
}
if (workspaceSettings.length === 0) {
let answer = await vscode.window.showErrorMessage(
"There needs to be an initialized workspace",
"Initialize now",
"Cancel"
);
if (answer === "Initialize now") {
try {
await fs.writeFile(
path.join(workspace, "soiworkspace.json"),
soiWorkspaceTemplate_0_8_0(store)
);
} catch (err) {
vscode.window.showErrorMessage(
"Error initializing workspace: " + err.toString()
);
return null;
}
} else {
return null;
}
return null;
}
try {
return (await fs.readFile(
path.join(workspace, "soiworkspace.json")
)).toString();
return (
await fs.readFile(path.join(workspace, "soiworkspace.json"))
).toString();
} catch (err) {
vscode.window.showErrorMessage(
"Cannot read soi workspace settings file: " + err.toString()
......@@ -98,6 +52,35 @@ async function determineWorkspaceSettingsFileContent(
}
}
async function createWorkspaceSettingsFileContent(
store: Store,
workspace: string
): Promise<"failed" | "success"> {
let workspaceSettings = await vscode.workspace.findFiles("soiworkspace.json");
if (workspaceSettings.length >= 2 || workspaceSettings.length < 0) {
// Todo: Replace with assert
// throw new Error("This is impossible");
return "failed";
}
if (workspaceSettings.length === 0) {
try {
await fs.writeFile(
path.join(workspace, "soiworkspace.json"),
soiWorkspaceTemplate_0_8_0(store)
);
} catch (err) {
vscode.window.showErrorMessage(
"Error initializing workspace: " + err.toString()
);
return "failed";
}
}
if ((await determineWorkspaceSettings(store, workspace)) === null) {
return "failed";
}
return "success";
}
async function determineWorkspaceSettings(
store: Store,
workspace: string
......@@ -144,7 +127,10 @@ export async function readWorkspaceState(
export async function initializeWorkspace(store: Store) {
let workspace = await determineWorkspaceFolder();
if (workspace !== null) {
await determineWorkspaceSettings(store, workspace);
let result = await createWorkspaceSettingsFileContent(store, workspace);
if (result === "failed") {
vscode.window.showErrorMessage("Couldn't initialize new workspace");
}
store.emitFsChange();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment