Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support javadoc on create table statements (#1802)
- Loading branch information
Alec Strong
committed
Jun 20, 2020
1 parent
333ae50
commit a4382c0
Showing
8 changed files
with
121 additions
and
37 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
37 changes: 37 additions & 0 deletions
37
...r/src/main/kotlin/com/squareup/sqldelight/core/compiler/integration/JavadocIntegration.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,37 @@ | ||
package com.squareup.sqldelight.core.compiler.integration | ||
|
||
import com.intellij.psi.PsiElement | ||
|
||
/** | ||
* This pattern consists of 3 parts: | ||
* | ||
* - `/\\*\\*` - matches the first line of the Javadoc: | ||
* | ||
* ``` | ||
* </**> | ||
* * Javadoc | ||
* */ | ||
* ``` | ||
* | ||
* - `\n \\*[ /]?` - matches every other line of Javadoc: | ||
* | ||
* ``` | ||
* /**< | ||
* * >Javadoc< | ||
* */> | ||
* ``` | ||
* | ||
* - ` \\**slash` - specifically matches the tail part of a single-line Javadoc: | ||
* | ||
* ``` | ||
* /* Javadoc< */> | ||
* ``` | ||
*/ | ||
private val JAVADOC_TEXT_REGEX = Regex("/\\*\\*|\n \\*[ /]?| \\*/") | ||
|
||
internal fun javadocText(javadoc: PsiElement): String? { | ||
return javadoc.text | ||
.split(JAVADOC_TEXT_REGEX) | ||
.dropWhile(String::isEmpty) | ||
.joinToString(separator = "\n", transform = String::trim) | ||
} |
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
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
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