本文整理汇总了Java中com.intellij.psi.codeStyle.PackageEntry.isBetterMatchForPackageThan方法的典型用法代码示例。如果您正苦于以下问题:Java PackageEntry.isBetterMatchForPackageThan方法的具体用法?Java PackageEntry.isBetterMatchForPackageThan怎么用?Java PackageEntry.isBetterMatchForPackageThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.codeStyle.PackageEntry
的用法示例。
在下文中一共展示了PackageEntry.isBetterMatchForPackageThan方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: getPackageEntryIdx
import com.intellij.psi.codeStyle.PackageEntry; //导入方法依赖的package包/类
protected static int getPackageEntryIdx(PackageEntry[] entries, 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;
}
示例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;
}