generated from redhat-developer/new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Wrong generated content after an LSP completion apply without
TextEdit Fixes #181 Signed-off-by: azerr <[email protected]>
- Loading branch information
1 parent
dbef326
commit 90546e2
Showing
4 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/test/java/com/redhat/devtools/lsp4ij/features/completion/ClojureCompletionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Red Hat, Inc. | ||
* Distributed under license by Red Hat, Inc. All rights reserved. | ||
* This program is made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
******************************************************************************/ | ||
package com.redhat.devtools.lsp4ij.features.completion; | ||
|
||
import com.redhat.devtools.lsp4ij.fixtures.LSPCompletionFixtureTestCase; | ||
|
||
/** | ||
* Completion tests by emulating LSP 'textDocument/completion' responses | ||
* from the clojure-lsp language server. | ||
*/ | ||
public class ClojureCompletionTest extends LSPCompletionFixtureTestCase { | ||
|
||
public void testCompletionWithoutTextEditAndEmptyContent() { | ||
// clojure-lsp returns completion items without text edit. | ||
// 1. Test completion items result | ||
assertCompletion("test.ts", | ||
"<caret>", """ | ||
[ | ||
{ | ||
"label": "let", | ||
"kind": 15, | ||
"detail": "Insert let", | ||
"insertText": "(let [${1:binding} ${2:value}])", | ||
"insertTextFormat": 2 | ||
}, | ||
{ | ||
"label": "letfn", | ||
"kind": 15, | ||
"detail": "Insert letfn", | ||
"insertText": "(letfn [(${1:name} [${2:args}]\\n $0)])", | ||
"insertTextFormat": 2 | ||
} | ||
]""" | ||
, "let", "letfn"); | ||
// 2. Test new editor content after applying the first completion item | ||
assertApplyCompletionItem(0, "(let [binding value])"); | ||
} | ||
|
||
public void testCompletionWithoutTextEdit() { | ||
// clojure-lsp returns completion items without text edit. | ||
// 1. Test completion items result | ||
assertCompletion("test.ts", | ||
"let<caret>", """ | ||
[ | ||
{ | ||
"label": "let", | ||
"kind": 15, | ||
"detail": "Insert let", | ||
"insertText": "(let [${1:binding} ${2:value}])", | ||
"insertTextFormat": 2 | ||
}, | ||
{ | ||
"label": "letfn", | ||
"kind": 15, | ||
"detail": "Insert letfn", | ||
"insertText": "(letfn [(${1:name} [${2:args}]\\n $0)])", | ||
"insertTextFormat": 2 | ||
} | ||
]""" | ||
, "let", "letfn"); | ||
// 2. Test new editor content after applying the first completion item | ||
assertApplyCompletionItem(0, "(let [binding value])"); | ||
} | ||
|
||
public void testCompletionWithoutTextEditAndCaretInsideToken() { | ||
// clojure-lsp returns completion items without text edit. | ||
// 1. Test completion items result | ||
assertCompletion("test.ts", | ||
"le<caret>t", """ | ||
[ | ||
{ | ||
"label": "let", | ||
"kind": 15, | ||
"detail": "Insert let", | ||
"insertText": "(let [${1:binding} ${2:value}])", | ||
"insertTextFormat": 2 | ||
}, | ||
{ | ||
"label": "letfn", | ||
"kind": 15, | ||
"detail": "Insert letfn", | ||
"insertText": "(letfn [(${1:name} [${2:args}]\\n $0)])", | ||
"insertTextFormat": 2 | ||
} | ||
]""" | ||
, "let", "letfn"); | ||
// 2. Test new editor content after applying the first completion item | ||
assertApplyCompletionItem(0, "(let [binding value])t"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters