Wuff 0.0.2__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Wuff might be problematic. Click here for more details.
- Wuff-0.0.4/MANIFEST.in +3 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/PKG-INFO +2 -2
- {Wuff-0.0.2 → Wuff-0.0.4}/Wuff.egg-info/PKG-INFO +2 -2
- Wuff-0.0.4/Wuff.egg-info/SOURCES.txt +71 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/setup.py +2 -2
- Wuff-0.0.4/wuff/Bindings.cpp +121 -0
- Wuff-0.0.4/wuff/CMakeLists.txt +133 -0
- Wuff-0.0.4/wuff/README.md +3 -0
- Wuff-0.0.4/wuff/WooWooAnalyzer.cpp +225 -0
- Wuff-0.0.4/wuff/WooWooAnalyzer.h +81 -0
- Wuff-0.0.4/wuff/components/Completer.cpp +153 -0
- Wuff-0.0.4/wuff/components/Completer.h +35 -0
- Wuff-0.0.4/wuff/components/Component.cpp +39 -0
- Wuff-0.0.4/wuff/components/Component.h +27 -0
- Wuff-0.0.4/wuff/components/Folder.cpp +52 -0
- Wuff-0.0.4/wuff/components/Folder.h +29 -0
- Wuff-0.0.4/wuff/components/Highlighter.cpp +288 -0
- Wuff-0.0.4/wuff/components/Highlighter.h +63 -0
- Wuff-0.0.4/wuff/components/Hoverer.cpp +54 -0
- Wuff-0.0.4/wuff/components/Hoverer.h +28 -0
- Wuff-0.0.4/wuff/components/Linter.cpp +94 -0
- Wuff-0.0.4/wuff/components/Linter.h +32 -0
- Wuff-0.0.4/wuff/components/Navigator.cpp +179 -0
- Wuff-0.0.4/wuff/components/Navigator.h +39 -0
- Wuff-0.0.4/wuff/dialect/Dialect.cpp +75 -0
- Wuff-0.0.4/wuff/dialect/Dialect.h +43 -0
- Wuff-0.0.4/wuff/dialect/DialectManager.cpp +198 -0
- Wuff-0.0.4/wuff/dialect/DialectManager.h +47 -0
- Wuff-0.0.4/wuff/dialect/DocumentPart.cpp +25 -0
- Wuff-0.0.4/wuff/dialect/DocumentPart.h +33 -0
- Wuff-0.0.4/wuff/dialect/Field.cpp +29 -0
- Wuff-0.0.4/wuff/dialect/Field.h +26 -0
- Wuff-0.0.4/wuff/dialect/IDescribable.h +17 -0
- Wuff-0.0.4/wuff/dialect/InnerEnvironment.cpp +36 -0
- Wuff-0.0.4/wuff/dialect/InnerEnvironment.h +37 -0
- Wuff-0.0.4/wuff/dialect/MetaBlock.cpp +28 -0
- Wuff-0.0.4/wuff/dialect/MetaBlock.h +23 -0
- Wuff-0.0.4/wuff/dialect/OuterEnvironment.cpp +26 -0
- Wuff-0.0.4/wuff/dialect/OuterEnvironment.h +33 -0
- Wuff-0.0.4/wuff/dialect/Reference.cpp +39 -0
- Wuff-0.0.4/wuff/dialect/Reference.h +33 -0
- Wuff-0.0.4/wuff/dialect/Shorthand.cpp +34 -0
- Wuff-0.0.4/wuff/dialect/Shorthand.h +27 -0
- Wuff-0.0.4/wuff/dialect/Wobject.cpp +23 -0
- Wuff-0.0.4/wuff/dialect/Wobject.h +34 -0
- Wuff-0.0.4/wuff/document/CommentLine.cpp +5 -0
- Wuff-0.0.4/wuff/document/CommentLine.h +20 -0
- Wuff-0.0.4/wuff/document/DialectedWooWooDocument.cpp +122 -0
- Wuff-0.0.4/wuff/document/DialectedWooWooDocument.h +42 -0
- Wuff-0.0.4/wuff/document/MetaContext.cpp +28 -0
- Wuff-0.0.4/wuff/document/MetaContext.h +27 -0
- Wuff-0.0.4/wuff/document/UTF8toUTF16Mapping.cpp +106 -0
- Wuff-0.0.4/wuff/document/UTF8toUTF16Mapping.h +32 -0
- Wuff-0.0.4/wuff/document/WooWooDocument.cpp +96 -0
- Wuff-0.0.4/wuff/document/WooWooDocument.h +44 -0
- Wuff-0.0.4/wuff/lsp/LSPTypes.h +146 -0
- Wuff-0.0.4/wuff/parser/Parser.cpp +117 -0
- Wuff-0.0.4/wuff/parser/Parser.h +36 -0
- Wuff-0.0.4/wuff/tree-sitter/woowoo/parser.c +10363 -0
- Wuff-0.0.4/wuff/tree-sitter/woowoo/scanner.cc +718 -0
- Wuff-0.0.4/wuff/tree-sitter/woowoo/tree_sitter/parser.h +224 -0
- Wuff-0.0.4/wuff/tree-sitter/yaml/parser.c +38751 -0
- Wuff-0.0.4/wuff/tree-sitter/yaml/scanner.cc +981 -0
- Wuff-0.0.4/wuff/tree-sitter/yaml/schema.generated.cc +204 -0
- Wuff-0.0.4/wuff/tree-sitter/yaml/tree_sitter/parser.h +224 -0
- Wuff-0.0.4/wuff/utils/utils.cpp +108 -0
- Wuff-0.0.4/wuff/utils/utils.h +21 -0
- Wuff-0.0.2/Wuff.egg-info/SOURCES.txt +0 -8
- {Wuff-0.0.2 → Wuff-0.0.4}/README.md +0 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/Wuff.egg-info/dependency_links.txt +0 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/Wuff.egg-info/not-zip-safe +0 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/Wuff.egg-info/requires.txt +0 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/Wuff.egg-info/top_level.txt +0 -0
- {Wuff-0.0.2 → Wuff-0.0.4}/setup.cfg +0 -0
Wuff-0.0.4/MANIFEST.in
ADDED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: Wuff
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Analyzer tools for WooWoo projects
|
|
5
5
|
Author: Michal Janecek
|
|
6
6
|
Author-email: michal.janecek@gmail.com
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Provides-Extra: test
|
|
10
10
|
Requires-Dist: pytest>=6.0; extra == "test"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: Wuff
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Analyzer tools for WooWoo projects
|
|
5
5
|
Author: Michal Janecek
|
|
6
6
|
Author-email: michal.janecek@gmail.com
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Provides-Extra: test
|
|
10
10
|
Requires-Dist: pytest>=6.0; extra == "test"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
Wuff.egg-info/PKG-INFO
|
|
5
|
+
Wuff.egg-info/SOURCES.txt
|
|
6
|
+
Wuff.egg-info/dependency_links.txt
|
|
7
|
+
Wuff.egg-info/not-zip-safe
|
|
8
|
+
Wuff.egg-info/requires.txt
|
|
9
|
+
Wuff.egg-info/top_level.txt
|
|
10
|
+
wuff/Bindings.cpp
|
|
11
|
+
wuff/CMakeLists.txt
|
|
12
|
+
wuff/README.md
|
|
13
|
+
wuff/WooWooAnalyzer.cpp
|
|
14
|
+
wuff/WooWooAnalyzer.h
|
|
15
|
+
wuff/components/Completer.cpp
|
|
16
|
+
wuff/components/Completer.h
|
|
17
|
+
wuff/components/Component.cpp
|
|
18
|
+
wuff/components/Component.h
|
|
19
|
+
wuff/components/Folder.cpp
|
|
20
|
+
wuff/components/Folder.h
|
|
21
|
+
wuff/components/Highlighter.cpp
|
|
22
|
+
wuff/components/Highlighter.h
|
|
23
|
+
wuff/components/Hoverer.cpp
|
|
24
|
+
wuff/components/Hoverer.h
|
|
25
|
+
wuff/components/Linter.cpp
|
|
26
|
+
wuff/components/Linter.h
|
|
27
|
+
wuff/components/Navigator.cpp
|
|
28
|
+
wuff/components/Navigator.h
|
|
29
|
+
wuff/dialect/Dialect.cpp
|
|
30
|
+
wuff/dialect/Dialect.h
|
|
31
|
+
wuff/dialect/DialectManager.cpp
|
|
32
|
+
wuff/dialect/DialectManager.h
|
|
33
|
+
wuff/dialect/DocumentPart.cpp
|
|
34
|
+
wuff/dialect/DocumentPart.h
|
|
35
|
+
wuff/dialect/Field.cpp
|
|
36
|
+
wuff/dialect/Field.h
|
|
37
|
+
wuff/dialect/IDescribable.h
|
|
38
|
+
wuff/dialect/InnerEnvironment.cpp
|
|
39
|
+
wuff/dialect/InnerEnvironment.h
|
|
40
|
+
wuff/dialect/MetaBlock.cpp
|
|
41
|
+
wuff/dialect/MetaBlock.h
|
|
42
|
+
wuff/dialect/OuterEnvironment.cpp
|
|
43
|
+
wuff/dialect/OuterEnvironment.h
|
|
44
|
+
wuff/dialect/Reference.cpp
|
|
45
|
+
wuff/dialect/Reference.h
|
|
46
|
+
wuff/dialect/Shorthand.cpp
|
|
47
|
+
wuff/dialect/Shorthand.h
|
|
48
|
+
wuff/dialect/Wobject.cpp
|
|
49
|
+
wuff/dialect/Wobject.h
|
|
50
|
+
wuff/document/CommentLine.cpp
|
|
51
|
+
wuff/document/CommentLine.h
|
|
52
|
+
wuff/document/DialectedWooWooDocument.cpp
|
|
53
|
+
wuff/document/DialectedWooWooDocument.h
|
|
54
|
+
wuff/document/MetaContext.cpp
|
|
55
|
+
wuff/document/MetaContext.h
|
|
56
|
+
wuff/document/UTF8toUTF16Mapping.cpp
|
|
57
|
+
wuff/document/UTF8toUTF16Mapping.h
|
|
58
|
+
wuff/document/WooWooDocument.cpp
|
|
59
|
+
wuff/document/WooWooDocument.h
|
|
60
|
+
wuff/lsp/LSPTypes.h
|
|
61
|
+
wuff/parser/Parser.cpp
|
|
62
|
+
wuff/parser/Parser.h
|
|
63
|
+
wuff/tree-sitter/woowoo/parser.c
|
|
64
|
+
wuff/tree-sitter/woowoo/scanner.cc
|
|
65
|
+
wuff/tree-sitter/woowoo/tree_sitter/parser.h
|
|
66
|
+
wuff/tree-sitter/yaml/parser.c
|
|
67
|
+
wuff/tree-sitter/yaml/scanner.cc
|
|
68
|
+
wuff/tree-sitter/yaml/schema.generated.cc
|
|
69
|
+
wuff/tree-sitter/yaml/tree_sitter/parser.h
|
|
70
|
+
wuff/utils/utils.cpp
|
|
71
|
+
wuff/utils/utils.h
|
|
@@ -132,7 +132,7 @@ with open(path.join(this_directory, 'wuff/README.md'), encoding='utf-8') as f:
|
|
|
132
132
|
# logic and declaration, and simpler if you include description/version in a file.
|
|
133
133
|
setup(
|
|
134
134
|
name="Wuff",
|
|
135
|
-
version="0.0.
|
|
135
|
+
version="0.0.4",
|
|
136
136
|
author="Michal Janecek",
|
|
137
137
|
author_email="michal.janecek@gmail.com",
|
|
138
138
|
description="Analyzer tools for WooWoo projects",
|
|
@@ -142,6 +142,6 @@ setup(
|
|
|
142
142
|
cmdclass={"build_ext": CMakeBuild},
|
|
143
143
|
zip_safe=False,
|
|
144
144
|
extras_require={"test": ["pytest>=6.0"]},
|
|
145
|
-
python_requires=">=3.
|
|
145
|
+
python_requires=">=3.7",
|
|
146
146
|
)
|
|
147
147
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Michal Janecek on 27.01.2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
#include <pybind11/pybind11.h>
|
|
7
|
+
#include <pybind11/stl.h>
|
|
8
|
+
#include "WooWooAnalyzer.h"
|
|
9
|
+
#include "lsp/LSPTypes.h"
|
|
10
|
+
|
|
11
|
+
namespace py = pybind11;
|
|
12
|
+
|
|
13
|
+
PYBIND11_MODULE(Wuff, m) {
|
|
14
|
+
py::class_<WooWooAnalyzer>(m, "WooWooAnalyzer")
|
|
15
|
+
.def(py::init<>())
|
|
16
|
+
.def("set_dialect", &WooWooAnalyzer::setDialect)
|
|
17
|
+
.def("load_workspace", &WooWooAnalyzer::loadWorkspace)
|
|
18
|
+
.def("hover", &WooWooAnalyzer::hover)
|
|
19
|
+
.def("semantic_tokens", &WooWooAnalyzer::semanticTokens)
|
|
20
|
+
.def("go_to_definition", &WooWooAnalyzer::goToDefinition)
|
|
21
|
+
.def("complete", &WooWooAnalyzer::complete)
|
|
22
|
+
.def("folding_ranges", &WooWooAnalyzer::foldingRanges)
|
|
23
|
+
.def("document_did_change", &WooWooAnalyzer::documentDidChange)
|
|
24
|
+
.def("open_document", &WooWooAnalyzer::openDocument)
|
|
25
|
+
.def("rename_document", &WooWooAnalyzer::renameDocument)
|
|
26
|
+
.def("diagnose", &WooWooAnalyzer::diagnose)
|
|
27
|
+
.def("set_token_types", &WooWooAnalyzer::setTokenTypes)
|
|
28
|
+
.def("set_token_modifiers", &WooWooAnalyzer::setTokenModifiers);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
py::class_<Position>(m, "Position")
|
|
32
|
+
.def(py::init<uint32_t, uint32_t>())
|
|
33
|
+
.def_readwrite("line", &Position::line)
|
|
34
|
+
.def_readwrite("character", &Position::character);
|
|
35
|
+
|
|
36
|
+
py::class_<Range>(m, "Range")
|
|
37
|
+
.def(py::init<Position, Position>())
|
|
38
|
+
.def_readwrite("start", &Range::start)
|
|
39
|
+
.def_readwrite("end", &Range::end);
|
|
40
|
+
|
|
41
|
+
py::class_<Location>(m, "Location")
|
|
42
|
+
.def(py::init<std::string, Range>())
|
|
43
|
+
.def_readwrite("uri", &Location::uri)
|
|
44
|
+
.def_readwrite("range", &Location::range);
|
|
45
|
+
|
|
46
|
+
py::enum_<CompletionTriggerKind>(m, "CompletionTriggerKind")
|
|
47
|
+
.value("Invoked", CompletionTriggerKind::Invoked)
|
|
48
|
+
.value("TriggerCharacter", CompletionTriggerKind::TriggerCharacter)
|
|
49
|
+
.value("TriggerForIncompleteCompletions", CompletionTriggerKind::TriggerForIncompleteCompletions)
|
|
50
|
+
.export_values();
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
py::class_<TextDocumentIdentifier>(m, "TextDocumentIdentifier")
|
|
54
|
+
.def(py::init<const std::string&>())
|
|
55
|
+
.def_readwrite("uri", &TextDocumentIdentifier::uri);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
py::class_<TextDocumentPositionParams>(m, "TextDocumentPositionParams")
|
|
59
|
+
.def(py::init<TextDocumentIdentifier, Position>())
|
|
60
|
+
.def_readwrite("text_document", &TextDocumentPositionParams::textDocument)
|
|
61
|
+
.def_readwrite("position", &TextDocumentPositionParams::position);
|
|
62
|
+
|
|
63
|
+
// just for clarity - internally, it is the same as TextDocumentPositionParams
|
|
64
|
+
py::class_<DefinitionParams, TextDocumentPositionParams>(m, "DefinitionParams")
|
|
65
|
+
.def(py::init<TextDocumentIdentifier, Position>());
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
py::class_<CompletionContext>(m, "CompletionContext")
|
|
70
|
+
.def(py::init<CompletionTriggerKind, std::optional<std::string>>())
|
|
71
|
+
.def_readwrite("trigger_kind", &CompletionContext::triggerKind)
|
|
72
|
+
.def_readwrite("trigger_character", &CompletionContext::triggerCharacter);
|
|
73
|
+
|
|
74
|
+
py::class_<CompletionParams, TextDocumentPositionParams>(m, "CompletionParams")
|
|
75
|
+
.def(py::init<const TextDocumentIdentifier&, const Position&, std::optional<CompletionContext>>())
|
|
76
|
+
.def_readwrite("context", &CompletionParams::context);
|
|
77
|
+
|
|
78
|
+
py::enum_<CompletionItemKind>(m, "CompletionItemKind")
|
|
79
|
+
.value("Text", CompletionItemKind::Text)
|
|
80
|
+
.value("Snippet", CompletionItemKind::Snippet)
|
|
81
|
+
// TODO: other possible values
|
|
82
|
+
.export_values();
|
|
83
|
+
|
|
84
|
+
py::enum_<InsertTextFormat>(m, "InsertTextFormat")
|
|
85
|
+
.value("PlainText", InsertTextFormat::PlainText)
|
|
86
|
+
.value("Snippet", InsertTextFormat::Snippet)
|
|
87
|
+
.export_values();
|
|
88
|
+
|
|
89
|
+
py::class_<CompletionItem>(m, "CompletionItem")
|
|
90
|
+
.def(py::init<std::string, std::optional<CompletionItemKind>,
|
|
91
|
+
std::optional<InsertTextFormat>, std::optional<std::string>>(),
|
|
92
|
+
py::arg("label"), py::arg("kind") = std::nullopt,
|
|
93
|
+
py::arg("insertTextFormat") = std::nullopt, py::arg("insertText") = std::nullopt)
|
|
94
|
+
.def_readwrite("label", &CompletionItem::label)
|
|
95
|
+
.def_readwrite("kind", &CompletionItem::kind)
|
|
96
|
+
.def_readwrite("insertTextFormat", &CompletionItem::insertTextFormat)
|
|
97
|
+
.def_readwrite("insertText", &CompletionItem::insertText);
|
|
98
|
+
|
|
99
|
+
py::enum_<DiagnosticSeverity>(m, "DiagnosticSeverity")
|
|
100
|
+
.value("Error", DiagnosticSeverity::Error)
|
|
101
|
+
.value("Warning", DiagnosticSeverity::Warning)
|
|
102
|
+
.value("Information", DiagnosticSeverity::Information)
|
|
103
|
+
.value("Hint", DiagnosticSeverity::Hint)
|
|
104
|
+
.export_values();
|
|
105
|
+
|
|
106
|
+
py::class_<Diagnostic>(m, "Diagnostic")
|
|
107
|
+
.def(py::init<Range, std::string, std::string, DiagnosticSeverity>())
|
|
108
|
+
.def_readwrite("range", &Diagnostic::range)
|
|
109
|
+
.def_readwrite("message", &Diagnostic::message)
|
|
110
|
+
.def_readwrite("source", &Diagnostic::source)
|
|
111
|
+
.def_readwrite("severity", &Diagnostic::severity);
|
|
112
|
+
|
|
113
|
+
py::class_<FoldingRange>(m, "FoldingRange")
|
|
114
|
+
.def_readwrite("start_line", &FoldingRange::startLine)
|
|
115
|
+
.def_readwrite("start_character", &FoldingRange::startCharacter)
|
|
116
|
+
.def_readwrite("end_line", &FoldingRange::endLine)
|
|
117
|
+
.def_readwrite("end_character", &FoldingRange::endCharacter)
|
|
118
|
+
.def_readwrite("kind", &FoldingRange::foldingRangeKind);
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.10)
|
|
2
|
+
project(Wuff)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
|
|
6
|
+
# - - - YAML-CPP
|
|
7
|
+
include(FetchContent)
|
|
8
|
+
|
|
9
|
+
FetchContent_Declare(
|
|
10
|
+
yaml-cpp
|
|
11
|
+
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
|
|
12
|
+
GIT_TAG master # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master)
|
|
13
|
+
)
|
|
14
|
+
FetchContent_GetProperties(yaml-cpp)
|
|
15
|
+
|
|
16
|
+
if (NOT yaml-cpp_POPULATED)
|
|
17
|
+
message(STATUS "Fetching yaml-cpp...")
|
|
18
|
+
FetchContent_Populate(yaml-cpp)
|
|
19
|
+
add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR})
|
|
20
|
+
endif ()
|
|
21
|
+
|
|
22
|
+
# - - - Tree-sitter
|
|
23
|
+
FetchContent_Declare(
|
|
24
|
+
tree_sitter
|
|
25
|
+
GIT_REPOSITORY https://github.com/tree-sitter/tree-sitter.git
|
|
26
|
+
GIT_TAG master
|
|
27
|
+
)
|
|
28
|
+
FetchContent_GetProperties(tree_sitter)
|
|
29
|
+
|
|
30
|
+
if (NOT tree_sitter_POPULATED)
|
|
31
|
+
message(STATUS "Fetching tree-sitter...")
|
|
32
|
+
FetchContent_Populate(tree_sitter)
|
|
33
|
+
# Since Tree-sitter does not use CMake, we manually add its source and include directories
|
|
34
|
+
set(TREE_SITTER_SRC ${tree_sitter_SOURCE_DIR}/lib/src/lib.c)
|
|
35
|
+
set(TREE_SITTER_INCLUDE_DIRS ${tree_sitter_SOURCE_DIR}/lib/include ${tree_sitter_SOURCE_DIR}/lib/src ${tree_sitter_SOURCE_DIR}/lib/src/unicode)
|
|
36
|
+
message(STATUS "Include directories: ${TREE_SITTER_INCLUDE_DIRS}")
|
|
37
|
+
endif ()
|
|
38
|
+
|
|
39
|
+
# Tree-Sitter WooWoo
|
|
40
|
+
set(WOOWOO_PARSER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter/woowoo/parser.c)
|
|
41
|
+
set(WOOWOO_SCANNER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter/woowoo/scanner.cc)
|
|
42
|
+
|
|
43
|
+
# Tree-Sitter YAML
|
|
44
|
+
set(YAML_PARSER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter/yaml/parser.c)
|
|
45
|
+
set(YAML_SCANNER_SRC ${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter/yaml/scanner.cc)
|
|
46
|
+
|
|
47
|
+
# - - - - -
|
|
48
|
+
|
|
49
|
+
FetchContent_Declare(
|
|
50
|
+
pybind11
|
|
51
|
+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
|
52
|
+
GIT_TAG v2.11.1
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Make pybind11 available for use
|
|
56
|
+
FetchContent_MakeAvailable(pybind11)
|
|
57
|
+
set(PYBIND11_PYTHON_VERSION "3.9")
|
|
58
|
+
pybind11_add_module(${PROJECT_NAME}
|
|
59
|
+
${TREE_SITTER_SRC} # Add Tree-sitter lib.c source
|
|
60
|
+
${WOOWOO_PARSER_SRC}
|
|
61
|
+
${WOOWOO_SCANNER_SRC}
|
|
62
|
+
${YAML_PARSER_SRC}
|
|
63
|
+
${YAML_SCANNER_SRC}
|
|
64
|
+
Bindings.cpp
|
|
65
|
+
WooWooAnalyzer.cpp
|
|
66
|
+
document/WooWooDocument.cpp
|
|
67
|
+
document/DialectedWooWooDocument.cpp
|
|
68
|
+
document/MetaContext.cpp
|
|
69
|
+
document/CommentLine.cpp
|
|
70
|
+
document/UTF8toUTF16Mapping.cpp
|
|
71
|
+
dialect/DialectManager.cpp
|
|
72
|
+
dialect/DocumentPart.cpp
|
|
73
|
+
dialect/Dialect.cpp
|
|
74
|
+
dialect/MetaBlock.cpp
|
|
75
|
+
dialect/Field.cpp
|
|
76
|
+
dialect/Shorthand.cpp
|
|
77
|
+
dialect/Reference.cpp
|
|
78
|
+
dialect/InnerEnvironment.cpp
|
|
79
|
+
dialect/OuterEnvironment.cpp
|
|
80
|
+
dialect/Wobject.cpp
|
|
81
|
+
components/Component.cpp
|
|
82
|
+
components/Hoverer.cpp
|
|
83
|
+
components/Highlighter.cpp
|
|
84
|
+
components/Navigator.cpp
|
|
85
|
+
components/Completer.cpp
|
|
86
|
+
components/Linter.cpp
|
|
87
|
+
components/Folder.cpp
|
|
88
|
+
parser/Parser.cpp
|
|
89
|
+
utils/utils.cpp
|
|
90
|
+
)
|
|
91
|
+
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${TREE_SITTER_INCLUDE_DIRS})
|
|
92
|
+
target_link_libraries(${PROJECT_NAME} PUBLIC yaml-cpp::yaml-cpp)
|
|
93
|
+
|
|
94
|
+
target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
|
|
95
|
+
|
|
96
|
+
# - - - WooWooTest
|
|
97
|
+
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
|
98
|
+
add_executable(WooWooTest
|
|
99
|
+
${TREE_SITTER_SRC}
|
|
100
|
+
${WOOWOO_PARSER_SRC}
|
|
101
|
+
${WOOWOO_SCANNER_SRC}
|
|
102
|
+
${YAML_PARSER_SRC}
|
|
103
|
+
${YAML_SCANNER_SRC}
|
|
104
|
+
main.cpp
|
|
105
|
+
WooWooAnalyzer.cpp
|
|
106
|
+
document/WooWooDocument.cpp
|
|
107
|
+
document/DialectedWooWooDocument.cpp
|
|
108
|
+
document/MetaContext.cpp
|
|
109
|
+
document/CommentLine.cpp
|
|
110
|
+
document/UTF8toUTF16Mapping.cpp
|
|
111
|
+
dialect/DialectManager.cpp
|
|
112
|
+
dialect/DocumentPart.cpp
|
|
113
|
+
dialect/Dialect.cpp
|
|
114
|
+
dialect/MetaBlock.cpp
|
|
115
|
+
dialect/Field.cpp
|
|
116
|
+
dialect/Shorthand.cpp
|
|
117
|
+
dialect/Reference.cpp
|
|
118
|
+
dialect/InnerEnvironment.cpp
|
|
119
|
+
dialect/OuterEnvironment.cpp
|
|
120
|
+
dialect/Wobject.cpp
|
|
121
|
+
components/Component.cpp
|
|
122
|
+
components/Hoverer.cpp
|
|
123
|
+
components/Highlighter.cpp
|
|
124
|
+
components/Navigator.cpp
|
|
125
|
+
components/Completer.cpp
|
|
126
|
+
components/Linter.cpp
|
|
127
|
+
components/Folder.cpp
|
|
128
|
+
parser/Parser.cpp
|
|
129
|
+
utils/utils.cpp
|
|
130
|
+
)
|
|
131
|
+
target_include_directories(WooWooTest SYSTEM PRIVATE ${TREE_SITTER_INCLUDE_DIRS})
|
|
132
|
+
target_link_libraries(WooWooTest PUBLIC yaml-cpp::yaml-cpp pybind11::embed)
|
|
133
|
+
endif ()
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Michal Janecek on 27.01.2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
//#include <pybind11/pybind11.h>
|
|
6
|
+
#include <filesystem>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <utility>
|
|
9
|
+
|
|
10
|
+
#include "WooWooAnalyzer.h"
|
|
11
|
+
#include "dialect/DialectManager.h"
|
|
12
|
+
#include "document/DialectedWooWooDocument.h"
|
|
13
|
+
|
|
14
|
+
#include "components/Hoverer.h"
|
|
15
|
+
#include "components/Highlighter.h"
|
|
16
|
+
#include "components/Navigator.h"
|
|
17
|
+
#include "components/Completer.h"
|
|
18
|
+
#include "components/Linter.h"
|
|
19
|
+
#include "components/Folder.h"
|
|
20
|
+
|
|
21
|
+
#include "utils/utils.h"
|
|
22
|
+
|
|
23
|
+
WooWooAnalyzer::WooWooAnalyzer() : dialectManager(nullptr) {
|
|
24
|
+
parser = new Parser();
|
|
25
|
+
highlighter = new Highlighter(this);
|
|
26
|
+
hoverer = new Hoverer(this);
|
|
27
|
+
navigator = new Navigator(this);
|
|
28
|
+
completer = new Completer(this);
|
|
29
|
+
linter = new Linter(this);
|
|
30
|
+
folder = new Folder(this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
WooWooAnalyzer::~WooWooAnalyzer() {
|
|
34
|
+
delete parser;
|
|
35
|
+
delete hoverer;
|
|
36
|
+
|
|
37
|
+
for (auto &project: projects) {
|
|
38
|
+
for (auto &docPair: project.second) {
|
|
39
|
+
delete docPair.second;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void WooWooAnalyzer::setDialect(const std::string &dialectPath) {
|
|
45
|
+
dialectManager = new DialectManager(dialectPath);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
bool WooWooAnalyzer::loadWorkspace(const std::string &workspaceUri) {
|
|
49
|
+
fs::path rootPath = utils::uriToPathString(workspaceUri);
|
|
50
|
+
auto projectFolders = findProjectFolders(rootPath);
|
|
51
|
+
|
|
52
|
+
for (const fs::path &projectFolderPath: projectFolders) {
|
|
53
|
+
for (const auto &entry: fs::recursive_directory_iterator(projectFolderPath)) {
|
|
54
|
+
if (entry.is_regular_file() && entry.path().extension() == ".woo") {
|
|
55
|
+
loadDocument(projectFolderPath, entry.path());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// now find and load all .woo files without a project
|
|
61
|
+
auto wooFiles = findAllWooFiles(rootPath);
|
|
62
|
+
|
|
63
|
+
for (auto &wooFile: wooFiles) {
|
|
64
|
+
if (!docToProject.contains(wooFile.string())) {
|
|
65
|
+
loadDocument("", wooFile);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
std::vector<fs::path> WooWooAnalyzer::findAllWooFiles(const fs::path &rootPath) {
|
|
73
|
+
std::vector<fs::path> wooFiles;
|
|
74
|
+
|
|
75
|
+
if (fs::exists(rootPath) && fs::is_directory(rootPath)) {
|
|
76
|
+
for (const auto &entry: fs::recursive_directory_iterator(rootPath)) {
|
|
77
|
+
if (entry.is_regular_file() && entry.path().extension() == ".woo") {
|
|
78
|
+
wooFiles.push_back(entry.path());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return wooFiles;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
std::vector<fs::path> WooWooAnalyzer::findProjectFolders(const fs::path &rootPath) {
|
|
87
|
+
|
|
88
|
+
std::vector<fs::path> projectFolders;
|
|
89
|
+
for (const auto &entry: fs::recursive_directory_iterator(rootPath)) {
|
|
90
|
+
if (entry.is_regular_file() && entry.path().filename() == "Woofile") {
|
|
91
|
+
projectFolders.push_back(entry.path().parent_path());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return projectFolders;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
std::optional<fs::path> WooWooAnalyzer::findProjectFolder(const std::string &uri) {
|
|
98
|
+
fs::path path = utils::uriToPathString(uri);
|
|
99
|
+
// Start from the given URI and move up the directory hierarchy
|
|
100
|
+
for (fs::path parent = path.parent_path(); parent!=parent.parent_path(); parent = parent.parent_path()) {
|
|
101
|
+
fs::path woofilePath = parent / "Woofile";
|
|
102
|
+
|
|
103
|
+
// Check if "Woofile" exists in this directory
|
|
104
|
+
if (fs::exists(woofilePath)) {
|
|
105
|
+
return parent; // Return the first parent directory containing "Woofile"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return std::nullopt; // Return an empty optional if no project folder is found
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void WooWooAnalyzer::loadDocument(const fs::path &projectPath, const fs::path &documentPath) {
|
|
114
|
+
projects[projectPath.generic_string()][documentPath.generic_string()] = new DialectedWooWooDocument(documentPath, parser, dialectManager);
|
|
115
|
+
docToProject[documentPath.generic_string()] = projectPath.generic_string();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
DialectedWooWooDocument *WooWooAnalyzer::getDocumentByUri(const std::string &docUri) {
|
|
119
|
+
auto path = utils::uriToPathString(docUri);
|
|
120
|
+
return getDocument(path);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
DialectedWooWooDocument *WooWooAnalyzer::getDocument(const std::string &pathToDoc) {
|
|
124
|
+
return projects[docToProject[pathToDoc]][pathToDoc];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
std::vector<DialectedWooWooDocument *> WooWooAnalyzer::getDocumentsFromTheSameProject(WooWooDocument *document) {
|
|
128
|
+
std::vector<DialectedWooWooDocument *> documents;
|
|
129
|
+
auto project = docToProject[document->documentPath.generic_string()];
|
|
130
|
+
if (projects.find(project) != projects.end()) {
|
|
131
|
+
std::unordered_map<std::string, DialectedWooWooDocument *> &pathDocMap = projects[project];
|
|
132
|
+
|
|
133
|
+
for (const auto &pair: pathDocMap) {
|
|
134
|
+
documents.emplace_back(pair.second);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
std::cerr << "Project with path '" << project << "' not found in projects map." << std::endl;
|
|
138
|
+
}
|
|
139
|
+
return documents;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
void WooWooAnalyzer::handleDocumentChange(const TextDocumentIdentifier &tdi, std::string &source) {
|
|
143
|
+
auto docPath = utils::uriToPathString(tdi.uri);
|
|
144
|
+
auto document = getDocument(docPath);
|
|
145
|
+
document->updateSource(source);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void WooWooAnalyzer::renameDocument(const std::string &oldUri, const std::string &newUri) {
|
|
149
|
+
|
|
150
|
+
auto oldPath = utils::uriToPathString(oldUri);
|
|
151
|
+
auto newPath = utils::uriToPathString(newUri);
|
|
152
|
+
|
|
153
|
+
if (endsWith(newUri, ".woo")) {
|
|
154
|
+
std::optional<fs::path> newProjectFolder = findProjectFolder(newUri);
|
|
155
|
+
std::string oldProjectFolder = docToProject[oldPath];
|
|
156
|
+
std::string newProjectFolderPathString = newProjectFolder.has_value() ? newProjectFolder.value().generic_string() : "";
|
|
157
|
+
|
|
158
|
+
docToProject[newPath] = newProjectFolderPathString;
|
|
159
|
+
docToProject.erase(oldPath);
|
|
160
|
+
projects[newProjectFolderPathString][newPath] = projects[oldProjectFolder][oldPath];
|
|
161
|
+
projects[oldProjectFolder].erase(oldPath);
|
|
162
|
+
projects[newProjectFolderPathString][newPath]->documentPath = fs::path(newPath);
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
// the file is no longer a WooWoo document
|
|
166
|
+
// TODO: Delete it.
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
bool WooWooAnalyzer::endsWith(const std::string &str, const std::string &suffix) {
|
|
174
|
+
if (str.length() >= suffix.length()) {
|
|
175
|
+
return (str.rfind(suffix) == (str.length() - suffix.length()));
|
|
176
|
+
} else {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// - LSP-like public interface - - -
|
|
182
|
+
|
|
183
|
+
std::string WooWooAnalyzer::hover(const std::string &docUri, int line, int character) {
|
|
184
|
+
return hoverer->hover(docUri, line, character);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
std::vector<int> WooWooAnalyzer::semanticTokens(const std::string &docUri) {
|
|
188
|
+
return highlighter->semanticTokens(docUri);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Location WooWooAnalyzer::goToDefinition(const DefinitionParams& params) {
|
|
192
|
+
return navigator->goToDefinition(params);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
std::vector<CompletionItem> WooWooAnalyzer::complete(const CompletionParams ¶ms) {
|
|
196
|
+
return completer->complete(params);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
std::vector<FoldingRange> WooWooAnalyzer::foldingRanges(const TextDocumentIdentifier &tdi) {
|
|
200
|
+
return folder->foldingRanges(tdi);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
void WooWooAnalyzer::documentDidChange(const TextDocumentIdentifier &tdi, std::string &source) {
|
|
204
|
+
handleDocumentChange(tdi, source);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
std::vector<Diagnostic> WooWooAnalyzer::diagnose(const TextDocumentIdentifier &tdi) {
|
|
208
|
+
return linter->diagnose(tdi);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
void WooWooAnalyzer::openDocument(const TextDocumentIdentifier &tdi) {
|
|
212
|
+
auto docPath = utils::uriToPathString(tdi.uri);
|
|
213
|
+
if (!docToProject.contains(docPath)) {
|
|
214
|
+
// unknown document opened
|
|
215
|
+
std::optional<fs::path> projectFolder = findProjectFolder(tdi.uri);
|
|
216
|
+
std::string projectFolderPathString = projectFolder.has_value() ? projectFolder.value().generic_string() : "";
|
|
217
|
+
loadDocument(projectFolderPathString, docPath);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
void WooWooAnalyzer::setTokenTypes(std::vector<std::string> tokenTypes) { return highlighter->setTokenTypes(std::move(tokenTypes)); }
|
|
223
|
+
void WooWooAnalyzer::setTokenModifiers (std::vector<std::string> tokenModifiers) { return highlighter->setTokenModifiers(std::move(tokenModifiers)); }
|
|
224
|
+
|
|
225
|
+
// - - - - - - - - - - - - - - - - -
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Michal Janecek on 27.01.2024.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#ifndef WUFF_WOOWOOANALYZER_H
|
|
6
|
+
#define WUFF_WOOWOOANALYZER_H
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#include <filesystem>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <pybind11/pytypes.h>
|
|
13
|
+
#include "document/DialectedWooWooDocument.h"
|
|
14
|
+
#include "parser/Parser.h"
|
|
15
|
+
#include "dialect/DialectManager.h"
|
|
16
|
+
#include "lsp/LSPTypes.h"
|
|
17
|
+
|
|
18
|
+
class Hoverer;
|
|
19
|
+
class Highlighter;
|
|
20
|
+
class Navigator;
|
|
21
|
+
class Completer;
|
|
22
|
+
class Linter;
|
|
23
|
+
class Folder;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
namespace fs = std::filesystem;
|
|
27
|
+
namespace py = pybind11;
|
|
28
|
+
|
|
29
|
+
class WooWooAnalyzer {
|
|
30
|
+
private:
|
|
31
|
+
std::unordered_map<std::string, std::unordered_map<std::string, DialectedWooWooDocument*>> projects;
|
|
32
|
+
std::unordered_map<std::string, std::string> docToProject;
|
|
33
|
+
Parser* parser;
|
|
34
|
+
Hoverer* hoverer;
|
|
35
|
+
Highlighter* highlighter;
|
|
36
|
+
Navigator * navigator;
|
|
37
|
+
Completer * completer;
|
|
38
|
+
Linter * linter;
|
|
39
|
+
Folder * folder;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
WooWooAnalyzer();
|
|
43
|
+
~WooWooAnalyzer();
|
|
44
|
+
void setDialect(const std::string& dialectPath);
|
|
45
|
+
bool loadWorkspace(const std::string& workspaceUri);
|
|
46
|
+
DialectedWooWooDocument * getDocumentByUri(const std::string & docUri);
|
|
47
|
+
DialectedWooWooDocument * getDocument(const std::string& pathToDoc);
|
|
48
|
+
DialectManager* dialectManager;
|
|
49
|
+
|
|
50
|
+
std::vector<DialectedWooWooDocument *> getDocumentsFromTheSameProject(WooWooDocument * document);
|
|
51
|
+
|
|
52
|
+
// LSP-like functionalities
|
|
53
|
+
std::string hover(const std::string& docUri, int line, int character);
|
|
54
|
+
std::vector<int> semanticTokens(const std::string& docUri);
|
|
55
|
+
Location goToDefinition(const DefinitionParams& params);
|
|
56
|
+
std::vector<CompletionItem> complete(const CompletionParams & params);
|
|
57
|
+
std::vector<Diagnostic> diagnose(const TextDocumentIdentifier & tdi);
|
|
58
|
+
std::vector<FoldingRange> foldingRanges(const TextDocumentIdentifier & tdi);
|
|
59
|
+
|
|
60
|
+
// LSP support functions
|
|
61
|
+
|
|
62
|
+
void setTokenTypes(std::vector<std::string> tokenTypes);
|
|
63
|
+
void setTokenModifiers (std::vector<std::string> tokenModifiers);
|
|
64
|
+
void documentDidChange(const TextDocumentIdentifier & tdi, std::string &source);
|
|
65
|
+
void renameDocument(const std::string & oldUri, const std::string & newUri);
|
|
66
|
+
void openDocument(const TextDocumentIdentifier & tdi);
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
|
|
70
|
+
static std::vector<fs::path> findProjectFolders(const fs::path& rootPath);
|
|
71
|
+
static std::optional<fs::path> findProjectFolder(const std::string& uri);
|
|
72
|
+
|
|
73
|
+
void loadDocument(const fs::path& projectPath, const fs::path& documentPath);
|
|
74
|
+
void handleDocumentChange(const TextDocumentIdentifier & tdi, std::string & source);
|
|
75
|
+
static bool endsWith(const std::string &str, const std::string &suffix) ;
|
|
76
|
+
static std::vector<fs::path> findAllWooFiles(const fs::path & rootPath);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
#endif //WUFF_WOOWOOANALYZER_H
|