use of com.intellij.psi.codeStyle.PackageEntry in project intellij-community by JetBrains.
the class ImportLayoutPanel method addPackageToImportLayouts.
private void addPackageToImportLayouts() {
int selected = myImportLayoutTable.getSelectedRow() + 1;
if (selected < 0) {
selected = myImportLayoutList.getEntryCount();
}
PackageEntry entry = new PackageEntry(false, "", true);
myImportLayoutList.insertEntryAt(entry, selected);
refreshTableModel(selected, myImportLayoutTable);
}
use of com.intellij.psi.codeStyle.PackageEntry in project intellij-community by JetBrains.
the class ImportLayoutPanel method moveRowDown.
private void moveRowDown() {
int selected = myImportLayoutTable.getSelectedRow();
if (selected >= myImportLayoutList.getEntryCount() - 1) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
PackageEntry nextEntry = myImportLayoutList.getEntryAt(selected + 1);
myImportLayoutList.setEntryAt(nextEntry, selected);
myImportLayoutList.setEntryAt(entry, selected + 1);
AbstractTableModel model = (AbstractTableModel) myImportLayoutTable.getModel();
model.fireTableRowsUpdated(selected, selected + 1);
myImportLayoutTable.setRowSelectionInterval(selected + 1, selected + 1);
}
use of com.intellij.psi.codeStyle.PackageEntry in project intellij-community by JetBrains.
the class GroovyCodeStyleManagerImpl method addLineFeedAfter.
protected void addLineFeedAfter(@NotNull PsiElement psiFile, GrImportStatement result) {
final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
final PackageEntry[] entries = layoutTable.getEntries();
PsiElement next = result.getNextSibling();
if (PsiImplUtil.isWhiteSpaceOrNls(next))
next = next.getNextSibling();
if (PsiImplUtil.hasElementType(next, GroovyTokenTypes.mSEMI))
next = next.getNextSibling();
while (PsiImplUtil.isWhiteSpaceOrNls(next)) {
next = next.getNextSibling();
}
if (next instanceof GrImportStatement) {
final int idx_after = getPackageEntryIdx(entries, (GrImportStatement) next);
final int idx = getPackageEntryIdx(entries, result);
final int spaceCount = getMaxSpaceCount(entries, idx, idx_after);
ASTNode node = psiFile.getNode();
while (PsiImplUtil.isWhiteSpaceOrNls(next.getPrevSibling())) {
node.removeChild(next.getPrevSibling().getNode());
}
node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
}
}
use of com.intellij.psi.codeStyle.PackageEntry in project android by JetBrains.
the class AndroidCodeStyleSettingsModifier method getAndroidImportOrder.
private static PackageEntryTable getAndroidImportOrder() {
PackageEntryTable table = new PackageEntryTable();
// From http://s.android.com/source/code-style.html, the order should be:
// 1. Android imports
// 2. Imports from 3rd parties (com, junit, net, org)
// 3. java and javax
table.addEntry(new PackageEntry(false, "android", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "com", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "junit", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "net", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "org", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "java", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
table.addEntry(new PackageEntry(false, "javax", true));
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
// handle any other conditions
table.addEntry(PackageEntry.ALL_OTHER_IMPORTS_ENTRY);
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
// location of static imports is not defined, we put it last
table.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY);
table.addEntry(PackageEntry.BLANK_LINE_ENTRY);
return table;
}
Aggregations