本文整理汇总了Java中com.intellij.psi.codeStyle.PackageEntryTable.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java PackageEntryTable.getEntries方法的具体用法?Java PackageEntryTable.getEntries怎么用?Java PackageEntryTable.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.codeStyle.PackageEntryTable
的用法示例。
在下文中一共展示了PackageEntryTable.getEntries方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLineFeedAfter
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的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());
}
}
示例2: addLineFeedAfter
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的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());
}
}
示例3: addLineFeedBefore
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedBefore(@NotNull PsiElement psiFile, @NotNull 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 prev = result.getPrevSibling();
while (PsiImplUtil.isWhiteSpaceOrNls(prev)) {
prev = prev.getPrevSibling();
}
if (PsiImplUtil.hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
if (PsiImplUtil.isWhiteSpaceOrNls(prev)) prev = prev.getPrevSibling();
if (prev instanceof GrImportStatement) {
final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
final int idx = getPackageEntryIdx(entries, result);
final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);
//skip space and semicolon after import
if (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling()) && PsiImplUtil
.hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
ASTNode node = psiFile.getNode();
while (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling())) {
node.removeChild(prev.getNextSibling().getNode());
}
node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
}
}
示例4: addLineFeedBefore
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedBefore(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 prev = result.getPrevSibling();
while (isWhiteSpace(prev)) {
prev = prev.getPrevSibling();
}
if (hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
if (isWhiteSpace(prev)) prev = prev.getPrevSibling();
if (prev instanceof GrImportStatement) {
final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
final int idx = getPackageEntryIdx(entries, result);
final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);
//skip space and semicolon after import
if (isWhiteSpace(prev.getNextSibling()) && hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
final FileASTNode node = getNode();
while (isWhiteSpace(prev.getNextSibling())) {
node.removeChild(prev.getNextSibling().getNode());
}
node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
}
}
示例5: getAnchorToInsertImportAfter
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
@Nullable
private PsiElement getAnchorToInsertImportAfter(@NotNull GroovyFile psiFile, @NotNull GrImportStatement statement) {
final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(
GroovyCodeStyleSettings.class);
final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
final PackageEntry[] entries = layoutTable.getEntries();
GrImportStatement[] importStatements = psiFile.getImportStatements();
if (importStatements.length == 0) {
final GrPackageDefinition definition = psiFile.getPackageDefinition();
if (definition != null) {
return definition;
}
return getShellComment(psiFile);
}
final Comparator<GrImportStatement> comparator = GroovyImportOptimizer.getComparator(settings);
final int idx = getPackageEntryIdx(entries, statement);
PsiElement anchor = null;
for (GrImportStatement importStatement : importStatements) {
final int i = getPackageEntryIdx(entries, importStatement);
if (i < idx) {
anchor = importStatement;
}
else if (i > idx) {
break;
}
else if (comparator.compare(statement, importStatement) > 0) {
anchor = importStatement;
}
else {
break;
}
}
if (anchor == null) anchor = psiFile.getPackageDefinition();
if (anchor == null) anchor = getShellComment(psiFile);
if (anchor == null && importStatements.length > 0) anchor = importStatements[0].getPrevSibling();
return anchor;
}
示例6: getAnchorToInsertImportAfter
import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
@Nullable
private PsiElement getAnchorToInsertImportAfter(GrImportStatement statement) {
final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(
GroovyCodeStyleSettings.class);
final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
final PackageEntry[] entries = layoutTable.getEntries();
GrImportStatement[] importStatements = getImportStatements();
if (importStatements.length == 0) {
final GrPackageDefinition definition = getPackageDefinition();
if (definition != null) {
return definition;
}
return getShellComment();
}
final Comparator<GrImportStatement> comparator = GroovyImportOptimizer.getComparator(settings);
final int idx = getPackageEntryIdx(entries, statement);
PsiElement anchor = null;
for (GrImportStatement importStatement : importStatements) {
final int i = getPackageEntryIdx(entries, importStatement);
if (i < idx) {
anchor = importStatement;
}
else if (i > idx) {
break;
}
else if (comparator.compare(statement, importStatement) > 0) {
anchor = importStatement;
}
else {
break;
}
}
if (anchor == null) anchor = getPackageDefinition();
if (anchor == null) anchor = getShellComment();
if (anchor == null && importStatements.length > 0) anchor = importStatements[0].getPrevSibling();
return anchor;
}