diff --git a/appveyor.yml b/appveyor.yml index 2b0fde43..7d07d05d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,7 @@ version: "{build}" +image: Visual Studio 2015 + platform: x64 branches: diff --git a/grammars/tree-sitter-php.cson b/grammars/tree-sitter-php.cson new file mode 100644 index 00000000..48810893 --- /dev/null +++ b/grammars/tree-sitter-php.cson @@ -0,0 +1,200 @@ +name: 'PHP' +scopeName: 'text.html.php' +type: 'tree-sitter' +parser: 'tree-sitter-php' + +firstLineRegex: [ + '^\\s*<\\?([pP][hH][pP]|=|\\s|$)' +] + +comments: + start: '#' + +fileTypes: [ + 'php' + 'phpt' +] + +folds: [ + { + type: 'comment' + } + { + start: {type: '{', index: 0}, + end: {'}', index: -1} + } + { + type: ['class_declaration', 'interface_declaration'] + start: {type: '{'}, + end: {type: '}'} + } + { + type: 'formal_parameters' + start: {type: '('} + end: {type: ')'} + } + { + start: {type: '(', index: 0}, + end: {')', index: -1} + } + { + start: {type: '[', index: 0}, + end: {']', index: -1} + } +] + +scopes: + 'program': 'source.php' + + '"echo"': 'support.function' + '"print"': 'support.function' + '"unset"': 'support.function' + '"isset"': 'support.function' + '"list"': 'support.function' + '"eval"': 'support.function' + '"array"': 'support.function' + '"list"': 'support.function' + '"empty"': 'support.function' + 'string': 'string.quoted' + 'float': 'constant.numeric' + + 'member_access_expression > name': 'variable.other.object.property' + + 'class_declaration > name': 'entity.name.type.class' + 'catch_clause > qualified_name > name': 'entity.name.type.class' + 'class_base_clause > qualified_name > name': 'entity.other.inherited-class' + + 'qualified_name > name': {match: /^(TRUE|FALSE|NULL|__(FILE|DIR|FUNCTION|CLASS|METHOD|LINE|NAMESPACE)__|ON|OFF|YES|NO|NL|BR|TAB)$/i, scopes: 'constant.language.php'} + + 'interface_declaration > name': 'entity.name.type.interface' + 'class_interface_clause > qualified_name > name': 'entity.other.implemented-interface' + + 'function_definition > name': 'entity.name.function' + 'function_call_expression > name': 'entity.name.function' + 'function_call_expression > qualified_name': 'entity.name.function' + 'scoped_call_expression > name': 'entity.name.function' + 'member_call_expression > name': 'entity.name.function' + '"require_once", "require", "include_once", "include"': 'entity.name.function' + + 'method_declaration > name': 'entity.name.function' + 'method_declaration > function_definition > name': 'entity.name.function' + 'constructor_definition > "__construct"': 'entity.name.function' + + 'object_creation_expression > qualified_name > name': 'entity.name.type.class' + 'object_creation_expression > new_variable > simple_variable': 'meta.class.instance.constructor' + + 'const_element > name': 'constant' + 'class_constant_access_expression >name': 'constant' + 'integer': 'constant.numeric.decimal' + 'float': 'constant.numeric.decimal' + 'string': 'string.quoted.single' + 'regex': 'string.regexp' + 'true': 'constant.language.boolean.true' + 'false': 'constant.language.boolean.false' + 'comment': 'comment.block' + + 'variable_name > "$"': 'punctuation.definition.variable.php' + '"("': 'punctuation.definition.parameters.begin.bracket.round.php' + '")"': 'punctuation.definition.parameters.end.bracket.round.php' + '"{"': 'punctuation.definition.begin.bracket.curly.php' + '"}"': 'punctuation.definition.end.bracket.curly.php' + '"["': 'punctuation.section.array.begin.php' + '"]"': 'punctuation.section.array.end.php' + '";"': 'punctuation.terminator.expression.php' + + '"static"': 'storage.modifier' + '"public"': 'storage.modifier' + '"private"': 'storage.modifier' + '"protected"': 'storage.modifier' + '"global"': 'storage.modifier' + '"const"': 'storage.modifier' + '"abstract"': 'storage.modifier.abstract' + '"extends"': 'storage.modifier.extends' + '"implements"': 'storage.modifier.implements' + '"final"': 'storage.modifier.final' + '"use"': 'keyword.other.use' + '"namespace"': 'keyword.other.namespace' + + '"callable"': 'storage.type' + '"var"': 'storage.type' + '"trait"': 'storage.type.trait' + '"class"': 'storage.type.class' + '"interface"': 'storage.type.interface' + '"function"': 'storage.type.function' + '"type"': 'storage.type.type' + 'cast_expression > cast_type': 'storage.type.cast' + + '"+"': 'keyword.operator.php' + '"-"': 'keyword.operator.php' + '"*"': 'keyword.operator.php' + '"/"': 'keyword.operator.php' + '"%"': 'keyword.operator.php' + '"**"': 'keyword.operator.php' + '"="': 'keyword.operator.php' + '"=="': 'keyword.operator.php' + '"==="': 'keyword.operator.php' + '"!="': 'keyword.operator.php' + '"!="': 'keyword.operator.php' + '"!=="': 'keyword.operator.php' + '"<"': 'keyword.operator.php' + '">"': 'keyword.operator.php' + '"<>"': 'keyword.operator.php' + '"<="': 'keyword.operator.php' + '"=>"': 'keyword.operator.php' + '">="': 'keyword.operator.php' + '"<=>"': 'keyword.operator.php' + '"&"': 'keyword.operator.php' + '"|"': 'keyword.operator.php' + '"^"': 'keyword.operator.php' + '"~"': 'keyword.opeator.php' + '"<<"': 'keyword.operator.php' + '">>"': 'keyword.operator.php' + '"++"': 'keyword.operator.php' + '"--"': 'keyword.operator.php' + '"and"': 'keyword.operator.php' + '"or"': 'keyword.operator.php' + '"xor"': 'keyword.operator.php' + '"!"': 'keyword.operator.php' + '"&&"': 'keyword.operator.php' + '"||"': 'keyword.operator.php' + '"."': 'keyword.operator.php' + '"?"': 'keyword.operator.php' + '":"': 'keyword.operator.php' + '"??"': 'keyword.operator.php' + '"as"': 'keyword.logical' + '"new"': 'keyword.new' + '"clone"': 'keyword.clone' + '"insteadof"': 'keyword.insteadof' + '"instanceof"': 'keyword.type' + + '"->"': 'keyword.operator.class' + '","': 'punctuation.separator.delimiter.php' + + '"if"': 'keyword.control' + '"do"': 'keyword.control' + '"else"': 'keyword.control' + '"elseif"': 'keyword.control' + '"endif"': 'keyword.control' + '"while"': 'keyword.control' + '"endwhile"': 'keyword.control' + '"for"': 'keyword.control' + '"endfor"': 'keyword.control' + '"foreach"': 'keyword.control' + '"endforeach"': 'keyword.control' + '"declare"': 'keyword.control' + '"enddeclare"': 'keyword.control' + '"return"': 'keyword.control' + '"break"': 'keyword.control' + '"continue"': 'keyword.control' + '"throw"': 'keyword.control' + '"try"': 'keyword.control' + '"catch"': 'keyword.control' + '"finally"': 'keyword.control' + '"switch"': 'keyword.control' + '"endswitch"': 'keyword.control' + '"case"': 'keyword.control' + '"default"': 'keyword.control' + '"yield"': 'keyword.control.yield' + '"goto"': 'keyword.control.goto' + '"exit"': 'keyword.control.exit' + '"die"': 'keyword.control.die' diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..1fb0e7a6 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,169 @@ +{ + "name": "language-php", + "version": "0.44.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "coffee-script": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz", + "integrity": "sha1-vxxHrWREOg2V0S3ysUfMCk2q1uk=", + "dev": true + }, + "coffeelint": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/coffeelint/-/coffeelint-1.16.2.tgz", + "integrity": "sha512-6mzgOo4zb17WfdrSui/cSUEgQ0AQkW3gXDht+6lHkfkqGUtSYKwGdGcXsDfAyuScVzTlTtKdfwkAlJWfqul7zg==", + "dev": true, + "requires": { + "coffee-script": "~1.11.0", + "glob": "^7.0.6", + "ignore": "^3.0.9", + "optimist": "^0.6.1", + "resolve": "^0.6.3", + "strip-json-comments": "^1.0.2" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "nan": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", + "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "resolve": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-0.6.3.tgz", + "integrity": "sha1-3ZV5gufnNt699TtYpN2RdUV13UY=", + "dev": true + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "tree-sitter-php": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/tree-sitter-php/-/tree-sitter-php-0.13.1.tgz", + "integrity": "sha512-Qc7w4D0XG3KGcfcEM9K/YBighVw2uijTIENmqPp32HcCR/8IZwzuNSbAkbD44PPw1WQFvtBZVJqOc91kMH+LPA==", + "requires": { + "nan": "^2.10.0" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/package.json b/package.json index 05d9c0fb..0506e1fe 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "bugs": { "url": "https://github.com/atom/language-php/issues" }, + "dependencies": { + "tree-sitter-php": "^0.13.1" + }, "devDependencies": { "coffeelint": "^1.10.1" } diff --git a/spec/html-spec.coffee b/spec/html-spec.coffee index 398172aa..701476f5 100644 --- a/spec/html-spec.coffee +++ b/spec/html-spec.coffee @@ -2,6 +2,7 @@ describe 'PHP in HTML', -> grammar = null beforeEach -> + atom.config.set('core.useTreeSitterParsers', false) waitsForPromise -> atom.packages.activatePackage 'language-php' diff --git a/spec/php-spec.coffee b/spec/php-spec.coffee index b9dddeb3..e5b6e9ea 100644 --- a/spec/php-spec.coffee +++ b/spec/php-spec.coffee @@ -2,6 +2,7 @@ describe 'PHP grammar', -> grammar = null beforeEach -> + atom.config.set('core.useTreeSitterParsers', false) waitsForPromise -> atom.packages.activatePackage 'language-php'