From 3cc3bae4414ebbb83176262f6aa26ae5eaccb554 Mon Sep 17 00:00:00 2001 From: ykiko Date: Sun, 7 Sep 2025 23:27:39 +0800 Subject: [PATCH] Format and simplify intergration test (#245) --- .dockerignore | 2 +- .clangd | 2 +- .github/workflows/check-format.yml | 51 ++++++---- .github/workflows/cmake.yml | 2 +- .gitignore | 2 +- .pre-commit-config.yaml | 22 +++- CMakeLists.txt | 8 +- Dockerfile | 4 +- README.md | 2 +- cmake/github.cmake | 18 ++-- cmake/llvm_setup.cmake | 8 +- cmake/utils.cmake | 8 +- docs/.vitepress/theme/sidebar.ts | 2 +- docs/.vitepress/theme/style.css | 1 - docs/clice.toml | 26 ++--- docs/en/design/header-context.md | 2 +- docs/en/dev/build.md | 8 +- docs/en/index.md | 2 +- docs/zh/design/architecture.md | 2 +- docs/zh/design/compilation.md | 2 - docs/zh/design/header-context.md | 4 +- docs/zh/design/index.md | 1 - docs/zh/design/template-resolver.md | 2 +- docs/zh/dev/build.md | 8 +- docs/zh/dev/contribution.md | 2 +- docs/zh/guide/configuration.md | 8 +- docs/zh/guide/quick-start.md | 2 +- docs/zh/guide/what-is-clice.md | 2 +- docs/zh/index.md | 2 +- flake.nix | 2 +- include/AST/Selection.h | 1 - include/AST/SymbolKind.h | 1 - include/Async/FileSystem.h | 1 - include/Async/Network.h | 1 - include/Async/Sleep.h | 1 - include/Compiler/Command.h | 1 - include/Feature/CodeAction.h | 1 - include/Feature/CodeCompletion.h | 1 - include/Feature/CodeLens.h | 1 - include/Feature/DocumentLink.h | 1 - include/Feature/DocumentSymbol.h | 1 - include/Feature/FoldingRange.h | 1 - include/Feature/Hover.h | 1 - include/Feature/SemanticToken.h | 1 - include/Server/Config.h | 1 - include/Support/Binary.h | 2 +- include/Support/Enum.h | 5 +- include/Support/FixedString.h | 2 +- include/Support/FuzzyMatcher.h | 1 - include/Support/Struct.h | 3 +- include/Support/StructedText.h | 1 - include/Test/TExpr.h | 1 - include/Test/Tester.h | 1 - pyproject.toml | 5 +- scripts/build-llvm-libs.py | 122 ++++++++++++----------- src/Async/FileSystem.cpp | 1 - src/Driver/clice.cc | 1 - src/Driver/helper.cc | 75 -------------- src/Feature/SignatureHelp.cpp | 1 - src/Index/USRGeneration.cpp | 1 - tests/conftest.py | 36 ++++++- tests/fixtures/client.py | 17 ++-- tests/fixtures/transport.py | 95 ++++++++++-------- tests/integration/test_file_operation.py | 33 +----- tests/integration/test_lifecycle.py | 11 +- tests/unit/AST/Resolver.cpp | 1 - tests/unit/AST/Selection.cpp | 12 +-- tests/unit/AST/SemanticVisitor.cpp | 1 - tests/unit/Async/FileSystem.cpp | 1 - tests/unit/Compiler/Compiler.cpp | 3 +- tests/unit/Compiler/Diagnostic.cpp | 1 - tests/unit/Compiler/Module.cpp | 4 +- tests/unit/Compiler/Preamble.cpp | 1 - tests/unit/Feature/CodeCompletion.cpp | 7 +- tests/unit/Feature/DocumentSymbol.cpp | 6 +- tests/unit/Feature/FoldingRange.cpp | 34 +++---- tests/unit/Feature/Hover.cpp | 12 +-- tests/unit/Feature/InlayHint.cpp | 37 ++++--- tests/unit/Feature/SignatureHelp.cpp | 1 - tests/unit/Index/Function.cpp | 42 ++++---- tests/unit/Index/HeaderIndex.cpp | 2 +- tests/unit/Index/Template.cpp | 1 - tests/unit/Support/Binary.cpp | 1 - tests/unit/Support/Doxygen.cpp | 2 +- tests/unit/Support/Enum.cpp | 1 - tests/unit/Support/Struct.cpp | 1 - tests/unit/Support/StructedText.cpp | 2 +- uv.lock | 103 +++++++++++++++++++ xmake.lua | 19 ++-- 89 files changed, 479 insertions(+), 452 deletions(-) delete mode 100644 src/Driver/helper.cc diff --git a/ .dockerignore b/ .dockerignore index 9994ccdb..4e7bf47a 100644 --- a/ .dockerignore +++ b/ .dockerignore @@ -1,2 +1,2 @@ build/ -.cache \ No newline at end of file +.cache diff --git a/.clangd b/.clangd index 47b262d9..ba4cbb36 100644 --- a/.clangd +++ b/.clangd @@ -1,2 +1,2 @@ Diagnostics: - UnusedIncludes: None \ No newline at end of file + UnusedIncludes: None diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 17e3902c..83f87c0f 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -4,7 +4,10 @@ on: push: branches: [main] paths: - - .clang-format + - ".clang-format" + - ".pre-commit-config.yaml" + - "**/*.py" + - "pyproject.toml" - "include/**" - "src/**" - "tests/**" @@ -12,7 +15,10 @@ on: pull_request: branches: [main] paths: - - .clang-format + - ".clang-format" + - ".pre-commit-config.yaml" + - "**/*.py" + - "pyproject.toml" - "include/**" - "src/**" - "tests/**" @@ -25,23 +31,34 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Install clang-format + - name: Install uv + uses: astral-sh/setup-uv@v6 + + - name: Run check + id: precommit run: | - wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/llvm.asc - echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee /etc/apt/sources.list.d/llvm20.list - echo "deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" | sudo tee -a /etc/apt/sources.list.d/llvm20.list - sudo apt-get update && sudo apt-get install -y clang-format-20 - clang-format-20 --version + uv venv + uv pip install pre-commit + uv run pre-commit run --all-files + continue-on-error: true - - name: Run clang-format check + - name: Show diff on failure + if: steps.precommit.outcome == 'failure' run: | - FILES=$(find ./ -type f | grep -P '^\.\/(src|include)(\/[^\/]+)*\/[^\/]+\.(h|cpp|cc)$') + echo "❌ pre-commit found issues that it auto-fixed." + echo " Please run 'pre-commit run --all-files' locally," + echo " commit the changes, and push again." + echo "" + echo "👇 The required changes are shown below:" + git diff - UNFORMATTED=$(clang-format-20 --dry-run --Werror $FILES) + - name: Fail the job if pre-commit failed + if: steps.precommit.outcome == 'failure' + run: | + echo "pre-commit checks failed." + exit 1 - if [ $? -ne 0 ]; then - echo "× Some files are not properly formatted. Run clang-format to fix them." - exit 1 - else - echo "✓ All files are properly formatted." - fi + - name: Auto correct + uses: huacnlee/autocorrect-action@main + with: + args: --lint ./docs diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4a52fab8..22085624 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -34,7 +34,7 @@ jobs: with: buckets: main apps: ninja - + - name: Setup llvm & libstdc++ & cmake & ninja if: matrix.os == 'ubuntu-24.04' run: | diff --git a/.gitignore b/.gitignore index 97c205f4..4ebb94da 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,4 @@ tests/unit/Local/ **/node_modules docs/.vitepress/dist -docs/.vitepress/cache \ No newline at end of file +docs/.vitepress/cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 35f54cd9..faa196a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,24 @@ +# .pre-commit-config.yaml + repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.12 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v20.1.0" + rev: v21.1.0 hooks: - id: clang-format - files: '^(src|include)(/[^/]+)*/[^/]+\.(h|cpp|cc)$' + types_or: [c++, c] diff --git a/CMakeLists.txt b/CMakeLists.txt index f5286e1a..c06cd68d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ endif() message(STATUS "Fetching tomlplusplus...") FetchContent_Declare( - tomlplusplus + tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git ) @@ -87,9 +87,9 @@ endif() file(GLOB_RECURSE CLICE_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/src/AST/*.cpp" "${CMAKE_SOURCE_DIR}/src/Async/*.cpp" - "${CMAKE_SOURCE_DIR}/src/Basic/*.cpp" - "${CMAKE_SOURCE_DIR}/src/Compiler/*.cpp" - "${CMAKE_SOURCE_DIR}/src/Index/*.cpp" + "${CMAKE_SOURCE_DIR}/src/Basic/*.cpp" + "${CMAKE_SOURCE_DIR}/src/Compiler/*.cpp" + "${CMAKE_SOURCE_DIR}/src/Index/*.cpp" "${CMAKE_SOURCE_DIR}/src/Feature/*.cpp" "${CMAKE_SOURCE_DIR}/src/Server/*.cpp" "${CMAKE_SOURCE_DIR}/src/Support/*.cpp" diff --git a/Dockerfile b/Dockerfile index 13004ed5..6ceac5e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /usr/share/keyrings/ll echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/trixie/ llvm-toolchain-trixie main" >> /etc/apt/sources.list && \ echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/trixie/ llvm-toolchain-trixie-20 main" >> /etc/apt/sources.list && \ apt-get update && apt-get install -y \ - clang-20 lld-20 + clang-20 lld-20 RUN ln -s /usr/bin/lld-20 /usr/bin/lld # Adds source code @@ -28,7 +28,7 @@ RUN cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=cla RUN cmake --build build -j && \ cmake --install build --prefix=/opt/clice -FROM debian:13 +FROM debian:13 COPY --from=builder /opt/clice /opt/clice/ COPY LICENSE /opt/clice/LICENSE diff --git a/README.md b/README.md index 234eab09..062e13cd 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,4 @@ Download the latest `clice` binary from the [releases page](https://github.com/c ## Documentation -To learn more about building, installing, and configuring clice, or to dive deep into its features and architecture, please visit our official documentation at [**clice.io**](https://clice.io/). \ No newline at end of file +To learn more about building, installing, and configuring clice, or to dive deep into its features and architecture, please visit our official documentation at [**clice.io**](https://clice.io/). diff --git a/cmake/github.cmake b/cmake/github.cmake index 861130ff..c59d7592 100644 --- a/cmake/github.cmake +++ b/cmake/github.cmake @@ -5,7 +5,7 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR) set(GITHUB_API_URL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/ref/tags/${TAG_NAME}") message(STATUS "Fetching tag info from: ${GITHUB_API_URL}") - + # Download tag info directly into a string download_to_string(${GITHUB_API_URL} TAG_JSON DOWNLOAD_RESULT) if(NOT DOWNLOAD_RESULT EQUAL "0") @@ -13,17 +13,17 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR) set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE) return() endif() - + # Parse the JSON to get object type and SHA parse_json_field_from_string("${TAG_JSON}" object "type" OBJECT_TYPE) parse_json_field_from_string("${TAG_JSON}" object "sha" OBJECT_SHA) - + if(OBJECT_TYPE STREQUAL "NOTFOUND" OR OBJECT_SHA STREQUAL "NOTFOUND") message(WARNING "Could not find object type or SHA in the JSON response.") set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE) return() endif() - + set(COMMIT_SHA "NOTFOUND") if(OBJECT_TYPE STREQUAL "commit") @@ -34,7 +34,7 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR) set(TAG_API_URL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/tags/${OBJECT_SHA}") message(STATUS "Fetching annotated tag info from: ${TAG_API_URL}") - + # Download annotated tag info directly into a string download_to_string(${TAG_API_URL} ANNOTATED_TAG_JSON TAG_DOWNLOAD_RESULT) if(NOT TAG_DOWNLOAD_RESULT EQUAL "0") @@ -42,16 +42,16 @@ function(github_lookup_tag_commit REPO_OWNER REPO_NAME TAG_NAME OUTPUT_VAR) set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE) return() endif() - + # Parse the annotated tag JSON to get the commit SHA parse_json_field_from_string("${ANNOTATED_TAG_JSON}" object "sha" COMMIT_SHA_FROM_TAG) - + if(NOT COMMIT_SHA_FROM_TAG STREQUAL "NOTFOUND") set(COMMIT_SHA ${COMMIT_SHA_FROM_TAG}) endif() else() message(WARNING "Unknown object type: ${OBJECT_TYPE}") endif() - + set(${OUTPUT_VAR} ${COMMIT_SHA} PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/llvm_setup.cmake b/cmake/llvm_setup.cmake index 11612a98..ef2d966a 100644 --- a/cmake/llvm_setup.cmake +++ b/cmake/llvm_setup.cmake @@ -29,7 +29,7 @@ function(fetch_private_clang_files llvm_ver) "Sema/TypeLocBuilder.h" "Sema/TreeTransform.h" ) - + # Check if all files already exist set(PRIVATE_FILE_EXISTS TRUE) foreach(FILE ${PRIVATE_CLANG_FILE_LIST}) @@ -119,7 +119,7 @@ endfunction() # Download and install prebuilt LLVM binaries with error checking function(install_prebuilt_llvm llvm_ver) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.llvm") - + # Determine platform-specific package name if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(LLVM_BUILD_TYPE "debug") @@ -140,7 +140,7 @@ function(install_prebuilt_llvm llvm_ver) if(NOT LLVM_PACKAGE) message(FATAL_ERROR "Unsupported platform or build type for prebuilt LLVM.") endif() - + set(DOWNLOAD_PATH "${CMAKE_CURRENT_BINARY_DIR}/${LLVM_PACKAGE}") # Download if file does not exist @@ -210,4 +210,4 @@ function(setup_llvm) # Fetch required private Clang headers fetch_private_clang_files("${LLVM_VERSION}") -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/utils.cmake b/cmake/utils.cmake index bf168a5d..33b8ade6 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -15,7 +15,7 @@ function(download_to_string URL OUTPUT_VAR RESULT_VAR) ) list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - + if(NOT STATUS_CODE EQUAL 0) list(GET DOWNLOAD_STATUS 1 ERROR_MSG) message(WARNING "Failed to download from ${URL}: ${ERROR_MSG}") @@ -25,7 +25,7 @@ function(download_to_string URL OUTPUT_VAR RESULT_VAR) file(READ ${CMAKE_CURRENT_BINARY_DIR}/temp_download_file DOWNLOADED_CONTENT) file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/temp_download_file) - + set(${OUTPUT_VAR} ${DOWNLOADED_CONTENT} PARENT_SCOPE) set(${RESULT_VAR} 0 PARENT_SCOPE) endfunction() @@ -43,7 +43,7 @@ function(parse_json_field_from_string JSON_CONTENT) list(REMOVE_AT ARGS -1) string(JSON FIELD_VALUE GET "${JSON_CONTENT}" ${ARGS}) - + if(NOT FIELD_VALUE) string(JOIN " " FIELD_PATH_STR ${ARGS}) message(WARNING "Could not parse field '${FIELD_PATH_STR}' from JSON.") @@ -52,4 +52,4 @@ function(parse_json_field_from_string JSON_CONTENT) endif() set(${OUTPUT_VAR} ${FIELD_VALUE} PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/docs/.vitepress/theme/sidebar.ts b/docs/.vitepress/theme/sidebar.ts index 95214ddb..8cc6c7c4 100644 --- a/docs/.vitepress/theme/sidebar.ts +++ b/docs/.vitepress/theme/sidebar.ts @@ -42,4 +42,4 @@ export const genSidebar = ( collapsed: options.collapsible || false, items } -} \ No newline at end of file +} diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 1a61cb13..8702981d 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -136,4 +136,3 @@ .DocSearch { --docsearch-primary-color: var(--vp-c-brand-1) !important; } - diff --git a/docs/clice.toml b/docs/clice.toml index f01d364b..c7581f0d 100644 --- a/docs/clice.toml +++ b/docs/clice.toml @@ -13,12 +13,12 @@ # Compile commands directories to search for compile_commands.json files. compile_commands_dirs = ["${workspace}/build"] - # Enable experimental clang-tidy diagnostics. + # Enable experimental clang-tidy diagnostics. # This feature is tracked in https://github.com/clice-project/clice/issues/90. clang_tidy = false # Maximum number of active files to keep in memory. If the number of active files - # exceeds this limit, the least recently used files will be removed. + # exceeds this limit, the least recently used files will be removed. # The default value is 8. Whatever the number you set, the minimum is 1, the maximum is 512. max_active_file = 8 @@ -39,8 +39,8 @@ # Whether to index entities in implicit template instantiations. implicitInstantiation = true -# Control the behavior for specific files. Note that Clice matches rules -# in order. If you want to add your own rules, either delete this rule +# Control the behavior for specific files. Note that Clice matches rules +# in order. If you want to add your own rules, either delete this rule # or insert your rule before it. [[rules]] # Files matching the specified pattern will have this rule applied. @@ -49,11 +49,11 @@ # - `*`: Matches one or more characters in a path segment. # - `?`: Matches a single character in a path segment. # - `**`: Matches any number of path segments, including none. - # - `{}`: Groups conditions (e.g., `**/*.{ts,js}` matches all TypeScript + # - `{}`: Groups conditions (e.g., `**/*.{ts,js}` matches all TypeScript # and JavaScript files). - # - `[]`: Declares a range of characters to match in a path segment + # - `[]`: Declares a range of characters to match in a path segment # (e.g., `example.[0-9]` matches `example.0`, `example.1`, etc.). - # - `[!...]`: Negates a range of characters to match in a path segment + # - `[!...]`: Negates a range of characters to match in a path segment # (e.g., `example.[!0-9]` matches `example.a`, `example.b`, but not `example.0`). pattern = "**/*" @@ -70,27 +70,27 @@ # - "always": Always treats the file as readonly. # - "never": Always treats the file as non-readonly. # - # Readonly means the file is not editable, and LSP requests such as - # code actions or completions will not be sent to the server. This avoids - # dynamic computation and allows pre-indexed results to be loaded directly, + # Readonly means the file is not editable, and LSP requests such as + # code actions or completions will not be sent to the server. This avoids + # dynamic computation and allows pre-indexed results to be loaded directly, # improving performance. readonly = "auto" # Controls how header files are treated. # Possible values: ["auto", "always", "never"] # - # - "auto": Attempts to infer the header context first. If no header context + # - "auto": Attempts to infer the header context first. If no header context # is found, the file will be treated as a normal source file. # - "always": Always treats the file as a header file. If no header context # is found, errors will be reported. # - "never": Always treats the file as a source file. # - # Header context refers to the related source files or additional metadata + # Header context refers to the related source files or additional metadata # linked to the header file. header = "auto" # Specifies extra header contexts (file paths) for the file. # Normally, header contexts are inferred automatically once the file is indexed. - # However, if you need immediate context before indexing completes, you can + # However, if you need immediate context before indexing completes, you can # provide it manually using this field. contexts = [] diff --git a/docs/en/design/header-context.md b/docs/en/design/header-context.md index 96e6ab24..19660cf7 100644 --- a/docs/en/design/header-context.md +++ b/docs/en/design/header-context.md @@ -28,7 +28,7 @@ A more extreme case is non-self-contained header files, for example: ```cpp // a.h -struct Y { +struct Y { X x; }; diff --git a/docs/en/dev/build.md b/docs/en/dev/build.md index 95ac387a..46e0bdd9 100644 --- a/docs/en/dev/build.md +++ b/docs/en/dev/build.md @@ -15,9 +15,9 @@ This section introduces the prerequisites for compiling clice. - clang >= 19 - c++23 compatible standard library - MSVC STL >= 19.44(VS 2022 17.4) - - GCC libstdc++ >= 14 + - GCC libstdc++ >= 14 - Clang libc++ >= 20 - + clice uses C++23 as the language standard. Please ensure you have an available clang 19 or above compiler, as well as a standard library compatible with C++23. > clice can currently only be compiled with clang. In the future, we will improve this to allow compilation with gcc and msvc. @@ -31,7 +31,7 @@ Due to the complexity of C++ syntax, writing a new parser from scratch is unreal If you can find the llvm commit corresponding to your system's llvm package, copy the following three files from that commit: - `clang/lib/Sema/CoroutineStmtBuilder.h` -- `clang/lib/Sema/TypeLocBuilder.h` +- `clang/lib/Sema/TypeLocBuilder.h` - `clang/lib/Sema/TreeTransform.h` Copy them to `LLVM_INSTALL_PATH/include/clang/Sema/`. @@ -59,7 +59,7 @@ $ 7z x x64-windows-msvc-release.7z "-o.llvm" > [!IMPORTANT] > > For debug versions of llvm libs, we enabled address sanitizer during build, and address sanitizer depends on compiler rt, which is very sensitive to compiler versions. So if using debug versions, please ensure your clang's compiler rt version is **strictly consistent** with what we used during build. -> +> > - Windows currently has no debug build of llvm libs because it doesn't support building clang as a dynamic library. Related progress can be found [here](https://discourse.llvm.org/t/llvm-is-buildable-as-a-windows-dll/87748) > - Linux uses clang20 > - MacOS uses homebrew llvm@20, definitely don't use apple clang diff --git a/docs/en/index.md b/docs/en/index.md index 81c6bebc..d10ac223 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -32,4 +32,4 @@ features: - icon: I title: Better Performance details: Excellent asynchronous task scheduling, support for compilation task cancellation, caching necessary information, avoiding meaningless CPU waste ---- \ No newline at end of file +--- diff --git a/docs/zh/design/architecture.md b/docs/zh/design/architecture.md index 3436a21d..89915f97 100644 --- a/docs/zh/design/architecture.md +++ b/docs/zh/design/architecture.md @@ -26,4 +26,4 @@ clice 是一个语言服务器,首先是一个服务器。它使用 [libuv](ht ## Support -一些其它的工具库。 \ No newline at end of file +一些其它的工具库。 diff --git a/docs/zh/design/compilation.md b/docs/zh/design/compilation.md index ea5b99ba..3da791a9 100644 --- a/docs/zh/design/compilation.md +++ b/docs/zh/design/compilation.md @@ -18,5 +18,3 @@ int main () { ## Cancel Compilation - - diff --git a/docs/zh/design/header-context.md b/docs/zh/design/header-context.md index fc067de2..30c73ec8 100644 --- a/docs/zh/design/header-context.md +++ b/docs/zh/design/header-context.md @@ -28,7 +28,7 @@ struct Y { ... }; ```cpp // a.h -struct Y { +struct Y { X x; }; @@ -39,4 +39,4 @@ struct X {}; `a.h`自身不能被编译,但是嵌入到`b.cpp`中的时候就编译正常了。这种情况下 clangd 会在`a.h`中报错,找不到`X`的定义。显然这是因为它把`a.h`当成一个独立的源文件了。在 libstdc++ 中的代码中就有很多这样的头文件,现在流行的一些 C++ 的 header-only 的库也有些有这样的代码,clangd 目前无法处理它们。 -clice 将会支持**头文件上下文 (header context)**,支持自动和用户主动切换头文件的状态,当然也会支持非自包含的头文件。我们想要实现如下的效果,以最开始那份代码为例。当你从`b.cpp`跳转到`a.h`的时候使用`b.cpp`作为`a.h`的上下文。同理,当你从`c.cpp`跳转到`a.h`的时候则使用`c.cpp`作为`a.h`的上下文。 \ No newline at end of file +clice 将会支持**头文件上下文 (header context)**,支持自动和用户主动切换头文件的状态,当然也会支持非自包含的头文件。我们想要实现如下的效果,以最开始那份代码为例。当你从`b.cpp`跳转到`a.h`的时候使用`b.cpp`作为`a.h`的上下文。同理,当你从`c.cpp`跳转到`a.h`的时候则使用`c.cpp`作为`a.h`的上下文。 diff --git a/docs/zh/design/index.md b/docs/zh/design/index.md index 2061bac5..8b013d6a 100644 --- a/docs/zh/design/index.md +++ b/docs/zh/design/index.md @@ -1,2 +1 @@ # Index - diff --git a/docs/zh/design/template-resolver.md b/docs/zh/design/template-resolver.md index 57412e14..989026bd 100644 --- a/docs/zh/design/template-resolver.md +++ b/docs/zh/design/template-resolver.md @@ -29,4 +29,4 @@ void foo(std::vector> vec2) { 3. 不考虑默认模板参数,无法处理由默认模板参数导致的依赖名 -尽管我们可以对标准库的类型开洞来提供相关的支持,但是我希望用户的代码能和标准库的代码有相同的地位,那么我们就需要一种通用的算法来处理依赖类型。为了解决这个问题,我编写了一个伪实例化器(pseudo instantiator)。它能在没有具体类型的前提下对依赖类型进行实例化,从而达到化简的目的。比如上面这个例子里面的`std::vector>::reference`就能被化简为`std::vector&`,进一步就能为用户提供代码补全选项。 \ No newline at end of file +尽管我们可以对标准库的类型开洞来提供相关的支持,但是我希望用户的代码能和标准库的代码有相同的地位,那么我们就需要一种通用的算法来处理依赖类型。为了解决这个问题,我编写了一个伪实例化器(pseudo instantiator)。它能在没有具体类型的前提下对依赖类型进行实例化,从而达到化简的目的。比如上面这个例子里面的`std::vector>::reference`就能被化简为`std::vector&`,进一步就能为用户提供代码补全选项。 diff --git a/docs/zh/dev/build.md b/docs/zh/dev/build.md index ead307df..c8458ae4 100644 --- a/docs/zh/dev/build.md +++ b/docs/zh/dev/build.md @@ -15,9 +15,9 @@ - clang >= 19 - c++23 compitable standard library - MSVC STL >= 19.44(VS 2022 17.4) - - GCC libstdc++ >= 14 + - GCC libstdc++ >= 14 - Clang libc++ >= 20 - + clice 使用 C++23 作为语言标准 ,请确保有可用的 clang 19 以及以上的编译器,以及兼容 C++23 的标准库。 > clice 暂时只能使用 clang 编译,在未来我们会改进这一点,使其能使用 gcc 和 msvc 编译。 @@ -31,7 +31,7 @@ clice 使用 C++23 作为语言标准 ,请确保有可用的 clang 19 以及 如果你能找到系统的 llvm package 对应的 llvm commit,将该 commit 下的如下三个文件 - `clang/lib/Sema/CoroutineStmtBuilder.h` -- `clang/lib/Sema/TypeLocBuilder.h` +- `clang/lib/Sema/TypeLocBuilder.h` - `clang/lib/Sema/TreeTransform.h` 拷贝到 `LLVM_INSTALL_PATH/include/clang/Sema/` 中即可。 @@ -59,7 +59,7 @@ $ 7z x x64-windows-msvc-release.7z "-o.llvm" > [!IMPORTANT] > > 对于 debug 版本的 llvm libs,构建的时候我们开启了 address sanitizer,而 address sanitizer 依赖于 compiler rt,它对编译器版本十分敏感。所以如果使用 debug 版本,请确保你的 clang 的 compiler rt 版本和我们构建的时候**严格一致**。 -> +> > - Windows 暂时无 debug 构建的 llvm libs,因为它不支持将 clang 构建为动态库,相关的进展可以在 [这里](https://discourse.llvm.org/t/llvm-is-buildable-as-a-windows-dll/87748) 找到 > - Linux 使用 clang20 > - MacOS 使用 homebrew llvm@20,一定不要使用 apple clang diff --git a/docs/zh/dev/contribution.md b/docs/zh/dev/contribution.md index 8150fd0f..e69c60fc 100644 --- a/docs/zh/dev/contribution.md +++ b/docs/zh/dev/contribution.md @@ -8,4 +8,4 @@ 命名 - 变量名:小写下换线 -- 类名,枚举名:大驼峰 \ No newline at end of file +- 类名,枚举名:大驼峰 diff --git a/docs/zh/guide/configuration.md b/docs/zh/guide/configuration.md index b3398527..4e53a831 100644 --- a/docs/zh/guide/configuration.md +++ b/docs/zh/guide/configuration.md @@ -18,9 +18,9 @@ - `*`: 匹配路径段中的一个或多个字符。 - `?`: 匹配路径段中的单个字符。 - `**`: 匹配任意数量的路径段,包括零个。 -- `{}`: 用于分组条件 (例如, `**/*.{ts,js}` 匹配所有 TypeScript 和 JavaScript 文件)。 -- `[]`: 声明要匹配的路径段中的字符范围 (例如, `example.[0-9]` 匹配 `example.0`, `example.1` 等)。 -- `[!...]`: 排除要匹配的路径段中的字符范围 (例如, `example.[!0-9]` 匹配 `example.a`, `example.b`,但不匹配 `example.0`)。 +- `{}`: 用于分组条件 (例如,`**/*.{ts,js}` 匹配所有 TypeScript 和 JavaScript 文件)。 +- `[]`: 声明要匹配的路径段中的字符范围 (例如,`example.[0-9]` 匹配 `example.0`, `example.1` 等)。 +- `[!...]`: 排除要匹配的路径段中的字符范围 (例如,`example.[!0-9]` 匹配 `example.a`, `example.b`,但不匹配 `example.0`)。
| 名称             | 类型                | 默认值 | @@ -89,4 +89,4 @@ 用于储存索引文件的文件夹。
-## Feature \ No newline at end of file +## Feature diff --git a/docs/zh/guide/quick-start.md b/docs/zh/guide/quick-start.md index 22bbdb9f..12152600 100644 --- a/docs/zh/guide/quick-start.md +++ b/docs/zh/guide/quick-start.md @@ -65,4 +65,4 @@ TODO: ### Others -对于任意其它的构建系统,可以尝试使用 [bear](https://github.com/rizsotto/Bear) 或者 [scan-build](https://github.com/rizsotto/scan-build) 来拦截编译命令并获取到编译数据库(不保证成功)。我们计划在未来编写一个**新的工具**,通过假编译器的方式来实现编译命令的捕获。 \ No newline at end of file +对于任意其它的构建系统,可以尝试使用 [bear](https://github.com/rizsotto/Bear) 或者 [scan-build](https://github.com/rizsotto/scan-build) 来拦截编译命令并获取到编译数据库(不保证成功)。我们计划在未来编写一个**新的工具**,通过假编译器的方式来实现编译命令的捕获。 diff --git a/docs/zh/guide/what-is-clice.md b/docs/zh/guide/what-is-clice.md index dca09b10..2aaf1112 100644 --- a/docs/zh/guide/what-is-clice.md +++ b/docs/zh/guide/what-is-clice.md @@ -20,4 +20,4 @@ clice 是一个全新的 C++ 的语言服务器,旨在解决现存 C++ 语言 既然如此,那么像为 clangd [初步支持 C++20 module](https://github.com/llvm/llvm-project/pull/66462) 这样的大型 PR 被拖了将近一年也就不奇怪了。意识到这个现状之后,我萌生了自己编写一个语言服务器的想法。我估计了一下项目大小,去除测试代码,大概 2w 行就能完成,是一个人花一段时间能完成的工作量,而且也有先例,例如 ccls 和 rust analyzer。另外一点就是 clangd 的代码已经上了年代了,尽管有非常多的注释,但是相关的逻辑仍然很绕,进行大范围修改所花费的时间可能还不如重写来得快。 -于是说干就干,我对 clangd 的几百个 issue 进行了分类,看看有没有一些问题是因为 clangd 一开始的架构设计错误而导致很难解决,然后被搁置的。如果有的话,是否能在重新设计的时候就考虑这个问题来解决呢?我发现,确实有一些!于是接下来的时间里,我花了大概两个月的时间来学习研究 clang 里面相关的机制,摸索相关问题的解决方法,探索原型实现,在确定相关的问题基本都可以解决之后,正式开始了 clice 的开发。 \ No newline at end of file +于是说干就干,我对 clangd 的几百个 issue 进行了分类,看看有没有一些问题是因为 clangd 一开始的架构设计错误而导致很难解决,然后被搁置的。如果有的话,是否能在重新设计的时候就考虑这个问题来解决呢?我发现,确实有一些!于是接下来的时间里,我花了大概两个月的时间来学习研究 clang 里面相关的机制,摸索相关问题的解决方法,探索原型实现,在确定相关的问题基本都可以解决之后,正式开始了 clice 的开发。 diff --git a/docs/zh/index.md b/docs/zh/index.md index 3d595176..87ee49a1 100644 --- a/docs/zh/index.md +++ b/docs/zh/index.md @@ -32,4 +32,4 @@ features: - icon: I title: 内存占用更低,速度更快 details: 优秀的异步任务调度,支持编译任务取消,缓存必要的信息,避免无意义的 CPU 浪费 ---- \ No newline at end of file +--- diff --git a/flake.nix b/flake.nix index 6c40b609..abc47548 100644 --- a/flake.nix +++ b/flake.nix @@ -51,7 +51,7 @@ pkgs.llvmPackages_20.bintools pkgs.llvmPackages_20.compiler-rt pkgs.llvmPackages_20.libunwind - pkgs.zlib + pkgs.zlib tomlplusplus ]; diff --git a/include/AST/Selection.h b/include/AST/Selection.h index 0430e0e4..16bbbac4 100644 --- a/include/AST/Selection.h +++ b/include/AST/Selection.h @@ -148,4 +148,3 @@ private: }; } // namespace clice - diff --git a/include/AST/SymbolKind.h b/include/AST/SymbolKind.h index aece18ca..1e659b16 100644 --- a/include/AST/SymbolKind.h +++ b/include/AST/SymbolKind.h @@ -83,4 +83,3 @@ struct SymbolModifiers : refl::Enum { }; } // namespace clice - diff --git a/include/Async/FileSystem.h b/include/Async/FileSystem.h index 836fad2e..cc898488 100644 --- a/include/Async/FileSystem.h +++ b/include/Async/FileSystem.h @@ -94,4 +94,3 @@ Result stat(std::string path); } // namespace fs } // namespace clice::async - diff --git a/include/Async/Network.h b/include/Async/Network.h index 9b083195..b777e66f 100644 --- a/include/Async/Network.h +++ b/include/Async/Network.h @@ -25,4 +25,3 @@ void spawn(llvm::StringRef path, llvm::ArrayRef args, Callback call Task<> write(json::Value value); } // namespace clice::async::net - diff --git a/include/Async/Sleep.h b/include/Async/Sleep.h index 7bc94241..6dd35a8e 100644 --- a/include/Async/Sleep.h +++ b/include/Async/Sleep.h @@ -34,4 +34,3 @@ inline auto sleep(std::size_t milliseconds) { } }; // namespace clice::async - diff --git a/include/Compiler/Command.h b/include/Compiler/Command.h index 76e6748e..760f2d62 100644 --- a/include/Compiler/Command.h +++ b/include/Compiler/Command.h @@ -181,4 +181,3 @@ struct std::formatter : return std::format_to(ctx.out(), "{} {}", e.kind.name(), e.detail); } }; - diff --git a/include/Feature/CodeAction.h b/include/Feature/CodeAction.h index 3f59c932..6f70f09b 100644 --- a/include/Feature/CodeAction.h +++ b/include/Feature/CodeAction.h @@ -1,2 +1 @@ #pragma once - diff --git a/include/Feature/CodeCompletion.h b/include/Feature/CodeCompletion.h index a805619c..a07cce44 100644 --- a/include/Feature/CodeCompletion.h +++ b/include/Feature/CodeCompletion.h @@ -104,4 +104,3 @@ std::vector code_complete(CompilationParams& params, } // namespace feature } // namespace clice - diff --git a/include/Feature/CodeLens.h b/include/Feature/CodeLens.h index 3f59c932..6f70f09b 100644 --- a/include/Feature/CodeLens.h +++ b/include/Feature/CodeLens.h @@ -1,2 +1 @@ #pragma once - diff --git a/include/Feature/DocumentLink.h b/include/Feature/DocumentLink.h index c6942eb2..7ae200ab 100644 --- a/include/Feature/DocumentLink.h +++ b/include/Feature/DocumentLink.h @@ -24,4 +24,3 @@ DocumentLinks document_links(CompilationUnit& unit); index::Shared index_document_link(CompilationUnit& unit); } // namespace clice::feature - diff --git a/include/Feature/DocumentSymbol.h b/include/Feature/DocumentSymbol.h index 32b51fa6..724666a4 100644 --- a/include/Feature/DocumentSymbol.h +++ b/include/Feature/DocumentSymbol.h @@ -35,4 +35,3 @@ DocumentSymbols document_symbols(CompilationUnit& unit); index::Shared index_document_symbol(CompilationUnit& unit); } // namespace clice::feature - diff --git a/include/Feature/FoldingRange.h b/include/Feature/FoldingRange.h index 115696d0..4ab46b18 100644 --- a/include/Feature/FoldingRange.h +++ b/include/Feature/FoldingRange.h @@ -53,4 +53,3 @@ FoldingRanges folding_ranges(CompilationUnit& unit); index::Shared index_folding_range(CompilationUnit& unit); } // namespace clice::feature - diff --git a/include/Feature/Hover.h b/include/Feature/Hover.h index 07b79361..95955454 100644 --- a/include/Feature/Hover.h +++ b/include/Feature/Hover.h @@ -72,4 +72,3 @@ Hover hover(CompilationUnit& unit, const clang::NamedDecl* decl); Hover hover(CompilationUnit& unit, std::uint32_t offset); } // namespace clice::feature - diff --git a/include/Feature/SemanticToken.h b/include/Feature/SemanticToken.h index 04c66efe..974290b0 100644 --- a/include/Feature/SemanticToken.h +++ b/include/Feature/SemanticToken.h @@ -27,4 +27,3 @@ SemanticTokens semantic_tokens(CompilationUnit& unit); index::Shared index_semantic_token(CompilationUnit& unit); } // namespace clice::feature - diff --git a/include/Server/Config.h b/include/Server/Config.h index 63b22f6d..e8522b50 100644 --- a/include/Server/Config.h +++ b/include/Server/Config.h @@ -50,4 +50,3 @@ extern const IndexOptions& index; extern llvm::ArrayRef rules; }; // namespace clice::config - diff --git a/include/Support/Binary.h b/include/Support/Binary.h index ee86d121..bd5eb153 100644 --- a/include/Support/Binary.h +++ b/include/Support/Binary.h @@ -275,7 +275,7 @@ struct Proxy { return &value(); } - operator const underlying_type& () const { + operator const underlying_type&() const { return value(); } }; diff --git a/include/Support/Enum.h b/include/Support/Enum.h index 3303ec16..11f693b3 100644 --- a/include/Support/Enum.h +++ b/include/Support/Enum.h @@ -104,7 +104,7 @@ public: return ((m_Value == underlying_value(kinds)) || ...); } - constexpr explicit operator bool () const { + constexpr explicit operator bool() const { return m_Value != invalid(); } @@ -199,7 +199,7 @@ public: return enum_table::table; } - constexpr explicit operator bool () const { + constexpr explicit operator bool() const { return m_Value != 0; } @@ -299,4 +299,3 @@ concept reflectable_enum = requires { }; } // namespace clice::refl - diff --git a/include/Support/FixedString.h b/include/Support/FixedString.h index 1c3cf833..3abd4a1b 100644 --- a/include/Support/FixedString.h +++ b/include/Support/FixedString.h @@ -19,7 +19,7 @@ struct fixed_string : std::array { return N; } - constexpr operator std::string_view () const { + constexpr operator std::string_view() const { return {this->data(), N}; } }; diff --git a/include/Support/FuzzyMatcher.h b/include/Support/FuzzyMatcher.h index 6df635b6..e9a02dfa 100644 --- a/include/Support/FuzzyMatcher.h +++ b/include/Support/FuzzyMatcher.h @@ -121,4 +121,3 @@ private: }; } // namespace clice - diff --git a/include/Support/Struct.h b/include/Support/Struct.h index 57265f60..30201a7d 100644 --- a/include/Support/Struct.h +++ b/include/Support/Struct.h @@ -15,7 +15,7 @@ struct Any { consteval Any(std::size_t); template - consteval operator T () const; + consteval operator T() const; }; template @@ -375,4 +375,3 @@ constexpr bool foreach(LHS&& lhs, RHS&& rhs, const Callback& callback) { } } // namespace clice::refl - diff --git a/include/Support/StructedText.h b/include/Support/StructedText.h index f4f7c9a7..5b5d5594 100644 --- a/include/Support/StructedText.h +++ b/include/Support/StructedText.h @@ -105,4 +105,3 @@ private: }; } // namespace clice - diff --git a/include/Test/TExpr.h b/include/Test/TExpr.h index 5c1cfff2..4c7ed908 100644 --- a/include/Test/TExpr.h +++ b/include/Test/TExpr.h @@ -108,4 +108,3 @@ BINARY_PREDICATE(has, has) { } #undef BINARY_PREDICATE - diff --git a/include/Test/Tester.h b/include/Test/Tester.h index d4073927..b7016d4d 100644 --- a/include/Test/Tester.h +++ b/include/Test/Tester.h @@ -185,4 +185,3 @@ struct Tester { }; } // namespace clice::testing - diff --git a/pyproject.toml b/pyproject.toml index b13ef8d1..a88667b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,17 @@ [project] name = "clice" version = "0.1.0" -description = "Clice is a language server for C/C++/Objective-C/Objective-C++/C#" +description = "clice is a language server for C/C++" readme = "README.md" authors = [ - { name = "Clice Developers" } + { name = "clice developers" } ] requires-python = ">=3.13" dependencies = [] [dependency-groups] dev = [ + "pre-commit>=4.3.0", "pytest", "pytest-asyncio>=1.1.0", ] diff --git a/scripts/build-llvm-libs.py b/scripts/build-llvm-libs.py index 6b2840d6..03d8810d 100755 --- a/scripts/build-llvm-libs.py +++ b/scripts/build-llvm-libs.py @@ -5,105 +5,112 @@ import shutil import argparse import sys + def get_build_config(build_type): """Return build configuration based on build type""" configs = { - 'debug': { - 'build_dir': 'build-debug', - 'install_dir': './build-debug-install', - 'build_type': 'Debug', - 'sanitizer': 'Address', - 'shared_libs': True + "debug": { + "build_dir": "build-debug", + "install_dir": "./build-debug-install", + "build_type": "Debug", + "sanitizer": "Address", + "shared_libs": True, }, - 'thread': { - 'build_dir': 'build-thread', - 'install_dir': './build-thread-install', - 'build_type': 'Debug', - 'sanitizer': 'Thread', - 'shared_libs': True + "thread": { + "build_dir": "build-thread", + "install_dir": "./build-thread-install", + "build_type": "Debug", + "sanitizer": "Thread", + "shared_libs": True, + }, + "release": { + "build_dir": "build-release", + "install_dir": "./build-release-install", + "build_type": "Release", + "sanitizer": None, + "shared_libs": False, }, - 'release': { - 'build_dir': 'build-release', - 'install_dir': './build-release-install', - 'build_type': 'Release', - 'sanitizer': None, - 'shared_libs': False - } } - + if build_type not in configs: print(f"Error: Unsupported build type '{build_type}'") print(f"Supported build types: {', '.join(configs.keys())}") sys.exit(1) - + return configs[build_type] + def build_llvm(config): """Execute LLVM build process""" print(f"Starting LLVM build ({config['build_type']} mode)") - + # Build CMake command config_args = [ "cmake", - "-G", "Ninja", - "-S", "./llvm", - "-B", config['build_dir'], + "-G", + "Ninja", + "-S", + "./llvm", + "-B", + config["build_dir"], "-DLLVM_USE_LINKER=lld", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++", - "-DCMAKE_BUILD_TYPE=" + config['build_type'], - # Only build native to speed up building llvm. + "-DCMAKE_BUILD_TYPE=" + config["build_type"], + # Only build native to speed up building llvm. "-DLLVM_TARGETS_TO_BUILD=Native", "-DLLVM_ENABLE_PROJECTS=clang", - "-DCMAKE_INSTALL_PREFIX=" + config['install_dir'], + "-DCMAKE_INSTALL_PREFIX=" + config["install_dir"], ] - + # Add optional configurations # Build shared lib to reduce binary size and speed up linking - if config['shared_libs']: + if config["shared_libs"]: config_args.append("-DBUILD_SHARED_LIBS=ON") - - if config['sanitizer']: + + if config["sanitizer"]: config_args.append(f"-DLLVM_USE_SANITIZER={config['sanitizer']}") - + # CMake build command list cmake_commands = [ config_args, - ["cmake", "--build", config['build_dir']], - ["cmake", "--install", config['build_dir']] + ["cmake", "--build", config["build_dir"]], + ["cmake", "--install", config["build_dir"]], ] - + # Execute CMake commands for i, command in enumerate(cmake_commands): - print(f"Executing command {i+1}/{len(cmake_commands)}: {' '.join(command)}") + print(f"Executing command {i + 1}/{len(cmake_commands)}: {' '.join(command)}") try: subprocess.run(command, check=True) except subprocess.CalledProcessError as e: print(f"Build failed: {e}") sys.exit(1) + def copy_header_files(config): """Copy header files to installation directory""" print("Copying header files...") - + src = "./clang/lib/Sema/" - dst = os.path.join(config['install_dir'], "include/clang/Sema/") + dst = os.path.join(config["install_dir"], "include/clang/Sema/") files = ["CoroutineStmtBuilder.h", "TypeLocBuilder.h", "TreeTransform.h"] - + # Ensure target directory exists os.makedirs(dst, exist_ok=True) - + for file in files: src_file = os.path.join(src, file) dst_file = os.path.join(dst, file) - + if os.path.exists(src_file): print(f"Copying {src_file} to {dst_file}") shutil.copy(src_file, dst_file) else: print(f"Warning: Source file does not exist {src_file}") + def main(): parser = argparse.ArgumentParser( description="Build LLVM libraries with different build configurations", @@ -118,45 +125,44 @@ Examples: python build-llvm-libs.py debug python build-llvm-libs.py thread python build-llvm-libs.py release - """ + """, ) - + parser.add_argument( - 'build_type', - choices=['debug', 'thread', 'release'], - help='Build type (debug/thread/release)' + "build_type", + choices=["debug", "thread", "release"], + help="Build type (debug/thread/release)", ) - + parser.add_argument( - '--skip-copy', - action='store_true', - help='Skip header file copying step' + "--skip-copy", action="store_true", help="Skip header file copying step" ) - + args = parser.parse_args() - + # Get build configuration config = get_build_config(args.build_type) - + print("=== LLVM Build Configuration ===") print(f"Build type: {args.build_type}") print(f"Build directory: {config['build_dir']}") print(f"Install directory: {config['install_dir']}") print(f"CMake build type: {config['build_type']}") - if config['sanitizer']: + if config["sanitizer"]: print(f"Sanitizer: {config['sanitizer']}") print(f"Shared libraries: {config['shared_libs']}") print("=" * 30) - + # Execute build build_llvm(config) - + # Copy header files (unless skipped) if not args.skip_copy: copy_header_files(config) - + print(f"\n✅ LLVM {args.build_type} build completed!") print(f"Install directory: {config['install_dir']}") + if __name__ == "__main__": main() diff --git a/src/Async/FileSystem.cpp b/src/Async/FileSystem.cpp index 25539d88..62b2a3e9 100644 --- a/src/Async/FileSystem.cpp +++ b/src/Async/FileSystem.cpp @@ -229,4 +229,3 @@ Result stat(std::string path) { } } // namespace clice::async::fs - diff --git a/src/Driver/clice.cc b/src/Driver/clice.cc index f5fdab8b..a0ea3f2b 100644 --- a/src/Driver/clice.cc +++ b/src/Driver/clice.cc @@ -165,4 +165,3 @@ int main(int argc, const char** argv) { return 0; } - diff --git a/src/Driver/helper.cc b/src/Driver/helper.cc deleted file mode 100644 index af87d425..00000000 --- a/src/Driver/helper.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include "Index/SymbolIndex.h" -#include "Support/FileSystem.h" -#include "llvm/Support/CommandLine.h" - -llvm::cl::opt input("input", llvm::cl::desc("The input file path prefix")); -llvm::cl::opt output("output", llvm::cl::desc("The output dictionary path")); -llvm::cl::opt format("format", llvm::cl::desc("The format of index")); - -using namespace clice; - -int main(int argc, char** argv) { - llvm::cl::ParseCommandLineOptions(argc, argv, "clice test\n"); - - if(input.empty()) { - llvm::errs() << "Input file path is required\n"; - return 1; - } - - if(output.empty()) { - llvm::errs() << "Output dictionary path is required\n"; - return 1; - } - - if(format.empty()) { - llvm::errs() << "Format of index is required, symbol or feature"; - return 1; - } - - auto dir = path::parent_path(input); - auto suffix = format == "symbol" ? ".sidx" : ".fidx"; - - std::vector files; - - std::error_code error; - auto iter = fs::directory_iterator(dir, error); - while(iter != fs::directory_iterator()) { - auto entry = *iter; - llvm::StringRef path = entry.path(); - if(path.starts_with(input) && path.ends_with(suffix)) { - files.emplace_back(path); - } - - iter.increment(error); - if(error) { - llvm::errs() << "Failed to iterate directory: " << error.message() << "\n"; - return 1; - } - } - - for(auto& file: files) { - auto content = fs::read(file); - if(!content) { - llvm::errs() << "Failed to read file: " << file << "\n"; - continue; - } - - if(format == "symbol") { - // index::SymbolIndex index(content->data(), content->size()); - // auto json = index.toJSON(); - // - // llvm::SmallString<128> path; - // path += file; - // - // path::replace_path_prefix(path, dir, output); - // path::replace_extension(path, ".json"); - // - // auto result = fs::write(path, std::format("{}", json)); - // if(!result) { - // llvm::errs() << "Failed to write file: " << path << "\n"; - //} - } - } - - return 0; -} diff --git a/src/Feature/SignatureHelp.cpp b/src/Feature/SignatureHelp.cpp index b2757147..ea11a219 100644 --- a/src/Feature/SignatureHelp.cpp +++ b/src/Feature/SignatureHelp.cpp @@ -208,4 +208,3 @@ proto::SignatureHelp signature_help(CompilationParams& params, } } // namespace clice::feature - diff --git a/src/Index/USRGeneration.cpp b/src/Index/USRGeneration.cpp index a965bd07..bb875899 100644 --- a/src/Index/USRGeneration.cpp +++ b/src/Index/USRGeneration.cpp @@ -970,4 +970,3 @@ bool generateUSRForMacro(StringRef MacroName, } } // namespace clice::index - diff --git a/tests/conftest.py b/tests/conftest.py index e224a84d..ddcd8e95 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,18 +1,21 @@ import os import pytest +import logging +import pytest_asyncio from pathlib import Path +from .fixtures.client import LSPClient def pytest_addoption(parser): parser.addoption( "--executable", action="store", - help="Path to the of the clice executable." + help="Path to the of the clice executable.", ) parser.addoption( "--resource-dir", action="store", - help="Path to the of the clang resource directory." + help="Path to the of the clang resource directory.", ) @@ -24,7 +27,7 @@ def executable(request): "Error: You must specify the 'clice' executable path using " "'--executable=' in pytest arguments, " "or configure it in your pytest.ini/conftest.py.", - returncode=64 + returncode=64, ) path = Path(executable) @@ -32,7 +35,7 @@ def executable(request): pytest.exit( f"Error: 'clice' executable not found at '{executable}'. " "Please ensure the path is correct and the file exists.", - returncode=64 + returncode=64, ) return path.resolve() @@ -48,3 +51,28 @@ def resource_dir(request): def test_data_dir(request): path = os.path.join(os.path.dirname(__file__), "data") return Path(path).resolve() + + +@pytest_asyncio.fixture(scope="function") +async def client(request, executable: Path, resource_dir: Path, test_data_dir: Path): + cmd = [ + str(executable), + "--mode=pipe", + f"--resource-dir={resource_dir}", + ] + + if hasattr(request, "param") and request.param: + if "config_project" in request.param: + project_name = request.param["config_project"] + config_path = test_data_dir / project_name / "clice.toml" + cmd.append(f"--config={config_path}") + + lsp_client = LSPClient(cmd) + await lsp_client.start() + + yield lsp_client + + try: + await lsp_client.exit() + except Exception as e: + logging.error(f"Error during LSP client exit: {e}") diff --git a/tests/fixtures/client.py b/tests/fixtures/client.py index 9d64ebec..07a3247a 100644 --- a/tests/fixtures/client.py +++ b/tests/fixtures/client.py @@ -1,4 +1,3 @@ -import asyncio from pathlib import Path from .transport import LSPTransport @@ -18,7 +17,10 @@ class LSPClient(LSPTransport): async def initialize(self, workspace: str): self.workspace = workspace params = { - "clientInfo": {"name": "clice tester", "version": "0.0.1", }, + "clientInfo": { + "name": "clice tester", + "version": "0.0.1", + }, "capabilities": {}, "workspaceFolders": [{"uri": Path(workspace).as_uri(), "name": "test"}], } @@ -68,13 +70,12 @@ class LSPClient(LSPTransport): file.version += 1 file.content = content params = { - "textDocument": { - "uri": path.as_uri(), - "version": file.version - }, + "textDocument": {"uri": path.as_uri(), "version": file.version}, "contentChanges": [ - {"text": content, } - ] + { + "text": content, + } + ], } await self.send_notification("textDocument/didChange", params) diff --git a/tests/fixtures/transport.py b/tests/fixtures/transport.py index 553e44b1..838feb99 100644 --- a/tests/fixtures/transport.py +++ b/tests/fixtures/transport.py @@ -1,4 +1,3 @@ -import os import json import asyncio import logging @@ -18,12 +17,12 @@ class LSPTransport: self.request_id = 0 self.pending_requests: dict[int, asyncio.Future] = {} - self.notification_handlers: dict[str, - Callable[[dict[str, Any]], Any]] = {} + self.notification_handlers: dict[str, Callable[[dict[str, Any]], Any]] = {} self.message_queue: asyncio.Queue = asyncio.Queue() - logging.basicConfig(level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s') + logging.basicConfig( + level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" + ) async def start(self): if self.mode == "stdio": @@ -32,29 +31,32 @@ class LSPTransport: *self.commands, stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.PIPE + stderr=asyncio.subprocess.PIPE, ) self.reader = self.process.stdout self.writer = self.process.stdin logging.info("LSP server started via stdio.") elif self.mode == "socket": logging.info( - f"Connecting to LSP server via socket: {self.host}:{self.port}") + f"Connecting to LSP server via socket: {self.host}:{self.port}" + ) # Note: For socket mode, you usually need to start the LSP server externally # or have it run as a daemon process already. This client will just connect. try: - self.reader, self.writer = await asyncio.open_connection(self.host, self.port) + self.reader, self.writer = await asyncio.open_connection( + self.host, self.port + ) logging.info("Connected to LSP server via socket.") except ConnectionRefusedError: logging.error( - f"Connection refused: No LSP server listening on {self.host}:{self.port}") + f"Connection refused: No LSP server listening on {self.host}:{self.port}" + ) raise except Exception as e: logging.error(f"Error connecting via socket: {e}") raise else: - raise ValueError( - "Invalid connection mode. Use 'stdio' or 'socket'.") + raise ValueError("Invalid connection mode. Use 'stdio' or 'socket'.") asyncio.create_task(self._read_messages()) asyncio.create_task(self._process_messages()) @@ -87,14 +89,13 @@ class LSPTransport: if not header_line: return None - if header_line.startswith(b'Content-Length:'): + if header_line.startswith(b"Content-Length:"): try: - return int(header_line.split(b':')[1].strip()) + return int(header_line.split(b":")[1].strip()) except ValueError: - logging.error( - f"Invalid Content-Length header: {header_line.decode()}") + logging.error(f"Invalid Content-Length header: {header_line.decode()}") return 0 - if header_line.startswith(b'Content-Type:'): + if header_line.startswith(b"Content-Type:"): return 0 logging.warning(f"Unknown header: {header_line.decode()}") @@ -102,19 +103,21 @@ class LSPTransport: async def _read_messages(self): content_length = 0 - content_bytes = b'' + content_bytes = b"" try: while True: if not self.reader: logging.info( - "LSP client reader is not available. Exiting _read_messages.") + "LSP client reader is not available. Exiting _read_messages." + ) break header_line = await self.reader.readline() if not header_line: logging.info( - "LSP server output stream closed. Exiting _read_messages.") + "LSP server output stream closed. Exiting _read_messages." + ) break parsed_length = await self._parse_header_line(header_line) @@ -123,7 +126,7 @@ class LSPTransport: if parsed_length is None: if content_length > 0: content_bytes = await self.reader.readexactly(content_length) - message = json.loads(content_bytes.decode('utf-8')) + message = json.loads(content_bytes.decode("utf-8")) await self.message_queue.put(message) content_length = 0 continue @@ -134,10 +137,14 @@ class LSPTransport: except asyncio.IncompleteReadError as e: logging.error(f"Incomplete message read: {e}") except json.JSONDecodeError as e: - decoded_content_attempt = content_bytes.decode( - 'utf-8', errors='ignore') if content_bytes else 'N/A' + decoded_content_attempt = ( + content_bytes.decode("utf-8", errors="ignore") + if content_bytes + else "N/A" + ) logging.error( - f"JSON decode error: {e}, Content (attempted): {decoded_content_attempt}") + f"JSON decode error: {e}, Content (attempted): {decoded_content_attempt}" + ) except Exception as e: logging.error(f"Error reading messages: {e}") finally: @@ -147,7 +154,8 @@ class LSPTransport: request_id = message["id"] if request_id not in self.pending_requests: logging.warning( - f"Received unknown request/response ID: {request_id}, message: {message}") + f"Received unknown request/response ID: {request_id}, message: {message}" + ) return future = self.pending_requests.pop(request_id) @@ -157,13 +165,15 @@ class LSPTransport: future.set_exception(Exception(f"LSP Error: {message['error']}")) else: future.set_exception( - Exception(f"LSP response missing 'result' or 'error': {message}")) + Exception(f"LSP response missing 'result' or 'error': {message}") + ) async def _handle_notification(self, message: dict[str, Any]): method = message["method"] if method not in self.notification_handlers: logging.warning( - f"Received unhandled notification: {method}, message: {message}") + f"Received unhandled notification: {method}, message: {message}" + ) return try: @@ -184,14 +194,12 @@ class LSPTransport: elif "method" in message: await self._handle_notification(message) else: - logging.warning( - f"Received malformed LSP message: {message}") + logging.warning(f"Received malformed LSP message: {message}") except asyncio.CancelledError: logging.info("_process_messages task cancelled.") except Exception as e: - logging.error( - f"Critical error processing message: {e}, Message: {message}") + logging.error(f"Critical error processing message: {e}, Message: {message}") finally: logging.info("_process_messages task finished.") @@ -200,45 +208,48 @@ class LSPTransport: logging.error("LSP client writer is not available.") return - encoded_message = json.dumps( - message, ensure_ascii=False).encode('utf-8') + encoded_message = json.dumps(message, ensure_ascii=False).encode("utf-8") content_length = len(encoded_message) - header = ( - f"Content-Length: {content_length}\r\n" - f"\r\n" - ).encode('utf-8') + header = (f"Content-Length: {content_length}\r\n\r\n").encode("utf-8") try: self.writer.write(header) self.writer.write(encoded_message) await self.writer.drain() logging.debug( - f"Sent message: {message.get('method', 'Unknown Method')} (ID: {message.get('id', 'N/A')})") + f"Sent message: {message.get('method', 'Unknown Method')} (ID: {message.get('id', 'N/A')})" + ) except Exception as e: logging.error(f"Error sending message: {e}, message: {message}") - async def send_request(self, method: str, params: dict[str, Any] | None = None) -> Any: + async def send_request( + self, method: str, params: dict[str, Any] | None = None + ) -> Any: self.request_id += 1 current_id = self.request_id message = { "jsonrpc": "2.0", "id": current_id, "method": method, - "params": params if params is not None else {} + "params": params if params is not None else {}, } await self._send_message(message) future = asyncio.Future() self.pending_requests[current_id] = future return await future - async def send_notification(self, method: str, params: dict[str, Any] | None = None): + async def send_notification( + self, method: str, params: dict[str, Any] | None = None + ): message = { "jsonrpc": "2.0", "method": method, - "params": params if params is not None else {} + "params": params if params is not None else {}, } await self._send_message(message) - def register_notification_handler(self, method: str, handler: Callable[[dict[str, Any]], Any]): + def register_notification_handler( + self, method: str, handler: Callable[[dict[str, Any]], Any] + ): self.notification_handlers[method] = handler diff --git a/tests/integration/test_file_operation.py b/tests/integration/test_file_operation.py index 4b5bc65f..9b287379 100644 --- a/tests/integration/test_file_operation.py +++ b/tests/integration/test_file_operation.py @@ -1,27 +1,16 @@ -import sys import pytest import asyncio -import logging -from ..fixtures.client import LSPClient @pytest.mark.asyncio -async def test_did_open(executable, test_data_dir, resource_dir): - client = LSPClient([executable, "--mode=pipe", f"--resource-dir={resource_dir}"]) - await client.start() - +async def test_did_open(client, test_data_dir): await client.initialize(test_data_dir / "hello_world") await client.did_open("main.cpp") - await asyncio.sleep(5) - await client.exit() @pytest.mark.asyncio -async def test_did_change(executable, test_data_dir, resource_dir): - client = LSPClient([executable, "--mode=pipe", f"--resource-dir={resource_dir}"]) - await client.start() - +async def test_did_change(client, test_data_dir): await client.initialize(test_data_dir / "hello_world") await client.did_open("main.cpp") @@ -34,25 +23,11 @@ async def test_did_change(executable, test_data_dir, resource_dir): await client.did_change("main.cpp", content) await asyncio.sleep(5) - logging.info("Send exit") - await client.exit() +@pytest.mark.parametrize("client", [{"config_project": "clang_tidy"}], indirect=True) @pytest.mark.asyncio -async def test_clang_tidy(executable, test_data_dir, resource_dir): - config_path = test_data_dir / "clang_tidy" / "clice.toml" - client = LSPClient( - [ - executable, - "--mode=pipe", - f"--resource-dir={resource_dir}", - f"--config={config_path}", - ] - ) - await client.start() - +async def test_clang_tidy(client, test_data_dir): await client.initialize(test_data_dir / "clang_tidy") await client.did_open("main.cpp") - await asyncio.sleep(5) - await client.exit() diff --git a/tests/integration/test_lifecycle.py b/tests/integration/test_lifecycle.py index e017c7df..7a2d3952 100644 --- a/tests/integration/test_lifecycle.py +++ b/tests/integration/test_lifecycle.py @@ -1,17 +1,8 @@ -import sys import pytest -import asyncio -from ..fixtures.client import LSPClient @pytest.mark.asyncio -async def test_initialize(executable, test_data_dir, resource_dir): - client = LSPClient([ - executable, "--mode=pipe", f"--resource-dir={resource_dir}" - ]) - await client.start() +async def test_initialize(client, test_data_dir): result = await client.initialize(test_data_dir) assert "serverInfo" in result assert result["serverInfo"]["name"] == "clice" - - await client.exit() diff --git a/tests/unit/AST/Resolver.cpp b/tests/unit/AST/Resolver.cpp index 78f0da18..6c8146f2 100644 --- a/tests/unit/AST/Resolver.cpp +++ b/tests/unit/AST/Resolver.cpp @@ -474,4 +474,3 @@ struct test { } // namespace } // namespace clice::testing - diff --git a/tests/unit/AST/Selection.cpp b/tests/unit/AST/Selection.cpp index 34284113..3679eda5 100644 --- a/tests/unit/AST/Selection.cpp +++ b/tests/unit/AST/Selection.cpp @@ -691,9 +691,9 @@ void test() { test("DeclContextIsLexical") = [&] { llvm::StringRef code = R"cpp( -namespace a { - void f$oo(); -} +namespace a { + void f$oo(); +} void a::foo() { } )cpp"; @@ -704,9 +704,9 @@ void a::foo() { } }); code = R"cpp( -namespace a { - void foo(); -} +namespace a { + void foo(); +} void a::f$oo() { } )cpp"; diff --git a/tests/unit/AST/SemanticVisitor.cpp b/tests/unit/AST/SemanticVisitor.cpp index 4d4d139a..8c147a4b 100644 --- a/tests/unit/AST/SemanticVisitor.cpp +++ b/tests/unit/AST/SemanticVisitor.cpp @@ -6,4 +6,3 @@ namespace clice::testing { namespace {} // namespace } // namespace clice::testing - diff --git a/tests/unit/Async/FileSystem.cpp b/tests/unit/Async/FileSystem.cpp index dc6d29f5..d203c1c3 100644 --- a/tests/unit/Async/FileSystem.cpp +++ b/tests/unit/Async/FileSystem.cpp @@ -45,4 +45,3 @@ suite<"Async"> suite = [] { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Compiler/Compiler.cpp b/tests/unit/Compiler/Compiler.cpp index 3ae274d2..b810212c 100644 --- a/tests/unit/Compiler/Compiler.cpp +++ b/tests/unit/Compiler/Compiler.cpp @@ -14,7 +14,7 @@ suite<"Compiler"> compiler = [] { llvm::StringRef content = R"( #include -int x = 1; +int x = 1; void foo {} @@ -66,4 +66,3 @@ struct Bar { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Compiler/Diagnostic.cpp b/tests/unit/Compiler/Diagnostic.cpp index e5b64678..fada417f 100644 --- a/tests/unit/Compiler/Diagnostic.cpp +++ b/tests/unit/Compiler/Diagnostic.cpp @@ -134,4 +134,3 @@ void foo() {} } // namespace } // namespace clice::testing - diff --git a/tests/unit/Compiler/Module.cpp b/tests/unit/Compiler/Module.cpp index d57e2955..ab48f482 100644 --- a/tests/unit/Compiler/Module.cpp +++ b/tests/unit/Compiler/Module.cpp @@ -57,7 +57,7 @@ suite<"Module"> module = [] { /// Simple case. const char* content = R"( export module A; -import B; +import B; )"; auto info = scan(content); expect(that % info.isInterfaceUnit == true); @@ -101,7 +101,7 @@ import B; content = R"( module A; -import B; +import B; import C; )"; info = scan(content); diff --git a/tests/unit/Compiler/Preamble.cpp b/tests/unit/Compiler/Preamble.cpp index 4275ea48..ca27f383 100644 --- a/tests/unit/Compiler/Preamble.cpp +++ b/tests/unit/Compiler/Preamble.cpp @@ -274,4 +274,3 @@ int y = foo(); } // namespace } // namespace clice::testing - diff --git a/tests/unit/Feature/CodeCompletion.cpp b/tests/unit/Feature/CodeCompletion.cpp index 0973c7cb..fdb48088 100644 --- a/tests/unit/Feature/CodeCompletion.cpp +++ b/tests/unit/Feature/CodeCompletion.cpp @@ -47,8 +47,8 @@ int x = fooo$(pos) test("Unqualified") = [&] { code_complete(R"cpp( -namespace A { - void fooooo(); +namespace A { + void fooooo(); } void bar() { @@ -66,7 +66,7 @@ void bar() { struct X { void operator() () {} }; - + void bar() { X foo; fo$(pos); @@ -93,4 +93,3 @@ void bar() { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Feature/DocumentSymbol.cpp b/tests/unit/Feature/DocumentSymbol.cpp index 0ccd95db..eca1f159 100644 --- a/tests/unit/Feature/DocumentSymbol.cpp +++ b/tests/unit/Feature/DocumentSymbol.cpp @@ -35,7 +35,7 @@ suite<"DocumentSymbol"> document_symbol = [] { const char* main = R"cpp( namespace _1 { namespace _2 { - + } } @@ -154,13 +154,13 @@ int y = 2; test("Macro") = [&] { const char* main = R"cpp( -#define CLASS(X) class X +#define CLASS(X) class X CLASS(test) { int x = 1; }; -#define VAR(X) int X = 1; +#define VAR(X) int X = 1; VAR(test) )cpp"; diff --git a/tests/unit/Feature/FoldingRange.cpp b/tests/unit/Feature/FoldingRange.cpp index 4b4c3301..4a605210 100644 --- a/tests/unit/Feature/FoldingRange.cpp +++ b/tests/unit/Feature/FoldingRange.cpp @@ -38,7 +38,7 @@ suite<"FoldingRange"> folding_range = [] { namespace single_line { } namespace with_nodes $(1){ - struct inner $(3){ + struct inner $(3){ int x; }$(4); }$(2) @@ -125,7 +125,7 @@ void foo() $(9){ test("Method") = [&] { run(R"cpp( -struct s2 $(1){ +struct s2 $(1){ int x; float y; @@ -134,13 +134,13 @@ struct s2 $(1){ struct s3; -struct s3 $(3){ - void method() $(5){ +struct s3 $(3){ + void method() $(5){ int x = 0; }$(6) - void parameter() $(7){ - + void parameter() $(7){ + }$(8) void skip() {}; @@ -165,19 +165,19 @@ auto z = $(1)[ static int array[4]; auto s = $(5)[ - x=0, + x=0, y = 1, z = array[ 0], k = -1 -]$(6) () $(7){ - return; +]$(6) () $(7){ + return; }$(8); auto l1 = [] () {}; auto l2 = [] () $(9){ - + }$(10); auto l3 = [] () $(11){ @@ -251,7 +251,7 @@ int f(int p1, int p2, int p3, int p4, int p5, int p6) { return p1 + p2; } int main() $(1){ int x = f(1, 2, 3, 4, 5, 6); - + int y = f $(2)( 1, 2, 3, 4, 5, 6 @@ -367,9 +367,9 @@ $(17)PROTECTED$(16) #else - #ifdef M2 - - + #ifdef M2 + + #endif #endif @@ -379,12 +379,12 @@ $(17)PROTECTED$(16) test("PragmaRegion") = [&] { run(R"cpp( $(1)#pragma region level1 - $(2)#pragma region level2 - $(3)#pragma region level3 + $(2)#pragma region level2 + $(3)#pragma region level3 #$(4)pragma endregion level3 - + #$(5)pragma endregion level2 diff --git a/tests/unit/Feature/Hover.cpp b/tests/unit/Feature/Hover.cpp index 097bd137..0ec24428 100644 --- a/tests/unit/Feature/Hover.cpp +++ b/tests/unit/Feature/Hover.cpp @@ -37,8 +37,8 @@ suite<"Hover"> hover = [] { namespace A { namespace B { namespace C {} - - /// anonymous namespace + + /// anonymous namespace namespace { namespace D {} } @@ -78,11 +78,11 @@ typedef struct A { } _; } T; -/// forward declaration +/// forward declaration struct FORWARD_STRUCT; struct FORWARD_CLASS; -/// in function body +/// in function body void f() { struct X {}; @@ -100,7 +100,7 @@ namespace n1 { struct NB {}; }; } - + namespace { struct NC {}; } @@ -139,7 +139,7 @@ ___ ___ -size: 24 (0x18) bytes, align: 8 (0x8) bytes, +size: 24 (0x18) bytes, align: 8 (0x8) bytes, ___ 5 fields: diff --git a/tests/unit/Feature/InlayHint.cpp b/tests/unit/Feature/InlayHint.cpp index 2a07b2a7..3b53ac9b 100644 --- a/tests/unit/Feature/InlayHint.cpp +++ b/tests/unit/Feature/InlayHint.cpp @@ -96,8 +96,8 @@ suite<"InlayHint"> inlay_hint = [] { expect_size(0); run(R"c( - namespace std { - template T&& forward(T&); + namespace std { + template T&& forward(T&); } int foo(int); @@ -450,7 +450,7 @@ suite<"InlayHint"> inlay_hint = [] { f3_t f3; using f4_t = void(*)(int param) noexcept; f4_t f4; - + void bar() { f1($(0)42); f2($(1)42); @@ -622,8 +622,8 @@ suite<"InlayHint"> inlay_hint = [] { run(R"c( void f() { int cap = 42; - auto L$(0) = [cap, init$(1) = 1 + 1](int a)$(2) { - return a + cap + init; + auto L$(0) = [cap, init$(1) = 1 + 1](int a)$(2) { + return a + cap + init; }; } )c"); @@ -677,10 +677,10 @@ suite<"InlayHint"> inlay_hint = [] { struct tuple_size { constexpr static unsigned value = 2; }; - + template struct tuple_element {}; - + template struct tuple_element { using type = int; @@ -695,7 +695,7 @@ suite<"InlayHint"> inlay_hint = [] { return p.b; } } - + IntPair bar(); auto [x$(0), y$(1)] = bar(); )c"); @@ -897,13 +897,13 @@ suite<"InlayHint"> inlay_hint = [] { return 41; $(0)} - template - int bar() { + template + int bar() { // No hint for lambda for now - auto f = []() { - return X; + auto f = []() { + return X; }; - return f(); + return f(); $(1)} // No hint because this isn't a definition @@ -924,7 +924,7 @@ suite<"InlayHint"> inlay_hint = [] { struct Test { // No hint because there's no function body Test() = default; - + ~Test() { $(0)} @@ -1205,7 +1205,7 @@ suite<"InlayHint"> inlay_hint = [] { run(R"c( // The hint is placed after the trailing ';' struct S1 { - $(0)} ; + $(0)} ; // The hint is always placed in the same line with the closing '}'. // So in this case where ';' is missing, it is attached to '}'. @@ -1226,7 +1226,7 @@ suite<"InlayHint"> inlay_hint = [] { struct { int x; $(2)} - + s2; )c"); expect_size(3); @@ -1441,12 +1441,12 @@ suite<"InlayHint"> inlay_hint = [] { struct Foo{ Foo(); Foo(int x); }; void foo(Foo a, int b); - + template void bar(Args... args) { foo(args...); } - + template void baz(Args... args) { foo($(0)Foo{args...}, $(1)1); } @@ -1526,4 +1526,3 @@ suite<"InlayHint"> inlay_hint = [] { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Feature/SignatureHelp.cpp b/tests/unit/Feature/SignatureHelp.cpp index d16d19dd..994fb9fb 100644 --- a/tests/unit/Feature/SignatureHelp.cpp +++ b/tests/unit/Feature/SignatureHelp.cpp @@ -41,4 +41,3 @@ int main() { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Index/Function.cpp b/tests/unit/Index/Function.cpp index 287f09fb..83c905bf 100644 --- a/tests/unit/Index/Function.cpp +++ b/tests/unit/Index/Function.cpp @@ -1,75 +1,75 @@ /// #include "Test/IndexTester.h" -/// +/// /// namespace clice::testing { -/// +/// /// namespace { -/// +/// /// TEST(Index, FunctionParams) { /// const char* code = R"cpp( /// void foo(int); -/// +/// /// void bar(int, int y = 2); /// )cpp"; -/// +/// /// IndexTester tester("main.cpp", code); /// tester.run(); -/// +/// /// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON(); -/// +/// /// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc. /// /// add tests for find references ..., !test symbol count. /// } -/// +/// /// TEST(Index, FunctionType) { /// const char* code = R"cpp( /// template /// struct function; -/// +/// /// void bar(function& f); -/// +/// /// void bar2(function& f); /// )cpp"; -/// +/// /// IndexTester tester("main.cpp", code); /// tester.run(); -/// +/// /// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON(); /// /// println("{}", data); /// /// tester.info->tu()->dump(); -/// +/// /// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc. /// /// add tests for find references ..., !test symbol count. /// } -/// +/// /// TEST(Index, Method) { /// const char* code = R"cpp( /// template /// struct function; -/// +/// /// template /// requires (__is_same(U, int)) /// struct function { /// void foo(); /// }; -/// +/// /// template /// requires (__is_same(U, float)) /// struct function { /// void foo(); /// }; /// )cpp"; -/// +/// /// IndexTester tester("main.cpp", code); /// tester.run(); -/// +/// /// /// auto data = tester.indices.find(tester.info->interested_file())->second.toJSON(); /// /// println("{}", data); /// /// tester.info->tu()->dump(); -/// +/// /// /// TODO: add more tests, FunctionTemplate, VarTemplate, ..., Dependent Name, ..., etc. /// /// add tests for find references ..., !test symbol count. /// } -/// +/// /// } // namespace -/// +/// /// } // namespace clice::testing diff --git a/tests/unit/Index/HeaderIndex.cpp b/tests/unit/Index/HeaderIndex.cpp index 86e8d584..e6f79b86 100644 --- a/tests/unit/Index/HeaderIndex.cpp +++ b/tests/unit/Index/HeaderIndex.cpp @@ -98,7 +98,7 @@ auto test_code = [](HeaderIndex& index, std::uint32_t id) { .kind = RelationKind::{}, .range = {{ {}, {} }}, .target_symbol = {}ull, - }} + }} );)", index_name, relation.kind.name(), diff --git a/tests/unit/Index/Template.cpp b/tests/unit/Index/Template.cpp index 9b62887b..9f3299cd 100644 --- a/tests/unit/Index/Template.cpp +++ b/tests/unit/Index/Template.cpp @@ -164,4 +164,3 @@ /// } // namespace /// /// } // namespace clice::testing - diff --git a/tests/unit/Support/Binary.cpp b/tests/unit/Support/Binary.cpp index 3b9fb9a0..d10470c7 100644 --- a/tests/unit/Support/Binary.cpp +++ b/tests/unit/Support/Binary.cpp @@ -211,4 +211,3 @@ suite<"Binary"> binary = [] { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Support/Doxygen.cpp b/tests/unit/Support/Doxygen.cpp index 72cbc74c..031cee80 100644 --- a/tests/unit/Support/Doxygen.cpp +++ b/tests/unit/Support/Doxygen.cpp @@ -164,7 +164,7 @@ suite<"Doxygen"> doxygen = [] { details 1 blah blah... line2 aabbcssss ~~~~~~^ - + A line not in a block @details details 2 blah blah... line1 diff --git a/tests/unit/Support/Enum.cpp b/tests/unit/Support/Enum.cpp index 025e4e0c..33cf60b4 100644 --- a/tests/unit/Support/Enum.cpp +++ b/tests/unit/Support/Enum.cpp @@ -146,4 +146,3 @@ suite<"Enum"> enum_tests = [] { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Support/Struct.cpp b/tests/unit/Support/Struct.cpp index 40e0ce24..9be3edd0 100644 --- a/tests/unit/Support/Struct.cpp +++ b/tests/unit/Support/Struct.cpp @@ -153,4 +153,3 @@ suite<"Struct"> struct_tests = [] { } // namespace } // namespace clice::testing - diff --git a/tests/unit/Support/StructedText.cpp b/tests/unit/Support/StructedText.cpp index d2c8a832..ad103c61 100644 --- a/tests/unit/Support/StructedText.cpp +++ b/tests/unit/Support/StructedText.cpp @@ -95,7 +95,7 @@ brief block brief line2 a b c d e f ~~~~^ -This is *Italic* **Bold** ~~Striketough~~, `InlineCode` +This is *Italic* **Bold** ~~Striketough~~, `InlineCode` )md"); st.add_ruler(); st.add_paragraph().append_text("Details:", Paragraph::Kind::Bold).append_newline_char(); diff --git a/uv.lock b/uv.lock index 22a442b0..797aa4d1 100644 --- a/uv.lock +++ b/uv.lock @@ -2,6 +2,15 @@ version = 1 revision = 3 requires-python = ">=3.13" +[[package]] +name = "cfgv" +version = "3.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/11/74/539e56497d9bd1d484fd863dd69cbbfa653cd2aa27abfe35653494d85e94/cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560", size = 7114, upload-time = "2023-08-12T20:38:17.776Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9", size = 7249, upload-time = "2023-08-12T20:38:16.269Z" }, +] + [[package]] name = "clice" version = "0.1.0" @@ -9,6 +18,7 @@ source = { virtual = "." } [package.dev-dependencies] dev = [ + { name = "pre-commit" }, { name = "pytest" }, { name = "pytest-asyncio" }, ] @@ -17,6 +27,7 @@ dev = [ [package.metadata.requires-dev] dev = [ + { name = "pre-commit", specifier = ">=4.3.0" }, { name = "pytest" }, { name = "pytest-asyncio", specifier = ">=1.1.0" }, ] @@ -30,6 +41,33 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] +[[package]] +name = "distlib" +version = "0.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/96/8e/709914eb2b5749865801041647dc7f4e6d00b549cfe88b65ca192995f07c/distlib-0.4.0.tar.gz", hash = "sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d", size = 614605, upload-time = "2025-07-17T16:52:00.465Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/6b/e0547afaf41bf2c42e52430072fa5658766e3d65bd4b03a563d1b6336f57/distlib-0.4.0-py2.py3-none-any.whl", hash = "sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16", size = 469047, upload-time = "2025-07-17T16:51:58.613Z" }, +] + +[[package]] +name = "filelock" +version = "3.19.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/40/bb/0ab3e58d22305b6f5440629d20683af28959bf793d98d11950e305c1c326/filelock-3.19.1.tar.gz", hash = "sha256:66eda1888b0171c998b35be2bcc0f6d75c388a7ce20c3f3f37aa8e96c2dddf58", size = 17687, upload-time = "2025-08-14T16:56:03.016Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/42/14/42b2651a2f46b022ccd948bca9f2d5af0fd8929c4eec235b8d6d844fbe67/filelock-3.19.1-py3-none-any.whl", hash = "sha256:d38e30481def20772f5baf097c122c3babc4fcdb7e14e57049eb9d88c6dc017d", size = 15988, upload-time = "2025-08-14T16:56:01.633Z" }, +] + +[[package]] +name = "identify" +version = "2.6.14" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/c4/62963f25a678f6a050fb0505a65e9e726996171e6dbe1547f79619eefb15/identify-2.6.14.tar.gz", hash = "sha256:663494103b4f717cb26921c52f8751363dc89db64364cd836a9bf1535f53cd6a", size = 99283, upload-time = "2025-09-06T19:30:52.938Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/ae/2ad30f4652712c82f1c23423d79136fbce338932ad166d70c1efb86a5998/identify-2.6.14-py2.py3-none-any.whl", hash = "sha256:11a073da82212c6646b1f39bb20d4483bfb9543bd5566fec60053c4bb309bf2e", size = 99172, upload-time = "2025-09-06T19:30:51.759Z" }, +] + [[package]] name = "iniconfig" version = "2.1.0" @@ -39,6 +77,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" }, ] +[[package]] +name = "nodeenv" +version = "1.9.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/16/fc88b08840de0e0a72a2f9d8c6bae36be573e475a6326ae854bcc549fc45/nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", size = 47437, upload-time = "2024-06-04T18:44:11.171Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, +] + [[package]] name = "packaging" version = "25.0" @@ -48,6 +95,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, ] +[[package]] +name = "platformdirs" +version = "4.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/23/e8/21db9c9987b0e728855bd57bff6984f67952bea55d6f75e055c46b5383e8/platformdirs-4.4.0.tar.gz", hash = "sha256:ca753cf4d81dc309bc67b0ea38fd15dc97bc30ce419a7f58d13eb3bf14c4febf", size = 21634, upload-time = "2025-08-26T14:32:04.268Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/4b/2028861e724d3bd36227adfa20d3fd24c3fc6d52032f4a93c133be5d17ce/platformdirs-4.4.0-py3-none-any.whl", hash = "sha256:abd01743f24e5287cd7a5db3752faf1a2d65353f38ec26d98e25a6db65958c85", size = 18654, upload-time = "2025-08-26T14:32:02.735Z" }, +] + [[package]] name = "pluggy" version = "1.6.0" @@ -57,6 +113,22 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, ] +[[package]] +name = "pre-commit" +version = "4.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cfgv" }, + { name = "identify" }, + { name = "nodeenv" }, + { name = "pyyaml" }, + { name = "virtualenv" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ff/29/7cf5bbc236333876e4b41f56e06857a87937ce4bf91e117a6991a2dbb02a/pre_commit-4.3.0.tar.gz", hash = "sha256:499fe450cc9d42e9d58e606262795ecb64dd05438943c62b66f6a8673da30b16", size = 193792, upload-time = "2025-08-09T18:56:14.651Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5b/a5/987a405322d78a73b66e39e4a90e4ef156fd7141bf71df987e50717c321b/pre_commit-4.3.0-py2.py3-none-any.whl", hash = "sha256:2b0747ad7e6e967169136edffee14c16e148a778a54e4f967921aa1ebf2308d8", size = 220965, upload-time = "2025-08-09T18:56:13.192Z" }, +] + [[package]] name = "pygments" version = "2.19.2" @@ -93,3 +165,34 @@ sdist = { url = "https://files.pythonhosted.org/packages/4e/51/f8794af39eeb870e8 wheels = [ { url = "https://files.pythonhosted.org/packages/c7/9d/bf86eddabf8c6c9cb1ea9a869d6873b46f105a5d292d3a6f7071f5b07935/pytest_asyncio-1.1.0-py3-none-any.whl", hash = "sha256:5fe2d69607b0bd75c656d1211f969cadba035030156745ee09e7d71740e58ecf", size = 15157, upload-time = "2025-07-16T04:29:24.929Z" }, ] + +[[package]] +name = "pyyaml" +version = "6.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/ed/79a089b6be93607fa5cdaedf301d7dfb23af5f25c398d5ead2525b063e17/pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e", size = 130631, upload-time = "2024-08-06T20:33:50.674Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/e3/3af305b830494fa85d95f6d95ef7fa73f2ee1cc8ef5b495c7c3269fb835f/PyYAML-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba", size = 181309, upload-time = "2024-08-06T20:32:43.4Z" }, + { url = "https://files.pythonhosted.org/packages/45/9f/3b1c20a0b7a3200524eb0076cc027a970d320bd3a6592873c85c92a08731/PyYAML-6.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1", size = 171679, upload-time = "2024-08-06T20:32:44.801Z" }, + { url = "https://files.pythonhosted.org/packages/7c/9a/337322f27005c33bcb656c655fa78325b730324c78620e8328ae28b64d0c/PyYAML-6.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133", size = 733428, upload-time = "2024-08-06T20:32:46.432Z" }, + { url = "https://files.pythonhosted.org/packages/a3/69/864fbe19e6c18ea3cc196cbe5d392175b4cf3d5d0ac1403ec3f2d237ebb5/PyYAML-6.0.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484", size = 763361, upload-time = "2024-08-06T20:32:51.188Z" }, + { url = "https://files.pythonhosted.org/packages/04/24/b7721e4845c2f162d26f50521b825fb061bc0a5afcf9a386840f23ea19fa/PyYAML-6.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5", size = 759523, upload-time = "2024-08-06T20:32:53.019Z" }, + { url = "https://files.pythonhosted.org/packages/2b/b2/e3234f59ba06559c6ff63c4e10baea10e5e7df868092bf9ab40e5b9c56b6/PyYAML-6.0.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc", size = 726660, upload-time = "2024-08-06T20:32:54.708Z" }, + { url = "https://files.pythonhosted.org/packages/fe/0f/25911a9f080464c59fab9027482f822b86bf0608957a5fcc6eaac85aa515/PyYAML-6.0.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652", size = 751597, upload-time = "2024-08-06T20:32:56.985Z" }, + { url = "https://files.pythonhosted.org/packages/14/0d/e2c3b43bbce3cf6bd97c840b46088a3031085179e596d4929729d8d68270/PyYAML-6.0.2-cp313-cp313-win32.whl", hash = "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183", size = 140527, upload-time = "2024-08-06T20:33:03.001Z" }, + { url = "https://files.pythonhosted.org/packages/fa/de/02b54f42487e3d3c6efb3f89428677074ca7bf43aae402517bc7cca949f3/PyYAML-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563", size = 156446, upload-time = "2024-08-06T20:33:04.33Z" }, +] + +[[package]] +name = "virtualenv" +version = "20.34.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "distlib" }, + { name = "filelock" }, + { name = "platformdirs" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1c/14/37fcdba2808a6c615681cd216fecae00413c9dab44fb2e57805ecf3eaee3/virtualenv-20.34.0.tar.gz", hash = "sha256:44815b2c9dee7ed86e387b842a84f20b93f7f417f95886ca1996a72a4138eb1a", size = 6003808, upload-time = "2025-08-13T14:24:07.464Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/76/06/04c8e804f813cf972e3262f3f8584c232de64f0cde9f703b46cf53a45090/virtualenv-20.34.0-py3-none-any.whl", hash = "sha256:341f5afa7eee943e4984a9207c025feedd768baff6753cd660c857ceb3e36026", size = 5983279, upload-time = "2025-08-13T14:24:05.111Z" }, +] diff --git a/xmake.lua b/xmake.lua index ed72956e..7e499515 100644 --- a/xmake.lua +++ b/xmake.lua @@ -54,9 +54,9 @@ target("clice-core") add_packages("libuv", "toml++", {public = true}) - if is_mode("debug") then + if is_mode("debug") then add_packages("llvm", { - public = true, + public = true, links = { "LLVMSupport", "LLVMFrontendOpenMP", @@ -108,10 +108,10 @@ target("clice-core") local llvm_dynlib_dir = path.join(target:pkg("llvm"):installdir(), "lib") target:add("rpathdirs", llvm_dynlib_dir) end) - elseif is_mode("release", "releasedbg") then + elseif is_mode("release", "releasedbg") then add_packages("llvm", {public = true}) add_ldflags("-Wl,--gc-sections") - end + end target("clice") set_kind("binary") @@ -132,13 +132,6 @@ target("clice") end end) -target("helper") - set_default(false) - set_kind("binary") - add_files("src/Driver/helper.cc") - - add_deps("clice-core") - target("unit_tests") set_default(false) set_kind("binary") @@ -150,7 +143,7 @@ target("unit_tests") add_tests("default") after_load(function (target) - target:set("runargs", + target:set("runargs", "--test-dir=" .. path.absolute("tests/data"), "--resource-dir=" .. path.join(target:dep("clice-core"):pkg("llvm"):installdir(), "lib/clang/20") ) @@ -192,7 +185,7 @@ rule("clice_build_config") target:add("cxflags", "cl::/Zc:preprocessor") target:set("exceptions", "no-cxx") - + if target:is_plat("windows") and not target:toolchain("msvc") then target:set("toolset", "ar", "llvm-ar") if target:toolchain("clang-cl") then