本文整理汇总了Java中com.intellij.codeInsight.TailType.NONE属性的典型用法代码示例。如果您正苦于以下问题:Java TailType.NONE属性的具体用法?Java TailType.NONE怎么用?Java TailType.NONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.codeInsight.TailType
的用法示例。
在下文中一共展示了TailType.NONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReturnTail
private static TailType getReturnTail(PsiElement position) {
PsiElement scope = position;
while(true){
if (scope instanceof PsiFile || scope instanceof PsiClassInitializer){
return TailType.NONE;
}
if (scope instanceof PsiMethod){
final PsiMethod method = (PsiMethod)scope;
if(method.isConstructor() || PsiType.VOID.equals(method.getReturnType())) {
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
if (scope instanceof PsiLambdaExpression) {
final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)scope));
if (PsiType.VOID.equals(returnType)) {
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
scope = scope.getParent();
}
}
示例2: addExpressionKeywords
private static void addExpressionKeywords(CompletionParameters parameters, Consumer<LookupElement> result, PsiElement position, @Nullable PsiElement prevLeaf) {
if (psiElement(JavaTokenType.DOUBLE_COLON).accepts(prevLeaf)) {
PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiMethodReferenceExpression.class);
TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), tail));
return;
}
if (isExpressionPosition(position)) {
if (PsiTreeUtil.getParentOfType(position, PsiAnnotation.class) == null) {
result.consume(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
result.consume(createKeyword(position, PsiKeyword.NULL));
}
if (mayExpectBoolean(parameters)) {
result.consume(createKeyword(position, PsiKeyword.TRUE));
result.consume(createKeyword(position, PsiKeyword.FALSE));
}
}
}
示例3: addLookupItem
protected void addLookupItem(Set<LookupElement> set, TailType tailType, @NotNull Object completion, final CompletionVariant variant) {
LookupElement ret = objectToLookupItem(completion);
if (ret == null) return;
if (!(ret instanceof LookupItem)) {
set.add(ret);
return;
}
LookupItem item = (LookupItem)ret;
final InsertHandler insertHandler = variant.getInsertHandler();
if(insertHandler != null && item.getInsertHandler() == null) {
item.setInsertHandler(insertHandler);
item.setTailType(TailType.UNKNOWN);
}
else if (tailType != TailType.NONE) {
item.setTailType(tailType);
}
final Map<Object, Object> itemProperties = variant.getItemProperties();
for (final Object key : itemProperties.keySet()) {
item.setAttribute(key, itemProperties.get(key));
}
set.add(ret);
}
示例4: handleCompletionChar
@NotNull
public static TailType handleCompletionChar(@NotNull final Editor editor, @NotNull final LookupElement lookupElement, final char completionChar) {
final TailType type = getDefaultTailType(completionChar);
if (type != null) {
return type;
}
if (lookupElement instanceof LookupItem) {
final LookupItem<?> item = (LookupItem)lookupElement;
final TailType attr = item.getAttribute(TAIL_TYPE_ATTR);
if (attr != null) {
return attr;
}
}
return TailType.NONE;
}
示例5: fillCompletions
@Override
public void fillCompletions(final CompletionParameters parameters, final CompletionResultSet result) {
PsiElement position = parameters.getPosition();
if (!inComment(position)) {
if (AFTER_DOUBLE_COLON.accepts(position)) {
PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiMethodReferenceExpression.class);
TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), tail));
return;
}
if (isSuitableForClass(position)) {
PsiElement scope = position.getParent();
while (scope != null && !(scope instanceof PsiFile)) {
if (scope instanceof PsiClass && ((PsiClass)scope).isInterface()) {
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.DEFAULT), TailType.HUMBLE_SPACE_BEFORE_WORD));
break;
}
scope = scope.getParent();
}
}
}
super.fillCompletions(parameters, result);
}
示例6: addStatementKeywords
private static void addStatementKeywords(CompletionResultSet variant, PsiElement position) {
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.SWITCH), TailTypes.SWITCH_LPARENTH));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.WHILE), TailTypes.WHILE_LPARENTH));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.DO), TailTypes.DO_LBRACE));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.FOR), TailTypes.FOR_LPARENTH));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.IF), TailTypes.IF_LPARENTH));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.TRY), TailTypes.TRY_LBRACE));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.THROW), TailType.INSERT_SPACE));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.SYNCHRONIZED), TailTypes.SYNCHRONIZED_LPARENTH));
if (PsiUtil.getLanguageLevel(position).isAtLeast(LanguageLevel.JDK_1_4)) {
variant.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.ASSERT), TailType.INSERT_SPACE));
}
TailType returnTail = getReturnTail(position);
LookupElement ret = createKeyword(position, PsiKeyword.RETURN);
if (returnTail != TailType.NONE) {
ret = new OverrideableSpace(ret, returnTail);
}
variant.addElement(ret);
}
示例7: addLookupItem
protected void addLookupItem(Set<LookupElement> set, TailType tailType, @NotNull Object completion, final PsiFile file,
final CompletionVariant variant) {
LookupElement ret = objectToLookupItem(completion);
if (ret == null) return;
if (!(ret instanceof LookupItem)) {
set.add(ret);
return;
}
LookupItem item = (LookupItem)ret;
final InsertHandler insertHandler = variant.getInsertHandler();
if(insertHandler != null && item.getInsertHandler() == null) {
item.setInsertHandler(insertHandler);
item.setTailType(TailType.UNKNOWN);
}
else if (tailType != TailType.NONE) {
item.setTailType(tailType);
}
final Map<Object, Object> itemProperties = variant.getItemProperties();
for (final Object key : itemProperties.keySet()) {
item.setAttribute(key, itemProperties.get(key));
}
set.add(ret);
}
示例8: handleCompletionChar
@NotNull
public static TailType handleCompletionChar(@NotNull final Editor editor, @NotNull final LookupElement lookupElement, final char completionChar) {
final TailType type = getDefaultTailType(completionChar);
if (type != null) {
return type;
}
if (lookupElement instanceof LookupItem) {
final LookupItem<?> item = (LookupItem)lookupElement;
final TailType attr = item.getAttribute(CompletionUtil.TAIL_TYPE_ATTR);
if (attr != null) {
return attr;
}
}
return TailType.NONE;
}
示例9: addLookupItem
protected void addLookupItem(Set<LookupElement> set, TailType tailType, @Nonnull Object completion, final CompletionVariant variant) {
LookupElement ret = objectToLookupItem(completion);
if (ret == null) return;
if (!(ret instanceof LookupItem)) {
set.add(ret);
return;
}
LookupItem item = (LookupItem)ret;
final InsertHandler insertHandler = variant.getInsertHandler();
if(insertHandler != null && item.getInsertHandler() == null) {
item.setInsertHandler(insertHandler);
item.setTailType(TailType.UNKNOWN);
}
else if (tailType != TailType.NONE) {
item.setTailType(tailType);
}
final Map<Object, Object> itemProperties = variant.getItemProperties();
for (final Object key : itemProperties.keySet()) {
item.setAttribute(key, itemProperties.get(key));
}
set.add(ret);
}
示例10: handleCompletionChar
@Nonnull
public static TailType handleCompletionChar(@Nonnull final Editor editor, @Nonnull final LookupElement lookupElement, final char completionChar) {
final TailType type = getDefaultTailType(completionChar);
if (type != null) {
return type;
}
if (lookupElement instanceof LookupItem) {
final LookupItem<?> item = (LookupItem)lookupElement;
final TailType attr = item.getAttribute(CompletionUtil.TAIL_TYPE_ATTR);
if (attr != null) {
return attr;
}
}
return TailType.NONE;
}
示例11: getTailType
private static TailType getTailType(final char completionChar, LookupItem item)
{
switch(completionChar)
{
case '.':
return new CharTailType('.', false);
case ',':
return TailType.COMMA;
case ';':
return TailType.SEMICOLON;
case '=':
return TailType.EQ;
case ' ':
return TailType.SPACE;
case ':':
return TailType.CASE_COLON; //?
case '<':
case '>':
case '\"':
}
final TailType attr = item.getTailType();
return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
示例12: getParenthesizedCastExpectationByOperandType
@Nullable
static ExpectedTypeInfo getParenthesizedCastExpectationByOperandType(PsiElement position)
{
PsiElement parenthesisOwner = getParenthesisOwner(position);
PsiExpression operand = getCastedExpression(parenthesisOwner);
if(operand == null || !(parenthesisOwner.getParent() instanceof PsiParenthesizedExpression))
{
return null;
}
PsiType dfaType = GuessManager.getInstance(operand.getProject()).getControlFlowExpressionType(operand);
if(dfaType != null)
{
return new ExpectedTypeInfoImpl(dfaType, ExpectedTypeInfo.TYPE_OR_SUPERTYPE, dfaType, TailType.NONE, null, () -> null);
}
PsiType type = operand.getType();
return type == null || type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? null : new ExpectedTypeInfoImpl(type, ExpectedTypeInfo.TYPE_OR_SUBTYPE, type, TailType.NONE, null, () -> null);
}
示例13: getTailType
private static TailType getTailType(final char completionChar, LookupItem item){
switch(completionChar){
case '.': return new CharTailType('.', false);
case ',': return TailType.COMMA;
case ';': return TailType.SEMICOLON;
case '=': return TailType.EQ;
case ' ': return TailType.SPACE;
case ':': return TailType.CASE_COLON; //?
case '<':
case '>':
case '\"':
}
final TailType attr = item.getTailType();
return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
示例14: addStatementKeywords
private static void addStatementKeywords(Consumer<LookupElement> variant, PsiElement position, @Nullable PsiElement prevLeaf) {
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.SWITCH), TailTypes.SWITCH_LPARENTH));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.WHILE), TailTypes.WHILE_LPARENTH));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.DO), TailTypes.DO_LBRACE));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.FOR), TailTypes.FOR_LPARENTH));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.IF), TailTypes.IF_LPARENTH));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.TRY), TailTypes.TRY_LBRACE));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.THROW), TailType.INSERT_SPACE));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.SYNCHRONIZED), TailTypes.SYNCHRONIZED_LPARENTH));
if (PsiUtil.getLanguageLevel(position).isAtLeast(LanguageLevel.JDK_1_4)) {
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ASSERT), TailType.INSERT_SPACE));
}
TailType returnTail = getReturnTail(position);
LookupElement ret = createKeyword(position, PsiKeyword.RETURN);
if (returnTail != TailType.NONE) {
ret = new OverrideableSpace(ret, returnTail);
}
variant.consume(ret);
if (psiElement().withText(";").withSuperParent(2, PsiIfStatement.class).accepts(prevLeaf) ||
psiElement().withText("}").withSuperParent(3, PsiIfStatement.class).accepts(prevLeaf)) {
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.ELSE), TailType.HUMBLE_SPACE_BEFORE_WORD));
}
if (psiElement().withText("}").withParent(psiElement(PsiCodeBlock.class).withParent(or(psiElement(PsiTryStatement.class), psiElement(PsiCatchSection.class)))).accepts(prevLeaf)) {
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.CATCH), TailTypes.CATCH_LPARENTH));
variant.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.FINALLY), TailTypes.FINALLY_LBRACE));
}
}
示例15: objectToLookupItem
public static LookupElement objectToLookupItem(final @NotNull Object object) {
if (object instanceof LookupElement) return (LookupElement)object;
String s = null;
TailType tailType = TailType.NONE;
if (object instanceof PsiElement){
s = PsiUtilCore.getName((PsiElement)object);
}
else if (object instanceof PsiMetaData) {
s = ((PsiMetaData)object).getName();
}
else if (object instanceof String) {
s = (String)object;
}
else if (object instanceof Template) {
s = ((Template) object).getKey();
}
else if (object instanceof PresentableLookupValue) {
s = ((PresentableLookupValue)object).getPresentation();
}
if (s == null) {
throw new AssertionError("Null string for object: " + object + " of class " + object.getClass());
}
LookupItem item = new LookupItem(object, s);
if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
item.setAttribute(LookupItem.TAIL_TYPE_ATTR, tailType);
return item;
}