Remove linting functionality
This commit is contained in:
parent
6ee8ade534
commit
4728e752d5
50
CHANGELOG.md
50
CHANGELOG.md
@ -1,44 +1,68 @@
|
|||||||
## WIP
|
# Changelog
|
||||||
- Improved error message parsing
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## 0.7.0 - Split grammar definitions
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.8.0] - 2017-11-17
|
||||||
|
### Removed
|
||||||
|
- Moved the linting functionality into a seperate package, [`linter-mzn`](https://github.com/Dekker1/linter-mzn). With eyes to the future and possibility for a full MiniZinc Suite in Atom.
|
||||||
|
|
||||||
|
## 0.7.0
|
||||||
|
### Changed
|
||||||
- Create seperate definitions for FlatZinc + Output models and DZN files.
|
- Create seperate definitions for FlatZinc + Output models and DZN files.
|
||||||
|
### Fixed
|
||||||
- Fixes linting error when opening DZN files
|
- Fixes linting error when opening DZN files
|
||||||
|
|
||||||
## 0.6.1 - Moved repository
|
## 0.6.1
|
||||||
|
### Changed
|
||||||
- Change the repository URL
|
- Change the repository URL
|
||||||
|
|
||||||
## 0.6.0 - Linter v2
|
## 0.6.0
|
||||||
|
### Changed
|
||||||
- Upgrade to Linter API v2
|
- Upgrade to Linter API v2
|
||||||
|
|
||||||
## 0.5.0 - Column matching
|
## 0.5.0
|
||||||
|
### Added
|
||||||
- The linter now indicates the right column if indicated by `mzn2fzn`
|
- The linter now indicates the right column if indicated by `mzn2fzn`
|
||||||
|
|
||||||
## 0.4.1
|
## 0.4.1
|
||||||
|
### Changed
|
||||||
- Enables the user to disable linting in the package settings
|
- Enables the user to disable linting in the package settings
|
||||||
|
### Fixed
|
||||||
- Fixes problem in highlighting of numerical constants
|
- Fixes problem in highlighting of numerical constants
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
### Added
|
||||||
- Combines the linter and syntax highlighting package (formerly https://github.com/jjdekker/linter-mzn). I'll look into the possibility of disabling the linter extension at a later stadium.
|
- Combines the linter and syntax highlighting package (formerly https://github.com/jjdekker/linter-mzn). I'll look into the possibility of disabling the linter extension at a later stadium.
|
||||||
|
|
||||||
## 0.3.2
|
## 0.3.2
|
||||||
|
### Fixed
|
||||||
- Removes some duplicate syntax
|
- Removes some duplicate syntax
|
||||||
- Fixes the highlighting of numerical constants
|
- Fixes the highlighting of numerical constants
|
||||||
|
|
||||||
## 0.3.1 - One tab too far
|
## 0.3.1
|
||||||
- Removes an tab in the forall snippet.
|
### Fixed
|
||||||
|
- Removes an tab in the `forall` snippet.
|
||||||
|
|
||||||
## 0.3.0 - Colored constraints
|
## 0.3.0
|
||||||
- Adds function coloring to all predicates documented in the 2.0 documentation.
|
### Added
|
||||||
|
- Adds function colouring to all predicates documented in the 2.0 documentation.
|
||||||
- Adds indentation rules for parentheses
|
- Adds indentation rules for parentheses
|
||||||
|
### Changed
|
||||||
- Removes newlines from snippets (just press enter, the indentation rules will do the rest)
|
- Removes newlines from snippets (just press enter, the indentation rules will do the rest)
|
||||||
|
|
||||||
## 0.2.0 - Snippets
|
## 0.2.0
|
||||||
|
### Added
|
||||||
- Adds snippets for basic MZN functionalities
|
- Adds snippets for basic MZN functionalities
|
||||||
- Adds snippets for possible solve statements
|
- Adds snippets for possible solve statements
|
||||||
|
|
||||||
## 0.1.1 - `endif`
|
## 0.1.1
|
||||||
|
### Fixed
|
||||||
- Adds syntax highlighting for the `endif` keyword
|
- Adds syntax highlighting for the `endif` keyword
|
||||||
|
|
||||||
## 0.1.0 - First Release
|
## 0.1.0
|
||||||
|
### Added
|
||||||
- Basic syntax highlighting
|
- Basic syntax highlighting
|
||||||
|
|
||||||
|
[0.8.0]: https://github.com/Dekker1/linter-mzn/compare/v0.7.0...v0.8.0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# MiniZinc for Atom
|
# MiniZinc for Atom
|
||||||
|
|
||||||
This package adds syntax highlighting and optional linting for the MiniZinc modeling language (.mzn and .dzn files). The package is based on the [similar package for Sublime](https://github.com/astenmark/sublime-mzn).
|
This package provides a MiniZinc grammar for Atom to add syntax highlighting.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
{CompositeDisposable} = require 'atom'
|
|
||||||
|
|
||||||
module.exports = AtomLanguageMZN =
|
|
||||||
config:
|
|
||||||
enableLinter:
|
|
||||||
type: 'boolean'
|
|
||||||
default: true
|
|
||||||
description: "Enable linting using `mzn2fzn`"
|
|
||||||
mzn2fznPath:
|
|
||||||
type: 'string'
|
|
||||||
default: 'mzn2fzn'
|
|
||||||
description: 'Path to Minizinc\'s compiler `mzn2fzn`'
|
|
||||||
|
|
||||||
activate: (state) ->
|
|
||||||
console.log 'language-mzn: package loaded,
|
|
||||||
ready to get initialized by AtomLinter.'
|
|
||||||
|
|
||||||
if not atom.packages.getLoadedPackage 'linter'
|
|
||||||
atom.notifications.addError 'Linter package not found',
|
|
||||||
detail: '[language-mzn] `linter` package not found. \
|
|
||||||
Please install https://github.com/AtomLinter/Linter'
|
|
||||||
|
|
||||||
@subscriptions = new CompositeDisposable
|
|
||||||
|
|
||||||
@subscriptions.add atom.config.observe 'linter-mzn.mzn2fznPath', (mzn2fznPath) =>
|
|
||||||
@mzn2fznPath = mzn2fznPath
|
|
||||||
|
|
||||||
deactivate: ->
|
|
||||||
@subscriptions.dispose()
|
|
||||||
|
|
||||||
serialize: ->
|
|
||||||
AtomLanguageMZNViewState: @AtomLanguageMZNView.serialize()
|
|
||||||
|
|
||||||
provideLinter: ->
|
|
||||||
LinterMZN = require('./linter-mzn')
|
|
||||||
@provider = new LinterMZN()
|
|
||||||
return {
|
|
||||||
name: 'MiniZinc',
|
|
||||||
grammarScopes: ['source.mzn'],
|
|
||||||
scope: 'file',
|
|
||||||
lintsOnChange: true,
|
|
||||||
lint: @provider.lint
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
{BufferedProcess} = require 'atom'
|
|
||||||
|
|
||||||
class LinterMZN
|
|
||||||
lintProcess: null
|
|
||||||
|
|
||||||
config: (key) ->
|
|
||||||
atom.config.get "language-mzn.#{key}"
|
|
||||||
|
|
||||||
lint: (textEditor) =>
|
|
||||||
if @config 'enableLinter'
|
|
||||||
return new Promise (resolve, reject) =>
|
|
||||||
output = ''
|
|
||||||
command = @config 'mzn2fznPath'
|
|
||||||
args = ['--instance-check-only', textEditor.getPath()]
|
|
||||||
options = process.env
|
|
||||||
|
|
||||||
stdout = (data) ->
|
|
||||||
atom.notifications.addWarning data
|
|
||||||
stderr = (data) ->
|
|
||||||
output += data
|
|
||||||
exit = (code) =>
|
|
||||||
if code is 0
|
|
||||||
resolve []
|
|
||||||
else
|
|
||||||
messages = @parse output, textEditor.getPath()
|
|
||||||
resolve messages
|
|
||||||
|
|
||||||
@lintProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})
|
|
||||||
@lintProcess.onWillThrowError ({error, handle}) ->
|
|
||||||
atom.notifications.addError "Failed to run #{command}",
|
|
||||||
detail: "#{error.message}"
|
|
||||||
dismissable: true
|
|
||||||
handle()
|
|
||||||
resolve []
|
|
||||||
else
|
|
||||||
return []
|
|
||||||
|
|
||||||
parse: (output, filePath) =>
|
|
||||||
messages = []
|
|
||||||
output = output.split('\n')
|
|
||||||
warningLines = (i for line, i in output when /:([0-9]+):/.test(line) && ! /(did you forget to specify a data file\?)/.test(output[i+1]))
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while i < warningLines.length
|
|
||||||
if i >= warningLines.length - 1
|
|
||||||
messages.push @generateMessage output[warningLines[i]..], filePath
|
|
||||||
else
|
|
||||||
messages.push @generateMessage output[warningLines[i]..warningLines[i+1]-1], filePath
|
|
||||||
i++
|
|
||||||
|
|
||||||
return messages
|
|
||||||
|
|
||||||
generateMessage: (output, filePath) ->
|
|
||||||
match = output[0].match(/:([0-9]+):/)
|
|
||||||
line = parseInt(match[1])
|
|
||||||
output = output[1..]
|
|
||||||
|
|
||||||
startcol = 0
|
|
||||||
endcol = 500;
|
|
||||||
if output.length > 1 and /\^/.test(output[1])
|
|
||||||
startcol = output[1].match(/\^/).index
|
|
||||||
endcol = output[1].match(/\^(\s|$)/).index + 1
|
|
||||||
output = output[2..]
|
|
||||||
|
|
||||||
message = {
|
|
||||||
severity: 'error',
|
|
||||||
excerpt: output.join('\n').replace(/MiniZinc: /, ""),
|
|
||||||
location:{
|
|
||||||
file: filePath,
|
|
||||||
position: [[line-1,startcol], [line-1,endcol]],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return message
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = LinterMZN
|
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "language-mzn",
|
"name": "language-mzn",
|
||||||
"main": "./lib/init",
|
|
||||||
"version": "0.7.0",
|
"version": "0.7.0",
|
||||||
"description": "A language package for the MiniZinc constraint modeling language",
|
"description": "A language package for the MiniZinc constraint modeling language",
|
||||||
"repository": "https://github.com/Dekker1/language-mzn",
|
"repository": "https://github.com/Dekker1/language-mzn",
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
include "globals.mzn";
|
include "globals.mzn";
|
||||||
|
|
||||||
% parameters
|
% parameters
|
||||||
int: n=;
|
int: n=8;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
% variables
|
% variables
|
||||||
array[1..n] of var 1..n: R;
|
array[1..n] of var 1..n: R;
|
||||||
|
BIN
sample.png
BIN
sample.png
Binary file not shown.
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 136 KiB |
Reference in New Issue
Block a user