本文整理汇总了Java中com.intellij.psi.codeStyle.PackageEntry类的典型用法代码示例。如果您正苦于以下问题:Java PackageEntry类的具体用法?Java PackageEntry怎么用?Java PackageEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PackageEntry类属于com.intellij.psi.codeStyle包,在下文中一共展示了PackageEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeEntryFromImportLayouts
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private void removeEntryFromImportLayouts() {
int selected = myImportLayoutTable.getSelectedRow();
if (selected < 0) {
return;
}
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
myImportLayoutList.removeEntryAt(selected);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsDeleted(selected, selected);
if (selected >= myImportLayoutList.getEntryCount()) {
selected--;
}
if (selected >= 0) {
myImportLayoutTable.setRowSelectionInterval(selected, selected);
}
}
示例2: sortItemsAccordingToSettings
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
public static List<Pair<String, Boolean>> sortItemsAccordingToSettings(List<Pair<String, Boolean>> names, final CodeStyleSettings settings) {
int[] entryForName = ArrayUtil.newIntArray(names.size());
PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries();
for(int i = 0; i < names.size(); i++){
Pair<String, Boolean> pair = names.get(i);
String packageName = pair.getFirst();
Boolean isStatic = pair.getSecond();
entryForName[i] = findEntryIndex(packageName, isStatic, entries);
}
List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
for(int i = 0; i < entries.length; i++){
for(int j = 0; j < names.size(); j++){
if (entryForName[j] == i){
resultList.add(names.get(j));
names.set(j, null);
}
}
}
for (Pair<String, Boolean> name : names) {
if (name != null) resultList.add(name);
}
return resultList;
}
示例3: getEmptyLinesBetween
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
public int getEmptyLinesBetween(@NotNull PsiImportStatementBase statement1, @NotNull PsiImportStatementBase statement2){
int index1 = findEntryIndex(statement1);
int index2 = findEntryIndex(statement2);
if (index1 == index2) return 0;
if (index1 > index2) {
int t = index1;
index1 = index2;
index2 = t;
}
PackageEntry[] entries = mySettings.IMPORT_LAYOUT_TABLE.getEntries();
int maxSpace = 0;
for(int i = index1 + 1; i < index2; i++){
if (entries[i] == PackageEntry.BLANK_LINE_ENTRY){
int space = 0;
do{
space++;
} while(entries[++i] == PackageEntry.BLANK_LINE_ENTRY);
maxSpace = Math.max(maxSpace, space);
}
}
return maxSpace;
}
示例4: findEntryIndex
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private static int findEntryIndex(@NotNull String packageName, boolean isStatic, @NotNull PackageEntry[] entries) {
PackageEntry bestEntry = null;
int bestEntryIndex = -1;
int allOtherStaticIndex = -1;
int allOtherIndex = -1;
for(int i = 0; i < entries.length; i++){
PackageEntry entry = entries[i];
if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
allOtherStaticIndex = i;
}
if (entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
allOtherIndex = i;
}
if (entry.isBetterMatchForPackageThan(bestEntry, packageName, isStatic)) {
bestEntry = entry;
bestEntryIndex = i;
}
}
if (bestEntryIndex == -1 && isStatic && allOtherStaticIndex == -1 && allOtherIndex != -1) {
// if no layout for static imports specified, put them among all others
bestEntryIndex = allOtherIndex;
}
return bestEntryIndex;
}
示例5: addLineFeedAfter
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
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());
}
}
示例6: addLineFeedAfter
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
protected void addLineFeedAfter(GrImportStatement result) {
final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
final PackageEntry[] entries = layoutTable.getEntries();
PsiElement next = result.getNextSibling();
if (isWhiteSpace(next)) next = next.getNextSibling();
if (hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
while (isWhiteSpace(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);
final FileASTNode node = getNode();
while (isWhiteSpace(next.getPrevSibling())) {
node.removeChild(next.getPrevSibling().getNode());
}
node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
}
}
示例7: addPackageToImportLayouts
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
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);
}
示例8: addBlankLine
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private void addBlankLine() {
int selected = myImportLayoutTable.getSelectedRow() + 1;
if (selected < 0) {
selected = myImportLayoutList.getEntryCount();
}
myImportLayoutList.insertEntryAt(PackageEntry.BLANK_LINE_ENTRY, selected);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsInserted(selected, selected);
myImportLayoutTable.setRowSelectionInterval(selected, selected);
}
示例9: moveRowUp
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private void moveRowUp() {
int selected = myImportLayoutTable.getSelectedRow();
if (selected < 1) {
return;
}
TableUtil.stopEditing(myImportLayoutTable);
PackageEntry entry = myImportLayoutList.getEntryAt(selected);
PackageEntry previousEntry = myImportLayoutList.getEntryAt(selected - 1);
myImportLayoutList.setEntryAt(previousEntry, selected);
myImportLayoutList.setEntryAt(entry, selected - 1);
AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
model.fireTableRowsUpdated(selected - 1, selected);
myImportLayoutTable.setRowSelectionInterval(selected - 1, selected - 1);
}
示例10: moveRowDown
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
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);
}
示例11: resizeColumns
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
public static void resizeColumns(final PackageEntryTable packageTable, JBTable result, boolean areStaticImportsEnabled) {
ColoredTableCellRenderer packageRenderer = new ColoredTableCellRenderer() {
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
PackageEntry entry = packageTable.getEntryAt(row);
if (entry == PackageEntry.BLANK_LINE_ENTRY) {
append("<blank line>", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else {
TextAttributes attributes = JavaHighlightingColors.KEYWORD.getDefaultAttributes();
append("import", SimpleTextAttributes.fromTextAttributes(attributes));
if (entry.isStatic()) {
append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
append("static", SimpleTextAttributes.fromTextAttributes(attributes));
}
append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
if (entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
append("all other imports", SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
else {
append(entry.getPackageName() + ".*", SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
}
};
if (areStaticImportsEnabled) {
fixColumnWidthToHeader(result, 0);
fixColumnWidthToHeader(result, 2);
result.getColumnModel().getColumn(1).setCellRenderer(packageRenderer);
result.getColumnModel().getColumn(0).setCellRenderer(new BooleanTableCellRenderer());
result.getColumnModel().getColumn(2).setCellRenderer(new BooleanTableCellRenderer());
}
else {
fixColumnWidthToHeader(result, 1);
result.getColumnModel().getColumn(0).setCellRenderer(packageRenderer);
result.getColumnModel().getColumn(1).setCellRenderer(new BooleanTableCellRenderer());
}
}
示例12: addPackageToPackages
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private static void addPackageToPackages(JBTable table, PackageEntryTable list) {
int selected = table.getSelectedRow() + 1;
if (selected < 0) {
selected = list.getEntryCount();
}
PackageEntry entry = new PackageEntry(false, "", true);
list.insertEntryAt(entry, selected);
ImportLayoutPanel.refreshTableModel(selected, table);
}
示例13: isModified
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
private static boolean isModified(PackageEntryTable list, PackageEntryTable table) {
if (list.getEntryCount() != table.getEntryCount()) {
return true;
}
for (int i = 0; i < list.getEntryCount(); i++) {
PackageEntry entry1 = list.getEntryAt(i);
PackageEntry entry2 = table.getEntryAt(i);
if (!entry1.equals(entry2)) {
return true;
}
}
return false;
}
示例14: getAndroidImportOrder
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
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;
}
示例15: getPackageEntryIdx
import com.intellij.psi.codeStyle.PackageEntry; //导入依赖的package包/类
protected static int getPackageEntryIdx(@NotNull PackageEntry[] entries, @NotNull GrImportStatement statement) {
final GrCodeReferenceElement reference = statement.getImportReference();
if (reference == null) return -1;
final String packageName = StringUtil.getPackageName(reference.getCanonicalText());
final boolean isStatic = statement.isStatic();
int best = -1;
int allOtherStatic = -1;
int allOther = -1;
PackageEntry bestEntry = null;
for (int i = 0, length = entries.length; i < length; i++) {
PackageEntry entry = entries[i];
if (entry.isBetterMatchForPackageThan(bestEntry, packageName, isStatic)) {
best = i;
bestEntry = entry;
}
else if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
allOtherStatic = i;
}
else if (entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
allOther = i;
}
}
if (best >= 0) return best;
if (isStatic && allOtherStatic != -1) return allOtherStatic;
return allOther;
}