/** * Inserts a completion. Any time a code completion event occurs, the actual * text insertion happens through this method. * * @param c A completion to insert. This cannot be <code>null</code>. */ protected final void insertCompletion(Completion c) { insertCompletion(c, false); }
/** * Inserts the currently selected completion. * * @see #getSelection() */ private void insertSelectedCompletion() { Completion comp = getSelection(); ac.insertCompletion(comp); }
@Override protected void insertCompletion(Completion c, boolean typedParamListStartChar) { super.insertCompletion(c, typedParamListStartChar); JTextComponent textComponent = getTextComponent(); Caret caret = textComponent.getCaret(); int dot = caret.getDot(); int start = 0; String text = null; try { text = textComponent.getText(0, dot); } catch (BadLocationException ex) { Logger.getLogger(VAutoCompletion.class.getName()). log(Level.SEVERE, null, ex); } for (ReplacementRule rule : replacementRules) { text = rule.replace(text, c); } caret.setDot(start); caret.moveDot(dot); textComponent.replaceSelection(text); }
@Override public void actionPerformed(ActionEvent e) { // Prevents keystrokes from messing up boolean wasVisible = hidePopupWindow(); // Only proceed if they were selecting a completion if (!wasVisible || !isParameterAssistanceEnabled()) { textComponent.replaceSelection(start); return; } Completion c = popupWindow.getSelection(); if (c instanceof ParameterizedCompletion) { // Should always be true // Fixes capitalization of the entered text. insertCompletion(c, true); } }
super.insertCompletion(c, typedParamListStartChar); if (importInfo!=null) { textArea.insert(importInfo.text, importInfo.offs);
SwingUtilities.invokeLater(() -> insertCompletion(completions.get(0)));