eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
documentSymbol Requests for files using lombok return symbols with wrong line locations
I started the working with JST LS for this project https://github.com/piiano/vault-code-samples-java-spring, and specifically doing documentSymbol requests on some files return wrong line positions. For example , for the file demo-app-using-vault-orm/src/main/java/com/demo/app/dal/User.java, I am getting wrong offsets . This is the file,
package com.demo.app.dal;
import com.piiano.orm.Tokenized;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import javax.persistence.*;
import static com.piiano.orm.Tokenized.COLLECTION;
import static com.piiano.orm.Tokenized.PROPERTY;
@Table(name = "users")
@Entity
@TypeDef(name = "Tokenized", typeClass = Tokenized.class)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class User {
public static final String USERS = "users";
public static final String NAME = "name";
public static final String PHONE_NUMBER = "phone_number";
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
@Column(name = "name")
@Type(type = "Tokenized", parameters = {@Parameter(name = COLLECTION, value = USERS), @Parameter(name = PROPERTY, value = NAME)})
private String name;
@Column(name = "phone_number")
@Type(type = "Tokenized", parameters = {@Parameter(name = COLLECTION, value = USERS), @Parameter(name = PROPERTY, value = PHONE_NUMBER)})
private String phoneNumber;
@Column(name = "country")
private String country;
}
and the returned symbols are these:
[{
'name': 'com.demo.app.dal',
'kind': 4,
'range': {
'start': {
'line': 0,
'character': 0
},
'end': {
'line': 0,
'character': 25
}
},
'selectionRange': {
'start': {
'line': 0,
'character': 0
},
'end': {
'line': 0,
'character': 25
}
},
'detail': ''
}, {
'name': 'User',
'kind': 5,
'range': {
'start': {
'line': 9,
'character': 0
},
'end': {
'line': 29,
'character': 1
}
},
'selectionRange': {
'start': {
'line': 15,
'character': 13
},
'end': {
'line': 15,
'character': 17
}
},
'detail': '',
'children': [{
'name': 'UserBuilder',
'kind': 5,
'range': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'selectionRange': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'detail': '',
'children': [{
'name': 'id',
'kind': 8,
'range': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'selectionRange': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'detail': '',
'children': []
}, {
'name': 'name',
'kind': 8,
'range': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'selectionRange': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'detail': '',
'children': []
}, {
'name': 'phoneNumber',
'kind': 8,
'range': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'selectionRange': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'detail': '',
'children': []
}, {
'name': 'country',
'kind': 8,
'range': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'selectionRange': {
'start': {
'line': 14,
'character': 0
},
'end': {
'line': 14,
'character': 8
}
},
'detail': '',
'children': []
}]
}, {
'name': 'id',
'kind': 8,
'range': {
'start': {
'line': 17,
'character': 4
},
'end': {
'line': 19,
'character': 23
}
},
'selectionRange': {
'start': {
'line': 19,
'character': 20
},
'end': {
'line': 19,
'character': 22
}
},
'detail': '',
'children': []
}, {
'name': 'name',
'kind': 8,
'range': {
'start': {
'line': 21,
'character': 4
},
'end': {
'line': 22,
'character': 24
}
},
'selectionRange': {
'start': {
'line': 22,
'character': 19
},
'end': {
'line': 22,
'character': 23
}
},
'detail': '',
'children': []
}, {
'name': 'phoneNumber',
'kind': 8,
'range': {
'start': {
'line': 24,
'character': 4
},
'end': {
'line': 25,
'character': 31
}
},
'selectionRange': {
'start': {
'line': 25,
'character': 19
},
'end': {
'line': 25,
'character': 30
}
},
'detail': '',
'children': []
}, {
'name': 'country',
'kind': 8,
'range': {
'start': {
'line': 27,
'character': 4
},
'end': {
'line': 28,
'character': 27
}
},
'selectionRange': {
'start': {
'line': 28,
'character': 19
},
'end': {
'line': 28,
'character': 26
}
},
'detail': '',
'children': []
}]
}]
As you can notice the lines are completely wrong , for example id is defined in line 33 of the file, but the symbol appears in line 14 in the response ( {'name': 'id', 'kind': 8, 'range': {'start': {'line': 14, 'character': 0}, 'end': {'line': 14, 'character': 8}}, 'selectionRange': {'start': {'line': 14, 'character': 0}, 'end': {'line': 14, 'character': 8}}, 'detail': '', 'children': []}, {'name': 'name', 'kind': 8, 'range': {'start': {'line': 14, 'character': 0}, 'end': {'line': 14, 'character': 8}}, 'selectionRange': {'start': {'line': 14, 'character': 0}, 'end': {'line': 14, 'character': 8}}, 'detail': '', 'children': []} )
Is there some workaround I can apply to get the correct lines?
@yuval-piiano I can't reproduce the issue using VS Code pre release, lombok edge
I get the following:
{
"name": "id",
"kind": 8,
"range": {
"start": {
"line": 33,
"character": 4
},
"end": {
"line": 35,
"character": 23
}
},
"selectionRange": {
"start": {
"line": 35,
"character": 20
},
"end": {
"line": 35,
"character": 22
}
},
"detail": "",
"children": []
},
Which version of VS Code/lombok you are using?
lombok version 1.18.26, I don't use vscode, I start the jdt using this command 'java', '-Xmx8G', '-noverify', '-Declipse.application=org.eclipse.jdt.ls.core.id1', '-Dosgi.bundles.defaultStartLevel=4', '-Declipse.product=org.eclipse.jdt.ls.core.product', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044', '-Dlog.protocol=true', '-Dlog.level=ALL', '-javaagent:/path/to/lombok.jar', '-jar', 'plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar', '-configuration', './config_mac', '-data', '/path/to/code/', '--add-modules=ALL-SYSTEM', '--add-opens java.base/java.util=ALL-UNNAMED', '--add-opens java.base/java.lang=ALL-UNNAMED' and init it using rpc messages
I think I understood when it happens - If I am opening another file with same name , eg. demo-app/src/main/java/com/demo/app/dal/User.java (called didOpen with this one), and then doing a symbolRequest on my original file (demo-app-using-vault-orm/src/main/java/com/demo/app/dal/User.java) I am getting the results for the recently opened file, instead of the one I am requesting. I guess it is related to them having the same package and name, which is somewhat unusual....
The TextDocumentIdentifier must be specified in the document symbol request. It should identify two files with the same name because the uris are different.