Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ gitVersioning.apply {
refs {
describeTagFirstParent = false
tag("v(?<tagVersion>[0-9].*)") {
version = $$"${ref.tagVersion}${dirty}"
version = "\${ref.tagVersion}\${dirty}"
}

branch("develop") {
version = $$"${describe.tag.version}." +
$$"${describe.distance}-SNAPSHOT${dirty}"
version = "\${describe.tag.version}." +
"\${describe.distance}-SNAPSHOT\${dirty}"
}
Comment thread
nixel2007 marked this conversation as resolved.

branch(".+") {
version = $$"${ref}-${commit.short}${dirty}"
version = "\${ref}-\${commit.short}\${dirty}"
}
}

rev {
version = $$"${commit.short}${dirty}"
version = "\${commit.short}\${dirty}"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
* все запросы, связанные с открытием, изменением, закрытием документов,
* а также предоставляет функции навигации, редактирования и анализа кода.
*/
@Component

Check warning on line 159 in src/main/java/com/github/_1c_syntax/bsl/languageserver/lsp/BSLTextDocumentService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use @Service instead of @Component, or rename this type if the @Component annotation is intentional

See more on https://sonarcloud.io/project/issues?id=1c-syntax_bsl-language-server&issues=AZ9_Mh001dwuyRxBVq7W&open=AZ9_Mh001dwuyRxBVq7W&pullRequest=4283
@RequiredArgsConstructor
@Slf4j
public class BSLTextDocumentService implements TextDocumentService, ProtocolExtension {
Expand Down Expand Up @@ -821,7 +821,11 @@
}
}

serverContext.closeDocument(documentContext);
// didClose приходит с потока диспетчеризации LSP4J, на котором workspace-контекст
// не установлен, — выставляем его явно (как в didOpen), чтобы workspace-scoped
// @EventListener-подписчики ServerContextDocumentClosedEvent корректно резолвились.
WorkspaceContextHolder.run(serverContext.getWorkspaceUri(),
() -> serverContext.closeDocument(documentContext));

if (!clientSupportsPullDiagnostics) {
diagnosticProvider.publishEmptyDiagnosticList(documentContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.github._1c_syntax.bsl.languageserver.context.FileType;
import com.github._1c_syntax.bsl.languageserver.context.ServerContextProvider;
import com.github._1c_syntax.bsl.languageserver.context.events.DocumentContextContentChangedEvent;
import com.github._1c_syntax.bsl.languageserver.context.events.ServerContextDocumentClosedEvent;
import com.github._1c_syntax.bsl.languageserver.infrastructure.WorkspaceContextHolder;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.DiagnosticParams;
import com.github._1c_syntax.bsl.languageserver.client.ClientCapabilitiesHolder;
Expand Down Expand Up @@ -323,6 +324,51 @@ void didClose() {
textDocumentService.didClose(params);
}

/**
* Воспроизводит warning из рантайма: didClose приходит с потока диспетчеризации LSP4J
* без установленного workspace-контекста, из-за чего workspace-scoped proxy beans
* (per-URI индексы) не резолвятся в @EventListener при ServerContextDocumentClosedEvent
* и молча теряют событие закрытия документа.
*/
@Test
void didClose_setsWorkspaceContextForEventListeners() throws IOException {
// given — открытый документ
textDocumentService.didOpen(new DidOpenTextDocumentParams(getTextDocumentItem()));

var capturedWorkspaceUri = new AtomicReference<URI>();
var listener = new SmartApplicationListener() {
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
return ServerContextDocumentClosedEvent.class.isAssignableFrom(eventType);
}

@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}

@Override
public void onApplicationEvent(ApplicationEvent event) {
capturedWorkspaceUri.compareAndSet(null, WorkspaceContextHolder.get());
}
};
applicationContext.addApplicationListener(listener);

try {
var params = new DidCloseTextDocumentParams(getTextDocumentIdentifier());
textDocumentService.didClose(params);

var expectedWorkspaceUri = Absolute.uri(new File("./src/test/resources").getAbsoluteFile().toURI());
assertThat(capturedWorkspaceUri.get())
.as("Workspace context must be set when ServerContextDocumentClosedEvent fires during didClose "
+ "(otherwise workspace-scoped per-URI indexes cannot be resolved and miss the event)")
.isNotNull()
.isEqualTo(expectedWorkspaceUri);
} finally {
applicationContext.removeApplicationListener(listener);
}
}

@Test
void didCloseWithPendingChanges() throws IOException {
// given - open a document and make changes
Expand Down
Loading