mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,6 +59,7 @@ public class CompoundPositionManager extends PositionManagerEx {
|
||||
|
||||
@Override
|
||||
public SourcePosition getSourcePosition(Location location) {
|
||||
if (location == null) return null;
|
||||
SourcePosition res = mySourcePositionCache.get(location);
|
||||
if (res != null) return res;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.FileContentUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -100,7 +99,7 @@ public class ConfigFileFactoryImpl extends ConfigFileFactory {
|
||||
else {
|
||||
childData = existingFile;
|
||||
}
|
||||
FileContentUtil.setFileText(project, childData, text);
|
||||
VfsUtil.saveText(childData, text);
|
||||
return childData;
|
||||
}
|
||||
catch (final IOException e) {
|
||||
|
||||
@@ -99,6 +99,15 @@ public class TargetElementUtil extends TargetElementUtilBase {
|
||||
if (ref instanceof PsiJavaReference) {
|
||||
refElement = ((PsiJavaReference)ref).advancedResolve(true).getElement();
|
||||
}
|
||||
else if (ref == null) {
|
||||
final PsiElement element = file.findElementAt(offset);
|
||||
if (element != null) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiFunctionalExpression) {
|
||||
refElement = PsiUtil.resolveClassInType(((PsiFunctionalExpression)parent).getFunctionalInterfaceType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (refElement != null) {
|
||||
|
||||
@@ -272,6 +272,10 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
" private int field1;\n" +
|
||||
" private int field2;\n" +
|
||||
"\n" +
|
||||
" {\n" +
|
||||
" field1 = 2;\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" public void foo1() {\n" +
|
||||
" new Runnable() {\n" +
|
||||
" public void run() {\n" +
|
||||
|
||||
@@ -428,7 +428,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
}
|
||||
else if (myRole1 == ChildRole.FIELD) {
|
||||
int blankLines = myJavaSettings.BLANK_LINES_AROUND_INITIALIZER + 1;
|
||||
myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, blankLines, true, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
|
||||
myResult = Spacing.createSpacing(0, mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
|
||||
}
|
||||
else if (myRole1 == ChildRole.CLASS) {
|
||||
setAroundClassSpacing();
|
||||
@@ -547,6 +547,10 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
if (myRole1 == ChildRole.LBRACE) {
|
||||
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, 0);
|
||||
}
|
||||
else if (myRole1 == ChildRole.CLASS_INITIALIZER) {
|
||||
int blankLines = myJavaSettings.BLANK_LINES_AROUND_INITIALIZER + 1;
|
||||
myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_BEFORE_RBRACE);
|
||||
}
|
||||
else {
|
||||
final int blankLines = getLinesAroundMethod() + 1;
|
||||
myResult = Spacing.createSpacing(0, 0, blankLines, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
|
||||
|
||||
+8
-15
@@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.file.JavaDirectoryServiceImpl;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.move.MoveCallback;
|
||||
@@ -215,11 +216,11 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate {
|
||||
final MoveClassesOrPackagesToNewDirectoryDialog dlg =
|
||||
new MoveClassesOrPackagesToNewDirectoryDialog(directories[0], new PsiElement[0], false, callback) {
|
||||
@Override
|
||||
protected void performRefactoring(Project project,
|
||||
final PsiDirectory targetDirectory,
|
||||
PsiPackage aPackage,
|
||||
boolean searchInComments,
|
||||
boolean searchForTextOccurences) {
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor(Project project,
|
||||
final PsiDirectory targetDirectory,
|
||||
PsiPackage aPackage,
|
||||
boolean searchInComments,
|
||||
boolean searchForTextOccurences) {
|
||||
try {
|
||||
for (PsiDirectory dir: directories) {
|
||||
MoveFilesOrDirectoriesUtil.checkIfMoveIntoSelf(dir, targetDirectory);
|
||||
@@ -227,17 +228,9 @@ public class JavaMoveClassesOrPackagesHandler extends MoveHandlerDelegate {
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
Messages.showErrorDialog(project, e.getMessage(), RefactoringBundle.message("cannot.move"));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
final MoveDirectoryWithClassesProcessor processor =
|
||||
new MoveDirectoryWithClassesProcessor(project, directories, targetDirectory, searchInComments, searchForTextOccurences,
|
||||
true, callback);
|
||||
processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
});
|
||||
processor.run();
|
||||
return new MoveDirectoryWithClassesProcessor(project, directories, targetDirectory, searchInComments, searchForTextOccurences, true, callback);
|
||||
}
|
||||
};
|
||||
dlg.show();
|
||||
|
||||
+15
-22
@@ -25,19 +25,16 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.JavaRefactoringFactory;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.MoveDestination;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.*;
|
||||
import com.intellij.refactoring.move.MoveCallback;
|
||||
import com.intellij.refactoring.move.MoveHandler;
|
||||
import com.intellij.refactoring.ui.RefactoringDialog;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -54,7 +51,7 @@ import java.util.Set;
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
public class MoveClassesOrPackagesToNewDirectoryDialog extends RefactoringDialog {
|
||||
private static final Logger LOG = Logger.getInstance("com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesToNewDirectoryDialog");
|
||||
|
||||
private final PsiDirectory myDirectory;
|
||||
@@ -69,7 +66,7 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
public MoveClassesOrPackagesToNewDirectoryDialog(@NotNull final PsiDirectory directory, PsiElement[] elementsToMove,
|
||||
boolean canShowPreserveSourceRoots,
|
||||
final MoveCallback moveCallback) {
|
||||
super(false);
|
||||
super(directory.getProject(), false);
|
||||
setTitle(MoveHandler.REFACTORING_NAME);
|
||||
myDirectory = directory;
|
||||
myElementsToMove = elementsToMove;
|
||||
@@ -149,7 +146,8 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
return myRootPanel;
|
||||
}
|
||||
|
||||
protected void doOKAction() {
|
||||
@Override
|
||||
protected void doAction() {
|
||||
final String path = FileUtil.toSystemIndependentName(myDestDirectoryField.getText());
|
||||
final Project project = myDirectory.getProject();
|
||||
PsiDirectory directory = ApplicationManager.getApplication().runWriteAction(new Computable<PsiDirectory>() {
|
||||
@@ -169,7 +167,6 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
super.doOKAction();
|
||||
final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory);
|
||||
if (aPackage == null) {
|
||||
Messages.showErrorDialog(project, RefactoringBundle.message("destination.directory.does.not.correspond.to.any.package"),
|
||||
@@ -182,8 +179,7 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
final boolean searchForTextOccurences = isSearchInNonJavaFiles();
|
||||
refactoringSettings.MOVE_SEARCH_IN_COMMENTS = searchInComments;
|
||||
refactoringSettings.MOVE_SEARCH_FOR_TEXT = searchForTextOccurences;
|
||||
|
||||
performRefactoring(project, directory, aPackage, searchInComments, searchForTextOccurences);
|
||||
invokeRefactoring(createRefactoringProcessor(project, directory, aPackage, searchInComments, searchForTextOccurences));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,14 +200,16 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
searchInComments, searchInNonJavaFiles, moveCallback);
|
||||
}
|
||||
|
||||
protected void performRefactoring(Project project, PsiDirectory directory, PsiPackage aPackage,
|
||||
boolean searchInComments,
|
||||
boolean searchForTextOccurences) {
|
||||
protected BaseRefactoringProcessor createRefactoringProcessor(Project project,
|
||||
PsiDirectory directory,
|
||||
PsiPackage aPackage,
|
||||
boolean searchInComments,
|
||||
boolean searchForTextOccurences) {
|
||||
final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(directory.getVirtualFile());
|
||||
if (sourceRoot == null) {
|
||||
Messages.showErrorDialog(project, RefactoringBundle.message("destination.directory.does.not.correspond.to.any.package"),
|
||||
RefactoringBundle.message("cannot.move"));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
final JavaRefactoringFactory factory = JavaRefactoringFactory.getInstance(project);
|
||||
final MoveDestination destination = myPreserveSourceRoot.isSelected() && myPreserveSourceRoot.isVisible()
|
||||
@@ -222,14 +220,9 @@ public class MoveClassesOrPackagesToNewDirectoryDialog extends DialogWrapper {
|
||||
searchInComments, searchForTextOccurences, myMoveCallback);
|
||||
|
||||
if (processor.verifyValidPackageName()) {
|
||||
processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
});
|
||||
|
||||
processor.run();
|
||||
return processor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
@@ -148,7 +149,7 @@ public class JavaFunctionalExpressionSearcher implements QueryExecutor<PsiFuncti
|
||||
|
||||
private void visitFunctionalExpression(PsiFunctionalExpression expression) {
|
||||
PsiType functionalInterfaceType = expression.getFunctionalInterfaceType();
|
||||
if (psiManager.areElementsEquivalent(PsiUtil.resolveClassInType(functionalInterfaceType), aClass)) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(PsiUtil.resolveClassInType(functionalInterfaceType), aClass, true)) {
|
||||
if (!consumer.process(expression)) {
|
||||
ref.set(false);
|
||||
}
|
||||
|
||||
+8
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.impl.source.resolve;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiAnchor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.ResolveState;
|
||||
@@ -23,6 +24,7 @@ import com.intellij.psi.scope.BaseScopeProcessor;
|
||||
import com.intellij.psi.scope.ElementClassHint;
|
||||
import com.intellij.psi.scope.JavaScopeProcessorEvent;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.MostlySingularMultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -71,21 +73,21 @@ public class SymbolCollectingProcessor extends BaseScopeProcessor implements Ele
|
||||
}
|
||||
|
||||
public static class ResultWithContext {
|
||||
private final PsiNamedElement myElement;
|
||||
private final PsiElement myFileContext;
|
||||
private final PsiAnchor myElement;
|
||||
private final PsiAnchor myFileContext;
|
||||
|
||||
public ResultWithContext(@NotNull PsiNamedElement element, PsiElement fileContext) {
|
||||
myElement = element;
|
||||
myFileContext = fileContext;
|
||||
myElement = PsiAnchor.create(element);
|
||||
myFileContext = fileContext == null ? null : PsiAnchor.create(fileContext);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiNamedElement getElement() {
|
||||
return myElement;
|
||||
return (PsiNamedElement)ObjectUtils.assertNotNull(myElement.retrieve());
|
||||
}
|
||||
|
||||
public PsiElement getFileContext() {
|
||||
return myFileContext;
|
||||
return myFileContext == null ? null : myFileContext.retrieve();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-1
@@ -17,6 +17,8 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
@@ -226,7 +228,9 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements
|
||||
// If unchecked conversion was necessary for the method to be applicable,
|
||||
// the parameter types of the invocation type are the parameter types of the method's type,
|
||||
// and the return type and thrown types are given by the erasures of the return type and thrown types of the method's type.
|
||||
if (result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isApplicable()) {
|
||||
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8) &&
|
||||
(method.hasTypeParameters() || JavaVersionService.getInstance().isAtLeast(call, JavaSdkVersion.JDK_1_8)) &&
|
||||
result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isApplicable()) {
|
||||
final PsiType[] args = call.getArgumentList().getExpressionTypes();
|
||||
final boolean allowUncheckedConversion = false;
|
||||
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method, substitutor, args, languageLevel, allowUncheckedConversion, true);
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class Test {
|
||||
|
||||
void testCall(final Set set) {
|
||||
for (String position : sortInvoice(set)) {}
|
||||
}
|
||||
|
||||
private List<String> sortInvoice(Set<Integer> set) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
enum TestEnum {EnumOne, EnumTwo, EnumThree}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String testString = "EnumOne=0, EnumTwo=2,EnumThree=1";
|
||||
|
||||
Map<TestEnum, Integer> enumMap = Optional.ofNullable(testString)
|
||||
.map(levelsString -> Arrays.stream(levelsString.split("\\s*,\\s*"))
|
||||
.map(splitStringComponent -> splitStringComponent.split("="))
|
||||
.filter(keyValArray -> keyValArray.length == 2)
|
||||
.collect(Collectors.toMap(keyValArray -> TestEnum.valueOf(keyValArray[0]), s -> Integer.valueOf(s[1]))))
|
||||
.orElse(new HashMap<>());
|
||||
|
||||
System.out.println(enumMap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Cleaning output files:
|
||||
out/production/moveClassToAnotherRoot/pkg/A.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src2/pkg/A.java
|
||||
End of files
|
||||
Cleaning output files:
|
||||
out/production/moveClassToAnotherRoot/pkg/Client.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/pkg/Client.java
|
||||
End of files
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectResources">
|
||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA jdk" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/moveClassToAnotherRoot.iml" filepath="$PROJECT_DIR$/moveClassToAnotherRoot.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src2" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="common" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package pkg;
|
||||
public class A {
|
||||
public static void foo() {}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package pkg;
|
||||
public class Client {
|
||||
public static void main(String[] args) {
|
||||
A.foo();
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package pkg;
|
||||
public class A {
|
||||
public static void foo() {}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
Cleaning output files:
|
||||
out/production/MoveToplevelClassToAnotherFile/pkg/A.class
|
||||
out/production/MoveToplevelClassToAnotherFile/pkg/B.class
|
||||
out/production/MoveToplevelClassToAnotherFile/pkg/Local.class
|
||||
End of files
|
||||
Compiling files:
|
||||
src/pkg/A.java
|
||||
src/pkg/B.java
|
||||
End of files
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package pkg;
|
||||
|
||||
public class A {
|
||||
|
||||
}
|
||||
|
||||
class Local {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package pkg;
|
||||
|
||||
public class A {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package pkg;
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package pkg;
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
|
||||
class Local {
|
||||
|
||||
}
|
||||
@@ -417,6 +417,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testMethodCallTypeErasedWhenUncheckedConversionWasAppliedDuringApplicabilityCheck() {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testMethodCallTypeNotErasedWhenUncheckedConversionWasAppliedButNoTypeParamsProvided() {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testInferredParameterInBoundsInRecursiveGenerics() {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
|
||||
+4
@@ -160,6 +160,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA127124() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.navigation
|
||||
import com.intellij.ide.actions.GotoFileItemProvider
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopup
|
||||
import com.intellij.ide.util.gotoByName.GotoFileModel
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
|
||||
import org.jetbrains.annotations.NotNull
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
class ChooseByNameHddTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
public void "test go to file by full path"() {
|
||||
def psiFile = myFixture.addFileToProject("foo/index.html", "foo")
|
||||
def path = psiFile.virtualFile.path
|
||||
|
||||
def popup = ChooseByNamePopup.createPopup(project, new GotoFileModel(project), new GotoFileItemProvider(project, null))
|
||||
assert ChooseByNameTest.calcPopupElements(popup, path) == [psiFile]
|
||||
assert ChooseByNameTest.calcPopupElements(popup, FileUtil.toSystemDependentName(path)) == [psiFile]
|
||||
popup.close(false)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runInDispatchThread() {
|
||||
return false
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invokeTestRunnable(@NotNull Runnable runnable) throws Exception {
|
||||
runnable.run()
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class Intf {
|
||||
return calcPopupElements(createPopup(model), text, checkboxState)
|
||||
}
|
||||
|
||||
private static ArrayList<String> calcPopupElements(ChooseByNamePopup popup, String text, boolean checkboxState = false) {
|
||||
static ArrayList<String> calcPopupElements(ChooseByNamePopup popup, String text, boolean checkboxState = false) {
|
||||
List<Object> elements = ['empty']
|
||||
def semaphore = new Semaphore()
|
||||
semaphore.down()
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.navigation;
|
||||
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
public class ShowImplementationHandlerTest extends JavaCodeInsightFixtureTestCase {
|
||||
|
||||
public void testMultipleImplsFromAbstractCall() throws Throwable {
|
||||
PsiFile file = myFixture.addFileToProject("Foo.java", "public abstract class Hello {" +
|
||||
" {" +
|
||||
" Runnable r = () <caret>-> {};\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"\n");
|
||||
myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
|
||||
|
||||
final PsiElement element =
|
||||
TargetElementUtilBase.findTargetElement(myFixture.getEditor(), TargetElementUtilBase.getInstance().getAllAccepted());
|
||||
assertTrue(element instanceof PsiClass);
|
||||
final String qualifiedName = ((PsiClass)element).getQualifiedName();
|
||||
assertEquals(CommonClassNames.JAVA_LANG_RUNNABLE, qualifiedName);
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -433,4 +433,29 @@ public class JavaFormatterBlankLinesTest extends AbstractJavaFormatterTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testBlankLinesAroundInitializer() {
|
||||
getJavaSettings().BLANK_LINES_AROUND_INITIALIZER = 3;
|
||||
doTextTest(
|
||||
"public class JavaClass {\n" +
|
||||
" int a = 3;\n" +
|
||||
" {\n" +
|
||||
" System.out.println(\"Hello\");\n" +
|
||||
" }\n" +
|
||||
"\n" +
|
||||
" public void test() {\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
"public class JavaClass {\n" +
|
||||
" int a = 3;\n" +
|
||||
"\n\n\n" +
|
||||
" {\n" +
|
||||
" System.out.println(\"Hello\");\n" +
|
||||
" }\n" +
|
||||
"\n\n\n" +
|
||||
" public void test() {\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +237,15 @@ public class Mappings {
|
||||
private void runPostPasses() {
|
||||
final Set<Pair<ClassRepr, File>> deleted = myDeletedClasses;
|
||||
if (deleted != null) {
|
||||
final TIntHashSet added = new TIntHashSet();
|
||||
for (ClassRepr aClass : myAddedClasses) {
|
||||
added.add(aClass.name);
|
||||
}
|
||||
for (Pair<ClassRepr, File> pair : deleted) {
|
||||
myChangedClasses.remove(pair.first.name);
|
||||
final int deletedClassName = pair.first.name;
|
||||
if (!added.contains(deletedClassName)) {
|
||||
myChangedClasses.remove(deletedClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Runnable pass = myPostPasses.poll(); pass != null; pass = myPostPasses.poll()) {
|
||||
@@ -1864,7 +1871,7 @@ public class Mappings {
|
||||
final Collection<File> currentSources = myClassToSourceFile.get(c.name);
|
||||
final File currentlyMappedTo = currentSources != null && currentSources.size() == 1? currentSources.iterator().next() : null;
|
||||
// only check, if exactly one file is mapped
|
||||
if (currentlyMappedTo != null && !FileUtil.filesEqual(currentlyMappedTo, srcFile) && currentlyMappedTo.exists() && myFilter.belongsToCurrentTargetChunk(currentlyMappedTo)) {
|
||||
if (currentlyMappedTo != null && !myCompiledFiles.contains(currentlyMappedTo) && !FileUtil.filesEqual(currentlyMappedTo, srcFile) && currentlyMappedTo.exists() && myFilter.belongsToCurrentTargetChunk(currentlyMappedTo)) {
|
||||
// Same classes from different source files.
|
||||
// Schedule for recompilation both to make possible 'duplicate sources' error evident
|
||||
debug("Scheduling for recompilation duplicated sources: ", currentlyMappedTo.getPath() + "; " + srcFile.getPath());
|
||||
|
||||
@@ -150,4 +150,12 @@ public class CommonTest extends IncrementalTestCase {
|
||||
doTestBuild(1).assertSuccessful();
|
||||
}
|
||||
|
||||
public void testMoveToplevelClassToAnotherFile() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMoveClassToAnotherRoot() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,7 @@ package com.intellij.psi.stubs;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface PsiFileStub<T extends PsiFile> extends StubElement<T>, UserDataHolder {
|
||||
IStubFileElementType getType();
|
||||
|
||||
@NotNull
|
||||
PsiFileStub[] getStubRoots();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
public static final IStubFileElementType TYPE = new IStubFileElementType(Language.ANY);
|
||||
private volatile T myFile;
|
||||
private volatile String myInvalidationReason;
|
||||
private volatile PsiFileStub[] myStubRoots;
|
||||
|
||||
public PsiFileStubImpl(final T file) {
|
||||
super(null, null);
|
||||
@@ -65,14 +64,4 @@ public class PsiFileStubImpl<T extends PsiFile> extends StubBase<T> implements P
|
||||
public IStubFileElementType getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiFileStub[] getStubRoots() {
|
||||
return myStubRoots != null ? myStubRoots : new PsiFileStub[]{this};
|
||||
}
|
||||
|
||||
public void setStubRoots(@NotNull PsiFileStub[] roots) {
|
||||
myStubRoots = roots;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.openapi.diagnostic.LogUtil;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.RecentStringInterner;
|
||||
import com.intellij.util.io.AbstractStringEnumerator;
|
||||
import com.intellij.util.io.DataInputOutputUtil;
|
||||
@@ -79,17 +78,7 @@ public class StubSerializationHelper {
|
||||
FileLocalStringEnumerator storage = new FileLocalStringEnumerator(true);
|
||||
StubOutputStream stubOutputStream = new StubOutputStream(out, storage);
|
||||
|
||||
if (rootStub instanceof PsiFileStub) {
|
||||
final PsiFileStub[] roots = ((PsiFileStub)rootStub).getStubRoots();
|
||||
DataInputOutputUtil.writeINT(stubOutputStream, roots.length);
|
||||
for (PsiFileStub root : roots) {
|
||||
doSerialize(root, stubOutputStream);
|
||||
}
|
||||
}
|
||||
else {
|
||||
DataInputOutputUtil.writeINT(stubOutputStream, 1);
|
||||
doSerialize(rootStub, stubOutputStream);
|
||||
}
|
||||
doSerialize(rootStub, stubOutputStream);
|
||||
DataOutputStream resultStream = new DataOutputStream(stream);
|
||||
DataInputOutputUtil.writeINT(resultStream, storage.myStrings.size());
|
||||
byte[] buffer = IOUtil.allocReadWriteUTFBuffer();
|
||||
@@ -122,24 +111,7 @@ public class StubSerializationHelper {
|
||||
++i;
|
||||
}
|
||||
|
||||
int stubFilesCount = DataInputOutputUtil.readINT(inputStream);
|
||||
if (stubFilesCount > 1) {
|
||||
final List<PsiFileStub> stubs = new SmartList<PsiFileStub>();
|
||||
while (stubFilesCount-- > 0) {
|
||||
final PsiFileStub fileStub = (PsiFileStub)deserialize(inputStream, null);
|
||||
stubs.add(fileStub);
|
||||
}
|
||||
final PsiFileStub[] stubsArray = stubs.toArray(new PsiFileStub[stubs.size()]);
|
||||
for (PsiFileStub stub : stubsArray) {
|
||||
if (stub instanceof PsiFileStubImpl) {
|
||||
((PsiFileStubImpl)stub).setStubRoots(stubsArray);
|
||||
}
|
||||
}
|
||||
return stubsArray[0];
|
||||
}
|
||||
else {
|
||||
return deserialize(inputStream, null);
|
||||
}
|
||||
return deserialize(inputStream, null);
|
||||
}
|
||||
|
||||
String intern(String str) {
|
||||
|
||||
@@ -675,10 +675,15 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
final VirtualFile vFile = getVirtualFile();
|
||||
if (!(vFile instanceof VirtualFileWithId)) return null;
|
||||
|
||||
final PsiFile stubBindingRoot = getViewProvider().getStubBindingRoot();
|
||||
if (stubBindingRoot != this) {
|
||||
LOG.error("Attempted to create stubs for non-root file: " + this + ", stub binding root: " + stubBindingRoot);
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), vFile, this);
|
||||
if (!(tree instanceof StubTree)) return null;
|
||||
StubTree stubHolder = (StubTree)tree;
|
||||
final List<Pair<IStubFileElementType, PsiFile>> roots = StubTreeBuilder.getStubbedRoots(getViewProvider());
|
||||
|
||||
synchronized (PsiLock.LOCK) {
|
||||
if (getTreeElement() != null) return null;
|
||||
@@ -686,14 +691,9 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
final StubTree derefdOnLock = derefStub();
|
||||
if (derefdOnLock != null) return derefdOnLock;
|
||||
|
||||
final PsiFileStub[] stubRoots = stubHolder.getRoot().getStubRoots();
|
||||
int matchingRoot = 0;
|
||||
for (Pair<IStubFileElementType, PsiFile> root : roots) {
|
||||
final PsiFileStub matchingStub = stubRoots[matchingRoot++];
|
||||
//noinspection unchecked
|
||||
((StubBase)matchingStub).setPsi(this);
|
||||
((PsiFileImpl)root.second).myStub = new SoftReference<StubTree>(new StubTree(matchingStub));
|
||||
}
|
||||
//noinspection unchecked
|
||||
((StubBase)stubHolder.getRoot()).setPsi(this);
|
||||
myStub = new SoftReference<StubTree>(stubHolder);
|
||||
return stubHolder;
|
||||
}
|
||||
}
|
||||
@@ -777,7 +777,6 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
public int getStartOffsetInParent() {
|
||||
return calcTreeElement().getStartOffsetInParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextOffset() {
|
||||
return calcTreeElement().getTextOffset();
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
|
||||
public class CumulativeStubVersion {
|
||||
private static final int VERSION = 28;
|
||||
private static final int VERSION = 27;
|
||||
|
||||
public static int getCumulativeVersion() {
|
||||
int version = VERSION;
|
||||
|
||||
@@ -53,17 +53,12 @@ public class ObjectStubTree<T extends Stub> {
|
||||
return myPlainList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<T> getPlainListFromAllRoots() {
|
||||
return getPlainList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<StubIndexKey, Map<Object, int[]>> indexStubTree() {
|
||||
StubIndexSink sink = new StubIndexSink();
|
||||
final List<T> plainList = getPlainListFromAllRoots();
|
||||
for (int i = 0, plainListSize = plainList.size(); i < plainListSize; i++) {
|
||||
final Stub stub = plainList.get(i);
|
||||
|
||||
for (int i = 0, plainListSize = myPlainList.size(); i < plainListSize; i++) {
|
||||
final Stub stub = myPlainList.get(i);
|
||||
sink.myStubIdx = i;
|
||||
StubSerializationUtil.getSerializer(stub).indexStub(stub, sink);
|
||||
}
|
||||
@@ -71,15 +66,11 @@ public class ObjectStubTree<T extends Stub> {
|
||||
return sink.getResult();
|
||||
}
|
||||
|
||||
protected void enumerateStubs(@NotNull Stub root, @NotNull List<Stub> result) {
|
||||
enumerateStubs(root, result, 0);
|
||||
}
|
||||
|
||||
protected static void enumerateStubs(@NotNull Stub root, @NotNull List<Stub> result, int idOffset) {
|
||||
((ObjectStubBase)root).id = idOffset + result.size();
|
||||
protected static void enumerateStubs(@NotNull Stub root, @NotNull List<Stub> result) {
|
||||
((ObjectStubBase)root).id = result.size();
|
||||
result.add(root);
|
||||
for (Stub child : root.getChildrenStubs()) {
|
||||
enumerateStubs(child, result, idOffset);
|
||||
enumerateStubs(child, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,8 @@
|
||||
*/
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class StubTree extends ObjectStubTree<StubElement<?>> {
|
||||
|
||||
public StubTree(@NotNull final PsiFileStub root) {
|
||||
@@ -37,31 +31,6 @@ public class StubTree extends ObjectStubTree<StubElement<?>> {
|
||||
super((ObjectStubBase)root, withBackReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enumerateStubs(@NotNull Stub root, @NotNull List<Stub> result) {
|
||||
final PsiFileStub[] files = ((PsiFileStub)root).getStubRoots();
|
||||
int idOffset = 0;
|
||||
final List<Stub> dummyList = new ArrayList<Stub>();
|
||||
for (PsiFileStub file : files) {
|
||||
if (file == root) break;
|
||||
dummyList.clear();
|
||||
enumerateStubs(file, dummyList, idOffset);
|
||||
idOffset += dummyList.size();
|
||||
}
|
||||
enumerateStubs(root, result, idOffset);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<StubElement<?>> getPlainListFromAllRoots() {
|
||||
return ContainerUtil.concat(getRoot().getStubRoots(), new Function<PsiFileStub, Collection<? extends StubElement<?>>>() {
|
||||
@Override
|
||||
public Collection<? extends StubElement<?>> fun(PsiFileStub stub) {
|
||||
return new StubTree(stub).getPlainList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiFileStub getRoot() {
|
||||
|
||||
@@ -20,29 +20,16 @@ import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBuilder;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.intellij.util.indexing.FileContentImpl;
|
||||
import com.intellij.util.indexing.IndexingDataKeys;
|
||||
import com.intellij.util.indexing.SubstitutedFileType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class StubTreeBuilder {
|
||||
private static final Key<Stub> stubElementKey = Key.create("stub.tree.for.file.content");
|
||||
|
||||
@@ -72,8 +59,7 @@ public class StubTreeBuilder {
|
||||
CharSequence contentAsText = inputData.getContentAsText();
|
||||
FileContentImpl fileContent = (FileContentImpl)inputData;
|
||||
PsiFile psi = fileContent.getPsiFileForPsiDependentIndex();
|
||||
final FileViewProvider viewProvider = psi.getViewProvider();
|
||||
psi = viewProvider.getStubBindingRoot();
|
||||
psi = psi.getViewProvider().getStubBindingRoot();
|
||||
psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, contentAsText);
|
||||
|
||||
// if we load AST, it should be easily gc-able. See PsiFileImpl.createTreeElementPointer()
|
||||
@@ -94,31 +80,11 @@ public class StubTreeBuilder {
|
||||
stubFileElementType = null;
|
||||
}
|
||||
if (stubFileElementType != null) {
|
||||
final StubBuilder stubBuilder = stubFileElementType.getBuilder();
|
||||
StubBuilder stubBuilder = stubFileElementType.getBuilder();
|
||||
if (stubBuilder instanceof LightStubBuilder) {
|
||||
LightStubBuilder.FORCED_AST.set(fileContent.getLighterASTForPsiDependentIndex());
|
||||
}
|
||||
data = stubBuilder.buildStubTree(psi);
|
||||
|
||||
final List<Pair<IStubFileElementType, PsiFile>> stubbedRoots = getStubbedRoots(viewProvider);
|
||||
if (stubbedRoots.size() > 1) {
|
||||
final SmartList<PsiFileStub> stubs = new SmartList<PsiFileStub>();
|
||||
stubs.add((PsiFileStub)data);
|
||||
|
||||
for (Pair<IStubFileElementType, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
if (psi == stubbedRoot.second) continue;
|
||||
final StubElement element = stubbedRoot.first.getBuilder().buildStubTree(stubbedRoot.second);
|
||||
if (element instanceof PsiFileStub) {
|
||||
stubs.add((PsiFileStub)element);
|
||||
}
|
||||
}
|
||||
final PsiFileStub[] stubsArray = stubs.toArray(new PsiFileStub[stubs.size()]);
|
||||
for (PsiFileStub stub : stubsArray) {
|
||||
if (stub instanceof PsiFileStubImpl) {
|
||||
((PsiFileStubImpl)stub).setStubRoots(stubsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -131,37 +97,4 @@ public class StubTreeBuilder {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** Order is deterministic. First element matches {@link com.intellij.psi.FileViewProvider#getStubBindingRoot()} */
|
||||
@NotNull
|
||||
public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@NotNull FileViewProvider viewProvider) {
|
||||
final List<Trinity<Language, IStubFileElementType, PsiFile>> roots =
|
||||
new SmartList<Trinity<Language, IStubFileElementType, PsiFile>>();
|
||||
final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
|
||||
for (Language language : viewProvider.getLanguages()) {
|
||||
final PsiFile file = viewProvider.getPsi(language);
|
||||
if (file instanceof PsiFileImpl) {
|
||||
final IElementType contentType = ((PsiFileImpl)file).getContentElementType();
|
||||
if (contentType instanceof IStubFileElementType) {
|
||||
roots.add(Trinity.create(language, (IStubFileElementType)contentType, file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ContainerUtil.sort(roots, new Comparator<Trinity<Language, IStubFileElementType, PsiFile>>() {
|
||||
@Override
|
||||
public int compare(Trinity<Language, IStubFileElementType, PsiFile> o1, Trinity<Language, IStubFileElementType, PsiFile> o2) {
|
||||
if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1;
|
||||
else if (o2.third == stubBindingRoot) return 1;
|
||||
else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false);
|
||||
}
|
||||
});
|
||||
|
||||
return ContainerUtil.map(roots, new Function<Trinity<Language, IStubFileElementType, PsiFile>, Pair<IStubFileElementType, PsiFile>>() {
|
||||
@Override
|
||||
public Pair<IStubFileElementType, PsiFile> fun(Trinity<Language, IStubFileElementType, PsiFile> trinity) {
|
||||
return Pair.create(trinity.second, trinity.third);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
|
||||
}
|
||||
|
||||
@NonNls public static final ID<Integer, TIntArrayList> NAME = ID.create("DuplicatesIndex");
|
||||
private static final int myBaseVersion = 13;
|
||||
private static final int myBaseVersion = 14;
|
||||
|
||||
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
|
||||
@Override
|
||||
|
||||
+10
-6
@@ -112,16 +112,20 @@ public class DuplocatorHashCallback implements FragmentsCollector {
|
||||
PsiFragment aFrag = fi.get(0);
|
||||
|
||||
if (aFrag.isEqual(elements, discardCost)) {
|
||||
boolean skip = false;
|
||||
boolean skipNew = false;
|
||||
|
||||
for (Iterator<PsiFragment> frags = fi.iterator(); frags.hasNext() && !skip; ) {
|
||||
skip = frag.intersectsWith(frags.next());
|
||||
if (skip) {
|
||||
frags.remove();
|
||||
for (Iterator<PsiFragment> frags = fi.iterator(); frags.hasNext() && !skipNew; ) {
|
||||
final PsiFragment old = frags.next();
|
||||
if (frag.intersectsWith(old)) {
|
||||
if (old.getCost() < frag.getCost() || frag.contains(old)) {
|
||||
frags.remove();
|
||||
} else {
|
||||
skipNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fi.add(frag);
|
||||
if (!skipNew) fi.add(frag);
|
||||
|
||||
found = true;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,16 @@ public abstract class PsiFragment {
|
||||
Comparing.equal(f.getFile(), getFile()) && ((start <= fStart && fStart <= end) || (start <= fEnd && fEnd <= end));
|
||||
}
|
||||
|
||||
public boolean contains(PsiFragment f) {
|
||||
final int start = getStartOffset();
|
||||
final int end = getEndOffset();
|
||||
final int fStart = f.getStartOffset();
|
||||
final int fEnd = f.getEndOffset();
|
||||
|
||||
return
|
||||
Comparing.equal(f.getFile(), getFile()) && (start <= fStart && end >= fEnd);
|
||||
}
|
||||
|
||||
public abstract boolean isEqual(PsiElement[] elements, int discardCost);
|
||||
|
||||
@Nullable
|
||||
|
||||
+7
-4
@@ -33,6 +33,8 @@ import java.awt.*;
|
||||
* User: cdr
|
||||
*/
|
||||
abstract class RangeHighlighterData {
|
||||
private static final Color NULL_COLOR = new Color(0, 0, 0);
|
||||
|
||||
private final MarkupModel myModel;
|
||||
private TextAttributes myTextAttributes;
|
||||
private LineMarkerRenderer myLineMarkerRenderer;
|
||||
@@ -54,9 +56,6 @@ abstract class RangeHighlighterData {
|
||||
myTextAttributes = textAttributes;
|
||||
setFlag(TARGET_AREA_IS_EXACT_FLAG, target == HighlighterTargetArea.EXACT_RANGE);
|
||||
myModel = model;
|
||||
if (textAttributes != null) {
|
||||
myErrorStripeColor = textAttributes.getErrorStripeColor();
|
||||
}
|
||||
}
|
||||
|
||||
private static final int AFTER_END_OF_LINE_FLAG = 0;
|
||||
@@ -137,10 +136,14 @@ abstract class RangeHighlighterData {
|
||||
}
|
||||
|
||||
public Color getErrorStripeMarkColor() {
|
||||
return myErrorStripeColor;
|
||||
if (myErrorStripeColor == NULL_COLOR) return null;
|
||||
if (myErrorStripeColor != null) return myErrorStripeColor;
|
||||
if (myTextAttributes != null) return myTextAttributes.getErrorStripeColor();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setErrorStripeMarkColor(Color color) {
|
||||
if (color == null) color = NULL_COLOR;
|
||||
Color old = myErrorStripeColor;
|
||||
myErrorStripeColor = color;
|
||||
if (!Comparing.equal(old, color)) {
|
||||
|
||||
@@ -3,16 +3,17 @@ package com.intellij.psi.stubs;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiPlainTextFile;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.PsiFileWithStubSupport;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -51,12 +52,11 @@ public abstract class StubProcessingHelperBase {
|
||||
boolean customStubs = false;
|
||||
|
||||
if (candidatePsiFile != null && !(candidatePsiFile instanceof PsiPlainTextFile)) {
|
||||
final FileViewProvider viewProvider = candidatePsiFile.getViewProvider();
|
||||
final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
|
||||
if (stubBindingRoot instanceof PsiFileWithStubSupport) {
|
||||
psiFile = (PsiFileWithStubSupport)stubBindingRoot;
|
||||
candidatePsiFile = candidatePsiFile.getViewProvider().getStubBindingRoot();
|
||||
if (candidatePsiFile instanceof PsiFileWithStubSupport) {
|
||||
psiFile = (PsiFileWithStubSupport)candidatePsiFile;
|
||||
stubTree = psiFile.getStubTree();
|
||||
if (stubTree == null && psiFile instanceof PsiFileImpl) {
|
||||
if (stubTree == null && psiFile instanceof PsiFileImpl) {
|
||||
IElementType contentElementType = ((PsiFileImpl)psiFile).getContentElementType();
|
||||
if (contentElementType instanceof IStubFileElementType) {
|
||||
stubTree = ((PsiFileImpl)psiFile).calcStubTree();
|
||||
@@ -67,26 +67,6 @@ public abstract class StubProcessingHelperBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!customStubs && stubTree != null) {
|
||||
final List<PsiFileStub> roots = new SmartList<PsiFileStub>(stubTree.getRoot());
|
||||
final List<Pair<IStubFileElementType, PsiFile>> stubbedRoots = StubTreeBuilder.getStubbedRoots(viewProvider);
|
||||
for (Pair<IStubFileElementType, PsiFile> stubbedRoot : stubbedRoots) {
|
||||
if (stubbedRoot.second == stubBindingRoot) continue;
|
||||
if (stubbedRoot.second instanceof PsiFileImpl) {
|
||||
final StubTree secondaryStubTree = ((PsiFileImpl)stubbedRoot.second).calcStubTree();
|
||||
if (secondaryStubTree != null) {
|
||||
final PsiFileStub root = secondaryStubTree.getRoot();
|
||||
roots.add(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
final PsiFileStub[] rootsArray = roots.toArray(new PsiFileStub[roots.size()]);
|
||||
for (PsiFileStub root : rootsArray) {
|
||||
if (root instanceof PsiFileStubImpl) {
|
||||
((PsiFileStubImpl)root).setStubRoots(rootsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stubTree == null && psiFile == null) {
|
||||
@@ -101,7 +81,7 @@ public abstract class StubProcessingHelperBase {
|
||||
return processor.process((Psi)psiFile); // e.g. dom indices
|
||||
}
|
||||
stubTree = (StubTree)objectStubTree;
|
||||
final List<StubElement<?>> plained = stubTree.getPlainListFromAllRoots();
|
||||
final List<StubElement<?>> plained = stubTree.getPlainList();
|
||||
for (int i = 0, size = value.size(); i < size; i++) {
|
||||
final int stubTreeIndex = value.get(i);
|
||||
if (stubTreeIndex >= plained.size()) {
|
||||
@@ -148,7 +128,7 @@ public abstract class StubProcessingHelperBase {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final List<StubElement<?>> plained = stubTree.getPlainListFromAllRoots();
|
||||
final List<StubElement<?>> plained = stubTree.getPlainList();
|
||||
for (int i = 0, size = value.size(); i < size; i++) {
|
||||
final int stubTreeIndex = value.get(i);
|
||||
if (stubTreeIndex >= plained.size()) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.ListTableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -93,6 +94,28 @@ public class EnvVariablesTable extends ListTableWithButtons<EnvironmentVariable>
|
||||
return new ListTableModel((new ColumnInfo[]{name, value}));
|
||||
}
|
||||
|
||||
public void editVariableName(final EnvironmentVariable environmentVariable) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final EnvironmentVariable actualEnvVar = ContainerUtil.find(getElements(), new Condition<EnvironmentVariable>() {
|
||||
@Override
|
||||
public boolean value(EnvironmentVariable item) {
|
||||
return StringUtil.equals(environmentVariable.getName(), item.getName());
|
||||
}
|
||||
});
|
||||
if (actualEnvVar == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(actualEnvVar);
|
||||
if (actualEnvVar.getNameIsWriteable()) {
|
||||
editSelection(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<EnvironmentVariable> getEnvironmentVariables() {
|
||||
return getElements();
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
package com.intellij.execution.util;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.AnActionButtonUpdater;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
@@ -32,6 +29,7 @@ import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
@@ -172,6 +170,18 @@ public abstract class ListTableWithButtons<T> extends Observable {
|
||||
myTableView.getComponent().repaint();
|
||||
}
|
||||
|
||||
protected void setSelection(T element) {
|
||||
myTableView.setSelection(Collections.singleton(element));
|
||||
TableUtil.scrollSelectionToVisible(myTableView);
|
||||
}
|
||||
|
||||
protected void editSelection(int column) {
|
||||
int row = myElements.indexOf(getSelection());
|
||||
if (row != -1) {
|
||||
TableUtil.editCellAt(myTableView, row, column);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract T createElement();
|
||||
|
||||
protected abstract boolean isEmpty(T element);
|
||||
|
||||
@@ -39,6 +39,9 @@ import java.util.LinkedHashSet;
|
||||
*/
|
||||
public class FileContentUtil extends FileContentUtilCore {
|
||||
|
||||
/**
|
||||
* @deprecated to be removed after IDEA 15. Use {@link VfsUtil#saveText(VirtualFile, String)} instead.
|
||||
*/
|
||||
public static void setFileText(@Nullable Project project, final VirtualFile virtualFile, final String text) throws IOException {
|
||||
if (project == null) {
|
||||
project = ProjectUtil.guessProjectForFile(virtualFile);
|
||||
|
||||
+89
-23
@@ -22,12 +22,14 @@ import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,25 +38,30 @@ import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfigurationSettings> {
|
||||
public class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfigurationSettings> {
|
||||
private final ArrayList<SettingsEditor<RunnerAndConfigurationSettings>> myRunnerEditors =
|
||||
new ArrayList<SettingsEditor<RunnerAndConfigurationSettings>>();
|
||||
private final Map<ProgramRunner, List<SettingsEditor>> myRunner2UnwrappedEditors = new HashMap<ProgramRunner, List<SettingsEditor>>();
|
||||
private RunnersEditorComponent myRunnersComponent;
|
||||
private final RunConfiguration myConfiguration;
|
||||
private final SettingsEditor<RunConfiguration> myConfigurationEditor;
|
||||
private SettingsEditorGroup<RunnerAndConfigurationSettings> myCompound;
|
||||
|
||||
private static final String RUNNERS_TAB_NAME = ExecutionBundle.message("run.configuration.startup.connection.rab.title");
|
||||
|
||||
private GroupSettingsBuilder<RunnerAndConfigurationSettings> myGroupSettingsBuilder;
|
||||
|
||||
@Override
|
||||
public CompositeSettingsBuilder<RunnerAndConfigurationSettings> getBuilder() {
|
||||
init();
|
||||
return new GroupSettingsBuilder<RunnerAndConfigurationSettings>(myCompound);
|
||||
myGroupSettingsBuilder = new GroupSettingsBuilder<RunnerAndConfigurationSettings>(myCompound);
|
||||
return myGroupSettingsBuilder;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
@@ -88,7 +95,7 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
|
||||
}
|
||||
|
||||
if (myRunnerEditors.size() > 0) {
|
||||
myCompound.addEditor(ExecutionBundle.message("run.configuration.startup.connection.rab.title"),
|
||||
myCompound.addEditor(RUNNERS_TAB_NAME,
|
||||
new CompositeSettingsEditor<RunnerAndConfigurationSettings>(getFactory()) {
|
||||
@Override
|
||||
public CompositeSettingsBuilder<RunnerAndConfigurationSettings> getBuilder() {
|
||||
@@ -125,27 +132,25 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
|
||||
SettingsEditor<RunnerAndConfigurationSettings> wrappedConfigEditor = null;
|
||||
SettingsEditor<RunnerAndConfigurationSettings> wrappedRunEditor = null;
|
||||
if (configEditor != null) {
|
||||
wrappedConfigEditor = new SettingsEditorWrapper<RunnerAndConfigurationSettings, ConfigurationPerRunnerSettings>(configEditor,
|
||||
new Convertor<RunnerAndConfigurationSettings, ConfigurationPerRunnerSettings>() {
|
||||
@Override
|
||||
public ConfigurationPerRunnerSettings convert(RunnerAndConfigurationSettings configurationSettings) {
|
||||
return configurationSettings.getConfigurationSettings(runner);
|
||||
}
|
||||
});
|
||||
myRunnerEditors.add(wrappedConfigEditor);
|
||||
Disposer.register(this, wrappedConfigEditor);
|
||||
wrappedConfigEditor = wrapEditor(configEditor,
|
||||
new Convertor<RunnerAndConfigurationSettings, ConfigurationPerRunnerSettings>() {
|
||||
@Override
|
||||
public ConfigurationPerRunnerSettings convert(RunnerAndConfigurationSettings configurationSettings) {
|
||||
return configurationSettings.getConfigurationSettings(runner);
|
||||
}
|
||||
},
|
||||
runner);
|
||||
}
|
||||
|
||||
if (runnerEditor != null) {
|
||||
wrappedRunEditor = new SettingsEditorWrapper<RunnerAndConfigurationSettings, RunnerSettings>(runnerEditor,
|
||||
new Convertor<RunnerAndConfigurationSettings, RunnerSettings>() {
|
||||
@Override
|
||||
public RunnerSettings convert(RunnerAndConfigurationSettings configurationSettings) {
|
||||
return configurationSettings.getRunnerSettings(runner);
|
||||
}
|
||||
});
|
||||
myRunnerEditors.add(wrappedRunEditor);
|
||||
Disposer.register(this, wrappedRunEditor);
|
||||
wrappedRunEditor = wrapEditor(runnerEditor,
|
||||
new Convertor<RunnerAndConfigurationSettings, RunnerSettings>() {
|
||||
@Override
|
||||
public RunnerSettings convert(RunnerAndConfigurationSettings configurationSettings) {
|
||||
return configurationSettings.getRunnerSettings(runner);
|
||||
}
|
||||
},
|
||||
runner);
|
||||
}
|
||||
|
||||
if (wrappedRunEditor != null && wrappedConfigEditor != null) {
|
||||
@@ -161,6 +166,55 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
|
||||
return wrappedConfigEditor.getComponent();
|
||||
}
|
||||
|
||||
private <T> SettingsEditor<RunnerAndConfigurationSettings> wrapEditor(SettingsEditor<T> editor,
|
||||
Convertor<RunnerAndConfigurationSettings, T> convertor,
|
||||
ProgramRunner runner) {
|
||||
SettingsEditor<RunnerAndConfigurationSettings> wrappedEditor
|
||||
= new SettingsEditorWrapper<RunnerAndConfigurationSettings, T>(editor, convertor);
|
||||
|
||||
List<SettingsEditor> unwrappedEditors = myRunner2UnwrappedEditors.get(runner);
|
||||
if (unwrappedEditors == null) {
|
||||
unwrappedEditors = new ArrayList<SettingsEditor>();
|
||||
myRunner2UnwrappedEditors.put(runner, unwrappedEditors);
|
||||
}
|
||||
unwrappedEditors.add(editor);
|
||||
|
||||
myRunnerEditors.add(wrappedEditor);
|
||||
Disposer.register(this, wrappedEditor);
|
||||
|
||||
return wrappedEditor;
|
||||
}
|
||||
|
||||
public <T extends SettingsEditor> T selectExecutorAndGetEditor(final ProgramRunner runner, Class<T> editorClass) {
|
||||
myGroupSettingsBuilder.selectEditor(RUNNERS_TAB_NAME);
|
||||
Executor executor = ContainerUtil.find(myRunnersComponent.getExecutors(), new Condition<Executor>() {
|
||||
|
||||
@Override
|
||||
public boolean value(Executor executor) {
|
||||
return runner.equals(RunnerRegistry.getInstance().getRunner(executor.getId(), myConfiguration));
|
||||
}
|
||||
});
|
||||
if (executor == null) {
|
||||
return null;
|
||||
}
|
||||
myRunnersComponent.selectExecutor(executor);
|
||||
return ContainerUtil.findInstance(myRunner2UnwrappedEditors.get(runner), editorClass);
|
||||
}
|
||||
|
||||
public <T extends SettingsEditor> T selectTabAndGetEditor(Class<T> editorClass) {
|
||||
for (Pair<String, SettingsEditor<RunnerAndConfigurationSettings>> name2editor : myCompound.getEditors()) {
|
||||
SettingsEditor<RunnerAndConfigurationSettings> editor = name2editor.getSecond();
|
||||
if (editor instanceof ConfigToSettingsWrapper) {
|
||||
SettingsEditor<RunConfiguration> configEditor = ((ConfigToSettingsWrapper)editor).getConfigEditor();
|
||||
if (editorClass.isInstance(configEditor)) {
|
||||
myGroupSettingsBuilder.selectEditor(name2editor.getFirst());
|
||||
return editorClass.cast(configEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConfigurationSettingsEditor(RunnerAndConfigurationSettings settings) {
|
||||
super(settings.createFactory());
|
||||
myConfigurationEditor = (SettingsEditor<RunConfiguration>)settings.getConfiguration().getConfigurationEditor();
|
||||
@@ -224,6 +278,14 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
|
||||
ListScrollingUtil.ensureSelectionExists(myRunnersList);
|
||||
}
|
||||
|
||||
public List<Executor> getExecutors() {
|
||||
return Collections.list((Enumeration<Executor>)myListModel.elements());
|
||||
}
|
||||
|
||||
public void selectExecutor(Executor executor) {
|
||||
myRunnersList.setSelectedValue(executor, true);
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myRunnersPanel;
|
||||
}
|
||||
@@ -239,6 +301,10 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsEditor<RunConfiguration> getConfigEditor() {
|
||||
return myConfigEditor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetEditorFrom(RunnerAndConfigurationSettings configurationSettings) {
|
||||
myConfigEditor.resetFrom(configurationSettings.getConfiguration());
|
||||
|
||||
+19
-8
@@ -20,18 +20,18 @@ import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.UnknownRunConfiguration;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.impl.TypeSafeDataProviderAdapter;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.HideableDecorator;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -55,6 +55,14 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
private final ConfigurationSettingsEditor myEditor;
|
||||
private final HideableDecorator myDecorator;
|
||||
|
||||
public <T extends SettingsEditor> T selectExecutorAndGetEditor(ProgramRunner runner, Class<T> editorClass) {
|
||||
return myEditor.selectExecutorAndGetEditor(runner, editorClass);
|
||||
}
|
||||
|
||||
public <T extends SettingsEditor> T selectTabAndGetEditor(Class<T> editorClass) {
|
||||
return myEditor.selectTabAndGetEditor(editorClass);
|
||||
}
|
||||
|
||||
public ConfigurationSettingsEditorWrapper(final RunnerAndConfigurationSettings settings) {
|
||||
myEditor = new ConfigurationSettingsEditor(settings);
|
||||
Disposer.register(this, myEditor);
|
||||
@@ -91,7 +99,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
protected JComponent createEditor() {
|
||||
myComponentPlace.setLayout(new BorderLayout());
|
||||
myComponentPlace.add(myEditor.getComponent(), BorderLayout.CENTER);
|
||||
DataManager.registerDataProvider(myWholePanel, new TypeSafeDataProviderAdapter(new MyDataProvider()));
|
||||
DataManager.registerDataProvider(myWholePanel, new MyDataProvider());
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
@@ -144,12 +152,15 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
myDecorator.setTitle(title);
|
||||
}
|
||||
|
||||
private class MyDataProvider implements TypeSafeDataProvider {
|
||||
private class MyDataProvider implements DataProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void calcData(DataKey key, DataSink sink) {
|
||||
if (key.equals(CONFIGURATION_EDITOR_KEY)) {
|
||||
sink.put(CONFIGURATION_EDITOR_KEY, ConfigurationSettingsEditorWrapper.this);
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (CONFIGURATION_EDITOR_KEY.is(dataId)) {
|
||||
return ConfigurationSettingsEditorWrapper.this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.execution.*;
|
||||
import com.intellij.execution.configuration.ConfigurationFactoryEx;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
@@ -387,11 +388,18 @@ class RunConfigurable extends BaseConfigurable {
|
||||
myRightPanel.removeAll();
|
||||
mySelectedConfigurable = configurable;
|
||||
|
||||
final JBScrollPane scrollPane = new JBScrollPane(configurable.createComponent());
|
||||
JComponent configurableComponent = configurable.createComponent();
|
||||
final JBScrollPane scrollPane = new JBScrollPane(configurableComponent);
|
||||
scrollPane.setBorder(null);
|
||||
myRightPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
if (configurable instanceof SingleConfigurationConfigurable) {
|
||||
myRightPanel.add(((SingleConfigurationConfigurable)configurable).getValidationComponent(), BorderLayout.SOUTH);
|
||||
if (configurableComponent != null) {
|
||||
DataProvider dataProvider = DataManager.getDataProvider(configurableComponent);
|
||||
if (dataProvider != null) {
|
||||
DataManager.registerDataProvider(myRightPanel, dataProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupDialogBounds();
|
||||
|
||||
+17
-1
@@ -20,6 +20,8 @@ import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
@@ -126,7 +128,9 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
@Override
|
||||
public final JComponent createComponent() {
|
||||
myComponent.myNameText.setEnabled(!myBrokenConfiguration);
|
||||
return myComponent.getWholePanel();
|
||||
JComponent result = myComponent.getWholePanel();
|
||||
DataManager.registerDataProvider(result, new MyDataProvider());
|
||||
return result;
|
||||
}
|
||||
|
||||
final JComponent getValidationComponent() {
|
||||
@@ -403,4 +407,16 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
return "<html><body><b>" + configurationException.getTitle() + ": </b>" + configurationException.getMessage() + "</body></html>";
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDataProvider implements DataProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.is(dataId)) {
|
||||
return getEditor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameFilter;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameModel;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent;
|
||||
import com.intellij.ide.util.gotoByName.*;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -184,12 +181,24 @@ public abstract class GotoActionBase extends AnAction {
|
||||
@Nullable final String findUsagesTitle,
|
||||
boolean useSelectionFromEditor,
|
||||
final boolean allowMultipleSelection) {
|
||||
showNavigationPopup(e, model, callback, findUsagesTitle, useSelectionFromEditor, allowMultipleSelection,
|
||||
new DefaultChooseByNameItemProvider(getPsiContext(e)));
|
||||
}
|
||||
|
||||
protected <T> void showNavigationPopup(AnActionEvent e,
|
||||
ChooseByNameModel model,
|
||||
final GotoActionCallback<T> callback,
|
||||
@Nullable final String findUsagesTitle,
|
||||
boolean useSelectionFromEditor,
|
||||
final boolean allowMultipleSelection,
|
||||
final DefaultChooseByNameItemProvider itemProvider) {
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
boolean mayRequestOpenInCurrentWindow = model.willOpenEditor() && FileEditorManagerEx.getInstanceEx(project).hasSplitOrUndockedWindows();
|
||||
Pair<String, Integer> start = getInitialText(useSelectionFromEditor, e);
|
||||
showNavigationPopup(callback, findUsagesTitle,
|
||||
ChooseByNamePopup.createPopup(project, model, getPsiContext(e), start.first,
|
||||
mayRequestOpenInCurrentWindow, start.second), allowMultipleSelection);
|
||||
ChooseByNamePopup.createPopup(project, model, itemProvider, start.first,
|
||||
mayRequestOpenInCurrentWindow,
|
||||
start.second), allowMultipleSelection);
|
||||
}
|
||||
|
||||
protected <T> void showNavigationPopup(final GotoActionCallback<T> callback,
|
||||
|
||||
@@ -17,13 +17,9 @@
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameFilter;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
|
||||
import com.intellij.ide.util.gotoByName.GotoFileConfiguration;
|
||||
import com.intellij.ide.util.gotoByName.GotoFileModel;
|
||||
import com.intellij.ide.util.gotoByName.*;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
@@ -34,6 +30,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -58,7 +55,7 @@ public class GotoFileAction extends GotoActionBase implements DumbAware {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file");
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
final GotoFileModel gotoFileModel = new GotoFileModel(project);
|
||||
showNavigationPopup(e, gotoFileModel, new GotoActionCallback<FileType>() {
|
||||
GotoActionCallback<FileType> callback = new GotoActionCallback<FileType>() {
|
||||
@Override
|
||||
protected ChooseByNameFilter<FileType> createFilter(@NotNull ChooseByNamePopup popup) {
|
||||
return new GotoFileFilter(popup, gotoFileModel, project);
|
||||
@@ -84,7 +81,9 @@ public class GotoFileAction extends GotoActionBase implements DumbAware {
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}, "Files matching pattern", true);
|
||||
};
|
||||
PsiElement context = getPsiContext(e);
|
||||
showNavigationPopup(e, gotoFileModel, callback, "Files matching pattern", true, true, new GotoFileItemProvider(project, context));
|
||||
}
|
||||
|
||||
protected static class GotoFileFilter extends ChooseByNameFilter<FileType> {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNameBase;
|
||||
import com.intellij.ide.util.gotoByName.DefaultChooseByNameItemProvider;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class GotoFileItemProvider extends DefaultChooseByNameItemProvider {
|
||||
private final Project myProject;
|
||||
|
||||
public GotoFileItemProvider(@NotNull Project project, @Nullable PsiElement context) {
|
||||
super(context);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterElements(@NotNull ChooseByNameBase base,
|
||||
@NotNull String pattern,
|
||||
boolean everywhere,
|
||||
@NotNull ProgressIndicator indicator,
|
||||
@NotNull Processor<Object> consumer) {
|
||||
if (pattern.contains("/") || pattern.contains("\\")) {
|
||||
File ioFile = new File(pattern);
|
||||
VirtualFile vFile = ioFile.exists() ? LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile) : null;
|
||||
PsiFile psiFile = vFile == null ? null : PsiManager.getInstance(myProject).findFile(vFile);
|
||||
if (psiFile != null && !consumer.process(psiFile)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.filterElements(base, pattern, everywhere, indicator, consumer);
|
||||
}
|
||||
}
|
||||
@@ -341,10 +341,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
if (!data.isEmpty()) {
|
||||
final SerializedStubTree stub = data.values().iterator().next();
|
||||
ObjectStubBase root = (ObjectStubBase)stub.getStub(true);
|
||||
|
||||
ObjectStubTree objectStubTree = root instanceof PsiFileStub ? new StubTree((PsiFileStub)root, false) :
|
||||
new ObjectStubTree(root, false);
|
||||
Map<StubIndexKey, Map<Object, int[]>> map = objectStubTree.indexStubTree();
|
||||
Map<StubIndexKey, Map<Object, int[]>> map = new ObjectStubTree(root, false).indexStubTree();
|
||||
|
||||
// xxx:fix refs inplace
|
||||
stubTree = (Map)map;
|
||||
|
||||
+5
-8
@@ -32,7 +32,7 @@ import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.CharTable;
|
||||
@@ -46,7 +46,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class TemplateDataElementType extends IStubFileElementType implements ITemplateDataElementType {
|
||||
public class TemplateDataElementType extends IFileElementType implements ITemplateDataElementType {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.templateLanguages.TemplateDataElementType");
|
||||
|
||||
public static final LanguageExtension<TreePatcher> TREE_PATCHER = new LanguageExtension<TreePatcher>("com.intellij.lang.treePatcher", new SimpleTreePatcher());
|
||||
@@ -72,8 +72,7 @@ public class TemplateDataElementType extends IStubFileElementType implements ITe
|
||||
public ASTNode parseContents(ASTNode chameleon) {
|
||||
final CharTable table = SharedImplUtil.findCharTableByTree(chameleon);
|
||||
final FileElement treeElement = new DummyHolder(((TreeElement)chameleon).getManager(), null, table).getTreeElement();
|
||||
final FileElement fileElement = TreeUtil.getFileElement((TreeElement)chameleon);
|
||||
final PsiFile file = (PsiFile)fileElement.getPsi();
|
||||
final PsiFile file = (PsiFile)TreeUtil.getFileElement((TreeElement)chameleon).getPsi();
|
||||
PsiFile originalFile = file.getOriginalFile();
|
||||
|
||||
final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)originalFile.getViewProvider();
|
||||
@@ -113,10 +112,8 @@ public class TemplateDataElementType extends IStubFileElementType implements ITe
|
||||
DebugUtil.checkTreeStructure(parsed);
|
||||
DebugUtil.checkTreeStructure(treeElement);
|
||||
DebugUtil.checkTreeStructure(chameleon);
|
||||
if (fileElement != chameleon) {
|
||||
DebugUtil.checkTreeStructure(file.getNode());
|
||||
DebugUtil.checkTreeStructure(originalFile.getNode());
|
||||
}
|
||||
DebugUtil.checkTreeStructure(file.getNode());
|
||||
DebugUtil.checkTreeStructure(originalFile.getNode());
|
||||
|
||||
return childNode;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.options;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.components.JBTabbedPane;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -63,4 +64,17 @@ public class GroupSettingsBuilder<T> implements CompositeSettingsBuilder<T> {
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
public void selectEditor(String tabName) {
|
||||
List<Pair<String,SettingsEditor<T>>> editors = myGroup.getEditors();
|
||||
if (myComponent != null && editors.size() > 1) {
|
||||
for (int i = 0; i < editors.size(); i++) {
|
||||
Pair<String, SettingsEditor<T>> pair = editors.get(i);
|
||||
if (StringUtil.equals(tabName, pair.getFirst())) {
|
||||
((JTabbedPane)myComponent).setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1204,11 +1204,11 @@ public abstract class DialogWrapper {
|
||||
};
|
||||
toggleShowOptions.registerCustomShortcutSet(sc, root);
|
||||
|
||||
final JPanel northSection = new JPanel(new BorderLayout());
|
||||
root.add(northSection, BorderLayout.NORTH);
|
||||
|
||||
JComponent titlePane = createTitlePane();
|
||||
if (titlePane != null) {
|
||||
JPanel northSection = new JPanel(new BorderLayout());
|
||||
root.add(northSection, BorderLayout.NORTH);
|
||||
|
||||
northSection.add(titlePane, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui.table;
|
||||
|
||||
import com.intellij.ui.BooleanTableCellRenderer;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -266,6 +267,24 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
TableUtil.stopEditing(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultRenderers() {
|
||||
super.createDefaultRenderers();
|
||||
|
||||
UIDefaults.LazyValue booleanRenderer = new UIDefaults.LazyValue() {
|
||||
@Override
|
||||
public Object createValue(@NotNull UIDefaults table) {
|
||||
DefaultCellEditor editor = new DefaultCellEditor(GuiUtils.createUndoableTextField());
|
||||
editor.setClickCountToStart(1);
|
||||
return new BooleanTableCellRenderer();
|
||||
}
|
||||
};
|
||||
//noinspection unchecked
|
||||
defaultRenderersByColumnClass.put(boolean.class, booleanRenderer);
|
||||
//noinspection unchecked
|
||||
defaultRenderersByColumnClass.put(Boolean.class, booleanRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultEditors() {
|
||||
super.createDefaultEditors();
|
||||
@@ -273,11 +292,14 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
//noinspection unchecked
|
||||
defaultEditorsByColumnClass.put(String.class, new UIDefaults.LazyValue() {
|
||||
@Override
|
||||
public Object createValue(UIDefaults table) {
|
||||
public Object createValue(@NotNull UIDefaults table) {
|
||||
DefaultCellEditor editor = new DefaultCellEditor(GuiUtils.createUndoableTextField());
|
||||
editor.setClickCountToStart(1);
|
||||
return editor;
|
||||
}
|
||||
});
|
||||
|
||||
//noinspection unchecked
|
||||
defaultEditorsByColumnClass.put(boolean.class, defaultEditorsByColumnClass.get(Boolean.class));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-10
@@ -109,20 +109,13 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
|
||||
}
|
||||
|
||||
setLineMarkerRenderer(rangeMarker, fragment, type);
|
||||
setErrorStripes(rangeMarker, fragment, attributes.getErrorStripeColor());
|
||||
saveHighlighter(rangeMarker);
|
||||
}
|
||||
|
||||
private static void setErrorStripes(@NotNull RangeHighlighter rangeMarker, @NotNull Fragment fragment, @Nullable Color stripeBarColor) {
|
||||
rangeMarker.setThinErrorStripeMark(true);
|
||||
if (DiffUtil.isInlineWrapper(fragment)) {
|
||||
rangeMarker.setErrorStripeMarkColor(null);
|
||||
}
|
||||
else {
|
||||
if (stripeBarColor != null) {
|
||||
rangeMarker.setErrorStripeMarkColor(stripeBarColor);
|
||||
rangeMarker.setThinErrorStripeMark(true);
|
||||
}
|
||||
}
|
||||
|
||||
saveHighlighter(rangeMarker);
|
||||
}
|
||||
|
||||
private static void setLineMarkerRenderer(RangeHighlighter rangeMarker, Fragment fragment, TextDiffType type) {
|
||||
|
||||
@@ -76,7 +76,8 @@ public class TableModelEditor<T> implements ElementProducer<T> {
|
||||
table.setEnableAntialiasing(true);
|
||||
preferredScrollableViewportHeightInRows(JBTable.PREFERRED_SCROLLABLE_VIEWPORT_HEIGHT_IN_ROWS);
|
||||
new TableSpeedSearch(table);
|
||||
if (columns[0].getColumnClass() == Boolean.class && columns[0].getName().isEmpty()) {
|
||||
ColumnInfo firstColumn = columns[0];
|
||||
if ((firstColumn.getColumnClass() == boolean.class || firstColumn.getColumnClass() == Boolean.class) && firstColumn.getName().isEmpty()) {
|
||||
TableUtil.setupCheckboxColumn(table.getColumnModel().getColumn(0));
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ public class TableModelEditor<T> implements ElementProducer<T> {
|
||||
public abstract void dataChanged(@NotNull ColumnInfo<T, ?> columnInfo, int rowIndex);
|
||||
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
public void tableChanged(@NotNull TableModelEvent e) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +358,7 @@ public class TableModelEditor<T> implements ElementProducer<T> {
|
||||
return toolbarDecorator.addExtraAction(
|
||||
new ToolbarDecorator.ElementActionButton(IdeBundle.message("button.copy"), PlatformIcons.COPY_ICON) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
TableUtil.stopEditing(table);
|
||||
|
||||
List<T> selectedItems = table.getSelectedObjects();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.intellij.util.messages.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.util.SmartFMap;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.messages.MessageHandler;
|
||||
@@ -117,7 +118,10 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
|
||||
catch (AbstractMethodError e) {
|
||||
//Do nothing. This listener just does not implement something newly added yet.
|
||||
}
|
||||
catch(Throwable e) {
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e.getCause() == null ? e : e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ public final class VcsConfiguration implements PersistentStateComponent<VcsConfi
|
||||
public boolean USE_COMMIT_MESSAGE_MARGIN = false;
|
||||
public int COMMIT_MESSAGE_MARGIN_SIZE = 72;
|
||||
public boolean WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = false;
|
||||
public boolean SHOW_UNREGISTERED_ROOTS_IN_SETTINGS = true;
|
||||
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "path")
|
||||
@Tag("ignored-roots")
|
||||
|
||||
+9
-23
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.openapi.vcs.configurable;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
@@ -127,16 +126,18 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDirectoryRenderer extends ColoredTableCellRenderer {
|
||||
private static class MyDirectoryRenderer extends ColoredTableCellRenderer {
|
||||
private final Project myProject;
|
||||
|
||||
public MyDirectoryRenderer(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
|
||||
if (value instanceof MapInfo) {
|
||||
MapInfo info = (MapInfo)value;
|
||||
|
||||
if (!myVcsConfiguration.SHOW_UNREGISTERED_ROOTS_IN_SETTINGS && !info.type.isRegistered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!selected && (info == MapInfo.SEPARATOR || info.type == MapInfo.Type.UNREGISTERED)) {
|
||||
setBackground(getUnregisteredRootBackground());
|
||||
}
|
||||
@@ -218,10 +219,6 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab
|
||||
return new ColoredTableCellRenderer() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
|
||||
if (!myVcsConfiguration.SHOW_UNREGISTERED_ROOTS_IN_SETTINGS && !info.type.isRegistered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (info == MapInfo.SEPARATOR) {
|
||||
if (!selected) {
|
||||
setBackground(getUnregisteredRootBackground());
|
||||
@@ -315,7 +312,7 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab
|
||||
setLayout(new BorderLayout());
|
||||
add(createMainComponent());
|
||||
|
||||
myDirectoryRenderer = new MyDirectoryRenderer();
|
||||
myDirectoryRenderer = new MyDirectoryRenderer(myProject);
|
||||
DIRECTORY = new ColumnInfo<MapInfo, MapInfo>(VcsBundle.message("column.info.configure.vcses.directory")) {
|
||||
@Override
|
||||
public MapInfo valueOf(final MapInfo mapping) {
|
||||
@@ -568,18 +565,7 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab
|
||||
public boolean isEnabled(AnActionEvent e) {
|
||||
return !myIsDisabled && onlyRegisteredRootsInSelection();
|
||||
}
|
||||
}).disableUpDownActions().addExtraAction(new ToggleActionButton("Show unregistered roots", AllIcons.General.Filter) {
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return myVcsConfiguration.SHOW_UNREGISTERED_ROOTS_IN_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
myVcsConfiguration.SHOW_UNREGISTERED_ROOTS_IN_SETTINGS = state;
|
||||
myDirectoryMappingTable.repaint();
|
||||
}
|
||||
}).createPanel();
|
||||
}).disableUpDownActions().createPanel();
|
||||
panelForTable.setPreferredSize(new Dimension(-1, 200));
|
||||
return panelForTable;
|
||||
}
|
||||
|
||||
@@ -190,11 +190,10 @@ public class LineStatusTracker {
|
||||
int second =
|
||||
range.getLine2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine2());
|
||||
|
||||
final RangeHighlighter highlighter = DocumentMarkupModel.forDocument(myDocument, myProject, true)
|
||||
.addRangeHighlighter(first, second, HighlighterLayer.FIRST - 1, null, HighlighterTargetArea.LINES_IN_RANGE);
|
||||
|
||||
final TextAttributes attr = LineStatusTrackerDrawing.getAttributesFor(range);
|
||||
highlighter.setErrorStripeMarkColor(attr.getErrorStripeColor());
|
||||
final RangeHighlighter highlighter = DocumentMarkupModel.forDocument(myDocument, myProject, true)
|
||||
.addRangeHighlighter(first, second, HighlighterLayer.FIRST - 1, attr, HighlighterTargetArea.LINES_IN_RANGE);
|
||||
|
||||
highlighter.setThinErrorStripeMark(true);
|
||||
highlighter.setGreedyToLeft(true);
|
||||
highlighter.setGreedyToRight(true);
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.markup.ActiveGutterRenderer;
|
||||
import com.intellij.openapi.editor.markup.EffectType;
|
||||
import com.intellij.openapi.editor.markup.LineMarkerRenderer;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
@@ -63,10 +62,12 @@ public class LineStatusTrackerDrawing {
|
||||
}
|
||||
|
||||
static TextAttributes getAttributesFor(final Range range) {
|
||||
final Color stripeColor = getDiffColor(range);
|
||||
final TextAttributes textAttributes = new TextAttributes(null, stripeColor, null, EffectType.BOXED, Font.PLAIN);
|
||||
textAttributes.setErrorStripeColor(stripeColor);
|
||||
return textAttributes;
|
||||
return new TextAttributes() {
|
||||
@Override
|
||||
public Color getErrorStripeColor() {
|
||||
return getDiffColor(range);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void paintGutterFragment(final Editor editor, final Graphics g, final Rectangle r, final Range range) {
|
||||
|
||||
@@ -186,7 +186,7 @@ public class VcsRootProblemNotifier {
|
||||
description.append("<br/>");
|
||||
}
|
||||
|
||||
String add = invalidRoots.isEmpty() ? "<a href='add'>Add " + pluralize("root", unregisteredRoots.size()) + "<a/> " : "";
|
||||
String add = invalidRoots.isEmpty() ? "<a href='add'>Add " + pluralize("root", unregisteredRoots.size()) + "</a> " : "";
|
||||
String configure = "<a href='configure'>Configure</a>";
|
||||
String ignore = invalidRoots.isEmpty() ? " <a href='ignore'>Ignore</a>" : "";
|
||||
description.append(add + configure + ignore);
|
||||
|
||||
@@ -97,7 +97,9 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
|
||||
LogInfo data = loadRecentData(new CommitCountRequirements(myRecentCommitCount).asMap(myProviders.keySet()));
|
||||
Collection<List<GraphCommit<Integer>>> commits = data.getCommits();
|
||||
Map<VirtualFile, Set<VcsRef>> refs = data.getRefs();
|
||||
DataPack dataPack = DataPack.build(multiRepoJoin(commits), refs, myProviders, myHashMap, false);
|
||||
List<GraphCommit<Integer>> compoundList = multiRepoJoin(commits);
|
||||
compoundList = compoundList.subList(0, Math.min(myRecentCommitCount, compoundList.size()));
|
||||
DataPack dataPack = DataPack.build(compoundList, refs, myProviders, myHashMap, false);
|
||||
mySingleTaskController.request(RefreshRequest.RELOAD_ALL); // build/rebuild the full log in background
|
||||
return dataPack;
|
||||
}
|
||||
|
||||
@@ -149,14 +149,9 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
@Override
|
||||
public void run() {
|
||||
myVisiblePack.getVisibleGraph().getActionController().setLinearBranchesExpansion(false);
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleAnswer(null, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
handleAnswer(null, true);
|
||||
}
|
||||
|
||||
public void hideAll() {
|
||||
@@ -164,14 +159,9 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
@Override
|
||||
public void run() {
|
||||
myVisiblePack.getVisibleGraph().getActionController().setLinearBranchesExpansion(true);
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleAnswer(null, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
handleAnswer(null, true);
|
||||
}
|
||||
|
||||
public void setLongEdgeVisibility(boolean visibility) {
|
||||
|
||||
+52
-4
@@ -21,11 +21,13 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NotNullComputable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.SearchTextFieldWithStoredHistory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -39,6 +41,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -49,6 +53,7 @@ import java.util.List;
|
||||
public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
|
||||
private static final String HASH_PATTERN = "[a-fA-F0-9]{7,}";
|
||||
private static final Logger LOG = Logger.getInstance(VcsLogClassicFilterUi.class);
|
||||
|
||||
@NotNull private final VcsLogUiImpl myUi;
|
||||
|
||||
@@ -61,7 +66,7 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
@NotNull private final FilterModel<VcsLogUserFilter> myUserFilterModel;
|
||||
@NotNull private final FilterModel<VcsLogDateFilter> myDateFilterModel;
|
||||
@NotNull private final FilterModel<VcsLogStructureFilter> myStructureFilterModel;
|
||||
@NotNull private final FilterModel<VcsLogTextFilter> myTextFilterModel;
|
||||
@NotNull private final TextFilterModel myTextFilterModel;
|
||||
|
||||
public VcsLogClassicFilterUi(@NotNull VcsLogUiImpl ui,
|
||||
@NotNull VcsLogDataHolder logDataHolder,
|
||||
@@ -83,7 +88,7 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
myUserFilterModel = new FilterModel<VcsLogUserFilter>(dataPackGetter);
|
||||
myDateFilterModel = new FilterModel<VcsLogDateFilter>(dataPackGetter);
|
||||
myStructureFilterModel = new FilterModel<VcsLogStructureFilter>(dataPackGetter);
|
||||
myTextFilterModel = new FilterModel<VcsLogTextFilter>(dataPackGetter);
|
||||
myTextFilterModel = new TextFilterModel(dataPackGetter);
|
||||
|
||||
updateUiOnFilterChange();
|
||||
}
|
||||
@@ -196,9 +201,9 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
|
||||
private static class TextFilterComponent extends DumbAwareAction implements CustomComponentAction {
|
||||
|
||||
private final FilterModel<VcsLogTextFilter> myFilterModel;
|
||||
private final TextFilterModel myFilterModel;
|
||||
|
||||
public TextFilterComponent(FilterModel<VcsLogTextFilter> filterModel) {
|
||||
public TextFilterComponent(TextFilterModel filterModel) {
|
||||
myFilterModel = filterModel;
|
||||
}
|
||||
|
||||
@@ -219,6 +224,7 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
myFilterModel.setFilter(null);
|
||||
}
|
||||
};
|
||||
textFilter.setText(myFilterModel.getText());
|
||||
textFilter.getTextEditor().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
@@ -226,6 +232,17 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
textFilter.addCurrentTextToHistory();
|
||||
}
|
||||
});
|
||||
textFilter.addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
try {
|
||||
myFilterModel.setUnsavedText(e.getDocument().getText(0, e.getDocument().getLength()));
|
||||
}
|
||||
catch (BadLocationException ex) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
return textFilter;
|
||||
}
|
||||
|
||||
@@ -251,4 +268,35 @@ public class VcsLogClassicFilterUi implements VcsLogFilterUi {
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TextFilterModel extends FilterModel<VcsLogTextFilter> {
|
||||
@Nullable private String myText;
|
||||
|
||||
public TextFilterModel(NotNullComputable<VcsLogDataPack> dataPackProvider) {
|
||||
super(dataPackProvider);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String getText() {
|
||||
if (myText != null) {
|
||||
return myText;
|
||||
}
|
||||
else if (getFilter() != null) {
|
||||
return getFilter().getText();
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void setUnsavedText(@NotNull String text) {
|
||||
myText = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setFilter(@Nullable VcsLogTextFilter filter) {
|
||||
super.setFilter(filter);
|
||||
myText = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
myDebuggerManager.updateExecutionPoint(myCurrentStackFrame.getSourcePosition(), !isTopFrame, getPositionIconRenderer(isTopFrame));
|
||||
}
|
||||
|
||||
private boolean isTopFrameSelected() {
|
||||
public boolean isTopFrameSelected() {
|
||||
return myCurrentExecutionStack != null && myIsTopFrame;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -34,6 +34,7 @@ import com.intellij.util.NotNullProducer;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
import com.intellij.xdebugger.impl.frame.XDebugView;
|
||||
import com.intellij.xdebugger.impl.frame.XVariablesView;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
|
||||
@@ -98,7 +99,9 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
|
||||
catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
final Color color = bpLine == lineNumber ? new JBColor(new Color(0, 255, 86), new Color(255, 235, 9)) : getForeground();
|
||||
XDebugSession session = XDebugView.getSession(values.iterator().next().getTree());
|
||||
boolean isTopFrame = session instanceof XDebugSessionImpl && ((XDebugSessionImpl)session).isTopFrameSelected();
|
||||
final Color color = bpLine == lineNumber && isTopFrame ? new JBColor(new Color(0, 255, 86), new Color(255, 235, 9)) : getForeground();
|
||||
|
||||
final String name = value.getName();
|
||||
if (StringUtil.isEmpty(text.toString())) {
|
||||
|
||||
+9
-2
@@ -108,7 +108,14 @@ public class WeakestTypeFinder {
|
||||
referenceParent = referenceElement.getParent();
|
||||
}
|
||||
final PsiElement referenceGrandParent = referenceParent.getParent();
|
||||
if (referenceParent instanceof PsiExpressionList) {
|
||||
if (reference instanceof PsiMethodReferenceExpression) {
|
||||
final PsiMethodReferenceExpression methodReferenceExpression = (PsiMethodReferenceExpression)reference;
|
||||
final PsiType type = methodReferenceExpression.getFunctionalInterfaceType();
|
||||
final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(type);
|
||||
if (!PsiType.VOID.equals(returnType) && !checkType(returnType, weakestTypeClasses)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else if (referenceParent instanceof PsiExpressionList) {
|
||||
if (!(referenceGrandParent instanceof PsiMethodCallExpression)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -186,7 +193,7 @@ public class WeakestTypeFinder {
|
||||
if (referenceElement.equals(condition)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final PsiType type = ExpectedTypeUtils.findExpectedType( conditionalExpression, true);
|
||||
final PsiType type = ExpectedTypeUtils.findExpectedType(conditionalExpression, true);
|
||||
if (!checkType(type, weakestTypeClasses)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
+22
-3
@@ -1,10 +1,8 @@
|
||||
package com.siyeh.igtest.abstraction.weaken_type;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.*;
|
||||
|
||||
public class TypeMayBeWeakened {
|
||||
|
||||
@@ -173,4 +171,25 @@ class Helper {
|
||||
B<String> <warning descr="Type of variable 'b' may be weakened to 'A'">b</warning> = new B();
|
||||
b.foo();
|
||||
}
|
||||
}
|
||||
class MethodReference1 {
|
||||
public void m(Set<Integer> list) {
|
||||
f(MethodReference1::myTransform);
|
||||
}
|
||||
|
||||
void f(java.util.function.Function<Integer, String> function) {}
|
||||
|
||||
private static String myTransform(int in) {
|
||||
return Integer.toString(in);
|
||||
}
|
||||
}
|
||||
class MethodReference2 {
|
||||
public void main(String[] args) {
|
||||
Runnable r = MethodReference2::myTransform;
|
||||
Object o = myTransform();
|
||||
}
|
||||
|
||||
private static String <warning descr="Return type of method 'myTransform()' may be weakened to 'java.lang.Object'">myTransform</warning>() {
|
||||
return "Integer.toString(in)";
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
|
||||
<problem>
|
||||
<file>TypeMayBeWeakened.java</file>
|
||||
<line>55</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of parameter <code>b</code> may be weakened to 'java.lang.Object'</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TypeMayBeWeakened.java</file>
|
||||
<line>85</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of parameter <code>list</code> may be weakened to 'java.lang.Iterable'</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TypeMayBeWeakened.java</file>
|
||||
<line>68</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of variable <code>iaex</code> may be weakened to 'java.lang.RuntimeException'</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TypeMayBeWeakened.java</file>
|
||||
<line>133</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of parameter <code>objectInput</code> may be weakened to 'com.siyeh.igtest.abstraction.weaken_type.DataInput' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoClosableTest.java</file>
|
||||
<line>34</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of variable <code>bar</code> may be weakened to 'com.siyeh.igtest.abstraction.weaken_type.AutoClosableTest2.Foo' #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoClosableTest.java</file>
|
||||
<line>40</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Type may be weakened</problem_class>
|
||||
<description>Type of variable <code>reader</code> may be weakened to 'java.io.Closeable' #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+5
@@ -28,6 +28,11 @@ public class TypeMayBeWeakenedInspectionTest extends LightInspectionTestCase {
|
||||
" public int getNumberOne() {\n" +
|
||||
" return super.getNumberOne();\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
"package java.util.function;" +
|
||||
"@FunctionalInterface " +
|
||||
"public interface Function<T, R> {" +
|
||||
" R apply(T t);" +
|
||||
"}"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ public class GitAdd extends ScheduleForAdditionAction {
|
||||
|
||||
@Override
|
||||
protected boolean isStatusForAddition(FileStatus status) {
|
||||
return status == FileStatus.UNKNOWN || status == FileStatus.MODIFIED || status == FileStatus.MERGED_WITH_CONFLICTS;
|
||||
return status == FileStatus.UNKNOWN ||
|
||||
status == FileStatus.MODIFIED ||
|
||||
status == FileStatus.MERGED_WITH_CONFLICTS ||
|
||||
status == FileStatus.ADDED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package git4idea.settings;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import git4idea.config.UpdateMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -26,11 +27,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
@State(name = "Git.Push.Settings", storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)})
|
||||
public class GitPushSettings implements PersistentStateComponent<GitPushSettings.State> {
|
||||
|
||||
private static final UpdateMethod DEFAULT_UPDATE_METHOD = UpdateMethod.MERGE;
|
||||
|
||||
private State myState = new State();
|
||||
|
||||
public static class State {
|
||||
public boolean myUpdateAllRoots = true;
|
||||
public UpdateMethod myUpdateMethod = UpdateMethod.MERGE;
|
||||
public UpdateMethod myUpdateMethod = DEFAULT_UPDATE_METHOD;
|
||||
}
|
||||
|
||||
public static GitPushSettings getInstance(Project project) {
|
||||
@@ -57,7 +60,7 @@ public class GitPushSettings implements PersistentStateComponent<GitPushSettings
|
||||
|
||||
@NotNull
|
||||
public UpdateMethod getUpdateMethod() {
|
||||
return myState.myUpdateMethod;
|
||||
return ObjectUtils.notNull(myState.myUpdateMethod, DEFAULT_UPDATE_METHOD);
|
||||
}
|
||||
|
||||
public void setUpdateMethod(@NotNull UpdateMethod updateMethod) {
|
||||
|
||||
+6
-6
@@ -38,27 +38,27 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
return ServiceManager.getService(DslActivationStatus.class);
|
||||
}
|
||||
|
||||
public void activateUntilModification(@NotNull VirtualFile vfile) {
|
||||
public synchronized void activateUntilModification(@NotNull VirtualFile vfile) {
|
||||
myStatus.put(vfile, ENABLED);
|
||||
}
|
||||
|
||||
public void disableFile(@NotNull VirtualFile vfile, @NotNull String error) {
|
||||
public synchronized void disableFile(@NotNull VirtualFile vfile, @NotNull String error) {
|
||||
myStatus.put(vfile, error);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getInactivityReason(VirtualFile file) {
|
||||
public synchronized String getInactivityReason(VirtualFile file) {
|
||||
String status = myStatus.get(file);
|
||||
return status == null || status == ENABLED ? null : status;
|
||||
}
|
||||
|
||||
public boolean isActivated(VirtualFile file) {
|
||||
public synchronized boolean isActivated(VirtualFile file) {
|
||||
return myStatus.get(file) == ENABLED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Element getState() {
|
||||
public synchronized Element getState() {
|
||||
Element root = new Element("x");
|
||||
for (Map.Entry<VirtualFile, String> entry : myStatus.entrySet()) {
|
||||
VirtualFile file = entry.getKey();
|
||||
@@ -72,7 +72,7 @@ public class DslActivationStatus implements PersistentStateComponent<Element> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
public synchronized void loadState(Element state) {
|
||||
List<Element> children = state.getChildren("file");
|
||||
for (Element element : children) {
|
||||
String url = element.getAttributeValue("url", "");
|
||||
|
||||
@@ -385,6 +385,13 @@ public class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
return Result.create(Collections.<GroovyDslScript>emptyList(), ModificationTracker.NEVER_CHANGED);
|
||||
}
|
||||
|
||||
// eagerly initialize some services used by background gdsl parsing threads
|
||||
// because service init requires a read action
|
||||
// and there could be a deadlock with a write action waiting already on EDT
|
||||
// if current thread is inside a non-cancellable read action
|
||||
GroovyDslExecutor.getIdeaVersion();
|
||||
DslActivationStatus.getInstance();
|
||||
|
||||
int count = 0;
|
||||
|
||||
List<GroovyDslScript> result = new ArrayList<GroovyDslScript>();
|
||||
|
||||
+4
-2
@@ -381,11 +381,13 @@ public class ResolveUtil {
|
||||
else {
|
||||
key = base.getCanonicalText();
|
||||
}
|
||||
Map<String, PsiType> result = cache.get(key);
|
||||
Map<String, PsiType> result = key == null ? null : cache.get(key);
|
||||
if (result == null) {
|
||||
result = new HashMap<String, PsiType>();
|
||||
collectSuperTypes(base, result, project);
|
||||
cache.put(key, result);
|
||||
if (key != null) {
|
||||
cache.put(key, result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+16
-2
@@ -326,6 +326,16 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
return compiled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildStarted(CompileContext context) {
|
||||
if (myForStubs) {
|
||||
File stubRoot = getStubRoot(context);
|
||||
if (stubRoot.exists() && !FileUtil.deleteWithRenaming(stubRoot)) {
|
||||
context.processMessage(new CompilerMessage(myBuilderName, BuildMessage.Kind.ERROR, "External make cannot clean " + stubRoot.getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkBuildFinished(CompileContext context, ModuleChunk chunk) {
|
||||
JavaBuilderUtil.cleanupChunkResources(context);
|
||||
@@ -334,10 +344,10 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static Map<ModuleBuildTarget, String> getStubGenerationOutputs(ModuleChunk chunk, CompileContext context) throws IOException {
|
||||
Map<ModuleBuildTarget, String> generationOutputs = new HashMap<ModuleBuildTarget, String>();
|
||||
File commonRoot = new File(context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(), "groovyStubs");
|
||||
File commonRoot = getStubRoot(context);
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
File targetRoot = new File(commonRoot, target.getModule().getName() + File.separator + target.getTargetType().getTypeId());
|
||||
if (!FileUtil.deleteWithRenaming(targetRoot)) {
|
||||
if (targetRoot.exists() && !FileUtil.deleteWithRenaming(targetRoot)) {
|
||||
throw new IOException("External make cannot clean " + targetRoot.getPath());
|
||||
}
|
||||
if (!targetRoot.mkdirs()) {
|
||||
@@ -348,6 +358,10 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
return generationOutputs;
|
||||
}
|
||||
|
||||
private static File getStubRoot(CompileContext context) {
|
||||
return new File(context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(), "groovyStubs");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Map<ModuleBuildTarget, String> getCanonicalModuleOutputs(CompileContext context, ModuleChunk chunk, Builder builder) {
|
||||
Map<ModuleBuildTarget, String> finalOutputs = new HashMap<ModuleBuildTarget, String>();
|
||||
|
||||
+16
-3
@@ -15,11 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.compiler;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -520,7 +523,7 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
}
|
||||
|
||||
public void testUpdatingWhenPropertiesInFiltersAreChanged() throws Exception {
|
||||
VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1");
|
||||
final VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1");
|
||||
createProjectSubFile("resources/file.properties", "value=${xxx}");
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
@@ -541,7 +544,12 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
compileModules("project");
|
||||
assertResult("target/classes/file.properties", "value=1");
|
||||
|
||||
VfsUtil.saveText(filter, "xxx=2");
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
VfsUtil.saveText(filter, "xxx=2");
|
||||
}
|
||||
}.execute().throwException();
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
compileModules("project");
|
||||
assertResult("target/classes/file.properties", "value=2");
|
||||
@@ -1010,7 +1018,12 @@ public class ResourceFilteringTest extends MavenCompilingTestCase {
|
||||
public void testDoNotFilterButCopyBigFiles() throws Exception {
|
||||
assertEquals(FileTypeManager.getInstance().getFileTypeByFileName("file.xyz"), FileTypes.UNKNOWN);
|
||||
|
||||
createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
createProjectSubFile("resources/file.xyz").setBinaryContent(new byte[1024 * 1024 * 20]);
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
importProject("<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
|
||||
+1
-1
@@ -521,7 +521,7 @@ public class MavenModuleCompletionAndResolutionTest extends MavenDomWithIndicesT
|
||||
|
||||
importProject(parentPom);
|
||||
|
||||
VfsUtil.saveText(parentPom, createPomXml(
|
||||
myFixture.saveText(parentPom, createPomXml(
|
||||
"<groupId>test</groupId>" +
|
||||
"<artifactId>project</artifactId>" +
|
||||
"<version>1</version>" +
|
||||
|
||||
+5
-6
@@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.importing
|
||||
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
@@ -28,7 +27,7 @@ class EncodingImportingTest extends MavenImportingTestCase {
|
||||
byte[] text = [-12, -59, -53, -45, -44] // Russian text in koi8-r encoding.
|
||||
|
||||
VirtualFile file = createProjectSubFile("src/main/resources/A.txt")
|
||||
file.setBinaryContent(text)
|
||||
ApplicationManager.application.runWriteAction { file.setBinaryContent(text) }
|
||||
|
||||
importProject("""
|
||||
<groupId>test</groupId>
|
||||
@@ -49,7 +48,7 @@ class EncodingImportingTest extends MavenImportingTestCase {
|
||||
byte[] text = [-12, -59, -53, 45, -44] // Russian text in koi8-r encoding.
|
||||
|
||||
VirtualFile file = createProjectSubFile("src/main/resources/A.txt")
|
||||
file.setBinaryContent(text)
|
||||
ApplicationManager.application.runWriteAction { file.setBinaryContent(text) }
|
||||
|
||||
importProject("""
|
||||
<groupId>test</groupId>
|
||||
|
||||
+10
-1
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.importing;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.MavenCustomRepositoryHelper;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.model.MavenProjectProblem;
|
||||
@@ -34,7 +37,13 @@ public class InvalidProjectImportingTest extends MavenImportingTestCase {
|
||||
|
||||
public void testUnknownProblemWithEmptyFile() throws Exception {
|
||||
createProjectPom("");
|
||||
myProjectPom.setBinaryContent(new byte[0]);
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
myProjectPom.setBinaryContent(new byte[0]);
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
importProject();
|
||||
|
||||
assertModules("project");
|
||||
|
||||
+46
-46
@@ -244,13 +244,13 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
protected void run(Result<VirtualFile> result) throws Throwable {
|
||||
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
|
||||
result.setResult(res);
|
||||
VfsUtil.saveText(res, "<project>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
VfsUtil.saveText(file, "<project>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
"</project>");
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
MavenModel p = readProject(file);
|
||||
|
||||
@@ -309,49 +309,49 @@ public class MavenProjectReaderTest extends MavenTestCase {
|
||||
protected void run(Result<VirtualFile> result) throws Throwable {
|
||||
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
|
||||
result.setResult(res);
|
||||
VfsUtil.saveText(res, "<project>" +
|
||||
" <modelVersion>1.2.3</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <name>foo</name>" +
|
||||
" <packaging>pom</packaging>" +
|
||||
|
||||
" <parent>" +
|
||||
" <groupId>testParent</groupId>" +
|
||||
" <artifactId>projectParent</artifactId>" +
|
||||
" <version>2</version>" +
|
||||
" <relativePath>../parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
|
||||
" <build>" +
|
||||
" <finalName>xxx</finalName>" +
|
||||
" <defaultGoal>someGoal</defaultGoal>" +
|
||||
" <sourceDirectory>mySrc</sourceDirectory>" +
|
||||
" <testSourceDirectory>myTestSrc</testSourceDirectory>" +
|
||||
" <scriptSourceDirectory>myScriptSrc</scriptSourceDirectory>" +
|
||||
" <resources>" +
|
||||
" <resource>" +
|
||||
" <directory>myRes</directory>" +
|
||||
" <filtering>true</filtering>" +
|
||||
" <targetPath>dir</targetPath>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" <excludes><exclude>**.xml</exclude></excludes>" +
|
||||
" </resource>" +
|
||||
" </resources>" +
|
||||
" <testResources>" +
|
||||
" <testResource>" +
|
||||
" <directory>myTestRes</directory>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" </testResource>" +
|
||||
" </testResources>" +
|
||||
" <directory>myOutput</directory>" +
|
||||
" <outputDirectory>myClasses</outputDirectory>" +
|
||||
" <testOutputDirectory>myTestClasses</testOutputDirectory>" +
|
||||
" </build>" +
|
||||
"</project>");
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
VfsUtil.saveText(file, "<project>" +
|
||||
" <modelVersion>1.2.3</modelVersion>" +
|
||||
" <groupId>test</groupId>" +
|
||||
" <artifactId>project</artifactId>" +
|
||||
" <version>1</version>" +
|
||||
" <name>foo</name>" +
|
||||
" <packaging>pom</packaging>" +
|
||||
|
||||
" <parent>" +
|
||||
" <groupId>testParent</groupId>" +
|
||||
" <artifactId>projectParent</artifactId>" +
|
||||
" <version>2</version>" +
|
||||
" <relativePath>../parent/pom.xml</relativePath>" +
|
||||
" </parent>" +
|
||||
|
||||
" <build>" +
|
||||
" <finalName>xxx</finalName>" +
|
||||
" <defaultGoal>someGoal</defaultGoal>" +
|
||||
" <sourceDirectory>mySrc</sourceDirectory>" +
|
||||
" <testSourceDirectory>myTestSrc</testSourceDirectory>" +
|
||||
" <scriptSourceDirectory>myScriptSrc</scriptSourceDirectory>" +
|
||||
" <resources>" +
|
||||
" <resource>" +
|
||||
" <directory>myRes</directory>" +
|
||||
" <filtering>true</filtering>" +
|
||||
" <targetPath>dir</targetPath>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" <excludes><exclude>**.xml</exclude></excludes>" +
|
||||
" </resource>" +
|
||||
" </resources>" +
|
||||
" <testResources>" +
|
||||
" <testResource>" +
|
||||
" <directory>myTestRes</directory>" +
|
||||
" <includes><include>**.properties</include></includes>" +
|
||||
" </testResource>" +
|
||||
" </testResources>" +
|
||||
" <directory>myOutput</directory>" +
|
||||
" <outputDirectory>myClasses</outputDirectory>" +
|
||||
" <testOutputDirectory>myTestClasses</testOutputDirectory>" +
|
||||
" </build>" +
|
||||
"</project>");
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
MavenModel p = readProject(file);
|
||||
|
||||
|
||||
+12
-4
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.MavenImportingTestCase;
|
||||
import org.jetbrains.idea.maven.model.MavenExplicitProfiles;
|
||||
import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
@@ -46,9 +49,14 @@ public abstract class MavenProjectsTreeTestCase extends MavenImportingTestCase {
|
||||
myTree.delete(asList(file), getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
|
||||
}
|
||||
|
||||
protected void updateTimestamps(VirtualFile... files) throws IOException {
|
||||
for (VirtualFile each : files) {
|
||||
each.setBinaryContent(each.contentsToByteArray());
|
||||
}
|
||||
protected void updateTimestamps(final VirtualFile... files) throws IOException {
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
for (VirtualFile each : files) {
|
||||
each.setBinaryContent(each.contentsToByteArray());
|
||||
}
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ final class BrowserSettingsPanel {
|
||||
browsersEditor = new TableModelEditor<ConfigurableWebBrowser>(COLUMNS, itemEditor, "No web browsers configured")
|
||||
.modelListener(new TableModelEditor.DataChangedListener<ConfigurableWebBrowser>() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent event) {
|
||||
public void tableChanged(@NotNull TableModelEvent event) {
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package com.intellij.xml.actions.xmlbeans;
|
||||
|
||||
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.*;
|
||||
@@ -62,11 +60,6 @@ public class FileUtils {
|
||||
return name + num + ext;
|
||||
}
|
||||
|
||||
|
||||
public static void saveText(VirtualFile virtualFile, String text) throws IOException {
|
||||
VfsUtil.saveText(virtualFile, text);
|
||||
}
|
||||
|
||||
public static boolean copyFile(File in, File out) {
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(in);
|
||||
|
||||
Reference in New Issue
Block a user