Skip to content

Commit

Permalink
Merge branch 'release/v1.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Jun 7, 2016
2 parents 5863673 + e4e0271 commit a0bc1a5
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.5.5

* Добавлена команда быстрого создания файла `tasks.json`
* Исправлено зависание обновления кэша при редактировании файлов со смешанным режимом переносов строк
* В варианты запуска скриптов oscript добавлен режим `-check`

## 1.5.4

* Иcправлена работа автодополнения, перехода к определению в новосозданных несохраненных файлах
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"displayName": "Language 1C (BSL)",
"description": "Syntax highlighting for 1C:Enterprise 8.",
"icon": "images/xDDIcon.png",
"version": "1.5.4",
"version": "1.5.5",
"publisher": "xDrivenDevelopment",
"galleryBanner": {
"color": "#0000FF",
"theme": "dark"
},
"license": "LICENSE.md",
"license": "SEE LICENSE IN LICENSE.md",
"bugs": {
"url": "https://github.com/xDrivenDevelopment/vsc-language-1c-bsl/issues"
},
Expand All @@ -33,6 +33,7 @@
"activationEvents": [
"onLanguage:bsl",
"onLanguage:sdbl",
"onCommand:language-1c-bsl.createTasks",
"onCommand:language-1c-bsl.update"
],
"contributes": {
Expand All @@ -46,6 +47,11 @@
"command": "language-1c-bsl.createComments",
"title": "Create comment to current method",
"category": "Language 1C (BSL)"
},
{
"command": "language-1c-bsl.createTasks",
"title": "Create tasks.json for current workspace",
"category": "Language 1C (BSL)"
},
{
"command": "language-1c-bsl.dynamicSnippets",
Expand Down
50 changes: 46 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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 fs from "fs";
import * as path from "path";
import * as vscode from "vscode";
import { BSL_MODE } from "./const";
import {Global} from "./global";
Expand All @@ -15,6 +16,7 @@ import HoverProvider from "./features/hoverProvider";
import SyntaxHelper from "./features/syntaxHelper";
import * as vscAdapter from "./vscAdapter";
import * as dynamicSnippets from "./features/dynamicSnippets";
import * as tasksTemplate from "./features/tasksTemplate";

let diagnosticCollection: vscode.DiagnosticCollection;

Expand Down Expand Up @@ -90,6 +92,46 @@ export function activate(context: vscode.ExtensionContext) {
}
}));

context.subscriptions.push(vscode.commands.registerCommand("language-1c-bsl.createTasks", () => {
let rootPath = vscode.workspace.rootPath;
if (rootPath === undefined) {
return;
}
let vscodePath = path.join(rootPath, ".vscode");
let promise = new Promise( (resolve, reject) => {
fs.stat(vscodePath, (err: NodeJS.ErrnoException, stats: fs.Stats) => {
if (err) {
fs.mkdir(vscodePath, (err) => {
if (err) {
reject(err);
}
resolve();
})
return;
}
resolve();
});
});

promise.then( (result) => {
let tasksPath = path.join(vscodePath, "tasks.json");
fs.stat(tasksPath, (err: NodeJS.ErrnoException, stats: fs.Stats) => {
if (err) {
fs.writeFile(tasksPath, JSON.stringify(tasksTemplate.getTasksObject(), null, 4), (err: NodeJS.ErrnoException) => {
if (err) {
throw err;
}
vscode.window.showInformationMessage("tasks.json was created");
});
} else {
vscode.window.showInformationMessage("tasks.json already exists")
}
});
}).catch( (reason) => {
throw reason;
});
}));

vscode.languages.setLanguageConfiguration("bsl", {
indentationRules: {
decreaseIndentPattern: /^\s*(конецесли|конеццикла|конецпроцедуры|конецфункции|иначе|иначеесли|конецпопытки|исключение|endif|enddo|endprocedure|endfunction|else|elseif|endtry|except).*$/i,
Expand Down Expand Up @@ -172,9 +214,6 @@ export function activate(context: vscode.ExtensionContext) {
}
}));

let previewUriString = "syntax-helper://authority/Синтакс-Помощник";
let previewUri = vscode.Uri.parse(previewUriString);

context.subscriptions.push(vscode.commands.registerCommand("language-1c-bsl.dynamicSnippets", () => {
let editor = vscode.window.activeTextEditor;
if (!editor || editor.selection.isEmpty) {
Expand Down Expand Up @@ -236,6 +275,9 @@ export function activate(context: vscode.ExtensionContext) {
});
}));

let previewUriString = "syntax-helper://authority/Синтакс-Помощник";
let previewUri = vscode.Uri.parse(previewUriString);

context.subscriptions.push(vscode.commands.registerCommand("language-1c-bsl.syntaxHelper", () => {
if (!vscode.window.activeTextEditor) {
return;
Expand All @@ -245,7 +287,7 @@ export function activate(context: vscode.ExtensionContext) {
if (globalMethod) {
global.methodForDescription = { label: globalMethod.name, description: globalMethod.description };
syntaxHelper.update(previewUri);
vscode.commands.executeCommand("vscode.previewHtml", vscode.Uri.parse(previewUriString), vscode.ViewColumn.Two).then((success) => {
vscode.commands.executeCommand("vscode.previewHtml", previewUri, vscode.ViewColumn.Two).then((success) => {
}, (reason) => {
vscode.window.showErrorMessage(reason);
});
Expand Down
66 changes: 66 additions & 0 deletions src/features/tasksTemplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
export function getTasksObject(): any {
return {
"version": "0.1.0",
"command": "oscript",
"isShellCommand": true,
"showOutput": "silent",
"args": [
"-encoding=utf-8"
],
"tasks": [
{
"taskName": "OneScript: compile",
"args": [
"-compile",
"${file}"
],
"echoCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"isBuildCommand": false
},
{
"taskName": "OneScript: check",
"args": [
"-check",
"${file}"
],
"echoCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"isBuildCommand": false
},
{
"taskName": "OneScript: make",
"args": [
"-make",
"${file}",
"${fileBasename}.exe"
],
"echoCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"isBuildCommand": false
},
{
"taskName": "OneScript: run",
"args": [
"${file}"
],
"echoCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"isBuildCommand": true,
"problemMatcher": {
"fileLocation": "absolute",
"pattern": {
"regexp": "^{Модуль\\s+(.*)\\s\\/\\s.*:\\s+(\\d+)\\s+\\/\\s+(.*)}$",
"file": 1,
"location": 2,
"message": 3
}
}
}
]
};
}
2 changes: 1 addition & 1 deletion src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class Global {
throw err;
}
let moduleStr = fullpath.endsWith(".bsl") ? this.getModuleForPath(fullpath, rootPath) : "";
source = source.replace(/\r(?!\n)/g, "\r\n");
source = source.replace(/\r\n?/g, "\n");
let parsesModule = new Parser().parse(source);
source = null;
let entries = parsesModule.getMethodsTable().find();
Expand Down

0 comments on commit a0bc1a5

Please sign in to comment.