Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] parsing of project view file fails if the file doesn't exist | …
Browse files Browse the repository at this point in the history
…#BAZEL-21 Fixed | (#215)

* parsing fails if file doesnt exist

* Rename .java to .kt

* project view parser impl is in kotlin

* Rename .java to .kt

* project view parser impl mock is in kotlin

* project view parser impl test is in kotlin

* buildifier

* changelog

* new lines
  • Loading branch information
abrams27 authored Apr 11, 2022
1 parent 235d942 commit 56dc335
Show file tree
Hide file tree
Showing 12 changed files with 975 additions and 896 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

### Fixes 🛠️

- Parsing of project view file fails if the file doesn't exist.
| [#215](https://github.com/JetBrains/bazel-bsp/pull/215)
- Project view path is mapped to the absolute path in the installer.
| [#213](https://github.com/JetBrains/bazel-bsp/pull/213)
- Kotlin targets don't break import.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_java//java:defs.bzl", "java_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

java_library(
name = "parser",
Expand All @@ -9,15 +10,29 @@ java_library(
],
exports = [
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/model",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser:parser_kotlin",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser/sections",
],
deps = [
"//commons",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/model",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser:parser_kotlin",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser/sections",
"@maven//:com_google_guava_guava",
"@maven//:io_vavr_vavr",
"@maven//:org_apache_logging_log4j_log4j_api",
"@maven//:org_apache_logging_log4j_log4j_core",
],
)

kt_jvm_library(
name = "parser_kotlin",
srcs = glob(["*.kt"]),
deps = [
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/model",
"//executioncontext/projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser/sections",
"@maven//:io_vavr_vavr",
"@maven//:org_apache_logging_log4j_log4j_api",
"@maven//:org_apache_logging_log4j_log4j_core",
],
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package org.jetbrains.bsp.bazel.projectview.parser

import io.vavr.control.Try
import org.jetbrains.bsp.bazel.projectview.model.ProjectView
import java.nio.file.Path

/**
* Project view file parser. Its purpose is to parse *.bazelproject file and create an instance of
* ProjectView.
*
* @see org.jetbrains.bsp.bazel.projectview.model.ProjectView
*/
interface ProjectViewParser {
/**
* Parses file under `projectViewFilePath` using file under `
* defaultProjectViewFilePath` as a default.
*
* @param projectViewFilePath path to file with project view
* @param defaultProjectViewFilePath path to file with default project view
* @return
*
* `Try.success` with `ProjectView` if parsing has finished with
* success, it means:
*
* 1) files under `projectViewFilePath` and `defaultProjectViewFilePath
` * were successfully parsed (not all values have to be provided -- some fields in
* `ProjectView` might be `Optional.empty`). <br></br>
* File under `projectViewFilePath` can contain all values, then `
* defaultProjectViewFilePath` won't be used, or file under `projectViewFilePath
` * can be empty, then all values from file under `defaultProjectViewFilePath
` * will be used, any other configuration is possible as well.
*
* 2) file under `projectViewFilePath` doesn't exist, then all values from
* `defaultProjectViewFilePath` will be used.<br></br>
* <br></br>
*
* `Try.failure` with if:
*
* 1) file under `defaultProjectViewFilePath` doesn't exist
*
* 2) any other fail happen
*/
fun parse(projectViewFilePath: Path, defaultProjectViewFilePath: Path): Try<ProjectView>

/**
* Parses `projectViewFileContent` using `defaultProjectViewFileContent` as
* a default.
*
* @param projectViewFileContent string with project view
* @param defaultProjectViewFileContent string with default project view
* @return
*
* `Try.success` with `ProjectView` if parsing has finished with
* success, it means:
*
* 1) `projectViewFileContent` and `defaultProjectViewFileContent
` * were successfully parsed (not all values have to be provided -- some fields in
* `ProjectView` might be `Optional.empty`). <br></br>
* `projectViewFileContent` can contain all values, then `
* defaultProjectViewFileContent` won't be used, `projectViewFileContent
` * can be empty, then all values from `defaultProjectViewFileContent` will
* be used, any other configuration is possible as well.<br></br>
* <br></br>
*
* `Try.failure` with if:
*
* 1) any fail happen
*/
fun parse(projectViewFileContent: String, defaultProjectViewFileContent: String): Try<ProjectView>

/**
* Parses file under `projectViewFilePath`.
*
* @param projectViewFilePath path to file with project view
* @return
*
* `Try.success` with `ProjectView` if parsing has finished with
* success, it means:
*
* 1) file under `projectViewFilePath` was successfully parsed (not all values
* have to be provided -- some fields in `ProjectView` might be `
* Optional.empty`). <br></br>
*
* `Try.failure` with if:
*
* 1) file under `projectViewFilePath` doesn't exist
*
* 2) any other fail happen
*/
fun parse(projectViewFilePath: Path): Try<ProjectView>

/**
* Parses `projectViewFileContent`.
*
* @param projectViewFileContent string with project view
* @return
*
* `Try.success` with `ProjectView` if parsing has finished with
* success, it means:
*
* 1) `projectViewFileContent` was successfully parsed (not all values have to
* be provided -- some fields in `ProjectView` might be `Optional.empty
` * ). <br></br>
*
* `Try.failure` with if:
*
* 1) any fail happen
*/
fun parse(projectViewFileContent: String): Try<ProjectView>
}
Loading

0 comments on commit 56dc335

Please sign in to comment.