Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring/code cleanup #817

Merged
merged 15 commits into from
Mar 2, 2024
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
128 changes: 123 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/******************************************************************************
* Copyright (c) 2016 TypeFox and others.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/

Expand All @@ -32,15 +32,16 @@ apply from: "${rootDir}/gradle/versions.gradle"

subprojects {
repositories.mavenCentral()

group = 'org.eclipse.lsp4j'
version = rootProject.version


apply plugin: 'eclipse'
apply plugin: 'java-library'
apply plugin: 'org.xtext.xtend'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

apply from: "${rootDir}/gradle/java-compiler-settings.gradle"
apply from: "${rootDir}/gradle/xtend-compiler-settings.gradle"
apply from: "${rootDir}/gradle/maven-deployment.gradle"
Expand All @@ -54,6 +55,123 @@ subprojects {
}
}
}

eclipse {
jdt.file.withProperties { properties ->
properties['org.eclipse.jdt.core.compiler.release']='enabled'
properties['org.eclipse.jdt.core.compiler.doc.comment.support']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.APILeak']='warning'
properties['org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated']='info'
properties['org.eclipse.jdt.core.compiler.problem.annotationSuperInterface']='warning'
properties['org.eclipse.jdt.core.compiler.problem.assertIdentifier']='error'
properties['org.eclipse.jdt.core.compiler.problem.autoboxing']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.comparingIdentical']='warning'
properties['org.eclipse.jdt.core.compiler.problem.deadCode']='warning'
properties['org.eclipse.jdt.core.compiler.problem.deprecation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.discouragedReference']='warning'
properties['org.eclipse.jdt.core.compiler.problem.emptyStatement']='warning'
properties['org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.enumIdentifier']='error'
properties['org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable']='warning'
properties['org.eclipse.jdt.core.compiler.problem.fallthroughCase']='warning'
properties['org.eclipse.jdt.core.compiler.problem.fatalOptionalError']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.fieldHiding']='warning'
properties['org.eclipse.jdt.core.compiler.problem.finalParameterBound']='warning'
properties['org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally']='warning'
properties['org.eclipse.jdt.core.compiler.problem.forbiddenReference']='error'
properties['org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock']='warning'
properties['org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod']='warning'
properties['org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch']='warning'
properties['org.eclipse.jdt.core.compiler.problem.indirectStaticAccess']='warning'
properties['org.eclipse.jdt.core.compiler.problem.invalidJavadoc']='warning'
properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTags']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility']='protected'
properties['org.eclipse.jdt.core.compiler.problem.localVariableHiding']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.methodWithConstructorName']='warning'
properties['org.eclipse.jdt.core.compiler.problem.missingDefaultCase']='info'
properties['org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod']='warning'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocComments']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility']='public'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription']='return_tag'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTags']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility']='public'
properties['org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.missingSerialVersion']='warning'
properties['org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod']='warning'
properties['org.eclipse.jdt.core.compiler.problem.noEffectAssignment']='warning'
properties['org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion']='warning'
properties['org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped']='warning'
properties['org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict']='error'
properties['org.eclipse.jdt.core.compiler.problem.nullReference']='warning'
properties['org.eclipse.jdt.core.compiler.problem.nullSpecViolation']='error'
properties['org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion']='warning'
properties['org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod']='warning'
properties['org.eclipse.jdt.core.compiler.problem.parameterAssignment']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables']='warning'
properties['org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment']='warning'
properties['org.eclipse.jdt.core.compiler.problem.potentialNullReference']='warning'
properties['org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable']='warning'
properties['org.eclipse.jdt.core.compiler.problem.rawTypeReference']='warning'
properties['org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.redundantNullCheck']='warning'
properties['org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments']='warning'
properties['org.eclipse.jdt.core.compiler.problem.redundantSuperinterface']='warning'
properties['org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures']='warning'
properties['org.eclipse.jdt.core.compiler.problem.specialParameterHidingField']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.staticAccessReceiver']='warning'
properties['org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.suppressWarnings']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed']='info'
properties['org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.terminalDeprecation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.typeParameterHiding']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unclosedCloseable']='warning'
properties['org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.unhandledWarningToken']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType']='info'
properties['org.eclipse.jdt.core.compiler.problem.unnecessaryElse']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.unusedImport']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedLabel']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedLocal']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedParameter']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference']='enabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete']='disabled'
properties['org.eclipse.jdt.core.compiler.problem.unusedPrivateMember']='warning'
properties['org.eclipse.jdt.core.compiler.problem.unusedTypeParameter']='ignore'
properties['org.eclipse.jdt.core.compiler.problem.unusedWarningToken']='warning'
properties['org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast']='warning'
}
}
}

task clean(type: Delete) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
/******************************************************************************
* Copyright (c) 2022 itemis AG and others.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/
package org.eclipse.lsp4j.debug.adapters;

import java.util.function.Predicate;

import org.eclipse.lsp4j.debug.AttachRequestArguments;
import org.eclipse.lsp4j.debug.LaunchRequestArguments;
import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter;
import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter.PropertyChecker;
import org.eclipse.lsp4j.jsonrpc.messages.Either;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

public class RestartArgumentsArgumentsTypeAdapter implements TypeAdapterFactory {

private static final TypeToken<Either<LaunchRequestArguments, AttachRequestArguments>> ELEMENT_TYPE = new TypeToken<Either<LaunchRequestArguments, AttachRequestArguments>>() {
private static final TypeToken<Either<LaunchRequestArguments, AttachRequestArguments>> ELEMENT_TYPE = new TypeToken<>() {
};

@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Predicate<JsonElement> leftChecker = new PropertyChecker("noDebug");
Predicate<JsonElement> rightChecker = leftChecker.negate();
TypeAdapter<Either<LaunchRequestArguments, AttachRequestArguments>> elementTypeAdapter = new EitherTypeAdapter<>(
gson, ELEMENT_TYPE, leftChecker, rightChecker);
final var leftChecker = new PropertyChecker("noDebug");
final var rightChecker = leftChecker.negate();
final var elementTypeAdapter = new EitherTypeAdapter<>(gson, ELEMENT_TYPE, leftChecker, rightChecker);
return (TypeAdapter<T>) elementTypeAdapter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface IDebugProtocolClient {
/**
* Version of Debug Protocol
*/
public static final String SCHEMA_VERSION = "1.60.0";
String SCHEMA_VERSION = "1.60.0";

/**
* This event indicates that the debug adapter is ready to accept configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public interface IDebugProtocolServer {
/**
* Version of Debug Protocol
*/
public static final String SCHEMA_VERSION = "1.60.0";
String SCHEMA_VERSION = "1.60.0";

/**
* The 'cancel' request is used by the client in two situations:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/******************************************************************************
* Copyright (c) 2016-2018 TypeFox and others.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/
package org.eclipse.lsp4j.jsonrpc.debug;
Expand Down Expand Up @@ -38,7 +38,7 @@
* and an output stream.
*/
public final class DebugLauncher {

private DebugLauncher() {}

/**
Expand Down Expand Up @@ -191,22 +191,21 @@ public static <T> Launcher<T> createIoLauncher(Object localService, Class<T> rem
.configureGson(configureGson)
.create();
}

/**
* Launcher builder for the debug protocol. Adapts the JSON-RPC message classes to the JSON format used
* by the debug protocol.
*/
public static class Builder<T> extends Launcher.Builder<T> {

@Override
protected MessageJsonHandler createJsonHandler() {
Map<String, JsonRpcMethod> supportedMethods = getSupportedMethods();
if (configureGson != null)
return new DebugMessageJsonHandler(supportedMethods, configureGson);
else
return new DebugMessageJsonHandler(supportedMethods);
return new DebugMessageJsonHandler(supportedMethods);
}

@Override
protected RemoteEndpoint createRemoteEndpoint(MessageJsonHandler jsonHandler) {
MessageConsumer outgoingMessageStream = new StreamMessageConsumer(output, jsonHandler);
Expand All @@ -221,6 +220,6 @@ protected RemoteEndpoint createRemoteEndpoint(MessageJsonHandler jsonHandler) {
remoteEndpoint.setJsonHandler(jsonHandler);
return remoteEndpoint;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {

}

private final Map<String, T> serializedFormToEnum = new HashMap<String, T>();
private final Map<T, String> enumToSerializedForm = new HashMap<T, String>();
private final Map<String, T> serializedFormToEnum = new HashMap<>();
private final Map<T, String> enumToSerializedForm = new HashMap<>();

public DebugEnumTypeAdapter(Class<T> clazz) {
try {
Expand Down Expand Up @@ -73,7 +73,7 @@ private String getSerializedForm(String name) {
m.appendReplacement(sb, m.group().toUpperCase());
}
m.appendTail(sb);
return sb.toString().replaceAll("_", "");
return sb.toString().replace("_", "");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/******************************************************************************
* Copyright (c) 2017 Kichwa Coders Ltd. and others.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
******************************************************************************/
package org.eclipse.lsp4j.jsonrpc.debug.adapters;
Expand Down Expand Up @@ -261,9 +261,8 @@ public Message read(JsonReader in) throws IOException {
Message resultMessage = createMessage(messageType, seq, request_seq, method, success, message, rawParams, rawBody);
MessageIssue issue = new MessageIssue("Message could not be parsed.", ResponseErrorCode.ParseError.getValue(), exception);
throw new MessageIssueException(resultMessage, issue);
} else {
throw exception;
}
throw exception;
}
}

Expand Down Expand Up @@ -329,7 +328,7 @@ protected Object parseBody(Object rawBody, String messageType, int request_seq,
if (!(rawBody instanceof JsonElement)) {
return rawBody;
}
JsonElement rawJsonParams = (JsonElement) rawBody;
final var rawJsonParams = (JsonElement) rawBody;
return fromJson(rawJsonParams, Object.class);
}
return rawBody;
Expand Down Expand Up @@ -388,7 +387,7 @@ private Message createMessage(String messageType, int seq, int request_seq, Stri
Type returnType = jsonRpcMethod.getReturnType();
if (jsonRpcMethod.getReturnTypeAdapterFactory() != null)
typeAdapter = jsonRpcMethod.getReturnTypeAdapterFactory().create(gson, TypeToken.get(returnType));
JsonElement jsonElement = (JsonElement) body;
final var jsonElement = (JsonElement) body;
if (typeAdapter != null)
body = typeAdapter.fromJsonTree(jsonElement);
else
Expand All @@ -410,7 +409,7 @@ private Message createMessage(String messageType, int seq, int request_seq, Stri
public void write(JsonWriter out, Message message) throws IOException {
out.beginObject();
if (message instanceof DebugRequestMessage) {
DebugRequestMessage requestMessage = (DebugRequestMessage) message;
final var requestMessage = (DebugRequestMessage) message;
out.name("type");
out.value("request");
out.name("seq");
Expand All @@ -419,11 +418,11 @@ public void write(JsonWriter out, Message message) throws IOException {
out.value(requestMessage.getMethod());
Object params = requestMessage.getParams();
if (params != null) {
out.name("arguments");
out.name("arguments");
gson.toJson(params, params.getClass(), out);
}
} else if (message instanceof DebugResponseMessage) {
DebugResponseMessage responseMessage = (DebugResponseMessage) message;
final var responseMessage = (DebugResponseMessage) message;
out.name("type");
out.value("response");
out.name("seq");
Expand Down Expand Up @@ -458,7 +457,7 @@ public void write(JsonWriter out, Message message) throws IOException {
}
}
} else if (message instanceof DebugNotificationMessage) {
DebugNotificationMessage notificationMessage = (DebugNotificationMessage) message;
final var notificationMessage = (DebugNotificationMessage) message;
out.name("type");
out.value("event");
out.name("seq");
Expand Down
Loading
Loading