org.eclipse.lsp4j.RenameParams Java Examples

The following examples show how to use org.eclipse.lsp4j.RenameParams. 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: RenameTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void doTest(final String fileName, final Position position) {
  try {
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileName);
    final RenameParams params = new RenameParams(_textDocumentIdentifier, position, "Tescht");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("changes :");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("MyType1.testlang : Tescht [[0, 5] .. [0, 9]]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Tescht [[1, 4] .. [1, 8]]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("MyType2.testlang : Tescht [[1, 4] .. [1, 8]]");
    _builder.newLine();
    _builder.append("documentChanges : ");
    _builder.newLine();
    this.assertEquals(_builder.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #2
Source File: XLanguageServerImpl.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Compute the rename edits. Executed in a read request.
 */
protected WorkspaceEdit rename(OpenFileContext ofc, RenameParams renameParams, CancelIndicator cancelIndicator) {
	URI uri = ofc.getURI();

	IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(uri);
	XIRenameService renameServiceOld = getService(resourceServiceProvider, XIRenameService.class);
	if (renameServiceOld != null) {
		// The deprecated version 1 of IRenameService is no longer supported, because it requires an
		// XWorkspaceManager which we do no longer allow to access outside the builder:
		throw new UnsupportedOperationException(XIRenameService.class.getSimpleName() + " is no longer supported");
	}
	IRenameService2 renameService2 = getService(resourceServiceProvider, IRenameService2.class);
	if ((renameService2 != null)) {
		IRenameService2.Options options = new IRenameService2.Options();
		options.setLanguageServerAccess(access);
		options.setRenameParams(renameParams);
		options.setCancelIndicator(cancelIndicator);
		return renameService2.rename(options);
	}
	return new WorkspaceEdit();
}
 
Example #3
Source File: EditorEventManager.java    From lsp4intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Rename a symbol in the document
 *
 * @param renameTo The new name
 */
public void rename(String renameTo, int offset) {
    pool(() -> {
        if (editor.isDisposed()) {
            return;
        }
        Position servPos = DocumentUtils.offsetToLSPPos(editor, offset);
        RenameParams params = new RenameParams(identifier, servPos, renameTo);
        CompletableFuture<WorkspaceEdit> request = requestManager.rename(params);
        if (request != null) {
            request.thenAccept(res -> {
                WorkspaceEditHandler
                        .applyEdit(res, "Rename to " + renameTo, new ArrayList<>(LSPRenameProcessor.getEditors()));
                LSPRenameProcessor.clearEditors();
            });
        }
    });
}
 
Example #4
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testRenameFqn_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 RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
    Assert.assertNull(this.languageServer.rename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #5
Source File: ActionScriptServices.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
/**
 * Renames a symbol at the specified document position.
 */
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params)
{
    return CompletableFutures.computeAsync(compilerWorkspace.getExecutorService(), cancelToken ->
    {
        cancelToken.checkCanceled();

        //make sure that the latest changes have been passed to
        //workspace.fileChanged() before proceeding
        if(realTimeProblemsChecker != null)
        {
            realTimeProblemsChecker.updateNow();
        }

        compilerWorkspace.startBuilding();
        try
        {
            RenameProvider provider = new RenameProvider(workspaceFolderManager, fileTracker);
            WorkspaceEdit result = provider.rename(params, cancelToken);
            if(result == null)
            {
                if (languageClient != null)
                {
                    MessageParams message = new MessageParams();
                    message.setType(MessageType.Info);
                    message.setMessage("You cannot rename this element.");
                    languageClient.showMessage(message);
                }
                return new WorkspaceEdit(new HashMap<>());
            }
            return result;
        }
        finally
        {
            compilerWorkspace.doneBuilding();
        }
    });
}
 
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: 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 #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 testRenameFqn_invalid_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 uri = this.writeFile("my-type-invalid.testlang", _builder);
    this.initializeWithPrepareSupport();
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 5);
    final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
    Assert.assertNull(this.languageServer.rename(params).get());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #12
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 #13
Source File: JDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
	logInfo(">> document/rename");
	RenameHandler handler = new RenameHandler(preferenceManager);
	return computeAsync((monitor) -> {
		waitForLifecycleJobs(monitor);
		return handler.rename(params, monitor);
	});
}
 
Example #14
Source File: XLanguageServerImpl.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams renameParams) {
	URI uri = getURI(renameParams.getTextDocument());
	return openFilesManager.runInOpenFileContext(uri, "rename", (ofc, ci) -> {
		return rename(ofc, renameParams, ci);
	});
}
 
Example #15
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Compute the rename edits. Executed in a read request.
 * @since 2.20
 */
protected WorkspaceEdit rename(RenameParams renameParams, CancelIndicator cancelIndicator) {
	URI uri = getURI(renameParams.getTextDocument());

	IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(uri);
	IRenameService2 renameService2 = getService(resourceServiceProvider, IRenameService2.class);
	if (renameService2 != null) {
		IRenameService2.Options options = new IRenameService2.Options();
		options.setLanguageServerAccess(access);
		options.setRenameParams(renameParams);
		options.setCancelIndicator(cancelIndicator);
		return renameService2.rename(options);
	}
	return new WorkspaceEdit();
}
 
Example #16
Source File: GroovyServices.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
	URI uri = URI.create(params.getTextDocument().getUri());
	recompileIfContextChanged(uri);

	RenameProvider provider = new RenameProvider(astVisitor, fileContentsTracker);
	return provider.provideRename(params);
}
 
Example #17
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testRenameFqn_before_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 uri = this.writeFile("my-type-valid.testlang", _builder);
    this.initializeWithPrepareSupport();
    TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
    Position _position = new Position(2, 13);
    final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "YourType");
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("changes :");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("my-type-valid.testlang : foo.bar.YourType [[2, 4] .. [2, 18]]");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("YourType [[4, 7] .. [4, 13]]");
    _builder_1.newLine();
    _builder_1.append("documentChanges : ");
    _builder_1.newLine();
    this.assertEquals(_builder_1.toString(), this.toExpectation(workspaceEdit));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #18
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 #19
Source File: IRenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public RenameParams getRenameParams() {
	return renameParams;
}
 
Example #20
Source File: IRenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setRenameParams(RenameParams renameParams) {
	this.renameParams = renameParams;
}
 
Example #21
Source File: RenameService2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * If this method returns {@code false}, it is sure, that the rename operation will fail. There is no guarantee that
 * it will succeed even if it returns {@code true}.
 */
protected boolean mayPerformRename(Either<Range, PrepareRenameResult> prepareRenameResult,
		RenameParams renameParams) {
	return prepareRenameResult != null && prepareRenameResult.getLeft() != null
			&& Ranges.containsPosition(prepareRenameResult.getLeft(), renameParams.getPosition());
}
 
Example #22
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams renameParams) {
	return requestManager.runRead(cancelIndicator -> rename(renameParams, cancelIndicator));
}
 
Example #23
Source File: PrepareRenameTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testRenameFqn_invalid_error() {
  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 uri = this.writeFile("my-type-invalid.testlang", _builder);
  this.initialize();
  TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
  Position _position = new Position(2, 5);
  final RenameParams params = new RenameParams(_textDocumentIdentifier, _position, "Does not matter");
  try {
    final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("Expected an expcetion when trying to rename document but got a valid workspace edit instead: ");
    _builder_1.append(workspaceEdit);
    Assert.fail(_builder_1.toString());
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception e = (Exception)_t;
      final Throwable rootCause = Throwables.getRootCause(e);
      Assert.assertTrue((rootCause instanceof ResponseErrorException));
      final ResponseError error = ((ResponseErrorException) rootCause).getResponseError();
      Assert.assertTrue(error.getData().toString().contains("No element found at position"));
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
Example #24
Source File: RenameHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private WorkspaceEdit getRenameEdit(ICompilationUnit cu, Position pos, String newName) {
	TextDocumentIdentifier identifier = new TextDocumentIdentifier(JDTUtils.toURI(cu));

	RenameParams params = new RenameParams(identifier, pos, newName);
	return handler.rename(params, monitor);
}
 
Example #25
Source File: TeiidDdlTextDocumentService.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
    LOGGER.debug("rename: {}", params.getTextDocument());
    return CompletableFuture.completedFuture(null);
}
 
Example #26
Source File: TextDocumentServiceImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams arg0) {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #27
Source File: XIRenameService.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Deprecated
WorkspaceEdit rename(XWorkspaceManager workspaceManager, RenameParams renameParams,
		CancelIndicator cancelIndicator);
 
Example #28
Source File: CamelTextDocumentService.java    From camel-language-server with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
	LOGGER.info("rename: {}", params.getTextDocument());
	return CompletableFuture.completedFuture(null);
}
 
Example #29
Source File: XMLTextDocumentService.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
	return computeDOMAsync(params.getTextDocument(), (cancelChecker, xmlDocument) -> {
		return getXMLLanguageService().doRename(xmlDocument, params.getPosition(), params.getNewName());
	});
}
 
Example #30
Source File: TextDocumentService.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The rename request is sent from the client to the server to do a
 * workspace wide rename of a symbol.
 * 
 * Registration Options: TextDocumentRegistrationOptions
 */
@JsonRequest
default CompletableFuture<WorkspaceEdit> rename(RenameParams params) {
	throw new UnsupportedOperationException();
}