Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
iSorp committed Jun 7, 2020
2 parents 6079c55 + 0df6c51 commit 9300913
Show file tree
Hide file tree
Showing 31 changed files with 1,468 additions and 961 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 0.1.12 (May , 2020)
## 0.1.13 (June 7, 2020)
- Syntax highlighting
- Semantic highlighting
- Bug fixes Parser (% eof sign added)
- Additional compiler parameter

## 0.1.12 (May 26, 2020)
- Rename provider
- Block skip support
- clean up
Expand Down
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@
Fanuc Macro Executor syntax highlighting, validating and project building

## News
- Rename provider
- Block skip support "/"

- [Semantic highlighting](#highlighting)
- [Additional compiler parameters](#ExtensionSettings)

## Features
* Compiling and linking
* Compiler problem matcher
* Syntax highlighting
* Syntax/Semantic highlighting
* Syntax validation
* Symbol provider
* Completion provider
* CodeLens
* Lint features
* Sequence number refactoring

**The program parsing is not yet complete implemented. There are cases where mistakes are not appropriate or not detected.** <br>
Report issues to https://github.com/iSorp/macro-executor/issues


### Validation
![Validation](./resources/validation.gif)
Expand All @@ -54,14 +51,33 @@ Report issues to https://github.com/iSorp/macro-executor/issues
## Coding conventions
* `$Include` paths must be absolute or relative to the workspace folder
* Uppercase for constants: `@MY_CONSTANT 100`
* Space between statements: `O SUB_PROBGRAM; N9000 G01 X1; DO 1; END 1; GOTO 1` etc.
* Space between statements: `O SUB_PROGRAM; N9000 G01 X1; DO 1; END 1; GOTO 1` etc.
* A comment of a declaration `@var` <span style="color:green">**/* my comment**</span> is displayed on hover and completion

## Sequence number refactoring for functions
* Consecutive numbering on completion (snippet N-Number)
* Command for renumbering sequences (incl. GOTOs)
* Command for adding missing sequences (for NC statements)


<a name="highlighting"></a>

## Semantic highlighting
Semantic highlighting is used to highlight the represented type of a symbol. Following types are supported:
* M-Code and G-Code
* PMC Address
* Macro variable
* Constant
* Label

![References](./resources/semantic.gif)

*The color theme used in screenshot →* ***[Noctis](https://marketplace.visualstudio.com/items?itemName=liviuschera.noctis#review-details)***





## Lint
The Lint is configurable by changing the following rules in the settings (user or workspace).
Three levels are supported: `error`, `warning` and `ignore`.
Expand Down Expand Up @@ -95,10 +111,12 @@ Three levels are supported: `error`, `warning` and `ignore`.
| Command | Key |
|---------|--------------|
| Build | Ctrl+Shift+B |
| Link | Ctrl+Shift+L |
| Link / build all | Ctrl+Shift+L |
| Clean | Ctrl+Shift+C |


<a name="settings"></a>

## Extension Settings

This extension contributes the following settings:
Expand All @@ -113,6 +131,7 @@ This extension contributes the following settings:
Build settings:
* `macro.build.compiler`: Selection of the macro compiler
* `macro.build.controlType`: Selection of the control type
* `macro.build.compilerParams`: Additional compiler parameters: -NR, -L1, -L2, -L3, -PR
* `macro.build.makeFile`: The path to the makefile
* `macro.project.exportPath`: The path to the directory for the memory card file (.mem)
* `macro.project.sourcePath`: The path to the directory for the source files (.src)
Expand All @@ -130,7 +149,7 @@ The following parameters are passed to the external script:
3. Compiler
4. Control type parameter

<a name="internalbuild"></a>
<a name="ExtensionSettings"></a>

## Internal build system
If `macro.build.makeFile` is empty the internal system is used.
Expand Down
54 changes: 26 additions & 28 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"url": "https://github.com/iSorp/macro-executor.git"
},
"engines": {
"vscode": "^1.43.0"
"vscode": "^1.45.1"
},
"dependencies": {
"vscode-languageclient": "^6.1.3",
"rxjs": "^6.5.2",
"vscode-languageclient": "7.0.0-next.1",
"rxjs": "^6.5.5",
"vscode-nls": "^4.1.2"
},
"devDependencies": {
"@types/vscode": "1.43.0",
"vscode-test": "^1.3.0"
"@types/vscode": "1.45.1",
"vscode-test": "^1.4.0"
}
}
8 changes: 5 additions & 3 deletions client/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BUILD_SYSTEMS:Systems = {
'MCOMP0': {compiler: 'MCOMP0', linker: 'MLINK', card: 'MMCARD' },
'MCOMP15': {compiler: 'MCOMP15', linker: 'MLINK', card: 'MMCARD15' },
'MCOMP15I': {compiler: 'MCOMP15I', linker: 'MLINK15I', card: 'MCARD15I' }
}
};

const CONTROL_TYPE = ['', '0', '30', 'PM', '0F'];
const build_ext_glob = 'ref,REL,PRG,ROM,MEM,MAP,tmp.lnk';
Expand Down Expand Up @@ -151,6 +151,7 @@ class ProjectService {

const compiler = settings.MacroSettings.getInstance().macroCompilerPath;
const type = settings.MacroSettings.getInstance().macroControlType;
const prm = settings.MacroSettings.getInstance().macroCompilerParams;
const currentFile = vscode.window.activeTextEditor?.document.uri.fsPath;
if (!currentFile){
return;
Expand All @@ -160,13 +161,14 @@ class ProjectService {

let buildPath = this.getAbsPath(settings.MacroSettings.getInstance().macroBuildPath);
if (!buildPath) {
buildPath = this.workspacePath;;
buildPath = this.workspacePath;
}

let arg = '';
if (type !== undefined && type !== ''){
arg = '-'+type;
}
arg += ' ' + prm;

let bscript = compiler + ' ' + currentFile + ' ' + arg;
if (buildPath){
Expand Down Expand Up @@ -233,7 +235,7 @@ class ProjectService {
if (!srcFiles){return;}

// filter file directories to compile all files in a directory at once
let dirs:string[] = srcFiles.map(a => path.dirname(a.fsPath))
let dirs:string[] = srcFiles.map(a => path.dirname(a.fsPath));
dirs = dirs.filter((v,i) => dirs.indexOf(v) === i);

for (const dir of dirs) {
Expand Down
1 change: 1 addition & 0 deletions client/src/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class MacroSettings extends events.EventEmitter {
let macroSettings = vscode.workspace.getConfiguration('macro');
this.macroCompilerPath = macroSettings.build.compiler;
this.macroControlType = macroSettings.build.controlType;
this.macroCompilerParams = macroSettings.build.compilerParams;
this.macroMakeFile = macroSettings.build.makeFile;
this.macroExportPath = macroSettings.project.exportPath;
this.macroSourcePath = macroSettings.project.sourcePath;
Expand Down
48 changes: 23 additions & 25 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import * as path from 'path';
import { ExtensionContext, workspace, commands, window as Window, Selection } from 'vscode';
import { ExtensionContext, workspace, commands, window as Window,
Selection, languages, TextDocument, CancellationToken
} from 'vscode';


import {
LanguageClient, LanguageClientOptions,
ServerOptions, TransportKind, RevealOutputChannelOn,
ExecuteCommandSignature
} from 'vscode-languageclient';
import registerCommands from './common/commands';

import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
import registerCommands from './common/commands';

import CompositeDisposable from './common/CompositeDisposable';
import { downloadAndUnzipVSCode } from 'vscode-test';
Expand All @@ -24,15 +30,8 @@ export function activate(context: ExtensionContext) {
let serverModule = context.asAbsolutePath(
path.join('server', 'out', 'server.js')
);
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used

// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
let debugOptions = { execArgv: ['--nolazy', '--inspect=6011'], cwd: process.cwd() };

// 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, options: { cwd: process.cwd() } },
debug: {
Expand All @@ -41,22 +40,24 @@ export function activate(context: ExtensionContext) {
options: debugOptions
}
};
const selector = { language: 'macro', scheme: 'file' };

// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [selector],

documentSelector: [{ language: 'macro', scheme: 'file' }],
initializationOptions: workspace.getConfiguration('macro'),
synchronize: {
// Notify the server about file changes
fileEvents: workspace.createFileSystemWatcher('**/*.{[sS][rR][cC],[dD][eE][fF],[lL][nN][kK]}')
},
diagnosticCollectionName: 'macro',
progressOnInitialization: true,
revealOutputChannelOn: RevealOutputChannelOn.Never,
revealOutputChannelOn: RevealOutputChannelOn.Never,
middleware: {
executeCommand: async (command, args, next) => {
// Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
async provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken, next: DocumentSemanticsTokensSignature) {
const res = await next(document, token);
if (res === undefined) {throw new Error('busy');}
return res;
},
executeCommand: async (command:string, args:any[], next:ExecuteCommandSignature) => {
if (command === 'macro.codelens.references') {
let line = Number(args[0]);
let char = Number(args[1]);
Expand Down Expand Up @@ -86,9 +87,7 @@ export function activate(context: ExtensionContext) {
value: config.sequence.increment,
validateInput: validate
});




if (Window.activeTextEditor) {
if (command === 'macro.action.addsequeces' && increment) {
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start, increment]);
Expand All @@ -99,8 +98,9 @@ export function activate(context: ExtensionContext) {
}
}
}
}
} as any
};

// Create the language client and start the client.
client = new LanguageClient(
'macroLanguageServer',
Expand All @@ -109,13 +109,11 @@ export function activate(context: ExtensionContext) {
clientOptions
);

client.registerFeature(new SemanticTokensFeature(client));

client.registerProposedFeatures();
disposables.add(registerCommands());
context.subscriptions.push(disposables);

// Start the client. This will also launch the server
client.start();
context.subscriptions.push(client.start());
}

export function deactivate(): Thenable<void> | undefined {
Expand Down
1 change: 1 addition & 0 deletions i18n/chs/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"macro.validate.workspace.description": "环境校验",
"macro.build.compiler.description": "选择宏编译器",
"macro.build.controlType.description": "选择NC系统类型",
"macro.build.compilerParams.description": "Additional compiler parameters: -NR, -L1, -L2, -L3, -PR",
"macro.build.makeFile.description": "生成文件路径。使用以下参数:输出路径、 [make, clean]、编译器、控制类型。若路径下未发现Clean.bat,则自动调用参数clean。若未指定路径,则使用内部生成系统。",
"macro.project.exportPath.description": "存储卡文件(.mem) 路径",
"macro.project.sourcePath.description": "源文件 (.src)路径",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"rule.nestingTooDeep": "嵌套太深",
"rule.mixedConditionals": "一个IF语句中不可同时使用&&与||运算符",
"rule.tooManyConditionals": "条件过多",
"duplicateDoEndNumber" : "Duplicate DO or END number",
"rule.duplicateDoEndNumber": "DO或END号码重复",
"rule.incompleteParameter": "参数不完整,G代码或M代码需要数值或变量做参数",
"rule.includeNotFound": "预加载文件未找到",
"rule.assignmentConstant": "常数已赋值"
}
}
Loading

0 comments on commit 9300913

Please sign in to comment.