Wuff 0.0.2__tar.gz → 0.0.3__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.

Files changed (77) hide show
  1. Wuff-0.0.3/MANIFEST.in +3 -0
  2. {Wuff-0.0.2 → Wuff-0.0.3}/PKG-INFO +1 -1
  3. {Wuff-0.0.2 → Wuff-0.0.3}/Wuff.egg-info/PKG-INFO +1 -1
  4. Wuff-0.0.3/Wuff.egg-info/SOURCES.txt +74 -0
  5. {Wuff-0.0.2 → Wuff-0.0.3}/setup.py +1 -1
  6. Wuff-0.0.3/wuff/Bindings.cpp +121 -0
  7. Wuff-0.0.3/wuff/CMakeLists.txt +133 -0
  8. Wuff-0.0.3/wuff/LICENSE +21 -0
  9. Wuff-0.0.3/wuff/README.md +3 -0
  10. Wuff-0.0.3/wuff/WooWooAnalyzer.cpp +225 -0
  11. Wuff-0.0.3/wuff/WooWooAnalyzer.h +81 -0
  12. Wuff-0.0.3/wuff/components/Completer.cpp +153 -0
  13. Wuff-0.0.3/wuff/components/Completer.h +35 -0
  14. Wuff-0.0.3/wuff/components/Component.cpp +39 -0
  15. Wuff-0.0.3/wuff/components/Component.h +27 -0
  16. Wuff-0.0.3/wuff/components/Folder.cpp +52 -0
  17. Wuff-0.0.3/wuff/components/Folder.h +29 -0
  18. Wuff-0.0.3/wuff/components/Highlighter.cpp +288 -0
  19. Wuff-0.0.3/wuff/components/Highlighter.h +63 -0
  20. Wuff-0.0.3/wuff/components/Hoverer.cpp +54 -0
  21. Wuff-0.0.3/wuff/components/Hoverer.h +28 -0
  22. Wuff-0.0.3/wuff/components/Linter.cpp +94 -0
  23. Wuff-0.0.3/wuff/components/Linter.h +32 -0
  24. Wuff-0.0.3/wuff/components/Navigator.cpp +179 -0
  25. Wuff-0.0.3/wuff/components/Navigator.h +39 -0
  26. Wuff-0.0.3/wuff/components/queries/highlights.scm +46 -0
  27. Wuff-0.0.3/wuff/components/queries/yaml-highlights.scm +56 -0
  28. Wuff-0.0.3/wuff/dialect/Dialect.cpp +75 -0
  29. Wuff-0.0.3/wuff/dialect/Dialect.h +43 -0
  30. Wuff-0.0.3/wuff/dialect/DialectManager.cpp +198 -0
  31. Wuff-0.0.3/wuff/dialect/DialectManager.h +47 -0
  32. Wuff-0.0.3/wuff/dialect/DocumentPart.cpp +25 -0
  33. Wuff-0.0.3/wuff/dialect/DocumentPart.h +33 -0
  34. Wuff-0.0.3/wuff/dialect/Field.cpp +29 -0
  35. Wuff-0.0.3/wuff/dialect/Field.h +26 -0
  36. Wuff-0.0.3/wuff/dialect/IDescribable.h +17 -0
  37. Wuff-0.0.3/wuff/dialect/InnerEnvironment.cpp +36 -0
  38. Wuff-0.0.3/wuff/dialect/InnerEnvironment.h +37 -0
  39. Wuff-0.0.3/wuff/dialect/MetaBlock.cpp +28 -0
  40. Wuff-0.0.3/wuff/dialect/MetaBlock.h +23 -0
  41. Wuff-0.0.3/wuff/dialect/OuterEnvironment.cpp +26 -0
  42. Wuff-0.0.3/wuff/dialect/OuterEnvironment.h +33 -0
  43. Wuff-0.0.3/wuff/dialect/Reference.cpp +39 -0
  44. Wuff-0.0.3/wuff/dialect/Reference.h +33 -0
  45. Wuff-0.0.3/wuff/dialect/Shorthand.cpp +34 -0
  46. Wuff-0.0.3/wuff/dialect/Shorthand.h +27 -0
  47. Wuff-0.0.3/wuff/dialect/Wobject.cpp +23 -0
  48. Wuff-0.0.3/wuff/dialect/Wobject.h +34 -0
  49. Wuff-0.0.3/wuff/document/CommentLine.cpp +5 -0
  50. Wuff-0.0.3/wuff/document/CommentLine.h +20 -0
  51. Wuff-0.0.3/wuff/document/DialectedWooWooDocument.cpp +122 -0
  52. Wuff-0.0.3/wuff/document/DialectedWooWooDocument.h +42 -0
  53. Wuff-0.0.3/wuff/document/MetaContext.cpp +28 -0
  54. Wuff-0.0.3/wuff/document/MetaContext.h +27 -0
  55. Wuff-0.0.3/wuff/document/UTF8toUTF16Mapping.cpp +106 -0
  56. Wuff-0.0.3/wuff/document/UTF8toUTF16Mapping.h +32 -0
  57. Wuff-0.0.3/wuff/document/WooWooDocument.cpp +96 -0
  58. Wuff-0.0.3/wuff/document/WooWooDocument.h +44 -0
  59. Wuff-0.0.3/wuff/lsp/LSPTypes.h +146 -0
  60. Wuff-0.0.3/wuff/parser/Parser.cpp +117 -0
  61. Wuff-0.0.3/wuff/parser/Parser.h +36 -0
  62. Wuff-0.0.3/wuff/tree-sitter/woowoo/parser.c +6173 -0
  63. Wuff-0.0.3/wuff/tree-sitter/woowoo/scanner.cc +718 -0
  64. Wuff-0.0.3/wuff/tree-sitter/woowoo/tree_sitter/parser.h +224 -0
  65. Wuff-0.0.3/wuff/tree-sitter/yaml/parser.c +38751 -0
  66. Wuff-0.0.3/wuff/tree-sitter/yaml/scanner.cc +981 -0
  67. Wuff-0.0.3/wuff/tree-sitter/yaml/schema.generated.cc +204 -0
  68. Wuff-0.0.3/wuff/tree-sitter/yaml/tree_sitter/parser.h +224 -0
  69. Wuff-0.0.3/wuff/utils/utils.cpp +108 -0
  70. Wuff-0.0.3/wuff/utils/utils.h +21 -0
  71. Wuff-0.0.2/Wuff.egg-info/SOURCES.txt +0 -8
  72. {Wuff-0.0.2 → Wuff-0.0.3}/README.md +0 -0
  73. {Wuff-0.0.2 → Wuff-0.0.3}/Wuff.egg-info/dependency_links.txt +0 -0
  74. {Wuff-0.0.2 → Wuff-0.0.3}/Wuff.egg-info/not-zip-safe +0 -0
  75. {Wuff-0.0.2 → Wuff-0.0.3}/Wuff.egg-info/requires.txt +0 -0
  76. {Wuff-0.0.2 → Wuff-0.0.3}/Wuff.egg-info/top_level.txt +0 -0
  77. {Wuff-0.0.2 → Wuff-0.0.3}/setup.cfg +0 -0
Wuff-0.0.3/MANIFEST.in ADDED
@@ -0,0 +1,3 @@
1
+ recursive-include wuff *
2
+ prune wuff/cmake_*
3
+ prune wuff/.idea
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Wuff
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Analyzer tools for WooWoo projects
5
5
  Author: Michal Janecek
6
6
  Author-email: michal.janecek@gmail.com
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Wuff
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Analyzer tools for WooWoo projects
5
5
  Author: Michal Janecek
6
6
  Author-email: michal.janecek@gmail.com
@@ -0,0 +1,74 @@
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/LICENSE
13
+ wuff/README.md
14
+ wuff/WooWooAnalyzer.cpp
15
+ wuff/WooWooAnalyzer.h
16
+ wuff/components/Completer.cpp
17
+ wuff/components/Completer.h
18
+ wuff/components/Component.cpp
19
+ wuff/components/Component.h
20
+ wuff/components/Folder.cpp
21
+ wuff/components/Folder.h
22
+ wuff/components/Highlighter.cpp
23
+ wuff/components/Highlighter.h
24
+ wuff/components/Hoverer.cpp
25
+ wuff/components/Hoverer.h
26
+ wuff/components/Linter.cpp
27
+ wuff/components/Linter.h
28
+ wuff/components/Navigator.cpp
29
+ wuff/components/Navigator.h
30
+ wuff/components/queries/highlights.scm
31
+ wuff/components/queries/yaml-highlights.scm
32
+ wuff/dialect/Dialect.cpp
33
+ wuff/dialect/Dialect.h
34
+ wuff/dialect/DialectManager.cpp
35
+ wuff/dialect/DialectManager.h
36
+ wuff/dialect/DocumentPart.cpp
37
+ wuff/dialect/DocumentPart.h
38
+ wuff/dialect/Field.cpp
39
+ wuff/dialect/Field.h
40
+ wuff/dialect/IDescribable.h
41
+ wuff/dialect/InnerEnvironment.cpp
42
+ wuff/dialect/InnerEnvironment.h
43
+ wuff/dialect/MetaBlock.cpp
44
+ wuff/dialect/MetaBlock.h
45
+ wuff/dialect/OuterEnvironment.cpp
46
+ wuff/dialect/OuterEnvironment.h
47
+ wuff/dialect/Reference.cpp
48
+ wuff/dialect/Reference.h
49
+ wuff/dialect/Shorthand.cpp
50
+ wuff/dialect/Shorthand.h
51
+ wuff/dialect/Wobject.cpp
52
+ wuff/dialect/Wobject.h
53
+ wuff/document/CommentLine.cpp
54
+ wuff/document/CommentLine.h
55
+ wuff/document/DialectedWooWooDocument.cpp
56
+ wuff/document/DialectedWooWooDocument.h
57
+ wuff/document/MetaContext.cpp
58
+ wuff/document/MetaContext.h
59
+ wuff/document/UTF8toUTF16Mapping.cpp
60
+ wuff/document/UTF8toUTF16Mapping.h
61
+ wuff/document/WooWooDocument.cpp
62
+ wuff/document/WooWooDocument.h
63
+ wuff/lsp/LSPTypes.h
64
+ wuff/parser/Parser.cpp
65
+ wuff/parser/Parser.h
66
+ wuff/tree-sitter/woowoo/parser.c
67
+ wuff/tree-sitter/woowoo/scanner.cc
68
+ wuff/tree-sitter/woowoo/tree_sitter/parser.h
69
+ wuff/tree-sitter/yaml/parser.c
70
+ wuff/tree-sitter/yaml/scanner.cc
71
+ wuff/tree-sitter/yaml/schema.generated.cc
72
+ wuff/tree-sitter/yaml/tree_sitter/parser.h
73
+ wuff/utils/utils.cpp
74
+ 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.2",
135
+ version="0.0.3",
136
136
  author="Michal Janecek",
137
137
  author_email="michal.janecek@gmail.com",
138
138
  description="Analyzer tools for WooWoo projects",
@@ -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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Martín D. Maas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # Wuff
2
+
3
+ This is the analyzer for WooWoo projects. It can be used for example within a Language Server to provide analysis.
@@ -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 &params) {
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
+ // - - - - - - - - - - - - - - - - -