Skip to content

Commit 966165b

Browse files
committed
[#528] remove some runtime dependencies to xbase.lib
Signed-off-by: Christian Dietrich <[email protected]>
1 parent 3397180 commit 966165b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

org.eclipse.lsp4j.generator/src/main/java/org/eclipse/lsp4j/generator/JsonRpcDataProcessor.xtend

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
******************************************************************************/
1212
package org.eclipse.lsp4j.generator
1313

14+
import com.google.common.base.MoreObjects
15+
import com.google.gson.annotations.JsonAdapter
1416
import org.eclipse.lsp4j.jsonrpc.validation.NonNull
1517
import org.eclipse.xtend.lib.annotations.AccessorsProcessor
1618
import org.eclipse.xtend.lib.annotations.EqualsHashCodeProcessor
@@ -22,8 +24,6 @@ import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration
2224
import org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration
2325
import org.eclipse.xtend.lib.macro.declaration.Type
2426
import org.eclipse.xtend.lib.macro.declaration.Visibility
25-
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder
26-
import com.google.gson.annotations.JsonAdapter
2727

2828
class JsonRpcDataProcessor extends AbstractClassProcessor {
2929

@@ -44,7 +44,12 @@ class JsonRpcDataProcessor extends AbstractClassProcessor {
4444
val fields = impl.declaredFields.filter[!static]
4545
equalsHashCodeUtil.addEquals(impl, fields, shouldIncludeSuper)
4646
equalsHashCodeUtil.addHashCode(impl, fields, shouldIncludeSuper)
47-
47+
impl.getDeclaredMethods.forEach [ method |
48+
val purified = method.findAnnotation(Pure.findTypeGlobally)
49+
if (purified !== null) {
50+
method.removeAnnotation(purified)
51+
}
52+
]
4853
return impl
4954
}
5055

@@ -154,10 +159,9 @@ class JsonRpcDataProcessor extends AbstractClassProcessor {
154159
impl.addMethod("toString") [
155160
returnType = string
156161
addAnnotation(newAnnotationReference(Override))
157-
addAnnotation(newAnnotationReference(Pure))
158162
val accessorsUtil = new AccessorsProcessor.Util(context)
159163
body = '''
160-
«ToStringBuilder» b = new «ToStringBuilder»(this);
164+
«MoreObjects.ToStringHelper» b = «MoreObjects».toStringHelper(this);
161165
«FOR field : toStringFields»
162166
b.add("«field.simpleName»", «IF field.declaringType == impl»this.«field.simpleName»«ELSE»«
163167
accessorsUtil.getGetterName(field)»()«ENDIF»);

org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend

+1-1
Original file line numberDiff line numberDiff line change
@@ -4406,7 +4406,7 @@ class FormattingOptions extends LinkedHashMap<String, Either3<String, Number, Bo
44064406
*/
44074407
@Deprecated
44084408
def Map<String, String> getProperties() {
4409-
val properties = newLinkedHashMap
4409+
val properties = new LinkedHashMap<String,String>
44104410
for (entry : entrySet) {
44114411
val value = switch it: entry.value {
44124412
case isFirst: getFirst

org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/HoverTypeAdapter.xtend

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.eclipse.lsp4j.MarkedString
2424
import org.eclipse.lsp4j.MarkupContent
2525
import org.eclipse.lsp4j.generator.TypeAdapterImpl
2626
import org.eclipse.lsp4j.jsonrpc.messages.Either
27+
import java.util.ArrayList
2728

2829
/**
2930
* A type adapter for the Hover protocol type.
@@ -37,15 +38,17 @@ class HoverTypeAdapter {
3738
protected def readContents(JsonReader in) throws IOException {
3839
val nextToken = in.peek()
3940
if (nextToken == JsonToken.STRING) {
40-
val List<Either<String, MarkedString>> value = newArrayList(Either.forLeft(in.nextString))
41+
val List<Either<String, MarkedString>> value = new ArrayList<Either<String, MarkedString>>()
42+
value.add(Either.forLeft(in.nextString))
4143
return Either.forLeft(value)
4244
} else if (nextToken == JsonToken.BEGIN_ARRAY) {
4345
val value = gson.fromJson(in, LIST_STRING_MARKEDSTRING.type)
4446
return Either.forLeft(value)
4547
} else {
4648
val object = JsonParser.parseReader(in) as JsonObject
4749
if (object.has("language")) {
48-
val List<Either<String, MarkedString>> value = newArrayList(Either.forRight(gson.fromJson(object, MarkedString)))
50+
val List<Either<String, MarkedString>> value = new ArrayList<Either<String, MarkedString>>()
51+
value.add(Either.forRight(gson.fromJson(object, MarkedString)))
4952
return Either.forLeft(value)
5053
} else {
5154
return Either.forRight(gson.fromJson(object, MarkupContent))

0 commit comments

Comments
 (0)