Skip to content

Commit

Permalink
Add Ruby support. Fixes #41
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed May 9, 2022
1 parent 0931d47 commit f29ebcf
Show file tree
Hide file tree
Showing 11 changed files with 404 additions and 5 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ If your contribution is to add support for a new programming language, follow th
- If the Cucumber implementation does not support Cucumber Expressions, make `defineParameterTypeQueries` an empty array
6. Add the name of the new language to the `LanguageName` type
7. Update `treeSitterLanguageByName` in `src/tree-sitter/ExpressionBuilder.ts`
8 Update `src/tree-sitter-node/NodeParserAdaapter.ts`
8. Run tests

As you are working on step 1 and 2 - use [tree-sitter playground](https://tree-sitter.github.io/tree-sitter/playground)
Expand Down
303 changes: 303 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"tree-sitter-c-sharp": "0.19.1",
"tree-sitter-java": "0.19.1",
"tree-sitter-php": "0.19.0",
"tree-sitter-ruby": "0.19.0",
"tree-sitter-typescript": "0.20.1",
"vscode-languageserver-types": "3.17.0-next.12"
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const languages = [
dir: '',
wasm: 'php',
},
{
npm: 'tree-sitter-ruby',
dir: '',
wasm: 'ruby',
},
]

// Build wasm parsers for supported languages
Expand Down
5 changes: 5 additions & 0 deletions src/tree-sitter-node/NodeParserAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Java from 'tree-sitter-java'
// @ts-ignore
import Php from 'tree-sitter-php'
// @ts-ignore
import Ruby from 'tree-sitter-ruby'
// @ts-ignore
import TypeScript from 'tree-sitter-typescript'

import { LanguageName, ParserAdapter } from '../tree-sitter/types.js'
Expand All @@ -31,6 +33,9 @@ export class NodeParserAdapter implements ParserAdapter {
case 'php':
this.parser.setLanguage(Php)
break
case 'ruby':
this.parser.setLanguage(Ruby)
break
default:
throw new Error(`Unsupported language: ${language}`)
}
Expand Down
Loading

0 comments on commit f29ebcf

Please sign in to comment.