diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..89773d6 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,44 @@ +import org.jetbrains.gradle.ext.Remote +import org.jetbrains.gradle.ext.runConfigurations +import org.jetbrains.gradle.ext.settings + +/* + * Copyright 2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.9" +} + +idea.project.settings { + runConfigurations { + runConfigurations { + create("Attaching debugger 5010") { + mode = Remote.RemoteMode.ATTACH + transport = Remote.RemoteTransport.SOCKET + sharedMemoryAddress = "javadebug" + host = "localhost" + port = 5010 + } + create("Listening debugger 5011") { + mode = Remote.RemoteMode.LISTEN + transport = Remote.RemoteTransport.SOCKET + sharedMemoryAddress = "javadebug" + host = "localhost" + port = 5011 + } + } + } +} \ No newline at end of file diff --git a/lsp/src/main/kotlin/org/gradle/declarative/lsp/DeclarativeTextDocumentService.kt b/lsp/src/main/kotlin/org/gradle/declarative/lsp/DeclarativeTextDocumentService.kt index 70a029b..fafdf2d 100644 --- a/lsp/src/main/kotlin/org/gradle/declarative/lsp/DeclarativeTextDocumentService.kt +++ b/lsp/src/main/kotlin/org/gradle/declarative/lsp/DeclarativeTextDocumentService.kt @@ -104,8 +104,12 @@ class DeclarativeTextDocumentService : TextDocumentService { val uri = URI(it.textDocument.uri) val text = it.textDocument.text val dom = parse(uri, text) - documentStore.storeInitial(uri, text, dom) - processDocument(uri) + if (dom != null) { + documentStore.storeInitial(uri, text, dom) + processDocument(uri) + } else { + documentStore.remove(uri) + } } } @@ -117,8 +121,12 @@ class DeclarativeTextDocumentService : TextDocumentService { val version = it.textDocument.version val text = change.text val dom = parse(uri, change.text) - documentStore.storeVersioned(uri, version, text, dom) - processDocument(uri) + if (dom != null) { + documentStore.storeVersioned(uri, version, text, dom) + processDocument(uri) + } else { + documentStore.remove(uri) + } } } } @@ -296,7 +304,7 @@ class DeclarativeTextDocumentService : TextDocumentService { ) } - private fun parse(uri: URI, text: String): DocumentOverlayResult { + private fun parse(uri: URI, text: String): DocumentOverlayResult? { val fileName = uri.path.substringAfterLast('/') val fileSchema = schemaAnalysisEvaluator.evaluate(fileName, text) val settingsSchema = schemaAnalysisEvaluator.evaluate(