本文整理汇总了Java中com.intellij.util.ArrayUtil.swap方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.swap方法的具体用法?Java ArrayUtil.swap怎么用?Java ArrayUtil.swap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.swap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerSwapFixes
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static void registerSwapFixes(final PsiExpression[] expressions, final PsiCall callExpression, final List<PsiCall> permutations,
MethodCandidateInfo candidate, final int incompatibilitiesCount, final int minIncompatibleIndex,
final int maxIncompatibleIndex) throws IncorrectOperationException {
PsiMethod method = candidate.getElement();
PsiSubstitutor substitutor = candidate.getSubstitutor();
if (incompatibilitiesCount >= 3) return; // no way we can fix it by swapping
for (int i = minIncompatibleIndex; i < maxIncompatibleIndex; i++) {
for (int j = i+1; j <= maxIncompatibleIndex; j++) {
ArrayUtil.swap(expressions, i, j);
if (PsiUtil.isApplicable(method, substitutor, expressions)) {
PsiCall copy = (PsiCall)callExpression.copy();
PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
copyExpressions[i].replace(expressions[i]);
copyExpressions[j].replace(expressions[j]);
JavaResolveResult result = copy.resolveMethodGenerics();
if (result.getElement() != null && result.isValidResult()) {
permutations.add(copy);
if (permutations.size() > 1) return;
}
}
ArrayUtil.swap(expressions, i, j);
}
}
}
示例2: suggestNames
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
protected String[] suggestNames(boolean replaceAll, PsiVariable variable) {
final PsiType defaultType = getType();
final String propertyName = variable != null
? JavaCodeStyleManager.getInstance(myProject).variableNameToPropertyName(variable.getName(), VariableKind.LOCAL_VARIABLE)
: null;
final String[] names = suggestNames(defaultType, propertyName);
if (propertyName != null && names.length > 1) {
final JavaCodeStyleManager javaCodeStyleManager = JavaCodeStyleManager.getInstance(myProject);
final String paramName = javaCodeStyleManager.propertyNameToVariableName(propertyName, getVariableKind());
final int idx = ArrayUtil.find(names, paramName);
if (idx > -1) {
ArrayUtil.swap(names, 0, idx);
}
}
return names;
}
示例3: moveupLibrariesFromMavenPlugin
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static OrderEntry[] moveupLibrariesFromMavenPlugin(ModuleRootModel moduleRootModel) {
LibraryOrderEntry newestLibrary = null;
int firstLibraryIndex = 0;
int newestLibraryIndex = 0;
OrderEntry[] orderEntries = moduleRootModel.getOrderEntries();
for (int i = 0; i < orderEntries.length; i++) {
if (orderEntries[i] instanceof LibraryOrderEntry) {
LibraryOrderEntry libraryEntry = (LibraryOrderEntry)orderEntries[i];
String libraryName = libraryEntry.getLibraryName();
if (libraryName != null && libraryName.contains("slf4j-api")) {
if (newestLibrary == null) {
newestLibrary = libraryEntry;
firstLibraryIndex = i;
newestLibraryIndex = i;
}
else {
if (libraryName.compareTo(newestLibrary.getLibraryName()) > 0) {
newestLibraryIndex = i;
newestLibrary = libraryEntry;
}
}
}
}
}
if (firstLibraryIndex == newestLibraryIndex) return null;
OrderEntry[] res = orderEntries.clone();
ArrayUtil.swap(res, firstLibraryIndex, newestLibraryIndex);
return res;
}