Skip to content

Commit

Permalink
Add neive GPR support
Browse files Browse the repository at this point in the history
  • Loading branch information
soiamsoNG committed Jan 11, 2017
1 parent 449814c commit 4ce694e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
35 changes: 32 additions & 3 deletions lib/linter-ada.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fs = require 'fs'
path = require 'path'
atom_linter = require 'atom-linter'

Expand All @@ -6,16 +7,44 @@ module.exports = class LinterAda
lint: (textEditor) ->
editingFile = textEditor.getPath()
cwd = path.dirname editingFile
efName = path.basename editingFile

regex = '(?<file>.+):(?<line>\\d+):(?<col>\\d+):\\s(?<message>.+)'
styleregex = '\\(style\\).*'
scs = atom.config.get('linter-ada.StyleCheckSwitch')
scp = atom.config.get('linter-ada.StyleCheckParametersList')

# Find out the projectpath base one current editingFile
[projectPath, relativePath] = atom.project.relativizePath(editingFile)

gprregex = '.+\\.gpr'
if projectPath == null
gprfiles = []
else
gprfiles = fs.readdirSync(projectPath).filter (x) -> x.match(gprregex)

#Check if need to do style check
if scs == true
parList = ["-f","-gnatef","-gnatc","-gnaty#{scp}",editingFile]
parList = ["-f","-F","-eS","-gnatef","-gnatc","-gnaty#{scp}"]
else
parList = ["-f","-F","-eS","-gnatef","-gnatc"]

#Check if we have .gpr file in the project (atom's project idea) path
#if we have .gpr then use the first one
if gprfiles.length != 0
firstGPR = gprfiles[0]
atom.notifications.addSuccess("LinterAda: Use #{firstGPR} for lint")
parList = ["-P",firstGPR].concat parList
parList = parList.concat efName
gnatMakeRunPath = projectPath
else
parList = ["-f","-gnatef","-gnatc",editingFile]
atom.notifications.addInfo "LinterAda: No GPR found in Atom's \
Project root will put obj file in current directory"
#Need to use the fullpath, so gnatmake wull givback a fullpath
parList = parList.concat editingFile
gnatMakeRunPath = cwd

atom_linter.exec("gnatmake", parList, {cwd: cwd, stream: 'both'})
atom_linter.exec("gnatmake", parList, {cwd:gnatMakeRunPath, stream: 'both'})
.then (output) ->
{stdout, stderr, exitCode} = output
warnings = atom_linter.parse(stderr,regex).map((parsed) ->
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "linter-ada",
"main": "./lib/init",
"version": "0.1.0",
"version": "0.1.1",
"description": "Linter for Ada use GNATMake",
"repository": "https://github.com/soiamsoNG/linter-ada",
"license": "MIT",
Expand Down

0 comments on commit 4ce694e

Please sign in to comment.