Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
iSorp committed May 17, 2020
2 parents fc1a9f5 + 9a05a7b commit e678a2f
Show file tree
Hide file tree
Showing 37 changed files with 11,710 additions and 303 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.1.9 ()
- Lint settings
- Label-Sequence number overlap check
- Duplicate value check
- Conditional logic check (max 4 statements, no mixed up operators)
- Supported display languages (English, Deutsch, 中文)
- Bug fixes (Sequence number refactoring if duplicates exists)

## 0.1.8 (May 11, 2020)
- Bug fixes Parser
- Parsing of declared statements (@var G04P10)
Expand Down
107 changes: 71 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@
Fanuc Macro Executor syntax highlighting, validating and project building

## News
### Sequence number refactoring for functions
* Consecutive numbering on completion (snippet N-Number)
* Command for renumbering sequences (incl. GOTOs)
* Command for adding missing sequences (NC statements)
* Supported display languages (English, Deutsch, 中文)
* Lint configuration

## Features

* Compiling and linking
* Problem matcher
* Compiler problem matcher
* Syntax 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.**
**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
Expand All @@ -42,21 +41,46 @@ Fanuc Macro Executor syntax highlighting, validating and project building
### Implementations
![Implementations](./resources/implementations.gif)

### Sequences
![Sequences](./resources/sequences.gif)

### CodeLens reference counter
![CodeLens](./resources/codelens.png)

## Required file extensions
* Macro files`.src`
* Include files `.def`
* Link files `.lnk`

## 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.
* A comment of a declaration `@var` <span style="color:green">/* my comment</span> is displayed on hover and completion
* 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)

## Lint
The Lint is configurable by changing the following rules in the settings (user or workspace).
Three levels are supported: `error`, `warning` and `ignore`.

```json
"macro.lint": {
"rules" : {
"duplicateInclude": "error",
"duplicateDeclaration": "error",
"duplicateFunction": "warning",
"duplicateAddress": "ignore",
"duplicateSequence": "warning",
"duplicateLabel": "warning",
"duplicateLabelSequence": "warning",
"unknownSymbol": "error",
"whileLogicOperator": "error",
"mixedConditionals": "error",
"tooManyConditionals": "error",
"incompleteParameter": "error",
"includeNotFound": "error",
"assignmentConstant": "warning"
}
```


## Default Commands
Expand All @@ -72,34 +96,37 @@ Fanuc Macro Executor syntax highlighting, validating and project building

This extension contributes the following settings:

* `macro.sequence.base`: Sequence number start
* `macro.sequence.increment`: Sequence number increment
* `macro.codelens.enable`: Reference counter for variable and label declarations
* `macro.validate.enable`: Syntax validation activation
* `macro.validate.workspace`: Syntax validation for entire workspace
* `macro.build.compiler`: Compiler Selection {MCOMPI, MCOMP0}
* `macro.build.controlType`: Control Type Selection {0, 30}
* `macro.build.makeFile`: Makefile
* `macro.project.exportPath`: Memoryfile Export Path
* `macro.project.sourcePath`: Source Path (.src)
* `macro.project.linkPath`: Linkfile and Library Path
* `macro.project.buildPath`: Build Files

* `macro.lint`: Lint settings and rule configuration
* `macro.sequence.base`: Sequences start number for refactoring
* `macro.sequence.increment`: Sequences increment for refactoring
* `macro.codelens.enable`: Enables or disables the CodeLens function
* `macro.validate.enable`: Enables or disables the validation
* `macro.validate.workspace`: Enables or disables the workspace validation

Build settings:
* `macro.build.compiler`: Selection of the macro compiler [MCOMPI, MCOMP0]
* `macro.build.controlType`: Selection of the control type [0, 30]
* `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)
* `macro.project.buildPath`: The path to the directory for the build files
* `macro.project.linkPath`: The path to the directory for the link files (.lnk) and the library (.mex)

## Building

### External build system
The building process can be performed by using an external script or the internal system. If an external script is used,
just set the path in `macro.build.makeFile`. If a Clean.bat in the same directory exists, it is used for the cleaning process.
The following arguments are passed to the Make.bat:
just set the path in `macro.build.makeFile`. If a `Clean.bat` in the same directory exists, it is used for the cleaning process.
The following parameters are passed to the script:

1. Export directory
2. Option [make, clean].
3. Compiler [MCOMP0, MCOMPI]
4. Control type [0, 30]

1. path for memory file
2. option {make, clean}. When perforing the cleaning command and no Clean.bat is found "clean" is passed
3. compiler {MCOMP0, MCOMPI}
4. compiler arg = control type {0, 30}

### Internal build system
If no Make.bat is used the internal building process is used.
If `macro.build.makeFile` is empty the internal system is used.
>- The compiler must be available over the system path
>- The library (mex) must be located in `macro.project.linkPath` path

Expand All @@ -114,15 +141,23 @@ project
└───def
│ file1.def
file1.def
file2.def
└───lnk
file1.lnk
file1.lnk
file2.lnk
F30iA_01.MEX
```




-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------



## Credits

Special thanks to Pan and Yu for translating the chinese texts

特别感谢潘先生和于先生翻译了中文文本
7 changes: 6 additions & 1 deletion client/package-lock.json

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

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"dependencies": {
"vscode-languageclient": "^6.1.3",
"rxjs": "^6.5.2"
"rxjs": "^6.5.2",
"vscode-nls": "^4.1.2"
},
"devDependencies": {
"@types/vscode": "1.43.0",
Expand Down
3 changes: 2 additions & 1 deletion client/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function registerCommands() : CompositeDisposable {
return disposables;
}


function compile() : Promise<void> {
return new Promise<void>((resolve, reject) => {
let compiler = settings.MacroSettings.getInstance().macroCompilerPath;
Expand Down Expand Up @@ -153,7 +154,7 @@ function clean() {
build_ext.forEach(element => {
bscript = bscript + 'del *.' + element + '\n\r';
});
bscript = bscript + 'cd ..\\' + build + '\n\r';
bscript = bscript + 'cd ' + build + '\n\r';
build_ext.forEach(element => {
bscript = bscript + 'del *.' + element + '\n\r';
});
Expand Down
34 changes: 23 additions & 11 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import registerCommands from './common/commands';
import CompositeDisposable from './common/CompositeDisposable';
import { downloadAndUnzipVSCode } from 'vscode-test';

import * as nls from 'vscode-nls';

// The example uses the file message format.
const localize = nls.config({ messageFormat: nls.MessageFormat.file })();

let client: LanguageClient;
let disposables = new CompositeDisposable();

Expand Down Expand Up @@ -56,35 +61,42 @@ export function activate(context: ExtensionContext) {
let line = Number(args[0]);
let char = Number(args[1]);
let selection = new Selection(line, char, line,char);
Window.activeTextEditor.selection = selection;
commands.executeCommand('references-view.find');
if (Window.activeTextEditor) {
Window.activeTextEditor.selection = selection;
commands.executeCommand('references-view.find');
}
}
else if (command === 'macro.action.refactorsequeces' || command === 'macro.action.addsequeces') {
function validate(input:string): string {
function validate(input:string): string | null {
return Number.isInteger(Number(input)) ? null : 'Integer expected';
}

const config = workspace.getConfiguration('macro');
if (command === 'macro.action.refactorsequeces'){
const start = await Window.showInputBox({
let start = undefined;
if (command === 'macro.action.refactorsequeces') {
start = await Window.showInputBox({
prompt: 'Start sequence number',
value: config.sequence.base,
validateInput: validate
});
if (config) {
config.update('sequence.base', Number(start));
}
}

const increment = await Window.showInputBox({
prompt: 'Sequence number increment',
value: config.sequence.increment,
validateInput: validate
});
if (increment){
config.update('sequence.increment', Number(increment));



if (Window.activeTextEditor) {
if (command === 'macro.action.addsequeces' && increment) {
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start]);
}
else if (command === 'macro.action.refactorsequeces' && start && increment) {
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start]);
}
}
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start]);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"outDir": "out",
"rootDir": "src",
"sourceMap": true
"sourceMap": true,
"strict": true
},
"include": ["src"],
"exclude": ["node_modules", ".vscode-test"]
}
Loading

0 comments on commit e678a2f

Please sign in to comment.