Skip to content

Commit 6267fbe

Browse files
committed
Moved org.javacs.kt.classpath and .util to 'shared' module and extracted PsiUtils from Utils.kt
1 parent 5738ae9 commit 6267fbe

File tree

13 files changed

+29
-22
lines changed

13 files changed

+29
-22
lines changed

server/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ description = 'Code completions, diagnostics and more for Kotlin'
1111
def debugPort = 8000
1212
def debugArgs = '-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y'
1313

14+
dependencies {
15+
implementation project(':shared')
16+
}
17+
1418
applicationDistribution.into('bin') {
1519
fileMode = 0755
1620
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.javacs.kt.util
2+
3+
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
4+
import com.intellij.psi.PsiElement
5+
import com.intellij.psi.PsiFile
6+
import java.nio.file.Path
7+
8+
inline fun<reified Find> PsiElement.findParent() =
9+
this.parentsWithSelf.filterIsInstance<Find>().firstOrNull()
10+
11+
fun PsiElement.preOrderTraversal(): Sequence<PsiElement> {
12+
val root = this
13+
14+
return sequence {
15+
yield(root)
16+
17+
for (child in root.children) {
18+
yieldAll(child.preOrderTraversal())
19+
}
20+
}
21+
}
22+
23+
fun PsiFile.toPath(): Path =
24+
winCompatiblePathOf(this.originalFile.viewProvider.virtualFile.path)

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rootProject.name = 'KotlinLanguageServer'
22

3-
include 'server'
3+
include 'shared', 'server'

shared/build.gradle

Whitespace-only changes.

0 commit comments

Comments
 (0)