Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

experimental hera types in Civet LSP #1036

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .civet/hera-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ const { compile: heraCompile } = Hera
export default {
transpilers: [{
extension: ".hera",
target: ".cjs",
target: ".ts",
compile: function (path, source) {
const code = heraCompile(source, {
return heraCompile(source, {
filename: path,
sourceMap: true,
types: true,
module: true,
})

return {
code
}
}
}],
}
2 changes: 1 addition & 1 deletion lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"dependencies": {},
"devDependencies": {
"@danielx/civet": "^0.6.72",
"@danielx/hera": "^0.7.12",
"@danielx/hera": "^0.8.11",
"@types/mocha": "^9",
"@types/node": "^14.17.0",
"@types/vscode": "^1.63.0",
Expand Down
1 change: 1 addition & 0 deletions lsp/source/extension.civet
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function activateClient(context: ExtensionContext)
documentSelector: [
{ scheme: 'file', language: 'civet' }
{ scheme: 'file', language: 'coffeescript' }
{ scheme: 'file', language: 'hera' }
{ scheme: 'file', language: 'javascript' }
{ scheme: 'file', language: 'javascriptreact' }
{ scheme: 'file', language: 'typescript' }
Expand Down
8 changes: 4 additions & 4 deletions lsp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@
"@typescript/vfs" "^1.5.0"
unplugin "^1.6.0"

"@danielx/hera@^0.7.12":
version "0.7.12"
resolved "https://registry.yarnpkg.com/@danielx/hera/-/hera-0.7.12.tgz#ce26d3ed052c39d23baf1b65e9c7de6dc38ad80d"
integrity sha512-YPqnLGZH7EML3t7u8KlBwjg9rv5h0gWIt8Kr3sZYB6rq1bqHgv30yQAyBs0hf1WTB76NQgA0ErJeIRbOuzRahw==
"@danielx/hera@^0.8.11":
version "0.8.11"
resolved "https://registry.yarnpkg.com/@danielx/hera/-/hera-0.8.11.tgz#ccf8ba4a231a0b1308bb0ee24b03c1c25d5b3488"
integrity sha512-1AQVUh0uji4ExSZk62vYQ6K152j+CZN1E6i39/Jb3z3A4b3VqYByezHwcg4mZloT4RWaPo35zT5pwtnwutNIcQ==

"@esbuild/android-arm64@0.19.2":
version "0.19.2"
Expand Down
6 changes: 5 additions & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ import {
wrapIIFE,
} from "./parser/lib.civet"

import type {
UpdateExpression,
} from "./parser/types.civet"

/**
* A global object to hold methods used in rule handlers
* We can probably transition away from this now that Hera
Expand Down Expand Up @@ -455,7 +459,7 @@ NWTypePostfix
# https://262.ecma-international.org/#prod-UpdateExpression
UpdateExpression
# NOTE: Not allowing whitespace betwen prefix and postfix increment operators and operand
UpdateExpressionSymbol UnaryWithoutParenthesizedAssignment ->
UpdateExpressionSymbol UnaryWithoutParenthesizedAssignment :: UpdateExpression ->
return {
type: "UpdateExpression",
assigned: $2,
Expand Down
1 change: 0 additions & 1 deletion source/parser/pipe.civet
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function constructPipeStep(fn, arg, returning) {
return [constructInvocation(fn, arg), null]
}


// head: expr
// body: [ws, pipe, ws, expr][]

Expand Down
5 changes: 5 additions & 0 deletions source/parser/types.civet
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export type StatementTuple = [IndentNode, ASTNode, StatementDelimiter?]

export type Condition = ParenthesizedExpression

export type UpdateExpression
type: "UpdateExpression"
children: Children
assigned: ASTNode

export type ParenthesizedExpression
type: "ParenthesizedExpression"
children: Children
Expand Down
Loading