use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.
the class PositionComparatorTest method withoutNull.
@Test
public void withoutNull() {
Position _position = new Position(2, 2);
Position _position_1 = new Position(2, 1);
Position _position_2 = new Position(1, 2);
Position _position_3 = new Position(1, 1);
final List<? extends Position> input = this.sort(CollectionLiterals.<Position>newArrayList(_position, _position_1, _position_2, _position_3));
Assert.assertEquals(1, input.get(0).getLine());
Assert.assertEquals(1, input.get(0).getCharacter());
Assert.assertEquals(1, input.get(1).getLine());
Assert.assertEquals(2, input.get(1).getCharacter());
Assert.assertEquals(2, input.get(2).getLine());
Assert.assertEquals(1, input.get(2).getCharacter());
Assert.assertEquals(2, input.get(3).getLine());
Assert.assertEquals(2, input.get(3).getCharacter());
}
use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.
the class RangeComparatorTest method newRange.
private Range newRange(final int startLine, final int startChar, final int endLine, final int endChar) {
Position _position = new Position(startLine, startChar);
Position _position_1 = new Position(endLine, endChar);
return new Range(_position, _position_1);
}
use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testSignatureHelp.
protected void testSignatureHelp(final Procedure1<? super SignatureHelpConfiguration> configurator) {
try {
@Extension final SignatureHelpConfiguration configuration = new SignatureHelpConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
};
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
final CompletableFuture<SignatureHelp> signatureHelpFuture = this.languageServer.signatureHelp(_doubleArrow);
final SignatureHelp signatureHelp = signatureHelpFuture.get();
Procedure1<? super SignatureHelp> _assertSignatureHelp = configuration.getAssertSignatureHelp();
boolean _tripleNotEquals = (_assertSignatureHelp != null);
if (_tripleNotEquals) {
configuration.getAssertSignatureHelp().apply(signatureHelp);
} else {
final String actualSignatureHelp = this.toExpectation(signatureHelp);
this.assertEquals(configuration.getExpectedSignatureHelp().trim(), actualSignatureHelp.trim());
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.Position in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testReferences.
protected void testReferences(final Procedure1<? super ReferenceTestConfiguration> configurator) {
try {
@Extension final ReferenceTestConfiguration configuration = new ReferenceTestConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
ReferenceParams _referenceParams = new ReferenceParams();
final Procedure1<ReferenceParams> _function = (ReferenceParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
boolean _isIncludeDeclaration = configuration.isIncludeDeclaration();
ReferenceContext _referenceContext = new ReferenceContext(_isIncludeDeclaration);
it.setContext(_referenceContext);
};
ReferenceParams _doubleArrow = ObjectExtensions.<ReferenceParams>operator_doubleArrow(_referenceParams, _function);
final CompletableFuture<List<? extends Location>> referencesFuture = this.languageServer.references(_doubleArrow);
final List<? extends Location> references = referencesFuture.get();
Procedure1<? super List<? extends Location>> _assertReferences = configuration.getAssertReferences();
boolean _tripleNotEquals = (_assertReferences != null);
if (_tripleNotEquals) {
configuration.getAssertReferences().apply(references);
} else {
final String actualReferences = this.toExpectation(references);
this.assertEquals(configuration.getExpectedReferences(), actualReferences);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.Position in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method definitionToSymbol.
private SymbolInformation definitionToSymbol(IDefinition definition) {
SymbolInformation symbol = new SymbolInformation();
if (definition instanceof IClassDefinition) {
symbol.setKind(SymbolKind.Class);
} else if (definition instanceof IInterfaceDefinition) {
symbol.setKind(SymbolKind.Interface);
} else if (definition instanceof IFunctionDefinition) {
IFunctionDefinition functionDefinition = (IFunctionDefinition) definition;
if (functionDefinition.isConstructor()) {
symbol.setKind(SymbolKind.Constructor);
} else {
symbol.setKind(SymbolKind.Function);
}
} else if (definition instanceof IFunctionDefinition) {
symbol.setKind(SymbolKind.Function);
} else if (definition instanceof IConstantDefinition) {
symbol.setKind(SymbolKind.Constant);
} else {
symbol.setKind(SymbolKind.Variable);
}
symbol.setName(definition.getQualifiedName());
Location location = new Location();
String sourcePath = definition.getSourcePath();
if (sourcePath == null) {
//I'm not sure why getSourcePath() can sometimes return null, but
//getContainingFilePath() seems to work as a fallback -JT
sourcePath = definition.getContainingFilePath();
}
Path definitionPath = Paths.get(sourcePath);
location.setUri(definitionPath.toUri().toString());
Position start = new Position();
Position end = new Position();
//getLine() and getColumn() may include things like metadata, so it
//makes more sense to jump to where the definition name starts
int line = definition.getNameLine();
int column = definition.getNameColumn();
if (line < 0 || column < 0) {
//this is not ideal, but MXML variable definitions may not have a
//node associated with them, so we need to figure this out from the
//offset instead of a pre-calculated line and column -JT
String code = sourceByPath.get(Paths.get(sourcePath));
offsetToLineAndCharacter(new StringReader(code), definition.getNameStart(), start);
end.setLine(start.getLine());
end.setCharacter(start.getCharacter());
} else {
start.setLine(line);
start.setCharacter(column);
end.setLine(line);
end.setCharacter(column);
}
Range range = new Range();
range.setStart(start);
range.setEnd(end);
location.setRange(range);
symbol.setLocation(location);
return symbol;
}
Aggregations