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


Java TailTypes类代码示例

本文整理汇总了Java中com.intellij.codeInsight.TailTypes的典型用法代码示例。如果您正苦于以下问题:Java TailTypes类的具体用法?Java TailTypes怎么用?Java TailTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TailTypes类属于com.intellij.codeInsight包,在下文中一共展示了TailTypes类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addStatementKeywords

import com.intellij.codeInsight.TailTypes; //导入依赖的package包/类
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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:JavaCompletionData.java

示例2: addStatementKeywords

import com.intellij.codeInsight.TailTypes; //导入依赖的package包/类
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));
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:JavaKeywordCompletion.java

示例3: registerControlCompletion

import com.intellij.codeInsight.TailTypes; //导入依赖的package包/类
private static void registerControlCompletion(PsiElement context, CompletionResultSet result) {
  if (isControlStructure(context)) {
    result.addElement(keyword(PsiKeyword.TRY, TailTypes.TRY_LBRACE));
    result.addElement(keyword(PsiKeyword.WHILE, TailTypes.WHILE_LPARENTH));
    result.addElement(keyword(PsiKeyword.SWITCH, TailTypes.SWITCH_LPARENTH));
    result.addElement(keyword(PsiKeyword.FOR, TailTypes.FOR_LPARENTH));
    result.addElement(keyword(PsiKeyword.THROW, TailType.HUMBLE_SPACE_BEFORE_WORD));
    result.addElement(keyword(PsiKeyword.ASSERT, TailType.HUMBLE_SPACE_BEFORE_WORD));
    result.addElement(keyword(PsiKeyword.SYNCHRONIZED, TailTypes.SYNCHRONIZED_LPARENTH));
    result.addElement(keyword(PsiKeyword.RETURN, hasReturnValue(context) ? TailType.HUMBLE_SPACE_BEFORE_WORD : TailType.NONE));
  }
  if (inCaseSection(context)) {
    result.addElement(keyword("case", TailType.HUMBLE_SPACE_BEFORE_WORD));
    result.addElement(keyword("default", TailType.CASE_COLON));
  }
  if (afterTry(context)) {
    result.addElement(keyword(PsiKeyword.CATCH, TailTypes.CATCH_LPARENTH));
    result.addElement(keyword(PsiKeyword.FINALLY, TailTypes.FINALLY_LBRACE));
  }
  if (afterIfOrElse(context)) {
    result.addElement(keyword(PsiKeyword.ELSE, TailType.HUMBLE_SPACE_BEFORE_WORD));
  }

  if (isCommandCallWithOneArg(context)) {
    result.addElement(keyword(PsiKeyword.ASSERT, TailType.HUMBLE_SPACE_BEFORE_WORD));
    if (hasReturnValue(context)) {
      result.addElement(keyword(PsiKeyword.RETURN, TailType.HUMBLE_SPACE_BEFORE_WORD));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:GroovyCompletionData.java

示例4: addStatementKeywords

import com.intellij.codeInsight.TailTypes; //导入依赖的package包/类
private void addStatementKeywords()
{
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.SWITCH), TailTypes.SWITCH_LPARENTH));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.WHILE), TailTypes.WHILE_LPARENTH));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.DO), TailTypes.DO_LBRACE));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.FOR), TailTypes.FOR_LPARENTH));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.IF), TailTypes.IF_LPARENTH));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.TRY), TailTypes.TRY_LBRACE));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.THROW), TailType.INSERT_SPACE));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.NEW), TailType.INSERT_SPACE));
	addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.SYNCHRONIZED), TailTypes.SYNCHRONIZED_LPARENTH));

	if(PsiUtil.getLanguageLevel(myPosition).isAtLeast(LanguageLevel.JDK_1_4))
	{
		addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.ASSERT), TailType.INSERT_SPACE));
	}

	TailType returnTail = getReturnTail(myPosition);
	LookupElement ret = createKeyword(PsiKeyword.RETURN);
	if(returnTail != TailType.NONE)
	{
		ret = new OverrideableSpace(ret, returnTail);
	}
	addKeyword(ret);

	if(psiElement().withText(";").withSuperParent(2, PsiIfStatement.class).accepts(myPrevLeaf) || psiElement().withText("}").withSuperParent(3, PsiIfStatement.class).accepts(myPrevLeaf))
	{
		addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.ELSE), TailType.HUMBLE_SPACE_BEFORE_WORD));
	}

	if(psiElement().withText("}").withParent(psiElement(PsiCodeBlock.class).withParent(or(psiElement(PsiTryStatement.class), psiElement(PsiCatchSection.class)))).accepts(myPrevLeaf))
	{
		addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.CATCH), TailTypes.CATCH_LPARENTH));
		addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.FINALLY), TailTypes.FINALLY_LBRACE));
	}

}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:38,代码来源:JavaKeywordCompletion.java

示例5: handleParentheses

import com.intellij.codeInsight.TailTypes; //导入依赖的package包/类
private static void handleParentheses(final boolean hasParams, final boolean needParenth, TailType tailType, InsertionContext context, InsertHandlerState myState){
  final Document document = context.getEditor().getDocument();
  boolean insertRightParenth = context.getCompletionChar() != Lookup.COMPLETE_STATEMENT_SELECT_CHAR;

  if (needParenth){
    if (context.getOffsetMap().getOffset(JavaCompletionUtil.LPAREN_OFFSET) >= 0 && context.getOffsetMap().getOffset(JavaCompletionUtil.ARG_LIST_END_OFFSET) >= 0){
      myState.tailOffset = context.getOffsetMap().getOffset(JavaCompletionUtil.ARG_LIST_END_OFFSET);
      if (context.getOffsetMap().getOffset(JavaCompletionUtil.RPAREN_OFFSET) < 0 && insertRightParenth){
        document.insertString(myState.tailOffset, ")");
        myState.tailOffset += 1;
      }
      if (hasParams){
        myState.caretOffset = context.getOffsetMap().getOffset(JavaCompletionUtil.LPAREN_OFFSET) + 1;
      }
      else{
        myState.caretOffset = context.getOffsetMap().getOffset(JavaCompletionUtil.ARG_LIST_END_OFFSET);
      }
    }
    else{
      final CommonCodeStyleSettings styleSettings = context.getCodeStyleSettings();
      myState.tailOffset = context.getSelectionEndOffset();
      myState.caretOffset = context.getSelectionEndOffset();

      if(styleSettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES){
        document.insertString(myState.tailOffset++, " ");
        myState.caretOffset ++;
      }
      if (insertRightParenth) {
        final CharSequence charsSequence = document.getCharsSequence();
        if (charsSequence.length() <= myState.tailOffset || charsSequence.charAt(myState.tailOffset) != '(') {
          document.insertString(myState.tailOffset, "(");
        }

        document.insertString(myState.tailOffset + 1, ")");
        if (hasParams){
          myState.tailOffset += 2;
          myState.caretOffset++;
        }
        else{
          if (tailType != TailTypes.CALL_RPARENTH) {
            myState.tailOffset += 2;
            myState.caretOffset += 2;
          }
          else {
            myState.tailOffset++;
            myState.caretOffset++;
          }
        }
      }
      else{
        document.insertString(myState.tailOffset++, "(");
        myState.caretOffset ++;
      }

      if(hasParams && styleSettings.SPACE_WITHIN_METHOD_CALL_PARENTHESES){
        document.insertString(myState.caretOffset++, " ");
        myState.tailOffset++;
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:DefaultInsertHandler.java


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