当前位置: 首页>>代码示例>>Java>>正文


Java TailType.SEMICOLON属性代码示例

本文整理汇总了Java中com.intellij.codeInsight.TailType.SEMICOLON属性的典型用法代码示例。如果您正苦于以下问题:Java TailType.SEMICOLON属性的具体用法?Java TailType.SEMICOLON怎么用?Java TailType.SEMICOLON使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.codeInsight.TailType的用法示例。


在下文中一共展示了TailType.SEMICOLON属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaKeywordCompletion.java

示例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));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaKeywordCompletion.java

示例3: addBreakContinue

private static void addBreakContinue(Consumer<LookupElement> result, PsiElement position) {
  PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);

  LookupElement br = createKeyword(position, PsiKeyword.BREAK);
  LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
  TailType tailType;
  if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
                                  or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
                                     psiElement(PsiClassInitializer.class))).accepts(position)) {
    tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
  }
  else {
    tailType = TailType.SEMICOLON;
  }
  br = TailTypeDecorator.withTail(br, tailType);
  cont = TailTypeDecorator.withTail(cont, tailType);

  if (loop != null && PsiTreeUtil.isAncestor(loop.getBody(), position, false)) {
    result.consume(br);
    result.consume(cont);
  }
  if (psiElement().inside(PsiSwitchStatement.class).accepts(position)) {
    result.consume(br);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaKeywordCompletion.java

示例4: 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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:Java18CompletionData.java

示例5: addBreakContinue

private static void addBreakContinue(CompletionResultSet result, PsiElement position) {
  PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);

  LookupElement br = createKeyword(position, PsiKeyword.BREAK);
  LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
  TailType tailType;
  if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
                                  or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
                                     psiElement(PsiClassInitializer.class))).accepts(position)) {
    tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
  }
  else {
    tailType = TailType.SEMICOLON;
  }
  br = TailTypeDecorator.withTail(br, tailType);
  cont = TailTypeDecorator.withTail(cont, tailType);

  if (loop != null && new InsideElementFilter(new ClassFilter(PsiStatement.class)).isAcceptable(position, loop)) {
    result.addElement(br);
    result.addElement(cont);
  }
  if (psiElement().inside(PsiSwitchStatement.class).accepts(position)) {
    result.addElement(br);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:JavaCompletionData.java

示例6: 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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:DefaultInsertHandler.java

示例7: 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:DefaultInsertHandler.java

示例8: getDefaultTailType

@Nullable
public static TailType getDefaultTailType(final char completionChar) {
  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; //?
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:LookupItem.java

示例9: getTailType

protected 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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:DefaultInsertHandler.java

示例10: 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();
    }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:JavaKeywordCompletion.java

示例11: addExpressionKeywords

private void addExpressionKeywords(boolean statementPosition)
{
    if(psiElement(JavaTokenType.DOUBLE_COLON).accepts(myPrevLeaf))
    {
        PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(myPosition, PsiMethodReferenceExpression.class);
        TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
        addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.NEW), tail));
        return;
    }

    if(isExpressionPosition(myPosition))
    {
        if(PsiTreeUtil.getParentOfType(myPosition, PsiAnnotation.class) == null)
        {
            if(!statementPosition)
            {
                addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.NEW), TailType.INSERT_SPACE));
            }
            addKeyword(createKeyword(PsiKeyword.NULL));
        }
        if(mayExpectBoolean(myParameters))
        {
            addKeyword(createKeyword(PsiKeyword.TRUE));
            addKeyword(createKeyword(PsiKeyword.FALSE));
        }
    }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:JavaKeywordCompletion.java

示例12: addBreakContinue

private void addBreakContinue()
{
    PsiLoopStatement loop = PsiTreeUtil.getParentOfType(myPosition, PsiLoopStatement.class, true, PsiLambdaExpression.class, PsiMember.class);

    LookupElement br = createKeyword(PsiKeyword.BREAK);
    LookupElement cont = createKeyword(PsiKeyword.CONTINUE);
    TailType tailType;
    if(psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class), or(psiElement(PsiFile.class), psiElement(PsiMethod.class), psiElement(PsiClassInitializer.class))).accepts
            (myPosition))
    {
        tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
    }
    else
    {
        tailType = TailType.SEMICOLON;
    }
    br = TailTypeDecorator.withTail(br, tailType);
    cont = TailTypeDecorator.withTail(cont, tailType);

    if(loop != null && PsiTreeUtil.isAncestor(loop.getBody(), myPosition, false))
    {
        addKeyword(br);
        addKeyword(cont);
    }
    if(psiElement().inside(PsiSwitchStatement.class).accepts(myPosition))
    {
        addKeyword(br);
    }

    for(PsiLabeledStatement labeled : psiApi().parents(myPosition).takeWhile(notInstanceOf(PsiMember.class)).filter(PsiLabeledStatement.class))
    {
        addKeyword(TailTypeDecorator.withTail(LookupElementBuilder.create("break " + labeled.getName()).bold(), TailType.SEMICOLON));
    }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:JavaKeywordCompletion.java

示例13: insertTail

public static boolean insertTail(InsertionContext context, LookupElement item, TailType tailType, boolean hasTail)
{
    TailType toInsert = tailType;
    LookupItem<?> lookupItem = item.as(LookupItem.CLASS_CONDITION_KEY);
    if(lookupItem == null || lookupItem.getAttribute(LookupItem.TAIL_TYPE_ATTR) != TailType.UNKNOWN)
    {
        if(!hasTail && item.getObject() instanceof PsiMethod && PsiType.VOID.equals(((PsiMethod) item.getObject()).getReturnType()))
        {
            PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
            if(psiElement().beforeLeaf(psiElement().withText(".")).accepts(context.getFile().findElementAt(context.getTailOffset() - 1)))
            {
                return false;
            }

            boolean insertAdditionalSemicolon = true;
            PsiElement leaf = context.getFile().findElementAt(context.getStartOffset());
            PsiElement composite = leaf == null ? null : leaf.getParent();
            if(composite instanceof PsiMethodReferenceExpression && LambdaHighlightingUtil.insertSemicolon(composite.getParent()))
            {
                insertAdditionalSemicolon = false;
            }
            else if(composite instanceof PsiReferenceExpression)
            {
                PsiElement parent = composite.getParent();
                if(parent instanceof PsiMethodCallExpression)
                {
                    parent = parent.getParent();
                }
                if(parent instanceof PsiLambdaExpression && !LambdaHighlightingUtil.insertSemicolonAfter((PsiLambdaExpression) parent))
                {
                    insertAdditionalSemicolon = false;
                }
            }
            if(insertAdditionalSemicolon)
            {
                toInsert = TailType.SEMICOLON;
            }

        }
    }
    toInsert.processTail(context.getEditor(), context.getTailOffset());
    return true;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:43,代码来源:JavaCompletionUtil.java


注:本文中的com.intellij.codeInsight.TailType.SEMICOLON属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。