Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ tasks.withType<GenerateModuleMetadata> {
}

tasks.register("updateLicenses") {
description = "Wrapper for licenseFormat"
group = "license"
dependsOn(tasks.licenseFormat)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.TextDocumentService;
import org.eclipse.lsp4j.services.WorkspaceService;
import org.jspecify.annotations.Nullable;
import org.springframework.stereotype.Component;

import java.io.File;
Expand Down Expand Up @@ -106,7 +107,7 @@ public class BSLLanguageServer implements LanguageServer, ProtocolExtension {
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {

clientCapabilitiesHolder.setCapabilities(params.getCapabilities());

setConfigurationRoot(params);

var capabilities = new ServerCapabilities();
Expand Down Expand Up @@ -142,7 +143,7 @@ private void setConfigurationRoot(InitializeParams params) {
return;
}

String rootUri = workspaceFolders.get(0).getUri();
var rootUri = workspaceFolders.get(0).getUri();
Path rootPath;
try {
rootPath = new File(new URI(rootUri).getPath()).getCanonicalFile().toPath();
Expand All @@ -151,7 +152,7 @@ private void setConfigurationRoot(InitializeParams params) {
return;
}

Path configurationRoot = LanguageServerConfiguration.getCustomConfigurationRoot(
var configurationRoot = LanguageServerConfiguration.getCustomConfigurationRoot(
configuration,
rootPath);
context.setConfigurationRoot(configurationRoot);
Expand All @@ -163,7 +164,7 @@ public void initialized(InitializedParams params) {
var executorService = new ForkJoinPool(ForkJoinPool.getCommonPoolParallelism(), factory, null, true);
CompletableFuture
.runAsync(context::populateContext, executorService)
.whenComplete((unused, throwable) -> {
.whenComplete((Void unused, @Nullable Throwable throwable) -> {
executorService.shutdown();
if (throwable != null) {
LOGGER.error("Error populating context", throwable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
import org.eclipse.lsp4j.ReferenceParams;
import org.eclipse.lsp4j.RelatedFullDocumentDiagnosticReport;
import org.eclipse.lsp4j.RenameParams;
import org.eclipse.lsp4j.SemanticTokens;
import org.eclipse.lsp4j.SemanticTokensParams;
import org.eclipse.lsp4j.SelectionRange;
import org.eclipse.lsp4j.SelectionRangeParams;
import org.eclipse.lsp4j.SemanticTokens;
import org.eclipse.lsp4j.SemanticTokensParams;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.ToString;
import org.eclipse.lsp4j.ClientCapabilities;
import org.eclipse.lsp4j.InitializeParams;
import org.jspecify.annotations.Nullable;
import org.springframework.stereotype.Component;

import java.util.Optional;
Expand All @@ -46,7 +47,7 @@ public class ClientCapabilitiesHolder {
* Возможности клиента.
*/
@Setter
private ClientCapabilities capabilities;
private @Nullable ClientCapabilities capabilities;

/**
* Получить возможности клиента, если было произведено подключение клиента к серверу.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*/
package com.github._1c_syntax.bsl.languageserver;

import org.jspecify.annotations.Nullable;
import lombok.NoArgsConstructor;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.lsp4j.services.LanguageClientAware;
import org.jspecify.annotations.Nullable;
import org.springframework.stereotype.Component;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.aspectj.lang.annotation.Aspect;
import org.eclipse.lsp4j.InitializeParams;
import org.eclipse.lsp4j.services.LanguageServer;
import org.jspecify.annotations.Nullable;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
Expand All @@ -57,7 +58,7 @@
public class EventPublisherAspect implements ApplicationEventPublisherAware {

private boolean active;
private ApplicationEventPublisher applicationEventPublisher;
private @Nullable ApplicationEventPublisher applicationEventPublisher;

@PreDestroy
public void destroy() {
Expand Down Expand Up @@ -100,7 +101,7 @@ public void languageServerInitialize(JoinPoint joinPoint, InitializeParams initi
}

private void publishEvent(ApplicationEvent event) {
if (!active) {
if (!active || applicationEventPublisher == null) {
LOGGER.warn("Trying to send event in not active event publisher.");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;
Expand All @@ -50,7 +51,7 @@
public class MeasuresAspect {

@Setter(onMethod = @__({@Autowired}))
private MeasureCollector measureCollector;
private @Nullable MeasureCollector measureCollector;

@PreDestroy
void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.github._1c_syntax.bsl.languageserver.LanguageClientHolder;
import com.github._1c_syntax.bsl.languageserver.utils.Resources;
import org.jspecify.annotations.Nullable;
import io.sentry.Sentry;
import io.sentry.protocol.SentryId;
import jakarta.annotation.PostConstruct;
Expand All @@ -34,6 +33,7 @@
import org.aspectj.lang.annotation.Aspect;
import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.MessageType;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

Expand Down Expand Up @@ -82,19 +82,21 @@ public void logThrowingLSPCall(Throwable ex) {

private void logException(Throwable ex) {
CompletableFuture.runAsync(() -> {
SentryId sentryId = Sentry.captureException(ex);
if (sentryId.equals(SentryId.EMPTY_ID)) {
return;
}
if (languageClientHolder == null) {
return;
}
var messageType = MessageType.Info;
var message = resources.getResourceString(getClass(), "logMessage", sentryId);
var messageParams = new MessageParams(messageType, message);
var sentryId = Sentry.captureException(ex);
if (sentryId.equals(SentryId.EMPTY_ID)) {
return;
}
var clientHolder = languageClientHolder;
if (clientHolder == null) {
return;
}
var messageType = MessageType.Info;
var message = resources.getResourceString(getClass(), "logMessage", sentryId);
var messageParams = new MessageParams(messageType, message);

languageClientHolder.execIfConnected(languageClient -> languageClient.showMessage(messageParams));
}, executorService);
clientHolder.execIfConnected(languageClient -> languageClient.showMessage(messageParams));
},
executorService);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
import com.github._1c_syntax.bsl.languageserver.configuration.SendErrorsMode;
import com.github._1c_syntax.bsl.languageserver.utils.Resources;
import org.jspecify.annotations.Nullable;
import io.sentry.Hint;
import io.sentry.SentryEvent;
import io.sentry.SentryOptions.BeforeSendCallback;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.lsp4j.MessageActionItem;
import org.eclipse.lsp4j.MessageType;
import org.eclipse.lsp4j.ServerInfo;
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.services.LanguageClient;
import org.jspecify.annotations.Nullable;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
Expand Down Expand Up @@ -71,7 +70,7 @@ public class PermissionFilterBeforeSendCallback implements BeforeSendCallback {
private final AtomicBoolean questionWasSend = new AtomicBoolean(false);

@Override
public SentryEvent execute(@NonNull SentryEvent event, @NonNull Hint hint) {
public @Nullable SentryEvent execute(SentryEvent event, Hint hint) {
if (sendToSentry()) {
return event;
}
Expand Down Expand Up @@ -132,8 +131,7 @@ private CompletableFuture<MessageActionItem> askUserForPermission(LanguageClient
return languageClient.showMessageRequest(requestParams);
}

@Nullable
private MessageActionItem waitForPermission(CompletableFuture<MessageActionItem> sendQuestion) {
@Nullable private MessageActionItem waitForPermission(CompletableFuture<MessageActionItem> sendQuestion) {
try {
return sendQuestion.get();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.jspecify.annotations.NullUnmarked;

import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
import lombok.Getter;
import lombok.Setter;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.jspecify.annotations.Nullable;

@Getter
public class ControlFlowGraph extends DefaultDirectedGraph<CfgVertex, CfgEdge> {

@Setter
private CfgVertex entryPoint;
private @Nullable CfgVertex entryPoint;

Check failure on line 33 in src/main/java/com/github/_1c_syntax/bsl/languageserver/cfg/ControlFlowGraph.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make non-static "entryPoint" transient or serializable.

See more on https://sonarcloud.io/project/issues?id=1c-syntax_bsl-language-server&issues=AZsOQrxmHkG9TIx0O_-V&open=AZsOQrxmHkG9TIx0O_-V&pullRequest=3657

private final ExitVertex exitPoint;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Objects;
import java.util.Set;

@RequiredArgsConstructor
Expand All @@ -34,7 +35,7 @@ public class ControlFlowGraphWalker {
private CfgVertex currentNode;

public void start() {
currentNode = graph.getEntryPoint();
currentNode = Objects.requireNonNull(graph.getEntryPoint());
}

public Set<CfgEdge> availableRoutes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
package com.github._1c_syntax.bsl.languageserver.cli.lsp;

import com.github._1c_syntax.bsl.languageserver.configuration.events.LanguageServerConfigurationChangedEvent;
import org.jspecify.annotations.Nullable;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.jspecify.annotations.Nullable;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import com.github._1c_syntax.bsl.languageserver.context.FileType;
import com.github._1c_syntax.bsl.languageserver.events.LanguageServerInitializeRequestReceivedEvent;
import com.github._1c_syntax.utils.Absolute;
import org.jspecify.annotations.Nullable;
import lombok.RequiredArgsConstructor;
import org.eclipse.lsp4j.ClientInfo;
import org.eclipse.lsp4j.InitializeParams;
import org.jspecify.annotations.Nullable;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.github._1c_syntax.bsl.languageserver.configuration.inlayhints.InlayHintOptions;
import com.github._1c_syntax.bsl.languageserver.configuration.references.ReferencesOptions;
import com.github._1c_syntax.utils.Absolute;
import org.jspecify.annotations.Nullable;
import jakarta.annotation.PostConstruct;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -45,6 +44,7 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
Expand Down Expand Up @@ -163,9 +163,9 @@ public void reset() {
*
* @param configuration Конфигурация language server
* @param srcDir Директория исходных файлов
* @return Корневой каталог для анализа
* @return Корневой каталог для анализа, или {@code null} если конфигурация находится вне srcDir
*/
public static Path getCustomConfigurationRoot(LanguageServerConfiguration configuration, Path srcDir) {
public static @Nullable Path getCustomConfigurationRoot(LanguageServerConfiguration configuration, Path srcDir) {

Path rootPath = null;
var pathFromConfiguration = configuration.getConfigurationRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration.capabilities;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration.codelens;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import com.github._1c_syntax.bsl.languageserver.configuration.databind.DiagnosticMetadataMapDeserializer;
import com.github._1c_syntax.bsl.languageserver.configuration.databind.ParametersDeserializer;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.jspecify.annotations.Nullable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.jspecify.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration.diagnostics;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration.documentlink;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration.formating;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
@NullMarked
package com.github._1c_syntax.bsl.languageserver.configuration;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullMarked;
Loading
Loading