本文整理汇总了Java中com.intellij.codeInsight.lookup.impl.LookupImpl类的典型用法代码示例。如果您正苦于以下问题:Java LookupImpl类的具体用法?Java LookupImpl怎么用?Java LookupImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LookupImpl类属于com.intellij.codeInsight.lookup.impl包,在下文中一共展示了LookupImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertPreferredCompletionItems
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void assertPreferredCompletionItems(final int selected, @NotNull @NonNls final String... expected) {
final LookupImpl lookup = getLookup();
Assert.assertNotNull("No lookup is shown", lookup);
final JList list = lookup.getList();
List<String> strings = getLookupElementStrings();
Assert.assertNotNull(strings);
final List<String> actual = strings.subList(0, Math.min(expected.length, strings.size()));
if (!actual.equals(Arrays.asList(expected))) {
UsefulTestCase.assertOrderedEquals(DumpLookupElementWeights.getLookupElementWeights(lookup), expected);
}
if (selected != list.getSelectedIndex()) {
System.out.println(DumpLookupElementWeights.getLookupElementWeights(lookup));
}
Assert.assertEquals(selected, list.getSelectedIndex());
}
示例2: actionPerformed
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (project != null && editor != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_FEATURE);
final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).getActiveLookup();
if (lookup != null) {
//dumpLookupElementWeights(lookup);
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_LOOKUP_FEATURE);
}
actionPerformedImpl(project, editor);
}
else if (project != null && element != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_CTRLN_FEATURE);
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
DocumentationManager.getInstance(project).showJavaDocInfo(element, null);
}
}, getCommandName(), null);
}
}
示例3: obtainLookup
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@NotNull
private LookupImpl obtainLookup(Editor editor) {
CompletionAssertions.checkEditorValid(editor);
LookupImpl existing = (LookupImpl)LookupManager.getActiveLookup(editor);
if (existing != null && existing.isCompletion()) {
existing.markReused();
if (!autopopup) {
existing.setFocusDegree(LookupImpl.FocusDegree.FOCUSED);
}
return existing;
}
LookupImpl lookup = (LookupImpl)LookupManager.getInstance(editor.getProject()).createLookup(editor, LookupElement.EMPTY_ARRAY, "",
new LookupArranger.DefaultArranger());
if (editor.isOneLineMode()) {
lookup.setCancelOnClickOutside(true);
lookup.setCancelOnOtherWindowOpen(true);
}
lookup.setFocusDegree(autopopup ? LookupImpl.FocusDegree.UNFOCUSED : LookupImpl.FocusDegree.FOCUSED);
return lookup;
}
示例4: addElement
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void addElement(Lookup lookup, LookupElement element, LookupElementPresentation presentation) {
StatisticsWeigher.clearBaseStatisticsInfo(element);
final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
element.putUserData(PRESENTATION_INVARIANT, invariant);
CompletionSorterImpl sorter = obtainSorter(element);
Classifier<LookupElement> classifier = myClassifiers.get(sorter);
if (classifier == null) {
myClassifiers.put(sorter, classifier = sorter.buildClassifier(new AlphaClassifier((LookupImpl)lookup)));
}
ProcessingContext context = createContext(true);
classifier.addElement(element, context);
super.addElement(lookup, element, presentation);
trimToLimit(lookup, context);
}
示例5: arrangeItems
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@NotNull Lookup lookup, boolean onExplicitAction) {
List<LookupElement> items = getMatchingItems();
MultiMap<CompletionSorterImpl, LookupElement> itemsBySorter = groupItemsBySorter(items);
LookupElement relevantSelection = findMostRelevantItem(itemsBySorter);
LookupImpl lookupImpl = (LookupImpl)lookup;
List<LookupElement> listModel = isAlphaSorted() ?
sortByPresentation(items, lookupImpl) :
fillModelByRelevance(lookupImpl, ContainerUtil.newIdentityTroveSet(items), itemsBySorter, relevantSelection);
int toSelect = getItemToSelect(lookupImpl, listModel, onExplicitAction, relevantSelection);
LOG.assertTrue(toSelect >= 0);
addDummyItems(items.size() - listModel.size(), listModel);
return new Pair<List<LookupElement>, Integer>(listModel, toSelect);
}
示例6: fillModelByRelevance
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
private List<LookupElement> fillModelByRelevance(LookupImpl lookup,
Set<LookupElement> items,
MultiMap<CompletionSorterImpl, LookupElement> inputBySorter,
@Nullable LookupElement relevantSelection) {
Iterator<LookupElement> byRelevance = sortByRelevance(inputBySorter).iterator();
final LinkedHashSet<LookupElement> model = new LinkedHashSet<LookupElement>();
addPrefixItems(model);
addFrozenItems(items, model);
addSomeItems(model, byRelevance, new Condition<LookupElement>() {
@Override
public boolean value(LookupElement lastAdded) {
return model.size() >= MAX_PREFERRED_COUNT;
}
});
addCurrentlySelectedItemToTop(lookup, items, model);
freezeTopItems(lookup, model);
ensureItemAdded(items, model, byRelevance, lookup.getCurrentItem());
ensureItemAdded(items, model, byRelevance, relevantSelection);
ensureEverythingVisibleAdded(lookup, model, byRelevance);
return new ArrayList<LookupElement>(model);
}
示例7: arrangeItems
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@NotNull Lookup lookup, boolean onExplicitAction) {
LinkedHashSet<LookupElement> result = new LinkedHashSet<LookupElement>();
result.addAll(getPrefixItems(true));
result.addAll(getPrefixItems(false));
List<LookupElement> items = getMatchingItems();
for (LookupElement item : items) {
if (CompletionServiceImpl.isStartMatch(item, (LookupImpl)lookup)) {
result.add(item);
}
}
result.addAll(items);
ArrayList<LookupElement> list = new ArrayList<LookupElement>(result);
int selected = !lookup.isSelectionTouched() && onExplicitAction ? 0 : list.indexOf(lookup.getCurrentItem());
return new Pair<List<LookupElement>, Integer>(list, selected >= 0 ? selected : 0);
}
示例8: execute
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void execute(@NotNull final Editor editor, final DataContext dataContext) {
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
if (lookup == null) {
throw new AssertionError("The last lookup disposed at: " + LookupImpl.getLastLookupDisposeTrace() + "\n-----------------------\n");
}
if (finishingChar == Lookup.NORMAL_SELECT_CHAR) {
if (!lookup.isFocused()) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ENTER);
}
} else if (finishingChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_SMART_ENTER);
} else if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_REPLACE);
} else if (finishingChar == '.') {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_CONTROL_DOT);
}
lookup.finishLookup(finishingChar);
}
示例9: isEnabled
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public boolean isEnabled(Editor editor, DataContext dataContext) {
LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
if (lookup == null) return false;
if (!lookup.isAvailableToUser()) return false;
if (focusedOnly && lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) return false;
if (finishingChar == Lookup.NORMAL_SELECT_CHAR && hasTemplatePrefix(lookup, TemplateSettings.ENTER_CHAR) ||
finishingChar == Lookup.REPLACE_SELECT_CHAR && hasTemplatePrefix(lookup, TemplateSettings.TAB_CHAR)) {
return false;
}
if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
return !lookup.getItems().isEmpty();
}
return true;
}
示例10: restoreOldCaretPositionAndSelection
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
private void restoreOldCaretPositionAndSelection(final int offset) {
//move to old offset
Runnable runnable = new Runnable() {
@Override
public void run() {
myEditor.getCaretModel().moveToOffset(restoreCaretOffset(offset));
restoreSelection();
}
};
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
if (lookup != null && lookup.getLookupStart() <= (restoreCaretOffset(offset))) {
lookup.setFocusDegree(LookupImpl.FocusDegree.UNFOCUSED);
lookup.performGuardedChange(runnable);
}
else {
runnable.run();
}
}
示例11: execute
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void execute(Editor editor, DataContext dataContext) {
final SelectionModel selectionModel = editor.getSelectionModel();
if (selectionModel.hasSelection()) {
final TemplateState state = TemplateManagerImpl.getTemplateState(editor);
if (state != null && editor.getUserData(InplaceRefactoring.INPLACE_RENAMER) != null) {
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
if (lookup != null) {
selectionModel.removeSelection();
lookup.hideLookup(true);
return;
}
}
}
myOriginalHandler.execute(editor, dataContext);
}
示例12: testAutoPopupAfterDotDuringAnotherAutoPopup
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
public void testAutoPopupAfterDotDuringAnotherAutoPopup() {
myFixture.configureByText("a.py", FOO_CLASS +
"foo = Foo()\n" +
"foo2 = Foo()\n" +
"<caret>");
myTester.typeWithPauses("foo");
LookupImpl lookup1 = myTester.getLookup();
assertNotNull(lookup1);
assertFalse(lookup1.isFocused());
myTester.typeWithPauses(".");
LookupImpl lookup2 = myTester.getLookup();
assertNotSame(lookup1, lookup2);
assertNotNull(lookup2);
assertFalse(lookup2.isFocused());
}
示例13: actionPerformed
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
if (project != null && editor != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_FEATURE);
final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).getActiveLookup();
if (lookup != null) {
//dumpLookupElementWeights(lookup);
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_LOOKUP_FEATURE);
}
actionPerformedImpl(project, editor);
}
else if (project != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.quickjavadoc.ctrln");
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
DocumentationManager.getInstance(project).showJavaDocInfo(element, null);
}
}, getCommandName(), null);
}
}
示例14: arrangeItems
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
@Override
public Pair<List<LookupElement>, Integer> arrangeItems(@NotNull Lookup lookup, boolean onExplicitAction) {
List<LookupElement> items = getMatchingItems();
MultiMap<CompletionSorterImpl, LookupElement> itemsBySorter = groupItemsBySorter(items);
LookupElement relevantSelection = findMostRelevantItem(itemsBySorter);
List<LookupElement> listModel = isAlphaSorted() ?
sortByPresentation(items, lookup) :
fillModelByRelevance((LookupImpl)lookup, items, itemsBySorter, relevantSelection);
int toSelect = getItemToSelect((LookupImpl)lookup, listModel, onExplicitAction, relevantSelection);
LOG.assertTrue(toSelect >= 0);
addDummyItems(items.size() - listModel.size(), listModel);
return new Pair<List<LookupElement>, Integer>(listModel, toSelect);
}
示例15: hasTemplatePrefix
import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入依赖的package包/类
public static boolean hasTemplatePrefix(LookupImpl lookup, char shortcutChar) {
lookup.refreshUi(false, false); // to bring the list model up to date
CompletionProcess completion = CompletionService.getCompletionService().getCurrentCompletion();
if (completion == null || !completion.isAutopopupCompletion()) {
return false;
}
if (lookup.isSelectionTouched()) {
return false;
}
final PsiFile file = lookup.getPsiFile();
if (file == null) return false;
final Editor editor = lookup.getEditor();
PsiDocumentManager.getInstance(file.getProject()).commitDocument(editor.getDocument());
return ((TemplateManagerImpl)TemplateManager.getInstance(file.getProject())).prepareTemplate(editor, shortcutChar, null) != null;
}