### Plugin Development Setup Guide Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/README.md A link to the guide for setting up the development environment for the Bazel plugin. This is for users who want to build, run, or contribute to the plugin. ```markdown [Plugin development setup guide](https://github.com/JetBrains/hirschgarten/blob/main/docs/dev/development_setup.md) ``` -------------------------------- ### Clone Bazel Plugin Repository Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/development_setup.md This command clones the official JetBrains Bazel plugin repository from GitHub. Ensure you have Git installed and SSH access configured for GitHub. ```bash git clone git@github.com:JetBrains/hirschgarten.git ``` -------------------------------- ### Hirschgarten Development Setup Source: https://github.com/jetbrains/hirschgarten/blob/main/README.md A guide for developers on setting up the development environment for the Hirschgarten plugin. It points to specific documentation for starting development and adding new components. ```en - [Guide to start developing the plugin](docs/dev/development_setup.md) - Each component has its own README file in corresponding folders - [Guide for adding new components from existing repositories](docs/dev/add_components.md) ``` -------------------------------- ### Bazel Project Configuration (.bazelrc) Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/guides/android.md Essential flags to include in the project's .bazelrc file to ensure compatibility and enable Android migration APIs for the Bazel plugin. ```bash common --experimental_google_legacy_api common --experimental_enable_android_migration_apis ``` -------------------------------- ### IntelliJ IDEA Plugin Repositories Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/guides/android.md Instructions for adding nightly plugin repositories to IntelliJ IDEA for accessing the latest Bazel plugin versions. ```plaintext https://plugins.jetbrains.com/plugins/nightly/20329 https://plugins.jetbrains.com/plugins/nightly/22977 ``` -------------------------------- ### Running Bazel Plugin Configurations Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/development_setup.md Instructions on how to run the Bazel plugin for debugging within JetBrains IDEA. Different configurations are available depending on the specific debugging needs, such as including or bypassing the server connection flow. ```java Right-click on `plugin-bazel-with-server-debug` and click `Run`. Note: For Bazel BSP connection flow, use `plugin-bazel/plugin-bazel-debug`. For BSP plugin only, use `plugin-bsp/plugin-bsp-debug`. ``` -------------------------------- ### Bazel Query: Get Attribute and Dependencies Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/commands/Attr.txt This example shows how to use the Bazel query command to retrieve a specific attribute ('value') of a target ('//path/to:target1') and its dependencies ('//path/to:target2'). The attribute pattern is designed to match values that might be enclosed in brackets or spaces. ```bazel attr("//path/to:target1", "[\[ ]value[,\]]", deps("//path/to:target2")) ``` -------------------------------- ### Bazelrc: Clean Command with Batch Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Quoting.txt Example of configuring the 'clean' command with a batch setting and disabling progress display. ```bazelrc clean:batch --noshow_progress ``` -------------------------------- ### Example Script Execution Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/add_components.md Provides a practical example of how to execute the `merge-component.py` script, showing placeholder paths for the Hirschgarten clone, the local repository, and the desired component name (subfolder). ```bash python merge-component.py /path/to/hirchgraten/clone /path/to/local/repo component-name ``` -------------------------------- ### Bazelrc Comment with Continuation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Continuations.txt An example of a Bazelrc comment that includes text that would typically be part of a build command with continuations. ```bazelrc # command includes continuations build --flag_a ``` -------------------------------- ### ProjectView Configuration for Android Rules Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/guides/android.md Configuration to enable native Android rules in the project's projectview file if not using rules_android. ```plaintext enable_native_android_rules: true ``` -------------------------------- ### Basic Bazel Build Command Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Continuations.txt A simple Bazel build command with a single flag. ```bazelrc build --flag_a ``` -------------------------------- ### Bazelrc: Common Build Flags Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Quoting.txt Example of setting common build flags in a Bazelrc file. This includes flags related to repository naming and disk caching. ```bazelrc common --incompatible_use_plus_in_repo_names build --protocopt=--fatal_warnings build --disk_cache=~/.cache/bazel ``` -------------------------------- ### Bazel Plugin Installation Source: https://github.com/jetbrains/hirschgarten/blob/main/README.md Instructions for installing and using the Bazel plugin for IntelliJ IDEA, directing users to the official plugin page for detailed information. ```en For information on installing and using the Bazel plugin for IntelliJ IDEA, please refer to the [plugin page](https://lp.jetbrains.com/new-bazel-plugin/). ``` -------------------------------- ### Bazelrc: Batch Configuration for Build and Query Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Quoting.txt Demonstrates how to configure batch processing for build and query commands, specifically disabling progress indicators. ```bazelrc build:batch --noshow_loading_progress build:batch --noshow_progress query:batch --noshow_progress ``` -------------------------------- ### Install git-filter-repo Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/add_components.md Instructions for installing the `git-filter-repo` tool, a prerequisite for managing Git history during component migration. It provides commands for macOS using Homebrew and for other systems via pip. ```bash brew install git-filter-repo ``` ```bash pip3 install git-filter-repo ``` -------------------------------- ### Select Targets and Exclude Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/other/SingleQuotes.txt This example shows how to select multiple targets and then exclude a specific target using the EXCEPT operator in Bazel query. ```bazel query('//path/to:target1', '//path/to:target2') except query('//path/to:target3') ``` -------------------------------- ### IntelliJ IDEA Plugin Installation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/README.md Instructions for installing the Bazel plugin within IntelliJ IDEA from the Marketplace. It emphasizes selecting the correct plugin and restarting the IDE. ```text 1. in IntelliJ IDEA, go to Preferences | Plugins 2. Go to Marketplace tab. 3. Then look for "Bazel" (check the description to be sure you don't install the legacy plugin version) and click Install. 4. Restart IntelliJ IDEA. You're ready! ``` -------------------------------- ### Bazel Build Command with Configuration and Multi-line Flags Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Continuations.txt Shows a Bazel build command that specifies a configuration alias and uses multi-line flags. ```bazelrc build:asdfa \ --flag_a \ --flag_b=asdfas \ --flag_c asdfa \ --flag_d=asdfas ``` -------------------------------- ### Install Bazel BSP Server Source: https://github.com/jetbrains/hirschgarten/blob/main/commons/src/main/kotlin/org/jetbrains/bazel/projectview/README.md Command to launch the Bazel BSP server, specifying the project view file to use for configuration. ```bash $ cs launch org.jetbrains.bsp:bazel-bsp: -M org.jetbrains.bazel.install.Install -- -p ``` -------------------------------- ### Bazel Build Command with Multi-line Flags Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Continuations.txt Demonstrates a Bazel build command with multiple flags spread across multiple lines using continuation characters. ```bazelrc build \ --flag_a \ --flag_b=asdfas \ --flag_c asdfa \ --flag_d=asdfas ``` -------------------------------- ### Bazel Query: Variable Assignment and Dependency Fetching Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/operations/Let.txt Demonstrates how to assign a target to a variable using 'let' and then use that variable in a subsequent 'deps' query. This is useful for breaking down complex queries or reusing target paths. ```bazel let a = deps(//path/to:my_target, 4) in deps($a, 3) ``` -------------------------------- ### Bazel Query allpaths Command Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/commands/TwoExprs.txt The `allpaths` command in Bazel query finds all paths from a set of start nodes to a set of end nodes. It requires specifying the start and end targets. ```bazel allpaths(//path/to:target1, //path/to:target2, //path/to:target3) ``` -------------------------------- ### Bazel Query Command Example Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/commands/WordAndExpr.txt Demonstrates a Bazel query command with nested 'kind' and 'filter' operations. It shows how targets are specified and filtered within the query language. ```BazelQuery kind(//path/to:target1, filter(//path/to:target2, //path/to:target3)) ``` -------------------------------- ### Starlark Less Than Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the less than comparison (<) between two integer literals in Starlark. ```starlark 0 < 1 ``` -------------------------------- ### Starlark Dictionary and Comprehension Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Operand.txt Illustrates the creation of empty dictionaries and dictionary comprehensions in Starlark. Dictionary comprehensions provide a compact way to build dictionaries. ```starlark {} {value: value for elem in set} ``` -------------------------------- ### Starlark List and Comprehension Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Operand.txt Demonstrates the syntax for creating empty lists and list comprehensions in Starlark. List comprehensions allow for concise creation of lists based on existing iterables. ```starlark [] [value for elem in set] ``` -------------------------------- ### Get All Loaded and Not Loaded Targets Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/main/kotlin/org/jetbrains/bazel/magicmetamodel/README.md Retrieves lists of all loaded and not loaded build targets, typically used for display purposes like a sidebar. ```python magicMetaModel.getAllLoadedTargets() magicMetaModel.getAllNotLoadedTargets() ``` -------------------------------- ### Starlark Logical AND Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the logical AND operation between two integer literals in Starlark. ```starlark 1 and 1 ``` -------------------------------- ### Starlark Addition Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates an addition operation between two integer literals in Starlark. ```starlark 0 + 0 ``` -------------------------------- ### Starlark Inequality Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the inequality comparison (!=) between two integer literals in Starlark. ```starlark 0 != 1 ``` -------------------------------- ### Query for Siblings of a Target Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelquery/parser/commands/Expr.txt This command retrieves all targets that are siblings of the specified target '//path/to:target'. It demonstrates the use of the 'siblings' function within Bazel queries. ```bazel tests(//path/to:target) ``` -------------------------------- ### Starlark Equality Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the equality comparison (==) between two integer literals in Starlark. ```starlark 0 == 0 ``` -------------------------------- ### Get Target Details for a Document Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/main/kotlin/org/jetbrains/bazel/magicmetamodel/README.md Fetches details of loaded and not loaded targets relevant to a specific document, often displayed in a widget. ```python magicMetaModel.getTargetsDetailsForDocument(documentId) ``` -------------------------------- ### Build and Publish Docker Image for Remote Execution Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/engflow_remote_execution.md This section provides instructions for building and publishing the Docker image used for remote execution. It requires Docker to be installed and credentials for the container registry. ```bash ./build-and-push.sh engflow ``` -------------------------------- ### Starlark Prefix Expression Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/stmt/ExprStmt.txt Demonstrates a Starlark prefix expression, specifically a unary plus operator. It applies an operation to a single operand. Dependencies: None. Input: A numeric operand. Output: The operand with the unary plus applied. ```starlark +1 ``` -------------------------------- ### Starlark Binary Expression Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/stmt/ExprStmt.txt Shows a Starlark binary expression for addition. It performs an arithmetic operation between two operands. Dependencies: None. Input: Two numeric operands. Output: The result of the addition. ```starlark 1 + 1 ``` -------------------------------- ### Create MagicMetaModel Instance Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/main/kotlin/org/jetbrains/bazel/magicmetamodel/README.md Initializes the MagicMetaModel with necessary dependencies. This is the first step in using the model. ```python MagicMetaModel.create(..) ``` -------------------------------- ### Starlark Function Call with Arguments Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Arguments.txt This snippet illustrates a Starlark function call named 'fun'. It includes a positional integer argument '4', a named argument 'name' with value '1', a star argument '*2', and a double-star argument '**3'. This demonstrates how Starlark handles different argument passing mechanisms. ```starlark fun(4, name = 1, *2, **3) ``` -------------------------------- ### Starlark Function Declaration with Parameters Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Parameters.txt Defines a Starlark function named 'fun' with an optional parameter 'firstParameter' defaulting to 0, a mandatory parameter 'secondParameter', a variadic parameter 'thirdParameter', and a keyword-only variadic parameter 'fourthParameter'. The function body contains a single expression. ```starlark def fun(firstParameter = 0, secondParameter, *thirdParameter, **fourthParameter): 0 ``` -------------------------------- ### Starlark Literals Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Operand.txt Examples of different literal types in Starlark, including identifiers, integers, floats, strings, and bytes. ```starlark name 0 0.0 "string" b"a" b'a' b"""a""" b'''a''' br"a" br'a' rb"a" rb'a' ``` -------------------------------- ### Starlark Parenthesized Expression Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/basicRules/Operand.txt Shows a simple example of a parenthesized expression in Starlark, which is used to control the order of operations or group expressions. ```starlark (0) ``` -------------------------------- ### Export QODANA_TOKEN Source: https://github.com/jetbrains/hirschgarten/blob/main/tools/qodana/QODANA_LOCAL_INSTRUCTIONS.md Sets the QODANA_TOKEN environment variable, which is required for authenticating with qodana.cloud. Replace '' with your actual project token. ```shell export QODANA_TOKEN= ``` -------------------------------- ### Project Directories Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/projectview/parser/sections/Minimal.txt Defines the directories to be included in the project. This section lists the paths that contain the source code and utility files. ```APIDOC directories: - src/kotlin/app - src/kotlin/utils ``` -------------------------------- ### Run Qodana Locally Source: https://github.com/jetbrains/hirschgarten/blob/main/tools/qodana/QODANA_LOCAL_INSTRUCTIONS.md Executes the Qodana analysis script. Running without arguments provides local results accessible via a web interface. Running with 'online' sends results to qodana.cloud. ```shell ./run_qodana.sh ``` ```shell ./run_qodana.sh online ``` -------------------------------- ### Starlark If-Elif-Else Statement Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/statement/IfStatement.txt This snippet illustrates a basic if-elif-else conditional structure in Starlark. It evaluates conditions and executes corresponding code blocks. The example includes integer literals and a reference to an identifier. ```Starlark if true: 1 elif false: 0 else: not_possible ``` -------------------------------- ### Starlark Lambda Expression Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/stmt/ExprStmt.txt Presents a Starlark lambda expression, defining an anonymous function. This example creates a simple function that takes no arguments and returns the value of a variable named 'value'. Dependencies: A variable named 'value' in scope. Input: None. Output: The value of the 'value' variable. ```starlark lambda: value ``` -------------------------------- ### Project Targets Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/projectview/parser/sections/Minimal.txt Specifies the targets for the project, mapping directory patterns to processing rules. It indicates how different parts of the project are handled. ```APIDOC targets: //src/kotlin/app/... : all //src/kotlin/utils/... : all ``` -------------------------------- ### Starlark Modulo Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates a modulo operation between two integer literals in Starlark. ```starlark 1 % 2 ``` -------------------------------- ### Running IntelliJ-BSP Benchmark Locally Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/opentelemetry.md Provides the command to run the IntelliJ-BSP performance benchmark locally. This command configures the benchmark with specific project paths and cache directories, and launches IDEA to collect metrics. ```shell bazel test //plugin-bazel/performance-testing:performance-testing --jvmopt="-Dbsp.benchmark.cache.directory=/Users//IdeaProjects/hirschgarten -Dbsp.benchmark.project.path=/Users//IdeaProjects/" --sandbox_writable_path=/ --action-env=PATH ``` -------------------------------- ### Starlark Multiplication Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Shows a multiplication operation between two integer literals in Starlark. ```starlark 0 * 0 ``` -------------------------------- ### Starlark Subtraction Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Shows a subtraction operation between two integer literals in Starlark. ```starlark 1 - 1 ``` -------------------------------- ### Starlark Bitwise OR Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the bitwise OR operation (|) between two integer literals in Starlark. ```starlark 0 | 0 ``` -------------------------------- ### Unknown Command and Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/Basic.txt This snippet demonstrates how unknown commands and configurations are handled, showing a basic flag assignment. ```bazelrc unknown flag unknown:config flag ``` -------------------------------- ### Run Bazel-BSP Benchmark Locally Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/opentelemetry.md Executes the Bazel-BSP benchmark on a local machine. The command requires the path to the project and an output file for metrics. The benchmark runs against all specified targets. ```bash bazel run //server/bspcli:bspcli /path/to/project /path/to/output/metrics.txt //... ``` -------------------------------- ### Starlark Greater Than Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the greater than comparison (>) between two integer literals in Starlark. ```starlark 1 > 0 ``` -------------------------------- ### Load Default Project Targets Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/main/kotlin/org/jetbrains/bazel/magicmetamodel/README.md Loads default build targets for the project. This method handles scenarios with shared and non-shared sources. ```python magicMetaModel.loadDefaultTargets() ``` -------------------------------- ### Phased Sync Settings Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/guides/phased_sync.md Instructions on how to enable phased sync within the Bazel application settings and additional experimental registry settings. ```APIDOC Settings | Build, Execution, Deployment | Build Tools | Bazel | Advanced Settings -> Enable phased sync Registry Settings: - `bsp.execute.second.phase.on.sync`: Controls whether to run the aspect phase after the query phase. If true, it runs the aspect phase. If false, it remains in query-synced mode. ``` -------------------------------- ### Starlark Logical OR Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the logical OR operation between two integer literals in Starlark. ```starlark 0 or 1 ``` -------------------------------- ### Project Formatting Command Source: https://github.com/jetbrains/hirschgarten/blob/main/CONTRIBUTING.md Command to run the project's code formatter using Bazel. ```bazel bazel run //tools/format:format ``` -------------------------------- ### Starlark Right Shift Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates a right shift operation on an integer literal in Starlark. ```starlark 2 >> 1 ``` -------------------------------- ### Starlark Left Shift Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates a left shift operation on an integer literal in Starlark. ```starlark 1 << 2 ``` -------------------------------- ### Starlark Bitwise XOR Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the bitwise XOR operation (^) between two integer literals in Starlark. ```starlark 0 ^ ``` -------------------------------- ### Run ProtocolSuite Tests Source: https://github.com/jetbrains/hirschgarten/blob/main/bsp-testkit2/README.md Executes the ProtocolSuite tests using Bazel. Requires a path to a BSP project directory as an argument. Adjust test timeouts based on the server and project size. ```shell bazel run //bsp-testkit/client:ProtocolSuite -- ``` -------------------------------- ### Starlark Floor Division Operation Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Shows a floor division operation between two integer literals in Starlark. ```starlark 1 // 2 ``` -------------------------------- ### Import Run Configurations Source: https://github.com/jetbrains/hirschgarten/blob/main/commons/src/main/kotlin/org/jetbrains/bazel/projectview/README.md Specifies a list of XML files containing run configurations to be imported into Bazel during synchronization. It also notes that configurations from Google's Bazel plugin are automatically converted. ```yaml import_run_configurations: tools/intellij/run_application.xml tools/intellij/run_tests.xml ``` -------------------------------- ### Starlark Membership Check (not in) Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the membership check ('not in') to see if an integer is not present in a tuple in Starlark. ```starlark 0 not in tuple ``` -------------------------------- ### Code Formatting with Buildifier Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/CONTRIBUTING.md Ensure code consistency and adherence to project standards by using `buildifier`. Run `buildifier -r .` to recursively format all files in the current directory. ```bash buildifier -r . ``` -------------------------------- ### Starlark Less Than or Equal To Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the less than or equal to comparison (<=) between two integer literals in Starlark. ```starlark 0 <= 0 ``` -------------------------------- ### Merge Component Script Usage Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/add_components.md Demonstrates the command-line syntax for the `merge-component.py` script, which is used to add components from existing repositories into the Hirschgarten monorepo. It outlines the required arguments: Hirschgarten path, local repository path, and the target subfolder. ```bash python merge-component.py ``` -------------------------------- ### Starlark Membership Check (in) Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the membership check ('in') to see if an integer is present in a tuple in Starlark. ```starlark 0 in tuple ``` -------------------------------- ### Starlark Greater Than or Equal To Comparison Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Demonstrates the greater than or equal to comparison (>=) between two integer literals in Starlark. ```starlark 0 >= 0 ``` -------------------------------- ### Starlark Integer Literal and Bitwise AND Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/starlark/parser/expression/BinaryExpression.txt Shows a Starlark integer literal and a bitwise AND operation between two integer literals. ```starlark 0 0 & 0 ``` -------------------------------- ### Scala SDK Management Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/kotlin/org/jetbrains/bazel/annotation/public-api-methods.txt Methods for managing Scala SDKs, including adding them to the project, comparing SDK instances, and accessing SDK properties like name, version, and jars. ```java public abstract void org.jetbrains.bazel.scala.sdk.ScalaSdkExtension.addScalaSdk(org.jetbrains.bazel.scala.sdk.ScalaSdk,com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) public boolean org.jetbrains.bazel.scala.sdk.ScalaSdk.equals(java.lang.Object) public final java.lang.String org.jetbrains.bazel.scala.sdk.ScalaSdk.component1() public final java.lang.String org.jetbrains.bazel.scala.sdk.ScalaSdk.component2() public final java.lang.String org.jetbrains.bazel.scala.sdk.ScalaSdk.getName() public final java.lang.String org.jetbrains.bazel.scala.sdk.ScalaSdk.getScalaVersion() public final java.util.List org.jetbrains.bazel.scala.sdk.ScalaSdk.component3() public final java.util.List org.jetbrains.bazel.scala.sdk.ScalaSdk.getSdkJars() public final org.jetbrains.bazel.scala.sdk.ScalaSdk org.jetbrains.bazel.scala.sdk.ScalaSdk.copy(java.lang.String,java.lang.String,java.util.List) public int org.jetbrains.bazel.scala.sdk.ScalaSdk.hashCode() public static org.jetbrains.bazel.scala.sdk.ScalaSdk org.jetbrains.bazel.scala.sdk.ScalaSdk.copy$default(org.jetbrains.bazel.scala.sdk.ScalaSdk,java.lang.String,java.lang.String,java.util.List,int,java.lang.Object) ``` -------------------------------- ### Import Project View - Basic Source: https://github.com/jetbrains/hirschgarten/blob/main/commons/src/main/kotlin/org/jetbrains/bazel/projectview/README.md Imports another project view file. Multiple imports can be used, and list-type sections are composed. Single-value sections override based on parse order. ```APIDOC import path/to/another/projectview.bazelproject ``` -------------------------------- ### Project Directories Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/projectview/parser/sections/Directories.txt Defines the directories to be included in the project view. It specifies paths for source code and test code, and also demonstrates how to exclude specific subdirectories. ```hirschgarten directories: java/com/google/android/myproject javatests/com/google/android/myproject -javatests/com/google/android/myproject/not_this ``` -------------------------------- ### Shard Approach Configuration Source: https://github.com/jetbrains/hirschgarten/blob/main/commons/src/main/kotlin/org/jetbrains/bazel/projectview/README.md Specifies the sharding strategy used when `shard_sync` is enabled. Options include `EXPAND_AND_SHARD`, `QUERY_AND_SHARD`, and `SHARD_ONLY`. ```APIDOC shard_approach: QUERY_AND_SHARD ``` -------------------------------- ### Bazel Build Command with Define Flag Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/testData/bazelrc/parser/ValueWithQuoteString.txt This snippet demonstrates a typical Bazelrc line defining a build command with the '--define' flag. It specifies the product name for an IntelliJ IDE build. ```bazelrc build --define=ij_product="intellij-2025.1" ``` -------------------------------- ### Bazel Project Synchronization Hooks Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/test/kotlin/org/jetbrains/bazel/annotation/public-api-methods.txt Provides methods related to project synchronization with Bazel. Includes checks for enabling synchronization and post-sync operations. ```java public abstract boolean org.jetbrains.bazel.extensionPoints.JvmBinaryJarsExtension.shouldImportJvmBinaryJars(com.intellij.openapi.project.Project) public abstract boolean org.jetbrains.bazel.sync.ProjectPostSyncHook.isEnabled(com.intellij.openapi.project.Project) public abstract java.lang.Object org.jetbrains.bazel.sync.ProjectPostSyncHook.onPostSync(org.jetbrains.bazel.sync.ProjectPostSyncHook$ProjectPostSyncHookEnvironment,kotlin.coroutines.Continuation) ``` -------------------------------- ### Check Bazel Version Source: https://github.com/jetbrains/hirschgarten/blob/main/plugin-bazel/src/main/resources/inspectionDescriptions/BazelVersion.html This script checks if the currently installed Bazel version is the latest available. It compares the local version against a known up-to-date version. ```bash #!/bin/bash # Define the expected up-to-date Bazel version EXPECTED_VERSION="6.1.0" # Get the current Bazel version CURRENT_VERSION=$(bazel --version | cut -d ' ' -f 2) # Compare versions if [[ "$CURRENT_VERSION" == "$EXPECTED_VERSION" ]]; then echo "Bazel version is up to date ($CURRENT_VERSION)." else echo "Bazel version is outdated. Current: $CURRENT_VERSION, Expected: $EXPECTED_VERSION." fi ``` -------------------------------- ### Copy pre-commit_format hook Source: https://github.com/jetbrains/hirschgarten/blob/main/tools/pre-commit_hooks/pre-commit_hooks_setup.md Copies the auto-formatting pre-commit hook script to the local Git hooks directory. ```shell cp plugins/bazel/tools/pre-commit_hooks/pre-commit_format .git/hooks/pre-commit ``` -------------------------------- ### Tracing Time Metrics in Bazel-BSP Source: https://github.com/jetbrains/hirschgarten/blob/main/docs/dev/opentelemetry.md Illustrates how time metrics are captured in Bazel-BSP using OpenTelemetry's span builder. This is similar to the approach used in IntelliJ-BSP. ```kotlin bspTracer.spanBuilder("Resolve project").use { // ... } ``` -------------------------------- ### Make pre-commit hook executable Source: https://github.com/jetbrains/hirschgarten/blob/main/tools/pre-commit_hooks/pre-commit_hooks_setup.md Sets the executable permission for the pre-commit hook script. ```shell chmod +x .git/hooks/pre-commit ``` -------------------------------- ### Specify Bazel Binary Path Source: https://github.com/jetbrains/hirschgarten/blob/main/commons/src/main/kotlin/org/jetbrains/bazel/projectview/README.md Sets the path to the Bazel executable used by the server for building and querying. ```APIDOC bazel_binary: /usr/local/bin/bazel ```