Help with labeling features [message #1832422] |
Thu, 17 September 2020 15:17 |
Jonathan Eugenio Messages: 11 Registered: March 2020 |
Junior Member |
|
|
Hello everyone,
A colleague and I are working on developing a DSL with Xtext, and one of the things we are trying to modify is the labeling capabilities of our language server. We are using our language server in a separate text editor through the LSP, and when we are editing a file, we have access to an outline view that displays the names for each element in the parse tree. The problem is that each of these element's name is effectively a single integer, so the outline view is populated entirely by numbers.
We want to make this outline view more verbose by adding strings of text to provide more information to the user. Rather than just display "1", we would like to display "surface 1". We have tried to do this by creating customized versions of the SimpleNameLabelProvider and DocumentSymbolMapper java files and placing them in the IDE source folder. However, after making some changes and binding our custom files to the IDE Module file, we have noticed that there weren't any changes.
Are we going about this in the right manner? We have also noticed that there was an absence of the NameLabelProvider and DocumentSymbolMapper files in the file explorer before we added the custom files. Is it possible that we may need to generate these default files before they are customized and overwritten in the IDE folder?
Edit: These are the files I am referring to, straight from the Xtext github.
* Document Symbol Mapper file: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/symbol/DocumentSymbolMapper.java
* Simple Name Label provider: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/labels/SimpleNameLabelProvider.java
* Hierarchical Document Symbol Service, which I believe gets the symbols from the Document Symbol mapper file: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/symbol/HierarchicalDocumentSymbolService.java
Thanks in advanced.
[Updated on: Thu, 17 September 2020 15:20] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Help with labeling features [message #1832715 is a reply to message #1832713] |
Wed, 23 September 2020 19:39 |
|
ahhhhhhhh. INameLabalProvider / SimpleNameLabelProvider is not used in LSP but in web only
what is used is
DocumentSymbolMapper.DocumentSymbolNameProvider (as stated in my initial answer)
the names are too similar though
=>
public class CustomDocumentSymbolNameProvider extends DocumentSymbolMapper.DocumentSymbolNameProvider {
@Override
public String getName(EObject object) {
String r = super.getName(object);
return r == null ? null : r + "Lala";
}
}
public class MyDslIdeModule extends AbstractMyDslIdeModule {
public Class<? extends DocumentSymbolMapper.DocumentSymbolNameProvider> bindDocumentSymbolMapper$DocumentSymbolNameProvider() {
return CustomDocumentSymbolNameProvider.class;
}
}
package org.xtext.example.mydsl.tests
import org.eclipse.lsp4j.ClientCapabilities
import org.eclipse.lsp4j.DocumentSymbolCapabilities
import org.eclipse.lsp4j.InitializeParams
import org.eclipse.lsp4j.TextDocumentClientCapabilities
import org.eclipse.xtext.testing.AbstractLanguageServerTest
import org.junit.jupiter.api.Test
class DocumentSymbolTest extends AbstractLanguageServerTest {
new() {
super("mydsl")
}
static val (InitializeParams)=>void INITIALIZER = [
capabilities = new ClientCapabilities() => [
textDocument = new TextDocumentClientCapabilities() => [
documentSymbol = new DocumentSymbolCapabilities() => [
it.hierarchicalDocumentSymbolSupport = true;
];
];
];
];
@Test
def void testDocumentSymbol_01() {
testDocumentSymbol[
initializer = INITIALIZER
model = '''
Hello A!
Hello B!
'''
expectedSymbols = '''
symbol "ALala" {
kind: 7
range: [[0, 0] .. [0, 8]]
selectionRange: [[0, 6] .. [0, 7]]
details:
deprecated: false
}
symbol "BLala" {
kind: 7
range: [[1, 0] .. [1, 8]]
selectionRange: [[1, 6] .. [1, 7]]
details:
deprecated: false
}
'''
]
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Wed, 23 September 2020 19:57] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04577 seconds