本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionInitializationContext类的典型用法代码示例。如果您正苦于以下问题:Java CompletionInitializationContext类的具体用法?Java CompletionInitializationContext怎么用?Java CompletionInitializationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionInitializationContext类属于com.intellij.codeInsight.completion包,在下文中一共展示了CompletionInitializationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: patternForVariableAssignment
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static ElementPattern<PsiElement> patternForVariableAssignment() {
final ElementPattern<PsiElement> patternForParent = or(psiElement().withText(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED)
.afterSiblingSkipping(psiElement(PsiWhiteSpace.class),
psiElement(PsiJavaToken.class).withText("=")));
return psiElement().withParent(patternForParent).withSuperParent(2, or(psiElement(PsiAssignmentExpression.class),
psiElement(PsiLocalVariable.class)
.inside(PsiDeclarationStatement.class)))
.inside(PsiMethod.class);
}
示例2: createInsertionContext
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
private static InsertionContext createInsertionContext(LookupElement item,
PsiFile psiFile,
List<? extends LookupElement> elements,
Editor editor, final char completionChar) {
final OffsetMap offsetMap = new OffsetMap(editor.getDocument());
final InsertionContext context = new InsertionContext(offsetMap, completionChar, elements.toArray(new LookupElement[elements.size()]), psiFile, editor, false);
context.setTailOffset(editor.getCaretModel().getOffset());
offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, context.getTailOffset() - item.getLookupString().length());
offsetMap.addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, context.getTailOffset());
offsetMap.addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, context.getTailOffset());
return context;
}
示例3: getText
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
private String getText() {
PsiElement element = PsiTreeUtil.getParentOfType(getElement(), PyFile.class);
if (element != null) {
return element.getText().replace(CompletionInitializationContext.DUMMY_IDENTIFIER, "");
}
return myPrefix;
}
示例4: setCorrectCase
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@NotNull
private String setCorrectCase() {
final PsiElement element = myContext.getFile().findElementAt(myContext.getStartOffset());
if (element == null) return DUMMY_IDENTIFIER_DECAPITALIZED;
final String text = element.getText();
if (text.isEmpty()) return DUMMY_IDENTIFIER_DECAPITALIZED;
return Character.isUpperCase(text.charAt(0)) ? CompletionInitializationContext.DUMMY_IDENTIFIER : DUMMY_IDENTIFIER_DECAPITALIZED;
}
示例5: beforeCompletion
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@Override
public void beforeCompletion(@NotNull CompletionInitializationContext context)
{
context.setDummyIdentifier(CompletionInitializationContext.DUMMY_IDENTIFIER.trim() + ";");
// final PsiFile file = context.getFile();
//
// final char c1 = file.getText().charAt(context.getStartOffset() - 1);
// if (c1 == ':' || c1 == '.') {
//
// final PsiReference e = file.findReferenceAt(context.getStartOffset() - 2);
//
// if (e != null) {
// int newStart = context.getStartOffset();
//
// if (e.getElement() instanceof LuaCompoundIdentifier) {
// LuaCompoundIdentifier c = (LuaCompoundIdentifier) e.getElement();
//
// LuaExpression s = c.getLeftSymbol();
// if (s != null)
// newStart = s.getTextOffset();
// } else {
// if (e.getElement() instanceof LuaIdentifier)
// newStart = e.getElement().getTextOffset();
// }
// context.getOffsetMap().addOffset(IDENTIFIER_START_OFFSET, newStart);
// }
// }
}
示例6: suggestKeywordsBasedOnParserExpectedKeywords
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@NotNull
private Collection<String> suggestKeywordsBasedOnParserExpectedKeywords(@NotNull PsiElement position) {
String text = getPrecedingText(position, CompletionInitializationContext.DUMMY_IDENTIFIER);
Project project = position.getProject();
PsiFile temporaryFileForCompletionCheck = createFileForText(project, text + " ");
int completionOffset = calculateCompletionOffset(position);
GeneratedParserUtilBase.CompletionState completionStateInTemporaryFile = getCompletionStateForKeywords(completionOffset);
temporaryFileForCompletionCheck.putUserData(COMPLETION_STATE_KEY, completionStateInTemporaryFile);
triggerParsingInFile(temporaryFileForCompletionCheck);
List<String> stripped = stringPrecedingText(StringUtils.normalizeWhitespaces(text), completionStateInTemporaryFile.items);
return expandMultiWordOptions(stripped);
}
示例7: beforeCompletion
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@Override
public void beforeCompletion(@NotNull CompletionInitializationContext context)
{
int offset = context.getStartOffset();
if(offset == 0 || !context.getFile().getViewProvider().getLanguages().contains(VtlLanguage.INSTANCE))
{
return;
}
final CharSequence chars = context.getEditor().getDocument().getCharsSequence();
char currChar;
do
{
currChar = chars.charAt(--offset);
}
while(offset > 0 && (Character.isLetterOrDigit(currChar) || currChar == '-' || currChar == '_'));
String dummyId;
if(currChar == '#')
{
dummyId = "dummyId()";
}
else if(currChar == '{' && offset > 0 && chars.charAt(offset - 1) == '#')
{
dummyId = "dummyId}()";
}
else
{
boolean upperCase = offset + 1 < chars.length() && Character.isUpperCase(chars.charAt(offset + 1));
dummyId = upperCase ? "DummyId" : "dummyId";
}
context.setDummyIdentifier(dummyId);
}
示例8: isSemicolonNeeded
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
private static boolean isSemicolonNeeded(@NotNull PsiFile file, @NotNull Editor editor) {
return JavaCompletionContributor.semicolonNeeded(editor, file, CompletionInitializationContext.calcStartOffset(editor.getCaretModel().getCurrentCaret()));
}
示例9: isSemicolonNeeded
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
private static boolean isSemicolonNeeded(@NotNull PsiFile file, @NotNull Editor editor) {
return JavaCompletionContributor.semicolonNeeded(editor, file, CompletionInitializationContext.calcStartOffset(editor.getCaretModel().getCurrentCaret()));
}
示例10: GrDummyIdentifierProvider
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
public GrDummyIdentifierProvider(@NotNull CompletionInitializationContext context) {
myContext = context;
}
示例11: matches
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
public boolean matches(XmlTag element) {
final String s = element.getAttributeValue("mode");
return myMode != null &&
s != null && s.indexOf(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED) == -1 &&
super.matches(element);
}
示例12: beforeCompletion
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@Override
public void beforeCompletion(@NotNull CompletionInitializationContext context)
{
context.setDummyIdentifier(CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED);
}
示例13: trimDummy
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
private static String trimDummy(String text) {
if (text.endsWith(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED)) {
text = text.substring(0, text.length() - CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED.length());
}
return text;
}
示例14: duringCompletion
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@Override
public void duringCompletion(@NotNull CompletionInitializationContext context)
{
super.duringCompletion(context);
}
示例15: beforeCompletion
import com.intellij.codeInsight.completion.CompletionInitializationContext; //导入依赖的package包/类
@Override
public void beforeCompletion(@NotNull CompletionInitializationContext context) {
overwriteDummyIdentifierToTryToCreateFunctionReference(context);
}