Skip to content

Commit 33c00e5

Browse files
committed
Merge pull request #13 from montegoulding/refactor/livecodescript
Refactor to merge LiveCode Script and iRev
2 parents c62bb39 + dab9a09 commit 33c00e5

File tree

9 files changed

+219
-1014
lines changed

9 files changed

+219
-1014
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ for Atom.
4242

4343
## Script Error Checking
4444

45-
This package provides a linter for LiveCode Script and Server to highlight and describe
46-
script compilation errors on the fly.
45+
This package provides a linter for LiveCode Script, LiveCode Server and LiveCode
46+
Builder to highlight and describe script compilation errors on the fly.
4747

4848
![Linter In Action](http://ecove.on-rev.com/linter.gif)
4949

5050
Dependencies:
5151

5252
* The [linter package](https://atom.io/packages/linter) needs to be installed
53-
* LiveCode 7.1+ Server engine for the platform it is being run on must be accessible
53+
* LiveCode 7.1+ Server engine for the platform it is being run on must be
54+
accessible
5455

5556
The default setting assumes you have installed the LiveCode Server engine somewhere
5657
on the current `$PATH` with the name `livecode-server`. However, you can enter any
@@ -63,6 +64,27 @@ by the inclusion of another file that error won't be detected.
6364
The linter supports an optional explicit variables mode which can be turned on
6465
via the package settings.
6566

67+
### LiveCode Builder Linting
68+
69+
Linting of LiveCode Builder files should be considered experimental. This is
70+
particularly the case for projects that have complex interdependencies between
71+
files.
72+
73+
In order to lint LiveCode Builder files ensure the following:
74+
75+
* lc-compile can be found at the location specified in settings
76+
* You have appropriately set the module paths to a directory with the standard
77+
`*.lci` files provided by LiveCode. You may add further paths delimited by `;`
78+
79+
The default settings assume you have a clone of the LiveCode repo in
80+
your home directory named livecode and you have built a debug build.
81+
82+
In the process of linting the LiveCode Builder file a `*.lci` file is created in
83+
a directory named `.lci` next to the file being edited. In the case of files
84+
that have dependencies you may receive a dependency error if you edit a
85+
file with the dependency before those it depends on because it won't be able to
86+
fine the appropriate `*.lci` file in the `.lci` directory.
87+
6688
## Authors
6789

6890
* Ralf Bitter

grammars/irev.cson

Lines changed: 9 additions & 226 deletions
Large diffs are not rendered by default.

grammars/livecodescript.cson

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'fileTypes': [
77
'livecodescript'
88
]
9-
'firstLineMatch': '^#!.*\\b(livecode)|^#\\s*-\\*-[^*]*mode:\\s*livecodescript[^*]*-\\*-'
9+
'firstLineMatch': '^#!.*\\b(livecode)|^#\\s*-\\*-[^*]*mode:\\s*livecodescript[^*]*-\\*-|script \"([A-Za-z_0-9]*)\"'
1010
'patterns': [
1111
{
1212
include: "#language"
@@ -31,25 +31,28 @@ repository:
3131
name: "comment.block.livecodescript"
3232
}
3333
{
34-
captures:
35-
"1":
36-
name: "punctuation.definition.comment.livecodescript"
37-
match: "(--).*?($\\n?)"
38-
name: "comment.line.double-dash.livecodescript"
34+
'begin': '--'
35+
'beginCaptures':
36+
'0':
37+
'name': 'punctuation.definition.comment.double-dash.livecodescript'
38+
'end': '\\n'
39+
'name': 'comment.line.livecodescript'
3940
}
4041
{
41-
captures:
42-
"1":
43-
name: "punctuation.definition.comment.livecodescript"
44-
match: "(#).*?($\\n?)"
45-
name: "comment.line.number-sign.livecodescript"
42+
'begin': '#'
43+
'beginCaptures':
44+
'0':
45+
'name': 'punctuation.definition.comment.number-sign.livecodescript'
46+
'end': '\\n'
47+
'name': 'comment.line.livecodescript'
4648
}
4749
{
48-
captures:
49-
"1":
50-
name: "punctuation.definition.comment.livecodescript"
51-
match: "(//).*?($\\n?)"
52-
name: "comment.line.number-sign.livecodescript"
50+
'begin': '//'
51+
'beginCaptures':
52+
'0':
53+
'name': 'punctuation.definition.comment.double-slash.livecodescript'
54+
'end': '\\n'
55+
'name': 'comment.line.livecodescript'
5356
}
5457
{
5558
match: "\\b(after|byte(s)*|codepoint(s)*|codeunit(s)*|english|segment(s)*|sentence(s)*|paragraph|the|trueWord(s)*|until|word(s)*|http|forever|descending|using|line|real8|with|seventh|for|stdout|finally|element|word|fourth|before|black|ninth|sixth|characters|chars|stderr|uInt(1|1s|2|2s)|stdin|string|lines|relative|rel|any|fifth|items|from|middle|mid|at|else|of|catch|then|third|it|file|milli(seconds|second|secs|sec)|int(1|1s|4|4s|ernet|2|2s)|normal|text|item|last|long|detailed|effective|uInt4|uInt4s|se(conds|cond|cs|c)|repeat|end\\s+repeat|URL|in|end\\s+try|into|switch|end\\s+switch|to|words|https|token|binfile|each|tenth|as|ticks|tick|system|real4|by|dateItems|without|cha(r|racter)|ascending|eighth|whole|dateTime|numeric|short|first|ftp|integer|abbreviated|abb(r|rev)|private|case|while|if|end\\s+if)\\b"
@@ -71,10 +74,12 @@ repository:
7174
"1":
7275
name: "storage.type.function.livecodescript"
7376
"2":
74-
name: "entity.name.function.livecodescript"
77+
name: "storage.type.function.livecodescript"
7578
"3":
76-
name: "variable.parameter.livecodescript"
77-
match: "((?i)function)\\s+([A-Za-z_0-9-]+)(\\s+[A-Za-z_0-9-]+,*?\\s+.*)*"
79+
name: "entity.name.function.livecodescript"
80+
"4":
81+
name: "punctuation.definition.variable.livecodescript"
82+
match: "(private\\s+)*((?i)function|on|command|before|after)\\s+([A-Za-z_0-9-]+)(\\s+@*[A-Za-z_0-9-]+,*?\\s+.*)*"
7883
name: "meta.function.livecodescript"
7984
}
8085
{
@@ -86,30 +91,6 @@ repository:
8691
match: "((?i)end){1}\\s+?([A-Za-z_0-9-]+)?"
8792
name: "meta.function.end.livecodescript"
8893
}
89-
{
90-
captures:
91-
"1":
92-
name: "storage.type.command.livecodescript"
93-
"2":
94-
name: "entity.name.command.livecodescript"
95-
"3":
96-
name: "variable.parameter.livecodescript"
97-
match: "((?i)before|after|command|on)\\s+([A-Za-z_0-9-]+)(\\s+[A-Za-z_0-9-]+,*?\\s+.*)*"
98-
name: "meta.command.livecodescript"
99-
}
100-
{
101-
captures:
102-
"1":
103-
name: "storage.type.test.livecodescript"
104-
"2":
105-
name: "entity.name.test.livecodescript"
106-
match: "((?i)blah){1}\\s+?([A-Za-z_0-9-]+)?"
107-
name: "meta.test.livecodescript"
108-
}
109-
{
110-
match: "((command|on)\\s+([A-Za-z_0-9-]+))"
111-
name: "meta.testA.livecodescript"
112-
}
11394
{
11495
match: "(\\-|\\+|\\*|/|%)"
11596
name: "keyword.operator.arithmetic.livecodescript"

lib/main.coffee

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ module.exports =
1313
title: 'Explicit Variables'
1414
default: 'false'
1515
description: 'Get errors on undeclared variables'
16+
lcCompilePath:
17+
type: 'string'
18+
title: 'Compiler Path For LiveCode Builder'
19+
default: switch
20+
when process.platform == 'darwin'
21+
then '~/livecode/_build/mac/Debug/lc-compile'
22+
when process.platform == 'linux'
23+
then '~/livecode/build-linux-x86_64/livecode/out/Debug/lc-compile'
24+
when process.platform == 'win32'
25+
then '~/livecode/_build/Win32/Debug/lc-compile.exe'
26+
description: 'Where is your lc-compile installed? ' +
27+
'Default assumes it\'s on $PATH'
28+
modulePaths:
29+
type: 'string'
30+
title: 'Module Paths For LiveCode Builder'
31+
default: switch
32+
when process.platform == 'darwin'
33+
then '~/livecode/_build/mac/Debug/modules/lci/'
34+
when process.platform == 'linux'
35+
then '~/livecode/build-linux-x86_64/livecode/out/Debug/modules/lci/'
36+
when process.platform == 'win32'
37+
then '~/livecode/_build/Win32/Debug/modules/lci/'
38+
description: 'Where are the modules installed? ' +
39+
'Default is where they should be after building ' +
40+
'a debug build of LiveCode. Delimit paths with `;`.'
1641

1742
activate: ->
1843
@subscriptions = new CompositeDisposable
@@ -22,6 +47,12 @@ module.exports =
2247
@subscriptions.add atom.config.observe 'language-livecode.explicitVars',
2348
(explicitVars) =>
2449
@explicitVars = explicitVars
50+
@subscriptions.add atom.config.observe 'language-livecode.lcCompilePath',
51+
(lcCompilePath) =>
52+
@lcCompilePath = lcCompilePath
53+
@subscriptions.add atom.config.observe 'language-livecode.modulePaths',
54+
(modulePaths) =>
55+
@modulePaths = modulePaths
2556
path = require 'path'
2657
@linterPath = path.join(__dirname, '..', 'tools', 'Linter.lc')
2758
@notified = false
@@ -31,7 +62,7 @@ module.exports =
3162

3263
provideLinter: ->
3364
provider =
34-
grammarScopes: ['source.livecodescript', 'source.iRev']
65+
grammarScopes: ['source.livecodescript', 'source.lcb']
3566
scope: 'file'
3667
lintOnFly: true
3768
lint: (textEditor) =>
@@ -44,6 +75,12 @@ module.exports =
4475
parameters.push(scope)
4576
explicitVariables = '-explicitVariables=' + @explicitVars
4677
parameters.push(explicitVariables)
78+
lcCompile = '-lcCompile=' + @lcCompilePath
79+
parameters.push(lcCompile)
80+
lcCompileModulePaths = '-modulePaths=' + @modulePaths
81+
parameters.push(lcCompileModulePaths)
82+
editorFilePath = '-filepath=' + filePath
83+
parameters.push(editorFilePath)
4784
text = textEditor.getText()
4885
return @exec(command, parameters, {stdin: text}).then (output) ->
4986
regex = /(\d+),(\d+),(.*)/g

0 commit comments

Comments
 (0)