This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] parsing of project view file fails if the file doesn't exist | …
…#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
Showing
12 changed files
with
975 additions
and
896 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 0 additions & 92 deletions
92
...ojectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser/ProjectViewParser.java
This file was deleted.
Oops, something went wrong.
110 changes: 110 additions & 0 deletions
110
...projectview/src/main/java/org/jetbrains/bsp/bazel/projectview/parser/ProjectViewParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
Oops, something went wrong.