mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectRootUtil;
|
||||
@@ -270,8 +271,9 @@ public class PackageUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PsiDirectory getWritableDirectory(Query<VirtualFile> vFiles, PsiManager manager) {
|
||||
private static PsiDirectory getWritableModuleDirectory(@NotNull Query<VirtualFile> vFiles, @NotNull Module module, PsiManager manager) {
|
||||
for (VirtualFile vFile : vFiles) {
|
||||
if (ModuleUtil.findModuleForFile(vFile, module.getProject()) != module) continue;
|
||||
PsiDirectory directory = manager.findDirectory(vFile);
|
||||
if (directory != null && directory.isValid() && directory.isWritable()) {
|
||||
return directory;
|
||||
@@ -286,7 +288,7 @@ public class PackageUtil {
|
||||
String nameToMatch = packageName;
|
||||
while (true) {
|
||||
Query<VirtualFile> vFiles = ModulePackageIndex.getInstance(module).getDirsByPackageName(nameToMatch, false);
|
||||
PsiDirectory directory = getWritableDirectory(vFiles, manager);
|
||||
PsiDirectory directory = getWritableModuleDirectory(vFiles, module, manager);
|
||||
if (directory != null) return JavaDirectoryService.getInstance().getPackage(directory);
|
||||
|
||||
int lastDotIndex = nameToMatch.lastIndexOf('.');
|
||||
|
||||
+10
-7
@@ -570,18 +570,21 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
String methodName = methodExpr.getReferenceName();
|
||||
if (methodName != null) {
|
||||
String[] words = NameUtil.nameToWords(methodName);
|
||||
if (words.length > 1) {
|
||||
String firstWord = words[0];
|
||||
if (words.length > 0) {
|
||||
final String firstWord = words[0];
|
||||
if (GET_PREFIX.equals(firstWord)
|
||||
|| IS_PREFIX.equals(firstWord)
|
||||
|| FIND_PREFIX.equals(firstWord)
|
||||
|| CREATE_PREFIX.equals(firstWord)) {
|
||||
final String propertyName = methodName.substring(firstWord.length());
|
||||
final String[] names = getSuggestionsByName(propertyName, variableKind, false);
|
||||
return new NamesByExprInfo(propertyName, names);
|
||||
if (words.length > 1) {
|
||||
final String propertyName = methodName.substring(firstWord.length());
|
||||
final String[] names = getSuggestionsByName(propertyName, variableKind, false);
|
||||
return new NamesByExprInfo(propertyName, names);
|
||||
}
|
||||
}
|
||||
else if (words.length == 1) {
|
||||
return new NamesByExprInfo(methodName, getSuggestionsByName(methodName, variableKind, false));
|
||||
}
|
||||
} else {
|
||||
return new NamesByExprInfo(methodName, getSuggestionsByName(methodName, variableKind, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-5
@@ -603,7 +603,9 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
PsiParameter[] parameters = list.getParameters();
|
||||
|
||||
final JavaParameterInfo[] parameterInfos = changeInfo.getNewParameters();
|
||||
PsiParameter[] newParms = new PsiParameter[parameterInfos.length];
|
||||
PsiParameter[] newParms = new PsiParameter[parameterInfos.length -
|
||||
(baseMethod != null ? baseMethod.getParameterList().getParametersCount() -
|
||||
method.getParameterList().getParametersCount() : 0)];
|
||||
final String[] oldParameterNames = changeInfo.getOldParameterNames();
|
||||
final String[] oldParameterTypes = changeInfo.getOldParameterTypes();
|
||||
for (int i = 0; i < newParms.length; i++) {
|
||||
@@ -634,7 +636,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
|
||||
|
||||
resolveParameterVsFieldsConflicts(newParms, method, list, changeInfo.toRemoveParm());
|
||||
fixJavadocsForChangedMethod(method, changeInfo);
|
||||
fixJavadocsForChangedMethod(method, changeInfo, newParms.length);
|
||||
if (changeInfo.isExceptionSetOrOrderChanged()) {
|
||||
final PsiClassType[] newExceptions = getPrimaryChangedExceptionInfo(changeInfo);
|
||||
fixPrimaryThrowsLists(method, newExceptions);
|
||||
@@ -707,13 +709,13 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
methodThrowsList.getTextRange().getEndOffset());
|
||||
}
|
||||
|
||||
private static void fixJavadocsForChangedMethod(PsiMethod method, JavaChangeInfo changeInfo) throws IncorrectOperationException {
|
||||
private static void fixJavadocsForChangedMethod(PsiMethod method, JavaChangeInfo changeInfo, int newParamsLength) throws IncorrectOperationException {
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
final JavaParameterInfo[] newParms = changeInfo.getNewParameters();
|
||||
LOG.assertTrue(parameters.length == newParms.length);
|
||||
LOG.assertTrue(parameters.length <= newParamsLength);
|
||||
final Set<PsiParameter> newParameters = new HashSet<PsiParameter>();
|
||||
final String[] oldParameterNames = changeInfo.getOldParameterNames();
|
||||
for (int i = 0; i < newParms.length; i++) {
|
||||
for (int i = 0; i < newParamsLength; i++) {
|
||||
JavaParameterInfo newParm = newParms[i];
|
||||
if (newParm.getOldIndex() < 0 ||
|
||||
!newParm.getName().equals(oldParameterNames[newParm.getOldIndex()])) {
|
||||
|
||||
+2
-2
@@ -103,7 +103,7 @@ class JavaChangeSignatureUsageSearcher {
|
||||
if (isOriginal) {
|
||||
deletedOrRenamedParameters.addAll(Arrays.asList(parameters));
|
||||
for (ParameterInfo parameterInfo : myChangeInfo.getNewParameters()) {
|
||||
if (parameterInfo.getOldIndex() >= 0) {
|
||||
if (parameterInfo.getOldIndex() >= 0 && parameterInfo.getOldIndex() < parameters.length) {
|
||||
final PsiParameter parameter = parameters[parameterInfo.getOldIndex()];
|
||||
if (parameterInfo.getName().equals(parameter.getName())) {
|
||||
deletedOrRenamedParameters.remove(parameter);
|
||||
@@ -115,7 +115,7 @@ class JavaChangeSignatureUsageSearcher {
|
||||
for (ParameterInfo parameterInfo : myChangeInfo.getNewParameters()) {
|
||||
final int oldParameterIndex = parameterInfo.getOldIndex();
|
||||
final String newName = parameterInfo.getName();
|
||||
if (oldParameterIndex >= 0) {
|
||||
if (oldParameterIndex >= 0 && oldParameterIndex < parameters.length) {
|
||||
if (isOriginal) { //Name changes take place only in primary method
|
||||
final PsiParameter parameter = parameters[oldParameterIndex];
|
||||
if (!newName.equals(parameter.getName())) {
|
||||
|
||||
@@ -116,22 +116,24 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner {
|
||||
field.setAccessible(true);
|
||||
final Filter filter = (Filter)field.get(request);
|
||||
final String filterDescription = filter.describe();
|
||||
try {
|
||||
final Description failedTestsDescription = Description.createSuiteDescription(filterDescription, null);
|
||||
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext();) {
|
||||
final Description childDescription = (Description)iterator.next();
|
||||
if (filter.shouldRun(childDescription)) {
|
||||
failedTestsDescription.addChild(childDescription);
|
||||
if (filterDescription != null && (filterDescription.startsWith("Failed tests") || filterDescription.startsWith("Ignored"))) {
|
||||
try {
|
||||
final Description failedTestsDescription = Description.createSuiteDescription(filterDescription, null);
|
||||
for (Iterator iterator = description.getChildren().iterator(); iterator.hasNext();) {
|
||||
final Description childDescription = (Description)iterator.next();
|
||||
if (filter.shouldRun(childDescription)) {
|
||||
failedTestsDescription.addChild(childDescription);
|
||||
}
|
||||
}
|
||||
description = failedTestsDescription;
|
||||
if (!failedTestsDescription.isTest() && failedTestsDescription.testCount() == 1 && filterDescription.startsWith("Method")) {
|
||||
description = (Description)failedTestsDescription.getChildren().get(0);
|
||||
}
|
||||
}
|
||||
description = failedTestsDescription;
|
||||
if (!failedTestsDescription.isTest() && failedTestsDescription.testCount() == 1 && filterDescription.startsWith("Method")) {
|
||||
description = (Description)failedTestsDescription.getChildren().get(0);
|
||||
catch (NoSuchMethodError e) {
|
||||
//junit 4.0 doesn't have method createSuite(String, Annotation...) : skip it
|
||||
}
|
||||
}
|
||||
catch (NoSuchMethodError e) {
|
||||
//junit 4.0 doesn't have method createSuite(String, Annotation...) : skip it
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,16 @@ public class JUnit4TestRunnerUtil {
|
||||
return super.getRunner();
|
||||
}
|
||||
};
|
||||
return classRequest.filterWith(Description.createTestDescription(clazz, methodName));
|
||||
final Filter ignoredTestFilter = Filter.matchMethodDescription(Description.createTestDescription(clazz, methodName));
|
||||
return classRequest.filterWith(new Filter() {
|
||||
public boolean shouldRun(Description description) {
|
||||
return ignoredTestFilter.shouldRun(description);
|
||||
}
|
||||
|
||||
public String describe() {
|
||||
return "Ignored " + methodName;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
|
||||
Reference in New Issue
Block a user