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


Java CodeInsightSettings类代码示例

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


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

示例1: insertClosingTagIfNecessary

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
/**
 * Checks if it's necessary to insert closing tag on typed character.
 * 
 * @param c         typed symbol
 * @param project   current project
 * @param editor    current editor
 * @param file      current file
 * @return          <code>true</code> if closing tag is inserted; <code>false</code> otherwise
 */
private static boolean insertClosingTagIfNecessary(char c, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  if (c != CLOSE_TAG_SYMBOL || !CodeInsightSettings.getInstance().JAVADOC_GENERATE_CLOSING_TAG) {
    return false;
  }

  PsiDocumentManager.getInstance(project).commitAllDocuments();

  if (!isAppropriatePlace(editor, file)) {
    return false;
  }

  // Inspect symbols to the left of the current caret position, insert closing tag only if valid tag is just typed
  // (e.g. don't insert anything on single '>' symbol typing).
  int offset = editor.getCaretModel().getOffset();
  Document document = editor.getDocument();
  String tagName = getTagName(document.getText(), offset);
  if (tagName == null || HtmlUtil.isSingleHtmlTag(tagName) || tagName.startsWith(COMMENT_PREFIX)) {
    return false;
  }

  document.insertString(offset, String.valueOf(START_TAG_SYMBOL) + SLASH + tagName + CLOSE_TAG_SYMBOL);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:JavadocTypedHandler.java

示例2: reset

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void reset() {
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
  DaemonCodeAnalyzerSettings daemonSettings = DaemonCodeAnalyzerSettings.getInstance();

  switch (codeInsightSettings.ADD_IMPORTS_ON_PASTE) {
    case CodeInsightSettings.YES:
      mySmartPasteCombo.setSelectedItem(INSERT_IMPORTS_ALWAYS);
      break;

    case CodeInsightSettings.NO:
      mySmartPasteCombo.setSelectedItem(INSERT_IMPORTS_NONE);
      break;

    case CodeInsightSettings.ASK:
      mySmartPasteCombo.setSelectedItem(INSERT_IMPORTS_ASK);
      break;
  }


  myCbShowImportPopup.setSelected(daemonSettings.isImportHintEnabled());
  myCbOptimizeImports.setSelected(codeInsightSettings.OPTIMIZE_IMPORTS_ON_THE_FLY);
  myCbAddUnambiguousImports.setSelected(codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY);

  myExcludePackagesTable.reset();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaAutoImportOptions.java

示例3: doTest

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
private void doTest(final char c) {
  boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION;
  if (c != Lookup.NORMAL_SELECT_CHAR) {
    CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = false;
  }

  try {
    configureByTestName();
    if (myItems != null) {
      select(c);
    }
    checkResultByTestName();
  }
  finally {
    if (c != Lookup.NORMAL_SELECT_CHAR) {
      CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = old;
    }
  }

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

示例4: testAutoImportAfterUncomment

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testAutoImportAfterUncomment() throws Throwable {
  @NonNls String text = "class S { /*ArrayList l; HashMap h; <caret>*/ }";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    doHighlighting();

    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());

    CommentByBlockCommentAction action = new CommentByBlockCommentAction();
    action.actionPerformedImpl(getProject(), getEditor());

    assertEmpty(highlightErrors());

    assertNotSame(0, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements().length);
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ImportHelperTest.java

示例5: testAutoOptimizeUnresolvedImports

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testAutoOptimizeUnresolvedImports() throws Throwable {
  @NonNls String text = "import xxx.yyy; class S { } <caret> ";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();

    assertEquals(1, errs.size());

    assertEquals(1, ((PsiJavaFile)getFile()).getImportList().getAllImportStatements().length);

    type("/* */");
    doHighlighting();
    UIUtil.dispatchAllInvocationEvents();

    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());
  }
  finally {
     CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = old;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ImportHelperTest.java

示例6: testAutoInsertImportForInnerClass

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testAutoInsertImportForInnerClass() throws Throwable {
  @NonNls String text = "package x; class S { void f(ReadLock r){} } <caret> ";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();
    assertEquals(1, errs.size());

    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());
    type("/* */");
    doHighlighting();
    UIUtil.dispatchAllInvocationEvents();
    assertEmpty(((PsiJavaFile)getFile()).getImportList().getAllImportStatements());
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ImportHelperTest.java

示例7: testAutoImportSkipsClassReferenceInMethodPosition

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testAutoImportSkipsClassReferenceInMethodPosition() throws Throwable {
  @NonNls String text = "package x; import java.util.HashMap; class S { HashMap<String,String> f(){ return  Hash<caret>Map <String, String >();} }  ";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();
    assertTrue(errs.size() > 1);

    PsiJavaFile javaFile = (PsiJavaFile)getFile();
    assertEquals(1, javaFile.getImportList().getAllImportStatements().length);

    PsiReference ref = javaFile.findReferenceAt(getEditor().getCaretModel().getOffset());
    ImportClassFix fix = new ImportClassFix((PsiJavaCodeReferenceElement)ref);
    assertFalse(fix.isAvailable(getProject(), getEditor(), getFile()));
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ImportHelperTest.java

示例8: testAutoImportDoNotBreakCode

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testAutoImportDoNotBreakCode() throws Throwable {
  @NonNls String text = "package x; class S {{ S.<caret>\n Runnable r; }}";
  configureByText(StdFileTypes.JAVA, text);

  boolean old = CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
  boolean opt = CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY;
  CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
  CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = true;
  DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);

  try {
    List<HighlightInfo> errs = highlightErrors();
    assertEquals(1, errs.size());
  }
  finally {
     CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old;
     CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = opt;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ImportHelperTest.java

示例9: doAction

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
@Override
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
  throws Exception {
  boolean old = CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY;

  try {
    CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = false;
    IntentionAction action = findActionWithText(text);
    if (action == null && actionShouldBeAvailable) {
      fail("Action with text '" + text + "' is not available in test " + testFullPath);
    }
    if (action != null && actionShouldBeAvailable) {
      action.invoke(getProject(), getEditor(), getFile());
      assertTrue(CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY);
    }
  }
  finally {
    CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY = old;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:EnableOptimizeImportsOnTheFlyTest.java

示例10: createMatcher

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
private MinusculeMatcher createMatcher(final boolean caseSensitive) {
  String prefix = applyMiddleMatching(myPrefix);

  if (!caseSensitive) {
    return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
  }

  switch (CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
    case CodeInsightSettings.NONE:
      return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
    case CodeInsightSettings.FIRST_LETTER:
      return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.FIRST_LETTER);
    default:
      return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.ALL);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CamelHumpMatcher.java

示例11: acceptChar

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
@Override
public Result acceptChar(char c, int prefixLength, Lookup lookup) {
  LookupElement item = lookup.getCurrentItem();
  if (item instanceof LiveTemplateLookupElement && lookup.isCompletion()) {
    if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;

    if (c == ((LiveTemplateLookupElement)item).getTemplateShortcut()) {
      return Result.SELECT_ITEM_AND_FINISH_LOOKUP;
    }
    return Result.HIDE_LOOKUP;
  }
  if (item instanceof TemplateExpressionLookupElement) {
    if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;
    if (CodeInsightSettings.getInstance().SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS) {
      return null;
    }
    return Result.HIDE_LOOKUP;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:LiveTemplateCharFilter.java

示例12: apply

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
  EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

  editorSettings.setSmartHome(myCbSmartHome.isSelected());
  codeInsightSettings.SMART_END_ACTION = myCbSmartEnd.isSelected();
  codeInsightSettings.SMART_INDENT_ON_ENTER = myCbSmartIndentOnEnter.isSelected();
  codeInsightSettings.INSERT_BRACE_ON_ENTER = myCbInsertPairCurlyBraceOnEnter.isSelected();
  codeInsightSettings.JAVADOC_STUB_ON_ENTER = myCbInsertJavadocStubOnEnter.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_BRACKET = myCbInsertPairBracket.isSelected();
  codeInsightSettings.AUTOINSERT_PAIR_QUOTE = myCbInsertPairQuote.isSelected();
  codeInsightSettings.REFORMAT_BLOCK_ON_RBRACE = myCbReformatBlockOnTypingRBrace.isSelected();
  codeInsightSettings.SURROUND_SELECTION_ON_QUOTE_TYPED = myCbSurroundSelectionOnTyping.isSelected();
  editorSettings.setCamelWords(myCbCamelWords.isSelected());
  codeInsightSettings.REFORMAT_ON_PASTE = getReformatPastedBlockValue();
  codeInsightSettings.setBackspaceMode(getSmartBackspaceModeValue());

  super.apply();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:EditorSmartKeysConfigurable.java

示例13: getReformatPastedBlockValue

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
private int getReformatPastedBlockValue(){
  Object selectedItem = myReformatOnPasteCombo.getSelectedItem();
  if (NO_REFORMAT.equals(selectedItem)){
    return CodeInsightSettings.NO_REFORMAT;
  }
  else if (INDENT_BLOCK.equals(selectedItem)){
    return CodeInsightSettings.INDENT_BLOCK;
  }
  else if (INDENT_EACH_LINE.equals(selectedItem)){
    return CodeInsightSettings.INDENT_EACH_LINE;
  }
  else if (REFORMAT_BLOCK.equals(selectedItem)){
    return CodeInsightSettings.REFORMAT_BLOCK;
  }
  else{
    LOG.assertTrue(false);
    return -1;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EditorSmartKeysConfigurable.java

示例14: apply

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void apply() {

    CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();

    codeInsightSettings.COMPLETION_CASE_SENSITIVE = getCaseSensitiveValue();

    codeInsightSettings.SELECT_AUTOPOPUP_SUGGESTIONS_BY_CHARS = myCbSelectByChars.isSelected();
    codeInsightSettings.AUTOCOMPLETE_ON_CODE_COMPLETION = myCbOnCodeCompletion.isSelected();
    codeInsightSettings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = myCbOnSmartTypeCompletion.isSelected();
    codeInsightSettings.SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = myCbShowFullParameterSignatures.isSelected();

    codeInsightSettings.AUTO_POPUP_PARAMETER_INFO = myCbParameterInfoPopup.isSelected();
    codeInsightSettings.AUTO_POPUP_COMPLETION_LOOKUP = myCbAutocompletion.isSelected();
    codeInsightSettings.AUTO_POPUP_JAVADOC_INFO = myCbAutopopupJavaDoc.isSelected();

    codeInsightSettings.PARAMETER_INFO_DELAY = getIntegerValue(myParameterInfoDelayField.getText(), 0);
    codeInsightSettings.JAVADOC_INFO_DELAY = getIntegerValue(myAutopopupJavaDocField.getText(), 0);
    
    UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = myCbSorting.isSelected();

    final Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
    if (project != null){
      DaemonCodeAnalyzer.getInstance(project).settingsChanged();
    }
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CodeCompletionPanel.java

示例15: testDocTypeRType

import com.intellij.codeInsight.CodeInsightSettings; //导入依赖的package包/类
public void testDocTypeRType() {
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
  boolean oldStubOnEnter = codeInsightSettings.JAVADOC_STUB_ON_ENTER;
  codeInsightSettings.JAVADOC_STUB_ON_ENTER = true;
  PyCodeInsightSettings pyCodeInsightSettings = PyCodeInsightSettings.getInstance();
  boolean oldInsertType = pyCodeInsightSettings.INSERT_TYPE_DOCSTUB;
  pyCodeInsightSettings.INSERT_TYPE_DOCSTUB = true;
  PyDocumentationSettings documentationSettings = PyDocumentationSettings.getInstance(myFixture.getModule());
  documentationSettings.setFormat(DocStringFormat.EPYTEXT);
  try {
    doTest();
  }
  finally {
    documentationSettings.setFormat(DocStringFormat.PLAIN);
    codeInsightSettings.JAVADOC_STUB_ON_ENTER = oldStubOnEnter;
    pyCodeInsightSettings.INSERT_TYPE_DOCSTUB = oldInsertType;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PySmartEnterTest.java


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