Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tree-sitter-java

Package Overview
Dependencies
Maintainers
10
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-sitter-java - npm Package Compare versions

Comparing version 0.16.0 to 0.19.1

bindings/node/binding.cc

2

CONTRIBUTING.md

@@ -55,3 +55,3 @@ # Introduction

_To test:_
- `./script/parse-examples.rb` runs the tests and outputs them to `known-errors.txt`, representing the files that have any errors or `MISSING ;` flags.
- `./script/parse-examples` runs the tests and outputs them to `known-errors.txt`, representing the files that have any errors or `MISSING ;` flags.
- The goal is to drive down the errors in `known-errors.txt` to 0.

@@ -58,0 +58,0 @@ - `known-errors.txt` allows you to find erroring files and parse them individually to diagnose and debug errors.

@@ -36,7 +36,7 @@ const DIGITS = token(sep1(/[0-9]+/, /_+/))

supertypes: $ => [
$._expression,
$._declaration,
$._statement,
$.expression,
$.declaration,
$.statement,
$.primary_expression,
$._literal,
$._primary,
$._type,

@@ -48,9 +48,5 @@ $._simple_type,

inline: $ => [
$._numeric_type,
$._ambiguous_name,
$._name,
$._simple_type,
$._reserved_identifier,
$._class_member_declaration,
$._interface_member_declaration,
$._annotation_type_member_declaration,
$._class_body_declaration,

@@ -63,11 +59,8 @@ $._variable_initializer

[$.modifiers, $.annotated_type, $.module_declaration, $.package_declaration],
[$._variable_declarator_id],
[$._unannotated_type, $._expression],
[$._unannotated_type, $._expression, $.inferred_parameters],
[$._unannotated_type, $.class_literal],
[$._unannotated_type, $.class_literal, $.array_access],
[$._unannotated_type, $.method_reference],
[$._unannotated_type, $.primary_expression, $.inferred_parameters],
[$._unannotated_type, $.primary_expression],
[$._unannotated_type, $.primary_expression, $.scoped_type_identifier],
[$._unannotated_type, $.scoped_type_identifier],
[$._unannotated_type, $.generic_type],
[$._expression, $.generic_type],
[$.scoped_identifier, $.scoped_type_identifier],
[$.generic_type, $.primary_expression],
],

@@ -78,3 +71,3 @@

rules: {
program: $ => repeat($._statement),
program: $ => repeat($.statement),

@@ -165,3 +158,3 @@ // Literals

_expression: $ => choice(
expression: $ => choice(
$.assignment_expression,

@@ -173,4 +166,3 @@ $.binary_expression,

$.update_expression,
prec.dynamic(1, $._ambiguous_name),
$._primary,
$.primary_expression,
$.unary_expression,

@@ -184,3 +176,3 @@ $.cast_expression

')',
field('value', $._expression)
field('value', $.expression)
)),

@@ -190,3 +182,4 @@

field('left', choice(
$._ambiguous_name,
$.identifier,
$._reserved_identifier,
$.field_access,

@@ -196,3 +189,3 @@ $.array_access

field('operator', choice('=', '+=', '-=', '*=', '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>=')),
field('right', $._expression)
field('right', $.expression)
)),

@@ -223,5 +216,5 @@

prec.left(precedence, seq(
field('left', $._expression),
field('left', $.expression),
field('operator', operator),
field('right', $._expression)
field('right', $.expression)
))

@@ -231,3 +224,3 @@ )),

instanceof_expression: $ => prec(PREC.REL, seq(
field('left', $._expression),
field('left', $.expression),
'instanceof',

@@ -242,3 +235,3 @@ field('right', $._type)

'->',
field('body', choice($._expression, $.block))
field('body', choice($.expression, $.block))
),

@@ -253,7 +246,7 @@

ternary_expression: $ => prec.right(PREC.TERNARY, seq(
field('condition', $._expression),
field('condition', $.expression),
'?',
field('consequence', $._expression),
field('consequence', $.expression),
':',
field('alternative', $._expression)
field('alternative', $.expression)
)),

@@ -269,3 +262,3 @@

field('operator', operator),
field('operand', $._expression)
field('operand', $.expression)
))

@@ -275,12 +268,14 @@ )),

update_expression: $ => prec.left(PREC.INC, choice(
seq($._expression, '++'),
seq($._expression, '--'),
seq('++', $._expression),
seq('--', $._expression)
seq($.expression, '++'),
seq($.expression, '--'),
seq('++', $.expression),
seq('--', $.expression)
)),
_primary: $ => choice(
primary_expression: $ => choice(
$._literal,
$.class_literal,
$.this,
$.identifier,
$._reserved_identifier,
$.parenthesized_expression,

@@ -310,17 +305,11 @@ $.object_creation_expression,

dimensions_expr: $ => seq(repeat($._annotation), '[', $._expression, ']'),
dimensions_expr: $ => seq(repeat($._annotation), '[', $.expression, ']'),
parenthesized_expression: $ => seq('(', $._expression, ')'),
parenthesized_expression: $ => seq('(', $.expression, ')'),
class_literal: $ => choice(
seq($._ambiguous_name, repeat(seq('[', ']')), '.', 'class'),
seq($._numeric_type, repeat(seq('[', ']')), '.', 'class'),
seq($.boolean_type, repeat(seq('[', ']')), '.', 'class'),
seq($.void_type, '.', 'class')
),
class_literal: $ => seq($._unannotated_type, '.', 'class'),
object_creation_expression: $ => choice(
$._unqualified_object_creation_expression,
seq($._ambiguous_name, '.', $._unqualified_object_creation_expression),
seq($._primary, '.', $._unqualified_object_creation_expression)
seq($.primary_expression, '.', $._unqualified_object_creation_expression)
),

@@ -336,26 +325,16 @@

field_access: $ => choice(
seq(
field('object', $._ambiguous_name),
field_access: $ => seq(
field('object', choice($.primary_expression, $.super)),
optional(seq(
'.',
field('field', $.this)
),
seq(
field('object', choice($._primary, $.super)),
'.',
field('field', $.identifier)
),
seq(
field('object', $._ambiguous_name),
'.',
$.super,
'.',
field('field', $.identifier)
)
$.super
)),
'.',
field('field', choice($.identifier, $._reserved_identifier, $.this))
),
array_access: $ => seq(
field('array', choice($._ambiguous_name, $._primary)),
field('array', $.primary_expression),
'[',
field('index', $._expression),
field('index', $.expression),
']',

@@ -368,19 +347,10 @@ ),

seq(
field('object', choice(
$._ambiguous_name,
$._primary,
field('object', choice($.primary_expression, $.super)),
'.',
optional(seq(
$.super,
$._ambiguous_name
'.'
)),
'.',
field('type_arguments', optional($.type_arguments)),
field('name', $.identifier),
),
seq(
field('object', $._ambiguous_name),
'.',
$.super,
'.',
field('type_arguments', optional($.type_arguments)),
field('name', $.identifier),
field('name', choice($.identifier, $._reserved_identifier)),
)

@@ -391,6 +361,6 @@ ),

argument_list: $ => seq('(', commaSep($._expression), ')'),
argument_list: $ => seq('(', commaSep($.expression), ')'),
method_reference: $ => seq(
choice($._type, $._ambiguous_name, $._primary, $.super),
choice($._type, $.primary_expression, $.super),
'::',

@@ -424,4 +394,4 @@ optional($.type_arguments),

_statement: $ => choice(
$._declaration,
statement: $ => choice(
$.declaration,
$.expression_statement,

@@ -442,3 +412,3 @@ $.labeled_statement,

$.synchronized_statement,
$.local_variable_declaration_statement,
$.local_variable_declaration,
$.throw_statement,

@@ -450,7 +420,7 @@ $.try_statement,

block: $ => seq(
'{', repeat($._statement), '}'
'{', repeat($.statement), '}'
),
expression_statement: $ => seq(
$._expression,
$.expression,
';'

@@ -460,8 +430,8 @@ ),

labeled_statement: $ => seq(
$.identifier, ':', $._statement
$.identifier, ':', $.statement
),
assert_statement: $ => choice(
seq('assert', $._expression, ';'),
seq('assert', $._expression, ':', $._expression, ';')
seq('assert', $.expression, ';'),
seq('assert', $.expression, ':', $.expression, ';')
),

@@ -477,3 +447,3 @@

'{',
repeat(choice($.switch_label, $._statement)),
repeat(choice($.switch_label, $.statement)),
'}'

@@ -483,3 +453,3 @@ ),

switch_label: $ => choice(
seq('case', $._expression, ':'),
seq('case', $.expression, ':'),
seq('default', ':')

@@ -489,3 +459,7 @@ ),

do_statement: $ => seq(
'do', $._statement, 'while', '(', $._expression, ')', ';'
'do',
field('body', $.statement),
'while',
field('condition', $.parenthesized_expression),
';'
),

@@ -499,9 +473,13 @@

'return',
optional($._expression),
optional($.expression),
';'
),
synchronized_statement: $ => seq('synchronized', '(', $._expression, ')', $.block),
synchronized_statement: $ => seq(
'synchronized',
$.parenthesized_expression,
field('body', $.block)
),
throw_statement: $ => seq('throw', $._expression, ';'),
throw_statement: $ => seq('throw', $.expression, ';'),

@@ -553,5 +531,5 @@ try_statement: $ => seq(

'=',
field('value', $._expression)
field('value', $.expression)
),
$._ambiguous_name,
$.identifier,
$.field_access

@@ -563,4 +541,4 @@ ),

field('condition', $.parenthesized_expression),
field('consequence', $._statement),
optional(seq('else', field('alternative', $._statement)))
field('consequence', $.statement),
optional(seq('else', field('alternative', $.statement)))
)),

@@ -571,3 +549,3 @@

field('condition', $.parenthesized_expression),
field('body', $._statement)
field('body', $.statement)
),

@@ -577,13 +555,14 @@

'for', '(',
optional($.for_init), ';',
optional($._expression), ';',
commaSep($._expression), ')',
$._statement
choice(
field('init', $.local_variable_declaration),
seq(
commaSep(field('init', $.expression)),
';'
)
),
field('condition', optional($.expression)), ';',
commaSep(field('update', $.expression)), ')',
field('body', $.statement)
),
for_init: $ => choice(
commaSep1($._expression),
$.local_variable_declaration,
),
enhanced_for_statement: $ => seq(

@@ -596,5 +575,5 @@ 'for',

':',
field('value', $._expression),
field('value', $.expression),
')',
field('body', $._statement)
field('body', $.statement)
),

@@ -611,3 +590,3 @@

'@',
field('name', choice($.identifier, $.scoped_identifier))
field('name', $._name)
),

@@ -617,3 +596,3 @@

'@',
field('name', choice($.identifier, $.scoped_identifier)),
field('name', $._name),
field('arguments', $.annotation_argument_list)

@@ -638,3 +617,3 @@ ),

_element_value: $ => prec(1, choice(
$._expression,
$.expression,
$.element_value_array_initializer,

@@ -653,3 +632,3 @@ $._annotation

_declaration: $ => prec(1, choice(
declaration: $ => prec(1, choice(
$.module_declaration,

@@ -668,3 +647,7 @@ $.package_declaration,

'module',
$._ambiguous_name,
field('name', $._name),
field('body', $.module_body)
),
module_body: $ => seq(
'{',

@@ -676,7 +659,7 @@ repeat($.module_directive),

module_directive: $ => seq(choice(
seq('requires', repeat($.requires_modifier), $.module_name),
seq('exports', $._ambiguous_name, optional('to'), optional($.module_name), repeat(seq(',', $.module_name))),
seq('opens', $._ambiguous_name, optional('to'), optional($.module_name), repeat(seq(',', $.module_name))),
seq('uses', $._ambiguous_name),
seq('provides', $._ambiguous_name, 'with', $._ambiguous_name, repeat(seq(',', $._ambiguous_name)))
seq('requires', repeat($.requires_modifier), $._name),
seq('exports', $._name, optional('to'), optional($._name), repeat(seq(',', $._name))),
seq('opens', $._name, optional('to'), optional($._name), repeat(seq(',', $._name))),
seq('uses', $._name),
seq('provides', $._name, 'with', $._name, repeat(seq(',', $._name)))
), ';'),

@@ -689,11 +672,6 @@

module_name: $ => choice(
$.identifier,
seq($.module_name, '.', $.identifier)
),
package_declaration: $ => seq(
repeat($._annotation),
'package',
$._ambiguous_name,
$._name,
';'

@@ -705,3 +683,3 @@ ),

optional('static'),
sep1($.identifier, '.'),
$._name,
optional(seq('.', $.asterisk)),

@@ -801,6 +779,12 @@ ';'

_class_body_declaration: $ => choice(
$._class_member_declaration,
$.field_declaration,
$.method_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration,
$.enum_declaration,
$.block,
$.static_initializer,
$.constructor_declaration
$.constructor_declaration,
';'
),

@@ -821,3 +805,3 @@

_constructor_declarator: $ => seq(
field('type_paramaters', optional($.type_parameters)),
field('type_parameters', optional($.type_parameters)),
field('name', $.identifier),

@@ -830,3 +814,3 @@ field('parameters', $.formal_parameters)

optional($.explicit_constructor_invocation),
repeat($._statement),
repeat($.statement),
'}'

@@ -842,3 +826,3 @@ ),

seq(
field('object', choice($._ambiguous_name, $._primary)),
field('object', choice($.primary_expression)),
'.',

@@ -853,3 +837,3 @@ field('type_arguments', optional($.type_arguments)),

_ambiguous_name: $ => choice(
_name: $ => choice(
$.identifier,

@@ -861,17 +845,7 @@ $._reserved_identifier,

scoped_identifier: $ => seq(
choice($.identifier, $._reserved_identifier, $.scoped_identifier),
field('scope', $._name),
'.',
$.identifier
field('name', $.identifier)
),
_class_member_declaration: $ => choice(
$.field_declaration,
$.method_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration,
$.enum_declaration,
';'
),
field_declaration: $ => seq(

@@ -892,13 +866,12 @@ optional($.modifiers),

annotation_type_body: $ => seq(
'{', repeat($._annotation_type_member_declaration), '}'
'{', repeat(choice(
$.annotation_type_element_declaration,
$.constant_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration
)),
'}'
),
_annotation_type_member_declaration: $ => choice(
$.annotation_type_element_declaration,
$.constant_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration
),
annotation_type_element_declaration: $ => seq(

@@ -935,16 +908,14 @@ optional($.modifiers),

'{',
repeat($._interface_member_declaration),
repeat(choice(
$.constant_declaration,
$.enum_declaration,
$.method_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration,
';'
)),
'}'
),
_interface_member_declaration: $ => choice(
$.constant_declaration,
$.enum_declaration,
$.method_declaration,
$.class_declaration,
$.interface_declaration,
$.annotation_type_declaration,
';'
),
constant_declaration: $ => seq(

@@ -972,3 +943,3 @@ optional($.modifiers),

_variable_initializer: $ => choice(
$._expression,
$.expression,
$.array_initializer

@@ -998,3 +969,4 @@ ),

$.void_type,
$._numeric_type,
$.integral_type,
$.floating_point_type,
$.boolean_type,

@@ -1035,7 +1007,2 @@ alias($.identifier, $.type_identifier),

_numeric_type: $ => choice(
$.integral_type,
$.floating_point_type
),
integral_type: $ => choice(

@@ -1077,5 +1044,3 @@ 'byte',

optional($.receiver_parameter),
commaSep($.formal_parameter),
optional(','),
optional($.spread_parameter),
commaSep(choice($.formal_parameter, $.spread_parameter)),
')'

@@ -1108,11 +1073,7 @@ ),

local_variable_declaration_statement: $ => seq(
$.local_variable_declaration,
';'
),
local_variable_declaration: $ => seq(
optional($.modifiers),
field('type', $._unannotated_type),
$._variable_declarator_list
$._variable_declarator_list,
';'
),

@@ -1135,3 +1096,4 @@

identifier: $ => /[a-zA-Z_]\w*/,
// https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-IdentifierChars
identifier: $ => /[A-Za-z_$][A-Za-z0-9_$]*/,

@@ -1138,0 +1100,0 @@ // http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890

{
"name": "tree-sitter-java",
"version": "0.16.0",
"version": "0.19.1",
"description": "Java grammar for tree-sitter",
"main": "index.js",
"main": "bindings/node",
"keywords": [

@@ -17,24 +17,7 @@ "parser",

"dependencies": {
"nan": "^2.12.1"
"nan": "^2.14.1"
},
"devDependencies": {
"npm-watch": "^0.3.0",
"tree-sitter-cli": "^0.16.1"
"tree-sitter-cli": "^0.19.2"
},
"watch": {
"test": {
"patterns": [
"corpus"
],
"extensions": "java",
"quiet": true
},
"build-test": {
"patterns": [
"./"
],
"extensions": "js",
"quiet": true
}
},
"scripts": {

@@ -44,5 +27,3 @@ "build": "tree-sitter generate && node-gyp build",

"test-windows": "tree-sitter test",
"build-test": "tree-sitter generate && node-gyp build && tree-sitter test",
"watch-test": "npm-watch test",
"watch-grammar": "npm-watch build-test"
"build-test": "tree-sitter generate && node-gyp build && tree-sitter test"
},

@@ -52,3 +33,11 @@ "repository": {

"url": "git+https://github.com/tree-sitter/tree-sitter-java.git"
}
},
"tree-sitter": [
{
"scope": "source.java",
"file-types": [
"java"
]
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc