use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class JavaFXQuickfixTest method doTestWithDefaultVisibility.
private void doTestWithDefaultVisibility(final String actionName, final String inputName, final String defaultVisibility, final String extension) throws Exception {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
String savedVisibility = settings.VISIBILITY;
try {
settings.VISIBILITY = defaultVisibility;
doTest(actionName, inputName, getTestName(false), extension);
} finally {
settings.VISIBILITY = savedVisibility;
}
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class GroovyMethodSignatureInsertHandler method handleInsert.
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
if (!(item.getObject() instanceof PsiMethod)) {
return;
}
PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getEditor().getDocument());
final Editor editor = context.getEditor();
final PsiMethod method = (PsiMethod) item.getObject();
final PsiParameter[] parameters = method.getParameterList().getParameters();
final StringBuilder buffer = new StringBuilder();
final CharSequence chars = editor.getDocument().getCharsSequence();
int endOffset = editor.getCaretModel().getOffset();
final Project project = context.getProject();
int afterSharp = CharArrayUtil.shiftBackwardUntil(chars, endOffset - 1, "#") + 1;
int signatureOffset = afterSharp;
PsiElement element = context.getFile().findElementAt(signatureOffset - 1);
final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(element.getProject());
PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class);
if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) {
final PsiDocTagValue value = tag.getValueElement();
endOffset = value.getTextRange().getEndOffset();
}
editor.getDocument().deleteString(afterSharp, endOffset);
editor.getCaretModel().moveToOffset(signatureOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
buffer.append(method.getName()).append("(");
final int afterParenth = afterSharp + buffer.length();
for (int i = 0; i < parameters.length; i++) {
final PsiType type = TypeConversionUtil.erasure(parameters[i].getType());
buffer.append(type.getCanonicalText());
if (i < parameters.length - 1) {
buffer.append(",");
if (styleSettings.SPACE_AFTER_COMMA)
buffer.append(" ");
}
}
buffer.append(")");
if (!(tag instanceof PsiInlineDocTag)) {
buffer.append(" ");
} else {
final int currentOffset = editor.getCaretModel().getOffset();
if (chars.charAt(currentOffset) == '}') {
afterSharp++;
} else {
buffer.append("} ");
}
}
String insertString = buffer.toString();
EditorModificationUtil.insertStringAtCaret(editor, insertString);
editor.getCaretModel().moveToOffset(afterSharp + buffer.length());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
shortenReferences(project, editor, context, afterParenth);
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class JavaFxEventHandlerInspectionTest method testQuickfixNoFieldNested.
public void testQuickfixNoFieldNested() throws Exception {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
final boolean oldImports = settings.INSERT_INNER_CLASS_IMPORTS;
try {
settings.INSERT_INNER_CLASS_IMPORTS = true;
doQuickfixTest("Create method 'void onColumnEditStart(CellEditEvent)'");
} finally {
settings.INSERT_INNER_CLASS_IMPORTS = oldImports;
}
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class PyWrapTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
myOldWrap = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
myOldMargin = pythonSettings.RIGHT_MARGIN;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
pythonSettings.RIGHT_MARGIN = 80;
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class PyWrapTest method tearDown.
@Override
protected void tearDown() throws Exception {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myOldWrap;
pythonSettings.RIGHT_MARGIN = myOldMargin;
super.tearDown();
}
Aggregations