mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OC-16351 [swift override operator completion] provide caret position for invokeAutoPopup
Consider you want to autopopup completion only if there's a line feed before the caret.
If you're staying on a white space with a line feed inside you have to know the caret position
to make sure that the line feed is before it and not after:
Example:
The whitespace at caret does contain a line feed but it is after the caret position
```
class A { <caret>
}
```
This commit is contained in:
@@ -190,11 +190,20 @@ public abstract class CompletionContributor {
|
||||
|
||||
/**
|
||||
* Allow autoPopup to appear after custom symbol
|
||||
* @deprecated use {@link CompletionContributor#invokeAutoPopup(PsiElement, char, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow autoPopup to appear after custom symbol
|
||||
*/
|
||||
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar, int offset) {
|
||||
return invokeAutoPopup(position, typeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked in a read action in parallel to the completion process. Used to calculate the replacement offset
|
||||
* (see {@link CompletionInitializationContext#setReplacementOffset(int)})
|
||||
|
||||
@@ -289,7 +289,7 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
final PsiElement element = file.findElementAt(offset);
|
||||
if (element != null) {
|
||||
for (CompletionContributor contributor : CompletionContributor.forLanguageHonorDumbness(element.getLanguage(), file.getProject())) {
|
||||
if (contributor.invokeAutoPopup(element, charTyped)) {
|
||||
if (contributor.invokeAutoPopup(element, charTyped, offset + 1)) {
|
||||
LOG.debug(contributor + " requested completion autopopup when typing '" + charTyped + "'");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user