org.eclipse.lsp4j.PrepareRenameParams Java Examples

The following examples show how to use org.eclipse.lsp4j.PrepareRenameParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPrepareRenameFqn_missing_file_null() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("missing.");
    _builder.append(this.fileExtension);
    final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
    this.initializeWithPrepareSupport();
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 5);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    Assert.assertNull(this.languageServer.prepareRename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #2
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPrepareRenameFqn_missing_file_exception() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("missing.");
  _builder.append(this.fileExtension);
  final String uri = this._uriExtensions.toUriString(new File(_builder.toString()).toURI().normalize());
  this.initialize();
  TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
  Position _position = new Position(2, 5);
  final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
  try {
    Assert.assertNull(this.languageServer.prepareRename(params).get());
    Assert.fail("Expected an error.");
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception e = (Exception)_t;
      Throwable _rootCause = Throwables.getRootCause(e);
      Assert.assertTrue((_rootCause instanceof FileNotFoundException));
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example #3
Source File: RenameTest3.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRenameAutoQuoteRef() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("type Bar extends Foo {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.renametl", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(3, 18);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "type");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("^type [[3, 17] .. [3, 20]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #4
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Prepare the rename operation. Executed in a read request.
 * @since 2.20
 */
protected Either<Range, PrepareRenameResult> prepareRename(PrepareRenameParams params,
		CancelIndicator cancelIndicator) {
	URI uri = getURI(params);
	IRenameService2 renameService = getService(uri, IRenameService2.class);
	if (renameService == null) {
		throw new UnsupportedOperationException();
	}
	IRenameService2.PrepareRenameOptions options = new IRenameService2.PrepareRenameOptions();
	options.setLanguageServerAccess(access);
	options.setParams(params);
	options.setCancelIndicator(cancelIndicator);
	return renameService.prepareRename(options);
}
 
Example #5
Source File: RenameTest2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRenameSelfRef() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.newLine();
    _builder.append("element Foo {");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("ref Foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(2, 9);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "Bar");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.fileawaretestlanguage <1> : Bar [[2, 8] .. [2, 11]]");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Bar [[3, 5] .. [3, 8]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #6
Source File: RenamePositionTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected void renameAndFail(final String model, final Position position, final String messageFragment) {
  final String modelFile = this.writeFile("MyType.testlang", model);
  this.initialize();
  try {
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(modelFile);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Either<Range, PrepareRenameResult> prepareRenameResult = this.languageServer.prepareRename(_prepareRenameParams).get();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("expected null result got ");
    _builder.append(prepareRenameResult);
    _builder.append(" instead");
    Assert.assertNull(_builder.toString(), prepareRenameResult);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(modelFile);
    final RenameParams renameParams = new RenameParams(_textDocumentIdentifier, position, "Tescht");
    this.languageServer.rename(renameParams).get();
    Assert.fail("Rename should have failed");
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception exc = (Exception)_t;
      final Throwable rootCause = Throwables.getRootCause(exc);
      Assert.assertTrue((rootCause instanceof ResponseErrorException));
      final ResponseError error = ((ResponseErrorException) rootCause).getResponseError();
      Assert.assertTrue(error.getData().toString().contains(messageFragment));
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example #7
Source File: RenameTest3.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRenameQuotedRef() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type ^type {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("type Bar extends ^type {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.renametl", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(3, 19);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "Foo");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo [[3, 17] .. [3, 22]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #8
Source File: JDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(PrepareRenameParams params) {
	logInfo(">> document/prepareRename");
	PrepareRenameHandler handler = new PrepareRenameHandler();
	return computeAsync((monitor) -> {
		waitForLifecycleJobs(monitor);
		return handler.prepareRename(params, monitor);
	});
}
 
Example #9
Source File: RenameTest3.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRenameQuoted() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type ^type {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.renametl", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(0, 6);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("^type", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "Foo");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.renametl <1> : Foo [[0, 5] .. [0, 10]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #10
Source File: RenameTest3.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRenameAutoQuote() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("type Foo {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.renametl", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(0, 6);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "type");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.renametl <1> : ^type [[0, 5] .. [0, 8]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #11
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPrepareRenameFqn_end_null() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo.bar {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type A {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("foo.bar.MyType bar");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type MyType { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    this.initialize();
    final String uri = this.writeFile("my-type-valid.testlang", model);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 18);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    Assert.assertNull(this.languageServer.prepareRename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #12
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPrepareRenameFqn_end_ok() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo.bar {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type A {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("foo.bar.MyType bar");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type MyType { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    this.initializeWithPrepareSupport();
    final String uri = this.writeFile("my-type-valid.testlang", model);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 18);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    final Range range = this.languageServer.prepareRename(params).get().getLeft();
    this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #13
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPrepareRenameFqn_in_ok() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo.bar {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type A {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("foo.bar.MyType bar");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type MyType { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    this.initializeWithPrepareSupport();
    final String uri = this.writeFile("my-type-valid.testlang", model);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 14);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    final Range range = this.languageServer.prepareRename(params).get().getLeft();
    this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #14
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPrepareRenameFqn_start_ok() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo.bar {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type A {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("foo.bar.MyType bar");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type MyType { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    this.initializeWithPrepareSupport();
    final String uri = this.writeFile("my-type-valid.testlang", model);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 12);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    final Range range = this.languageServer.prepareRename(params).get().getLeft();
    this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #15
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPrepareRenameFqn_before_nok() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo.bar {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type A {");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("foo.bar.MyType bar");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("  ");
    _builder.append("type MyType { }");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    this.initializeWithPrepareSupport();
    final String uri = this.writeFile("my-type-valid.testlang", model);
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 11);
    final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
    Assert.assertNull(this.languageServer.prepareRename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #16
Source File: RenameTest2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testRenameContainer() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.newLine();
    _builder.append("element Foo {");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("element Bar {");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("}");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("ref foo.Foo.Bar");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("ref Foo.Bar");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("ref Bar");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String model = _builder.toString();
    final String file = this.writeFile("foo/Foo.fileawaretestlanguage", model);
    this.initialize();
    final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
    final Position position = new Position(2, 9);
    PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
    final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
    this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
    final RenameParams params = new RenameParams(identifier, position, "Baz");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Foo.fileawaretestlanguage <1> : Baz [[2, 8] .. [2, 11]]");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Bar [[5, 5] .. [5, 16]]");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("Bar [[6, 5] .. [6, 12]]");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #17
Source File: IRenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public PrepareRenameParams getParams() {
	return params;
}
 
Example #18
Source File: IRenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setParams(PrepareRenameParams params) {
	this.params = params;
}
 
Example #19
Source File: RenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected Either<Range, PrepareRenameResult> doPrepareRename(Resource resource, Document document,
		PrepareRenameParams params, CancelIndicator cancelIndicator) {
	String uri = params.getTextDocument().getUri();
	if (resource instanceof XtextResource) {
		ICompositeNode rootNode = null;
		XtextResource xtextResource = (XtextResource) resource;
		if (xtextResource != null) {
			IParseResult parseResult = xtextResource.getParseResult();
			if (parseResult != null) {
				rootNode = parseResult.getRootNode();
			}
		}
		if (rootNode == null) {
			RenameService2.LOG.trace("Could not retrieve root node for resource. URI: " + uri);
			return null;
		}
		Position caretPosition = params.getPosition();
		try {
			int caretOffset = document.getOffSet(caretPosition);
			EObject element = null;
			int candidateOffset = caretOffset;
			do {
				element = getElementWithIdentifierAt(xtextResource, candidateOffset);
				if (element != null && !element.eIsProxy()) {
					ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(rootNode, candidateOffset);
					if (leaf != null && isIdentifier(leaf)) {
						String convertedNameValue = getConvertedValue(leaf.getGrammarElement(), leaf);
						String elementName = getElementName(element);
						if (!Strings.isEmpty(convertedNameValue) && !Strings.isEmpty(elementName)
								&& Objects.equal(convertedNameValue, elementName)) {
							Position start = document.getPosition(leaf.getOffset());
							Position end = document.getPosition(leaf.getEndOffset());
							return Either.forLeft(new Range(start, end));
						}
					}
				}
				candidateOffset = (candidateOffset - 1);
			} while (((candidateOffset >= 0) && ((candidateOffset + 1) >= caretOffset)));
		} catch (IndexOutOfBoundsException e) {
			RenameService2.LOG.trace("Invalid document " + toPositionFragment(caretPosition, uri));
			return null;
		}
		RenameService2.LOG.trace("No element found at " + toPositionFragment(caretPosition, uri));
	} else {
		RenameService2.LOG.trace("Loaded resource is not an XtextResource. URI: " + resource.getURI());
	}
	return null;
}
 
Example #20
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.18
 */
@Override
public CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(PrepareRenameParams params) {
	return requestManager.runRead(cancelIndicator -> prepareRename(params, cancelIndicator));
}
 
Example #21
Source File: TextDocumentService.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The prepare rename request is sent from the client to the server to setup and test the validity of a rename
 * operation at a given location.
 * 
 * Since version 3.12.0
 */
@JsonRequest
@ResponseJsonAdapter(PrepareRenameResponseAdapter.class)
default CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(PrepareRenameParams params) {
	throw new UnsupportedOperationException();
}