mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-3132 honor exact selection; some javadoc with HTML warnings
This commit is contained in:
@@ -21,15 +21,27 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @see com.intellij.codeInsight.hint.actions.ShowExpressionTypeAction
|
||||
*
|
||||
* @author gregsh
|
||||
*/
|
||||
public abstract class ExpressionTypeProvider<T extends PsiElement> {
|
||||
/**
|
||||
* Returns HTML string for type info hint.
|
||||
* @see com.intellij.openapi.util.text.StringUtil#escapeXml(String)
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getInformationHint(@NotNull T element);
|
||||
|
||||
/**
|
||||
* Returns HTML string if no target found at position.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getErrorHint();
|
||||
|
||||
/**
|
||||
* Returns the list of all possible targets at specified position.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract List<T> getExpressionsAt(@NotNull PsiElement elementAt);
|
||||
}
|
||||
|
||||
@@ -60,11 +60,14 @@ public class ShowExpressionTypeHandler implements CodeInsightActionHandler {
|
||||
final Set<ExpressionTypeProvider> handlers = getHandlers(project, language, file.getViewProvider().getBaseLanguage());
|
||||
if (handlers.isEmpty()) return;
|
||||
|
||||
boolean exactRange = false;
|
||||
TextRange range = EditorUtil.getSelectionInAnyMode(editor);
|
||||
final Map<PsiElement, ExpressionTypeProvider> map = ContainerUtil.newLinkedHashMap();
|
||||
for (ExpressionTypeProvider handler : handlers) {
|
||||
for (PsiElement element : ((ExpressionTypeProvider<? extends PsiElement>)handler).getExpressionsAt(elementAt)) {
|
||||
if (!element.getTextRange().contains(range)) continue;
|
||||
TextRange r = element.getTextRange();
|
||||
if (exactRange && !r.equals(range) || !r.contains(range)) continue;
|
||||
if (!exactRange) exactRange = r.equals(range);
|
||||
map.put(element, handler);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user