use of com.intellij.lang.parameterInfo.ParameterInfoHandler in project intellij-community by JetBrains.
the class ParameterInfoController method findArgumentList.
@Nullable
public static <E extends PsiElement> E findArgumentList(PsiFile file, int offset, int lbraceOffset) {
if (file == null)
return null;
ParameterInfoHandler[] handlers = ShowParameterInfoHandler.getHandlers(file.getProject(), PsiUtilCore.getLanguageAtOffset(file, offset), file.getViewProvider().getBaseLanguage());
if (handlers != null) {
for (ParameterInfoHandler handler : handlers) {
if (handler instanceof ParameterInfoHandlerWithTabActionSupport) {
final ParameterInfoHandlerWithTabActionSupport parameterInfoHandler2 = (ParameterInfoHandlerWithTabActionSupport) handler;
// please don't remove typecast in the following line; it's required to compile the code under old JDK 6 versions
final E e = (E) ParameterInfoUtils.findArgumentList(file, offset, lbraceOffset, parameterInfoHandler2);
if (e != null)
return e;
}
}
}
return null;
}
use of com.intellij.lang.parameterInfo.ParameterInfoHandler in project intellij-community by JetBrains.
the class ShowParameterInfoHandler method invoke.
public static void invoke(final Project project, final Editor editor, PsiFile file, int lbraceOffset, PsiElement highlightedElement, boolean requestFocus) {
ApplicationManager.getApplication().assertIsDispatchThread();
PsiDocumentManager.getInstance(project).commitAllDocuments();
final int offset = editor.getCaretModel().getOffset();
final PsiElement psiElement = findAnyElementAt(file, offset);
if (psiElement == null)
return;
final ShowParameterInfoContext context = new ShowParameterInfoContext(editor, project, file, offset, lbraceOffset, requestFocus);
context.setHighlightedElement(highlightedElement);
context.setRequestFocus(requestFocus);
final Language language = psiElement.getLanguage();
ParameterInfoHandler[] handlers = getHandlers(project, language, file.getViewProvider().getBaseLanguage());
if (handlers == null)
handlers = new ParameterInfoHandler[0];
Lookup lookup = LookupManager.getInstance(project).getActiveLookup();
if (lookup != null) {
LookupElement item = lookup.getCurrentItem();
if (item != null) {
for (ParameterInfoHandler handler : handlers) {
if (handler.couldShowInLookup()) {
final Object[] items = handler.getParametersForLookup(item, context);
if (items != null && items.length > 0) {
showLookupEditorHint(items, editor, project, handler, requestFocus);
}
return;
}
}
}
return;
}
DumbService.getInstance(project).setAlternativeResolveEnabled(true);
try {
for (ParameterInfoHandler<Object, ?> handler : handlers) {
Object element = handler.findElementForParameterInfo(context);
if (element != null) {
handler.showParameterInfo(element, context);
}
}
} finally {
DumbService.getInstance(project).setAlternativeResolveEnabled(false);
}
}
Aggregations