コード例 #1
0
 @Override
 public void updateParameterInfo(
     @NotNull JetValueArgumentList argumentList, @NotNull UpdateParameterInfoContext context) {
   if (context.getParameterOwner() != argumentList) context.removeHint();
   int offset = context.getOffset();
   ASTNode child = argumentList.getNode().getFirstChildNode();
   int i = 0;
   while (child != null && child.getStartOffset() < offset) {
     if (child.getElementType() == JetTokens.COMMA) ++i;
     child = child.getTreeNext();
   }
   context.setCurrentParameter(i);
 }
コード例 #2
0
  private void updateComponent() {
    if (!myHint.isVisible()) {
      Disposer.dispose(this);
      return;
    }

    final PsiFile file =
        PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
    CharSequence chars = myEditor.getDocument().getCharsSequence();
    boolean noDelimiter =
        myHandler instanceof ParameterInfoHandlerWithTabActionSupport
            && ((ParameterInfoHandlerWithTabActionSupport) myHandler)
                    .getActualParameterDelimiterType()
                == TokenType.WHITE_SPACE;
    int caretOffset = myEditor.getCaretModel().getOffset();
    final int offset =
        noDelimiter ? caretOffset : CharArrayUtil.shiftBackward(chars, caretOffset - 1, " \t") + 1;

    final UpdateParameterInfoContext context = new MyUpdateParameterInfoContext(offset, file);
    final Object elementForUpdating = myHandler.findElementForUpdatingParameterInfo(context);

    if (elementForUpdating != null) {
      myHandler.updateParameterInfo(elementForUpdating, context);
      if (!myDisposed
          && myHint.isVisible()
          && !myEditor.isDisposed()
          && myEditor.getComponent().getRootPane() != null) {
        myComponent.update();
        IdeTooltip tooltip = myHint.getCurrentIdeTooltip();
        short position =
            tooltip != null ? toShort(tooltip.getPreferredPosition()) : HintManager.UNDER;
        Pair<Point, Short> pos =
            myProvider.getBestPointPosition(
                myHint,
                elementForUpdating instanceof PsiElement ? (PsiElement) elementForUpdating : null,
                caretOffset,
                true,
                position);
        HintManagerImpl.adjustEditorHintPosition(myHint, myEditor, pos.getFirst(), pos.getSecond());
      }
    } else {
      context.removeHint();
    }
  }
コード例 #3
0
 private static JetValueArgumentList findCallAndUpdateContext(UpdateParameterInfoContext context) {
   PsiFile file = context.getFile();
   PsiElement element = file.findElementAt(context.getOffset());
   if (element == null) return null;
   PsiElement parent = element.getParent();
   while (parent != null && !(parent instanceof JetValueArgumentList)) {
     element = element.getParent();
     parent = parent.getParent();
   }
   if (parent == null) return null;
   JetValueArgumentList argumentList = (JetValueArgumentList) parent;
   if (element instanceof JetValueArgument) {
     JetValueArgument arg = (JetValueArgument) element;
     int i = argumentList.getArguments().indexOf(arg);
     context.setCurrentParameter(i);
     context.setHighlightedParameter(arg);
   }
   return argumentList;
 }
コード例 #4
0
  public void updateParameterInfo(@NotNull PsiElement place, UpdateParameterInfoContext context) {
    if (context.getParameterOwner() == null) {
      context.setParameterOwner(place);
    } else if (!context.getParameterOwner().equals(place)) {
      context.removeHint();
      return;
    }
    final Object[] objects = context.getObjectsToView();

    for (int i = 0; i < objects.length; i++) {
      context.setUIComponentEnabled(i, true);
    }
  }
コード例 #5
0
  @Override
  public void updateParameterInfo(@NotNull PsiElement place, UpdateParameterInfoContext context) {
    int parameterIndex = DartResolveUtil.getArgumentIndex(place);
    context.setCurrentParameter(parameterIndex);

    if (context.getParameterOwner() == null) {
      context.setParameterOwner(place);
    } else if (context.getParameterOwner()
        != PsiTreeUtil.getParentOfType(place, DartCallExpression.class, DartNewExpression.class)) {
      context.removeHint();
      return;
    }
    final Object[] objects = context.getObjectsToView();

    for (int i = 0; i < objects.length; i++) {
      context.setUIComponentEnabled(i, true);
    }
  }
コード例 #6
0
 @Override
 public PsiElement findElementForUpdatingParameterInfo(UpdateParameterInfoContext context) {
   return context.getFile().findElementAt(context.getEditor().getCaretModel().getOffset());
 }
コード例 #7
0
 public PsiElement findElementForUpdatingParameterInfo(UpdateParameterInfoContext context) {
   return findAnchorElement(context.getEditor().getCaretModel().getOffset(), context.getFile());
 }