Skip to content

Commit

Permalink
[#528] remove some runtime dependencies to xbase.lib
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
  • Loading branch information
cdietrich committed Mar 27, 2021
1 parent 3d34ab3 commit 2f1f0af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {

Expand All @@ -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
}

Expand Down Expand Up @@ -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»);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3629,7 +3629,7 @@ class FormattingOptions extends LinkedHashMap<String, Either3<String, Number, Bo
*/
@Deprecated
def Map<String, String> getProperties() {
val properties = newLinkedHashMap
val properties = new LinkedHashMap<String,String>
for (entry : entrySet) {
val value = switch it: entry.value {
case isFirst: getFirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -37,15 +38,17 @@ class HoverTypeAdapter {
protected def readContents(JsonReader in) throws IOException {
val nextToken = in.peek()
if (nextToken == JsonToken.STRING) {
val List<Either<String, MarkedString>> value = newArrayList(Either.forLeft(in.nextString))
val List<Either<String, MarkedString>> value = new ArrayList<Either<String, MarkedString>>()
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)
return Either.forLeft(value)
} else {
val object = JsonParser.parseReader(in) as JsonObject
if (object.has("language")) {
val List<Either<String, MarkedString>> value = newArrayList(Either.forRight(gson.fromJson(object, MarkedString)))
val List<Either<String, MarkedString>> value = new ArrayList<Either<String, MarkedString>>()
value.add(Either.forRight(gson.fromJson(object, MarkedString)))
return Either.forLeft(value)
} else {
return Either.forRight(gson.fromJson(object, MarkupContent))
Expand Down

0 comments on commit 2f1f0af

Please sign in to comment.