-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update parser to be compatible with
def
Index simple defs identifiers.
- Loading branch information
1 parent
5ee17d3
commit 9640d90
Showing
11 changed files
with
34,929 additions
and
19,885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
init: | ||
$(MAKE) clone-tree-sitter | ||
cp tree-sitter-c3/src/parser.c server/c3/parser.c | ||
cp -r tree-sitter-c3/src/tree_sitter server/c3/tree_sitter | ||
|
||
$(MAKE) copy-parser | ||
|
||
clone-tree-sitter: | ||
[ ! -d "tree-sitter-c3" ] && git clone [email protected]:zweimach/tree-sitter-c3.git tree-sitter-c3 || true | ||
|
||
|
||
#build-parser: | ||
# cp yacc-2-treesitter/grammar.js ./grammar.js | ||
# tree-sitter generate | ||
build-parser: | ||
cd tree-sitter-c3 && tree-sitter generate | ||
$(MAKE) copy-parser | ||
#cp yacc-2-treesitter/grammar.js ./grammar.js | ||
#tree-sitter generate | ||
|
||
copy-parser: | ||
cp -r tree-sitter-c3/src/tree_sitter server/lsp/tree_sitter | ||
cp tree-sitter-c3/src/parser.c server/lsp/parser.c | ||
|
||
build-dev: | ||
cd server && go build -gcflags="all=-N -l" -o c3-lsp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package indexables | ||
|
||
import protocol "github.com/tliron/glsp/protocol_3_16" | ||
|
||
type DefBuilder struct { | ||
def Def | ||
} | ||
|
||
func NewDefBuilder(name string, docId string) *DefBuilder { | ||
return &DefBuilder{ | ||
def: Def{ | ||
name: name, | ||
BaseIndexable: BaseIndexable{ | ||
documentURI: docId, | ||
Kind: protocol.CompletionItemKindTypeParameter, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (d *DefBuilder) WithIdentifierRange(lineStart uint, CharStart uint, lineEnd uint, CharEnd uint) *DefBuilder { | ||
d.def.BaseIndexable.identifierRange = NewRange(lineStart, CharStart, lineEnd, CharEnd) | ||
return d | ||
} | ||
|
||
func (d *DefBuilder) WithDocumentRange(lineStart uint, CharStart uint, lineEnd uint, CharEnd uint) *DefBuilder { | ||
d.def.BaseIndexable.documentRange = NewRange(lineStart, CharStart, lineEnd, CharEnd) | ||
return d | ||
} | ||
|
||
func (d *DefBuilder) Build() Def { | ||
return d.def | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package indexables | ||
|
||
import ( | ||
"fmt" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
type Def struct { | ||
name string | ||
BaseIndexable | ||
} | ||
|
||
func NewDef(name string, docId string, idRange Range, docRange Range) Def { | ||
return Def{ | ||
name: name, | ||
BaseIndexable: BaseIndexable{ | ||
documentURI: docId, | ||
identifierRange: idRange, | ||
documentRange: docRange, | ||
Kind: protocol.CompletionItemKindTypeParameter, | ||
}, | ||
} | ||
} | ||
|
||
func (d Def) GetName() string { | ||
return d.name | ||
} | ||
|
||
func (d Def) GetKind() protocol.CompletionItemKind { | ||
return d.Kind | ||
} | ||
|
||
func (d Def) GetDocumentURI() string { | ||
return d.documentURI | ||
} | ||
|
||
func (d Def) GetDeclarationRange() Range { | ||
return d.identifierRange | ||
} | ||
|
||
func (d Def) GetDocumentRange() Range { | ||
return d.documentRange | ||
} | ||
|
||
func (d Def) GetHoverInfo() string { | ||
return fmt.Sprintf("def %s = ???", d.name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.