2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.codeInsight.lookup;
19 import com.intellij.codeInsight.completion.PrefixMatcher;
20 import com.intellij.openapi.editor.Editor;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.psi.PsiElement;
23 import com.intellij.psi.PsiFile;
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
28 import java.util.List;
31 * Represents list with suggestions shown in code completion, refactorings, live templates etc.
33 public interface Lookup {
34 char NORMAL_SELECT_CHAR = '\n';
35 char REPLACE_SELECT_CHAR = '\t';
36 char COMPLETE_STATEMENT_SELECT_CHAR = '\r';
37 char AUTO_INSERT_SELECT_CHAR = (char) 0;
40 * @return the offset in {@link #getTopLevelEditor()} which this lookup's left side should be aligned with. Note that if the lookup doesn't fit
41 * the screen due to its dimensions, the actual position might differ from this editor offset.
46 LookupElement getCurrentItem();
48 void addLookupListener(LookupListener listener);
49 void removeLookupListener(LookupListener listener);
52 * @return bounds in layered pane coordinate system
54 Rectangle getBounds();
57 * @return bounds of the current item in the layered pane coordinate system.
59 Rectangle getCurrentItemBounds();
60 boolean isPositionedAboveCaret();
63 * @return leaf PSI element at this lookup's start position (see {@link #getLookupStart()}) in {@link #getPsiFile()} result.
66 PsiElement getPsiElement();
69 * Consider using {@link #getTopLevelEditor()} if you don't need injected editor.
70 * @return editor, possibly injected, where this lookup is shown
76 * @return the non-injected editor where this lookup is shown
79 Editor getTopLevelEditor();
85 * @return PSI file, possibly injected, associated with this lookup's editor
91 boolean isCompletion();
93 List<LookupElement> getItems();
98 String itemPattern(@NotNull LookupElement element);
101 PrefixMatcher itemMatcher(@NotNull LookupElement item);
103 boolean isSelectionTouched();
105 List<String> getAdvertisements();