diff --git a/org.eclipse.lsp4j.generator/src/main/java/org/eclipse/lsp4j/generator/JsonRpcDataProcessor.xtend b/org.eclipse.lsp4j.generator/src/main/java/org/eclipse/lsp4j/generator/JsonRpcDataProcessor.xtend index ce296a79..f7e4bb71 100644 --- a/org.eclipse.lsp4j.generator/src/main/java/org/eclipse/lsp4j/generator/JsonRpcDataProcessor.xtend +++ b/org.eclipse.lsp4j.generator/src/main/java/org/eclipse/lsp4j/generator/JsonRpcDataProcessor.xtend @@ -11,6 +11,8 @@ ******************************************************************************/ package org.eclipse.lsp4j.generator +import com.google.common.base.MoreObjects +import com.google.gson.annotations.JsonAdapter import org.eclipse.lsp4j.jsonrpc.validation.NonNull import org.eclipse.xtend.lib.annotations.AccessorsProcessor import org.eclipse.xtend.lib.annotations.EqualsHashCodeProcessor @@ -22,8 +24,6 @@ import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration import org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration import org.eclipse.xtend.lib.macro.declaration.Type import org.eclipse.xtend.lib.macro.declaration.Visibility -import org.eclipse.xtext.xbase.lib.util.ToStringBuilder -import com.google.gson.annotations.JsonAdapter class JsonRpcDataProcessor extends AbstractClassProcessor { @@ -44,7 +44,12 @@ class JsonRpcDataProcessor extends AbstractClassProcessor { val fields = impl.declaredFields.filter[!static] equalsHashCodeUtil.addEquals(impl, fields, shouldIncludeSuper) equalsHashCodeUtil.addHashCode(impl, fields, shouldIncludeSuper) - + impl.getDeclaredMethods.forEach [ method | + val purified = method.findAnnotation(Pure.findTypeGlobally) + if (purified !== null) { + method.removeAnnotation(purified) + } + ] return impl } @@ -154,10 +159,9 @@ class JsonRpcDataProcessor extends AbstractClassProcessor { impl.addMethod("toString") [ returnType = string addAnnotation(newAnnotationReference(Override)) - addAnnotation(newAnnotationReference(Pure)) val accessorsUtil = new AccessorsProcessor.Util(context) body = ''' - «ToStringBuilder» b = new «ToStringBuilder»(this); + «MoreObjects.ToStringHelper» b = «MoreObjects».toStringHelper(this); «FOR field : toStringFields» b.add("«field.simpleName»", «IF field.declaringType == impl»this.«field.simpleName»«ELSE»« accessorsUtil.getGetterName(field)»()«ENDIF»); diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend index 5da70ae6..91db76ff 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend @@ -3636,7 +3636,7 @@ class FormattingOptions extends LinkedHashMap getProperties() { - val properties = newLinkedHashMap + val properties = new LinkedHashMap for (entry : entrySet) { val value = switch it: entry.value { case isFirst: getFirst diff --git a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/HoverTypeAdapter.xtend b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/HoverTypeAdapter.xtend index 94ddde3b..00d91ebc 100644 --- a/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/HoverTypeAdapter.xtend +++ b/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/HoverTypeAdapter.xtend @@ -24,6 +24,7 @@ import org.eclipse.lsp4j.MarkedString import org.eclipse.lsp4j.MarkupContent import org.eclipse.lsp4j.generator.TypeAdapterImpl import org.eclipse.lsp4j.jsonrpc.messages.Either +import java.util.ArrayList /** * A type adapter for the Hover protocol type. @@ -37,7 +38,8 @@ class HoverTypeAdapter { protected def readContents(JsonReader in) throws IOException { val nextToken = in.peek() if (nextToken == JsonToken.STRING) { - val List> value = newArrayList(Either.forLeft(in.nextString)) + val List> value = new ArrayList>() + value.add(Either.forLeft(in.nextString)) return Either.forLeft(value) } else if (nextToken == JsonToken.BEGIN_ARRAY) { val value = gson.fromJson(in, LIST_STRING_MARKEDSTRING.type) @@ -45,7 +47,8 @@ class HoverTypeAdapter { } else { val object = JsonParser.parseReader(in) as JsonObject if (object.has("language")) { - val List> value = newArrayList(Either.forRight(gson.fromJson(object, MarkedString))) + val List> value = new ArrayList>() + value.add(Either.forRight(gson.fromJson(object, MarkedString))) return Either.forLeft(value) } else { return Either.forRight(gson.fromJson(object, MarkupContent))