当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtil.swap方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PermuteArgumentsFix.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AbstractJavaInplaceIntroducer.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:MvcModuleStructureUtil.java


注:本文中的com.intellij.util.ArrayUtil.swap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。