當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。