Java 类com.intellij.lang.parameterInfo.ParameterInfoHandler 实例源码

项目:intellij-ce-playground    文件:ShowParameterInfoHandler.java   
private static void showLookupEditorHint(Object[] descriptors, final Editor editor, final Project project, ParameterInfoHandler handler) {
  ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler);
  component.update();

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = ShowParameterInfoContext.chooseBestHintPosition(project, editor, -1, -1, hint, true, HintManager.DEFAULT);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (!editor.getComponent().isShowing()) return;
      hintManager.showEditorHint(hint, editor, pos.getFirst(),
                                 HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_LOOKUP_ITEM_CHANGE | HintManager.UPDATE_BY_SCROLLING,
                                 0, false, pos.getSecond());
    }
  });
}
项目:tools-idea    文件:ShowParameterInfoHandler.java   
private static void showLookupEditorHint(Object[] descriptors, final Editor editor, final Project project, ParameterInfoHandler handler) {
  ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler);
  component.update();

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = ShowParameterInfoContext.chooseBestHintPosition(project, editor, -1, -1, hint, true, HintManager.DEFAULT);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (!editor.getComponent().isShowing()) return;
      hintManager.showEditorHint(hint, editor, pos.getFirst(),
                                 HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_LOOKUP_ITEM_CHANGE | HintManager.UPDATE_BY_SCROLLING,
                                 0, false, pos.getSecond());
    }
  });
}
项目:consulo    文件:ShowParameterInfoHandler.java   
private static void showLookupEditorHint(Object[] descriptors, final Editor editor, final Project project, ParameterInfoHandler handler, boolean requestFocus) {
  ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler, requestFocus);
  component.update();

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = ShowParameterInfoContext.chooseBestHintPosition(project, editor, -1, -1, hint, true, HintManager.DEFAULT);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (!editor.getComponent().isShowing()) return;
      hintManager.showEditorHint(hint, editor, pos.getFirst(), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_LOOKUP_ITEM_CHANGE | HintManager.UPDATE_BY_SCROLLING, 0, false, pos.getSecond());
    }
  });
}
项目:intellij-ce-playground    文件:ShowParameterInfoContext.java   
private static void showMethodInfo(final Project project, final Editor editor,
                                   final PsiElement list,
                                   PsiElement highlighted,
                                   Object[] candidates,
                                   int offset,
                                   ParameterInfoHandler handler
                                   ) {
  showParameterHint(list, editor, candidates, project, candidates.length > 1 ? highlighted : null, offset, handler);
}
项目:intellij-ce-playground    文件:ShowParameterInfoHandler.java   
@Nullable
public static ParameterInfoHandler[] getHandlers(Project project, final Language... languages) {
  Set<ParameterInfoHandler> handlers = new THashSet<ParameterInfoHandler>();
  for (final Language language : languages) {
    handlers.addAll(DumbService.getInstance(project).filterByDumbAwareness(LanguageParameterInfo.INSTANCE.allForLanguage(language)));
  }
  if (handlers.isEmpty()) return null;
  return handlers.toArray(new ParameterInfoHandler[handlers.size()]);
}
项目:intellij-ce-playground    文件:ParameterInfoComponent.java   
@TestOnly
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, int currentParameterIndex, @Nullable PsiElement parameterOwner) {
  final ParameterInfoComponent infoComponent = new ParameterInfoComponent(objects, editor, handler);
  infoComponent.setCurrentParameterIndex(currentParameterIndex);
  infoComponent.setParameterOwner(parameterOwner);
  return infoComponent.new MyParameterContext();
}
项目:intellij-ce-playground    文件:ParameterInfoComponent.java   
ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler) {
  super(new BorderLayout());

  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    JComponent editorComponent = editor.getComponent();
    JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
    myWidthLimit = layeredPane.getWidth();
  }

  NORMAL_FONT = UIUtil.getLabelFont();
  BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD);

  myObjects = objects;

  setBackground(BACKGROUND_COLOR);

  myHandler = handler;
  myPanels = new OneElementComponent[myObjects.length];
  final JPanel panel = new JPanel(new GridBagLayout());
  for (int i = 0; i < myObjects.length; i++) {
    myPanels[i] = new OneElementComponent();
    panel.add(myPanels[i], new GridBagConstraints(0, i, 1, 1, 1, 0,
                                                  GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                                                  new Insets(0, 0, 0, 0), 0, 0));
  }

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel);
  pane.setBorder(null);
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  add(pane, BorderLayout.CENTER);

  myCurrentParameterIndex = -1;
}
项目:tools-idea    文件:ShowParameterInfoContext.java   
private static void showParameterHint(final PsiElement element, final Editor editor, final Object[] descriptors,
                                      final Project project, final ShowParameterInfoHandler.BestLocationPointProvider provider,
                                      @Nullable PsiElement highlighted,
                                      final int elementStart, final ParameterInfoHandler handler
                                      ) {
  if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;

  if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
  final ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor,handler);
  component.setParameterOwner(element);
  if (highlighted != null) {
    component.setHighlightedParameter(highlighted);
  }

  component.update(); // to have correct preferred size

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = provider.getBestPointPosition(hint, element, elementStart, true, HintManager.UNDER);

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (editor.isDisposed()) return;

      final Document document = editor.getDocument();
      if (document.getTextLength() < elementStart) return;

      HintHint hintHint = HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
      hintHint.setExplicitClose(true);

      hintManager.showEditorHint(hint, editor, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
      new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
    }
  });
}
项目:tools-idea    文件:ShowParameterInfoContext.java   
private static void showMethodInfo(final Project project, final Editor editor,
                                   final PsiElement list,
                                   PsiElement highlighted,
                                   Object[] candidates,
                                   int offset,
                                   ParameterInfoHandler handler
                                   ) {
  showParameterHint(list, editor, candidates, project, new MyBestLocationPointProvider(editor),
                    candidates.length > 1 ? highlighted: null,offset, handler);
}
项目:tools-idea    文件:ShowParameterInfoHandler.java   
@Nullable
public static ParameterInfoHandler[] getHandlers(Project project, final Language... languages) {
  Set<ParameterInfoHandler> handlers = new THashSet<ParameterInfoHandler>();
  for (final Language language : languages) {
    handlers.addAll(DumbService.getInstance(project).filterByDumbAwareness(LanguageParameterInfo.INSTANCE.allForLanguage(language)));
  }
  if (handlers.isEmpty()) return null;
  return handlers.toArray(new ParameterInfoHandler[handlers.size()]);
}
项目:tools-idea    文件:ParameterInfoComponent.java   
public ParameterInfoComponent(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler) {
  super(new BorderLayout());

  JComponent editorComponent = editor.getComponent();
  JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
  myWidthLimit = layeredPane.getWidth();

  NORMAL_FONT = UIUtil.getLabelFont();
  BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD);

  myObjects = objects;

  setBackground(BACKGROUND_COLOR);

  myHandler = handler;
  myPanels = new OneElementComponent[myObjects.length];
  final JPanel panel = new JPanel(new GridBagLayout());
  for (int i = 0; i < myObjects.length; i++) {
    myPanels[i] = new OneElementComponent();
    panel.add(myPanels[i], new GridBagConstraints(0, i, 1, 1, 1, 0,
                                                  GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                                                  new Insets(0, 0, 0, 0), 0, 0));
  }

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel);
  pane.setBorder(null);
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  add(pane, BorderLayout.CENTER);

  myCurrentParameterIndex = -1;
}
项目:consulo    文件:ShowParameterInfoContext.java   
private static void showMethodInfo(final Project project, final Editor editor,
                                   final PsiElement list,
                                   Object highlighted,
                                   Object[] candidates,
                                   int offset,
                                   ParameterInfoHandler handler,
                                   boolean requestFocus
) {
  showParameterHint(list, editor, candidates, project, candidates.length > 1 ? highlighted : null, offset, handler, requestFocus);
}
项目:consulo    文件:ShowParameterInfoHandler.java   
@Nullable
public static ParameterInfoHandler[] getHandlers(Project project, final Language... languages) {
  Set<ParameterInfoHandler> handlers = new THashSet<ParameterInfoHandler>();
  for (final Language language : languages) {
    handlers.addAll(DumbService.getInstance(project).filterByDumbAwareness(LanguageParameterInfo.INSTANCE.allForLanguage(language)));
  }
  if (handlers.isEmpty()) return null;
  return handlers.toArray(new ParameterInfoHandler[handlers.size()]);
}
项目:consulo    文件:ParameterInfoComponent.java   
@TestOnly
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @Nonnull ParameterInfoHandler handler, int currentParameterIndex, @Nullable PsiElement parameterOwner) {
  final ParameterInfoComponent infoComponent = new ParameterInfoComponent(objects, editor, handler);
  infoComponent.setCurrentParameterIndex(currentParameterIndex);
  infoComponent.setParameterOwner(parameterOwner);
  return infoComponent.new MyParameterContext();
}
项目:consulo    文件:ParameterInfoComponent.java   
ParameterInfoComponent(Object[] objects, Editor editor, @Nonnull ParameterInfoHandler handler, boolean requestFocus) {
  super(new BorderLayout());
  myRequestFocus = requestFocus;

  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    JComponent editorComponent = editor.getComponent();
    JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
    myWidthLimit = layeredPane.getWidth();
  }

  NORMAL_FONT = UIUtil.getLabelFont();
  BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD);

  myObjects = objects;

  setBackground(BACKGROUND_COLOR);

  myHandler = handler;
  myPanels = new OneElementComponent[myObjects.length];
  final JPanel panel = new JPanel(new GridBagLayout());
  for (int i = 0; i < myObjects.length; i++) {
    myPanels[i] = new OneElementComponent();
    panel.add(myPanels[i], new GridBagConstraints(0, i, 1, 1, 1, 0,
                                                  GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                                                  new Insets(0, 0, 0, 0), 0, 0));
  }
  if (myRequestFocus) {
    AccessibleContextUtil.setName(this, "Parameter Info. Press TAB to navigate through each element. Press ESC to close.");
  }

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel);
  pane.setBorder(null);
  pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  add(pane, BorderLayout.CENTER);

  myCurrentParameterIndex = -1;
}
项目:consulo-apache-velocity    文件:VtlParameterInfoTest.java   
private static CreateParameterInfoContext createCreateParameterInfoContext(CodeInsightTestFixture fixture)
{
    return new ShowParameterInfoContext(fixture.getEditor(), fixture.getProject(), fixture.getFile(), fixture.getEditor().getCaretModel().getOffset(), 0)
    {
        @Override
        public void showHint(final PsiElement element, final int offset, final ParameterInfoHandler handler)
        {
        }
    };
}
项目:intellij-ce-playground    文件:MockCreateParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {}
项目:intellij-ce-playground    文件:ShowParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {
  final Object[] itemsToShow = getItemsToShow();
  if (itemsToShow == null || itemsToShow.length == 0) return;
  showMethodInfo(getProject(), getEditor(), element, getHighlightedElement(), itemsToShow, offset, handler);
}
项目:intellij-ce-playground    文件:ShowParameterInfoContext.java   
private static void showParameterHint(final PsiElement element,
                                      final Editor editor,
                                      final Object[] descriptors,
                                      final Project project,
                                      @Nullable PsiElement highlighted,
                                      final int elementStart,
                                      final ParameterInfoHandler handler) {
  if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;

  if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
  final ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor,handler);
  component.setParameterOwner(element);
  if (highlighted != null) {
    component.setHighlightedParameter(highlighted);
  }

  component.update(); // to have correct preferred size

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final ShowParameterInfoHandler.BestLocationPointProvider provider = new MyBestLocationPointProvider(editor);
  final Pair<Point, Short> pos = provider.getBestPointPosition(hint, element, elementStart, true, HintManager.UNDER);

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (editor.isDisposed() || DumbService.isDumb(project)) return;

      final Document document = editor.getDocument();
      if (document.getTextLength() < elementStart) return;

      HintHint hintHint = HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
      hintHint.setExplicitClose(true);

      Editor editorToShow = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
      // is case of injection we need to calculate position for EditorWindow
      // also we need to show the hint in the main editor because of intention bulb
      hintManager.showEditorHint(hint, editorToShow, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
      new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
    }
  });
}
项目:intellij-ce-playground    文件:ParameterInfoComponent.java   
@TestOnly
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, int currentParameterIndex) {
  return createContext(objects, editor, handler, currentParameterIndex, null);
}
项目:intellij-ce-playground    文件:PyParameterInfoTest.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) { }
项目:tools-idea    文件:MockCreateParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {}
项目:tools-idea    文件:ShowParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {
  final Object[] itemsToShow = getItemsToShow();
  if (itemsToShow == null || itemsToShow.length == 0) return;
  showMethodInfo(getProject(), getEditor(), element, getHighlightedElement(), itemsToShow, offset, handler);
}
项目:intellij-xquery    文件:FakeCreateParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {
}
项目:consulo    文件:MockCreateParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {}
项目:consulo    文件:ShowParameterInfoContext.java   
@Override
public void showHint(PsiElement element, int offset, ParameterInfoHandler handler) {
  final Object[] itemsToShow = getItemsToShow();
  if (itemsToShow == null || itemsToShow.length == 0) return;
  showMethodInfo(getProject(), getEditor(), element, getHighlightedElement(), itemsToShow, offset, handler, myRequestFocus);
}
项目:consulo    文件:ShowParameterInfoContext.java   
private static void showParameterHint(final PsiElement element,
                                      final Editor editor,
                                      final Object[] descriptors,
                                      final Project project,
                                      @Nullable Object highlighted,
                                      final int elementStart,
                                      final ParameterInfoHandler handler,
                                      final boolean requestFocus) {
  if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;

  if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
  final ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor,handler,requestFocus);
  component.setParameterOwner(element);
  component.setRequestFocus(requestFocus);
  if (highlighted != null) {
    component.setHighlightedParameter(highlighted);
  }

  component.update(); // to have correct preferred size

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final ShowParameterInfoHandler.BestLocationPointProvider provider = new MyBestLocationPointProvider(editor);
  final Pair<Point, Short> pos = provider.getBestPointPosition(hint, element, elementStart, true, HintManager.UNDER);

  PsiDocumentManager.getInstance(project).performLaterWhenAllCommitted(new Runnable() {
    @Override
    public void run() {
      if (editor.isDisposed() || DumbService.isDumb(project)) return;

      final Document document = editor.getDocument();
      if (document.getTextLength() < elementStart) return;

      HintHint hintHint = HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
      hintHint.setExplicitClose(true);
      hintHint.setRequestFocus(requestFocus);

      Editor editorToShow = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
      // is case of injection we need to calculate position for EditorWindow
      // also we need to show the hint in the main editor because of intention bulb
      hintManager.showEditorHint(hint, editorToShow, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
      new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
    }
  });
}
项目:consulo    文件:ParameterInfoComponent.java   
@TestOnly
public static ParameterInfoUIContextEx createContext(Object[] objects, Editor editor, @Nonnull ParameterInfoHandler handler, int currentParameterIndex) {
  return createContext(objects, editor, handler, currentParameterIndex, null);
}
项目:consulo    文件:ParameterInfoComponent.java   
ParameterInfoComponent(Object[] objects, Editor editor, @Nonnull ParameterInfoHandler handler) {
  this(objects, editor, handler, false);
}