mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -265,7 +265,6 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase {
|
||||
};
|
||||
myProject.save();
|
||||
CompilerTestUtil.saveApplicationSettings();
|
||||
CompilerTestUtil.scanSourceRootsToRecompile(myProject);
|
||||
action.run(callback);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.intellij.psi.formatter.common.AbstractBlock;
|
||||
import com.intellij.psi.formatter.java.wrap.JavaWrapManager;
|
||||
import com.intellij.psi.formatter.java.wrap.ReservedWrapsProvider;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.codeStyle.*;
|
||||
import com.intellij.psi.impl.source.codeStyle.ShiftIndentInsideHelper;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.impl.source.tree.java.ClassElement;
|
||||
@@ -41,10 +41,12 @@ import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.psi.formatter.java.JavaFormatterUtil.getWrapType;
|
||||
import static com.intellij.psi.formatter.java.MultipleFieldDeclarationHelper.*;
|
||||
import static com.intellij.psi.formatter.java.MultipleFieldDeclarationHelper.findLastFieldInGroup;
|
||||
|
||||
public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlock, ReservedWrapsProvider {
|
||||
|
||||
@@ -436,9 +438,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
myIsAfterClassKeyword = true;
|
||||
}
|
||||
if (childType == JavaElementType.METHOD_CALL_EXPRESSION) {
|
||||
result.add(createMethodCallExpressionBlock(child,
|
||||
arrangeChildWrap(child, defaultWrap),
|
||||
arrangeChildAlignment(child, alignmentStrategy), childIndent));
|
||||
Alignment alignment = shouldAlignChild(child) ? alignmentStrategy.getAlignment(childType) : null;
|
||||
result.add(createMethodCallExpressionBlock(child, arrangeChildWrap(child, defaultWrap), alignment, childIndent));
|
||||
}
|
||||
else {
|
||||
IElementType nodeType = myNode.getElementType();
|
||||
@@ -505,7 +506,11 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
result.add(new SimpleJavaBlock(child, defaultWrap, alignmentStrategy, childIndent, mySettings, myJavaSettings));
|
||||
}
|
||||
else {
|
||||
AlignmentStrategy alignmentStrategyToUse = AlignmentStrategy.wrap(arrangeChildAlignment(child, alignmentStrategy));
|
||||
Alignment alignment = alignmentStrategy.getAlignment(childType);
|
||||
AlignmentStrategy alignmentStrategyToUse = shouldAlignChild(child)
|
||||
? AlignmentStrategy.wrap(alignment)
|
||||
: AlignmentStrategy.getNullStrategy();
|
||||
|
||||
if (myAlignmentStrategy.getAlignment(nodeType, childType) != null &&
|
||||
(nodeType == JavaElementType.IMPLEMENTS_LIST || nodeType == JavaElementType.CLASS)) {
|
||||
alignmentStrategyToUse = myAlignmentStrategy;
|
||||
@@ -646,54 +651,52 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Alignment arrangeChildAlignment(@NotNull final ASTNode child, @NotNull final AlignmentStrategy alignmentStrategy) {
|
||||
private boolean shouldAlignChild(@NotNull final ASTNode child) {
|
||||
int role = getChildRole(child);
|
||||
final IElementType nodeType = myNode.getElementType();
|
||||
Alignment defaultAlignment = alignmentStrategy.getAlignment(child.getElementType());
|
||||
|
||||
if (nodeType == JavaElementType.FOR_STATEMENT) {
|
||||
if (role == ChildRole.FOR_INITIALIZATION || role == ChildRole.CONDITION || role == ChildRole.FOR_UPDATE) {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
else if (nodeType == JavaElementType.EXTENDS_LIST || nodeType == JavaElementType.IMPLEMENTS_LIST) {
|
||||
if (role == ChildRole.REFERENCE_IN_LIST || role == ChildRole.IMPLEMENTS_KEYWORD) {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
else if (nodeType == JavaElementType.THROWS_LIST) {
|
||||
if (role == ChildRole.REFERENCE_IN_LIST) {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
else if (nodeType == JavaElementType.CLASS) {
|
||||
if (role == ChildRole.CLASS_OR_INTERFACE_KEYWORD) return defaultAlignment;
|
||||
if (myIsAfterClassKeyword) return null;
|
||||
if (role == ChildRole.MODIFIER_LIST) return defaultAlignment;
|
||||
return null;
|
||||
if (role == ChildRole.CLASS_OR_INTERFACE_KEYWORD) return true;
|
||||
if (myIsAfterClassKeyword) return false;
|
||||
if (role == ChildRole.MODIFIER_LIST) return true;
|
||||
return false;
|
||||
}
|
||||
else if (JavaElementType.FIELD == nodeType) {
|
||||
return getVariableDeclarationSubElementAlignment(child);
|
||||
return shouldAlignFieldInColumns(child);
|
||||
}
|
||||
else if (nodeType == JavaElementType.METHOD) {
|
||||
if (role == ChildRole.MODIFIER_LIST) return defaultAlignment;
|
||||
if (role == ChildRole.TYPE_PARAMETER_LIST) return defaultAlignment;
|
||||
if (role == ChildRole.TYPE) return defaultAlignment;
|
||||
if (role == ChildRole.NAME) return defaultAlignment;
|
||||
if (role == ChildRole.THROWS_LIST && mySettings.ALIGN_THROWS_KEYWORD) return defaultAlignment;
|
||||
return null;
|
||||
if (role == ChildRole.MODIFIER_LIST) return true;
|
||||
if (role == ChildRole.TYPE_PARAMETER_LIST) return true;
|
||||
if (role == ChildRole.TYPE) return true;
|
||||
if (role == ChildRole.NAME) return true;
|
||||
if (role == ChildRole.THROWS_LIST && mySettings.ALIGN_THROWS_KEYWORD) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
else if (nodeType == JavaElementType.ASSIGNMENT_EXPRESSION) {
|
||||
if (role == ChildRole.LOPERAND) return defaultAlignment;
|
||||
if (role == ChildRole.LOPERAND) return true;
|
||||
if (role == ChildRole.ROPERAND && child.getElementType() == JavaElementType.ASSIGNMENT_EXPRESSION) {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
else if (child.getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
|
||||
@@ -704,9 +707,9 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
CharSequence prevChars;
|
||||
if (previous != null && previous.getElementType() == TokenType.WHITE_SPACE && (prevChars = previous.getChars()).length() > 0
|
||||
&& prevChars.charAt(prevChars.length() - 1) == '\n') {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (nodeType == JavaElementType.MODIFIER_LIST) {
|
||||
@@ -714,13 +717,13 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
// that the list is aligned. We want to apply alignment rule only to the first element then.
|
||||
ASTNode previous = child.getTreePrev();
|
||||
if (previous == null || previous.getTreeParent() != myNode) {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
else {
|
||||
return defaultAlignment;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,12 +740,12 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
* @see CodeStyleSettings#ALIGN_GROUP_FIELD_DECLARATIONS
|
||||
*/
|
||||
@Nullable
|
||||
private Alignment getVariableDeclarationSubElementAlignment(@NotNull ASTNode child) {
|
||||
private boolean shouldAlignFieldInColumns(@NotNull ASTNode child) {
|
||||
// The whole idea of variable declarations alignment is that complete declaration blocks which children are to be aligned hold
|
||||
// reference to the same AlignmentStrategy object, hence, reuse the same Alignment objects. So, there is no point in checking
|
||||
// if it's necessary to align sub-blocks if shared strategy is not defined.
|
||||
if (!mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
IElementType childType = child.getElementType();
|
||||
@@ -751,10 +754,10 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
// should be aligned then.
|
||||
ASTNode previousNode = FormatterUtil.getPreviousNonWhitespaceSibling(child);
|
||||
if (childType == JavaTokenType.IDENTIFIER && (previousNode == null || previousNode.getElementType() == JavaTokenType.COMMA)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return myAlignmentStrategy.getAlignment(childType);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -64,21 +63,22 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
|
||||
myCurrentIndent = null;
|
||||
processHeadCommentsAndWhiteSpaces(result);
|
||||
|
||||
myReservedAlignment = createChildAlignment();
|
||||
myReservedAlignment2 = createChildAlignment2(myReservedAlignment);
|
||||
calculateReservedAlignments();
|
||||
|
||||
Wrap childWrap = createChildWrap();
|
||||
processRemainingChildren(result, childWrap);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Alignment createChildAlignment2(@Nullable Alignment base) {
|
||||
final IElementType nodeType = myNode.getElementType();
|
||||
if (nodeType == JavaElementType.CONDITIONAL_EXPRESSION) {
|
||||
return base == null ? createAlignment(mySettings.ALIGN_MULTILINE_TERNARY_OPERATION, null) : createAlignment(base, mySettings.ALIGN_MULTILINE_TERNARY_OPERATION, null);
|
||||
private void calculateReservedAlignments() {
|
||||
myReservedAlignment = createChildAlignment();
|
||||
|
||||
IElementType nodeType = myNode.getElementType();
|
||||
if (nodeType == JavaElementType.CONDITIONAL_EXPRESSION && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION) {
|
||||
myReservedAlignment2 = myReservedAlignment != null ? Alignment.createChildAlignment(myReservedAlignment)
|
||||
: Alignment.createAlignment();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void processRemainingChildren(List<Block> result, Wrap childWrap) {
|
||||
@@ -86,6 +86,12 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
|
||||
if (isNotEmptyNode(myCurrentChild)) {
|
||||
final ASTNode astNode = myCurrentChild;
|
||||
AlignmentStrategy alignmentStrategyToUse = AlignmentStrategy.wrap(chooseAlignment(myReservedAlignment, myReservedAlignment2, myCurrentChild));
|
||||
|
||||
if (myNode.getElementType() == JavaElementType.FIELD) {
|
||||
alignmentStrategyToUse = myAlignmentStrategy;
|
||||
}
|
||||
|
||||
|
||||
myCurrentChild = processChild(result, astNode, alignmentStrategyToUse, childWrap, myCurrentIndent, myCurrentOffset);
|
||||
if (astNode != myCurrentChild && myCurrentChild != null) {
|
||||
myCurrentOffset = myCurrentChild.getTextRange().getStartOffset();
|
||||
@@ -124,7 +130,7 @@ public class SimpleJavaBlock extends AbstractJavaBlock {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNotEmptyNode(@NotNull ASTNode child) {
|
||||
private static boolean isNotEmptyNode(@NotNull ASTNode child) {
|
||||
return !FormatterUtil.containsWhiteSpacesOnly(child) && child.getTextLength() > 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
}
|
||||
|
||||
public boolean isDeclareFinal() {
|
||||
return myCbFinal.isEnabled() && myCbFinalState;
|
||||
return myCbFinal.isSelected();
|
||||
}
|
||||
|
||||
public boolean isReplaceLValues() {
|
||||
@@ -264,7 +264,7 @@ class IntroduceVariableDialog extends DialogWrapper implements IntroduceVariable
|
||||
myNameSuggestionsManager.nameSelected();
|
||||
myTypeSelectorManager.typeSelected(getSelectedType());
|
||||
if (myCbFinal.isEnabled()) {
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbFinalState;
|
||||
JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbFinal.isSelected();
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class PsiCapturedWildcardType extends PsiType.Stub {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (myContext instanceof PsiReferenceExpression && !Comparing.equal(myParameter, captured.myParameter)) {
|
||||
if ((myContext instanceof PsiReferenceExpression || myContext instanceof PsiMethodCallExpression) && !Comparing.equal(myParameter, captured.myParameter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,23 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
}
|
||||
}
|
||||
if (alreadyFound) continue;*/
|
||||
final PsiType substituted = substituteInternal(original);
|
||||
PsiType substituted;
|
||||
if (original instanceof PsiWildcardType) {
|
||||
substituted = substituteInternal(original);
|
||||
if (substituted instanceof PsiCapturedWildcardType) {
|
||||
substituted = PsiCapturedWildcardType.create(((PsiCapturedWildcardType)substituted).getWildcard(), ((PsiCapturedWildcardType)substituted).getContext(), param);
|
||||
}
|
||||
else if (substituted instanceof PsiWildcardType) {
|
||||
PsiType bound = ((PsiWildcardType)substituted).getBound();
|
||||
if (bound instanceof PsiCapturedWildcardType) {
|
||||
bound = PsiCapturedWildcardType.create(((PsiCapturedWildcardType)bound).getWildcard(), ((PsiCapturedWildcardType)bound).getContext(), param);
|
||||
substituted = ((PsiWildcardType)substituted).isExtends() ? PsiWildcardType.createExtends(((PsiWildcardType)substituted).getManager(), bound)
|
||||
: PsiWildcardType.createSuper(((PsiWildcardType)substituted).getManager(), bound);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
substituted = substituteInternal(original);
|
||||
}
|
||||
//if (substituted == null) return false;
|
||||
substMap.put(param, substituted);
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class B<S, M> {}
|
||||
abstract class A<T> {
|
||||
<K> void baz(B<K, K> a) {}
|
||||
abstract B<?, ?> foo();
|
||||
void bar(A<?> a) {
|
||||
baz<error descr="'baz(B<capture<?>,capture<?>>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo())</error>;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
class B<T1,S> {}
|
||||
abstract class A<T> {
|
||||
<K> void baz5(B<K, K> a) {}
|
||||
abstract B<T, ? super T> foo5();
|
||||
void bar5(A<? super T> a) {
|
||||
baz5<error descr="'baz5(B<capture<? super T>,capture<? super T>>)' in 'A' cannot be applied to '(B<capture<? super T>,capture<? super T>>)'">(a.foo5())</error>;
|
||||
}
|
||||
|
||||
<K> void baz7(B<K, K> a) {}
|
||||
abstract B<T, ? extends T> foo7();
|
||||
void bar7(A<?> a) {
|
||||
baz7<error descr="'baz7(B<capture<?>,capture<?>>)' in 'A' cannot be applied to '(B<capture<?>,capture<?>>)'">(a.foo7())</error>;
|
||||
}
|
||||
|
||||
<K> void baz9(B<K, K> a) {}
|
||||
abstract B<T, ? extends T> foo9();
|
||||
void bar9(A<? extends T> a) {
|
||||
baz9<error descr="'baz9(B<capture<? extends T>,capture<? extends T>>)' in 'A' cannot be applied to '(B<capture<? extends T>,capture<? extends T>>)'">(a.foo9())</error>;
|
||||
}
|
||||
|
||||
|
||||
<K> void baz14(B<K, K> a) {}
|
||||
abstract B<? super T, ? super T> foo14();
|
||||
void bar14(A<? super T> a) {
|
||||
baz14<error descr="'baz14(B<capture<? super T>,capture<? super T>>)' in 'A' cannot be applied to '(B<capture<? super T>,capture<? super T>>)'">(a.foo14())</error>;
|
||||
}
|
||||
|
||||
|
||||
<K> void baz24(B<K, K> a) {}
|
||||
abstract B<? extends T, ? extends T> foo24();
|
||||
void bar24(A<? extends T> a) {
|
||||
baz24<error descr="'baz24(B<capture<? extends T>,capture<? extends T>>)' in 'A' cannot be applied to '(B<capture<? extends T>,capture<? extends T>>)'">(a.foo24())</error>;
|
||||
}
|
||||
}
|
||||
@@ -442,6 +442,14 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testDistinguishWildcardCapturesAlsoByMethodCalls() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testSubstituteTypeParameterOfCapturedWildcardOnSubstitution() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
assertNotNull(collectionsClass);
|
||||
|
||||
+14
@@ -407,4 +407,18 @@ public class JavaFormatterAlignmentTest extends AbstractJavaFormatterTest {
|
||||
getSettings().RIGHT_MARGIN = 75;
|
||||
doMethodTest(before, before);
|
||||
}
|
||||
|
||||
public void testAlignMethodCalls_PassedAsParameters_InMethodCall() {
|
||||
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
|
||||
|
||||
doMethodTest(
|
||||
"test(call1(),\n" +
|
||||
" call2(),\n" +
|
||||
" call3());\n",
|
||||
"test(call1(),\n" +
|
||||
" call2(),\n" +
|
||||
" call3());\n"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.JDOMExternalizable;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.NamedJDOMExternalizable;
|
||||
@@ -29,9 +28,9 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
import org.jetbrains.jps.model.serialization.JDomSerializationUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
@@ -54,11 +53,10 @@ public class CompilerTestUtil {
|
||||
compilerConfiguration.setDefaultCompiler(compilerConfiguration.getJavacCompiler());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated not needed anymore
|
||||
*/
|
||||
public static void scanSourceRootsToRecompile(Project project) {
|
||||
// need this to emulate project opening
|
||||
final List<VirtualFile> roots = ProjectRootManager.getInstance(project).getModuleSourceRoots(JavaModuleSourceRootTypes.SOURCES);
|
||||
// todo: forced source roots scan is not needed?
|
||||
//TranslatingCompilerFilesMonitor.getInstance().scanSourceContent(new TranslatingCompilerFilesMonitor.ProjectRef(project), roots, roots.size(), true);
|
||||
}
|
||||
|
||||
public static void saveApplicationSettings() {
|
||||
@@ -73,9 +71,9 @@ public class CompilerTestUtil {
|
||||
State state = StoreUtil.getStateSpec(appComponent.getClass());
|
||||
if (state != null) {
|
||||
componentName = state.name();
|
||||
Storage lastStorage = state.storages()[state.storages().length - 1];
|
||||
Storage storageToWrite = findNonDeprecated(state.storages());
|
||||
StateStorageManager storageManager = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager();
|
||||
file = new File(storageManager.expandMacros(lastStorage.file()));
|
||||
file = new File(storageManager.expandMacros(storageToWrite.file()));
|
||||
}
|
||||
else if (appComponent instanceof ExportableApplicationComponent && appComponent instanceof NamedJDOMExternalizable) {
|
||||
componentName = ((ExportableApplicationComponent)appComponent).getComponentName();
|
||||
@@ -123,6 +121,15 @@ public class CompilerTestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static Storage findNonDeprecated(Storage[] storages) {
|
||||
for (Storage storage : storages) {
|
||||
if (!storage.deprecated()) {
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
throw new AssertionFailedError("All storages are deprecated");
|
||||
}
|
||||
|
||||
public static void enableExternalCompiler() {
|
||||
new WriteAction() {
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.jetbrains.jps.incremental;
|
||||
|
||||
import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -151,7 +152,7 @@ public class FSOperations {
|
||||
for (final BuildTarget<?> target : targetChunk.getTargets()) {
|
||||
if (target instanceof ModuleBuildTarget) {
|
||||
final Set<JpsModule> deps = getDependentModulesRecursively(((ModuleBuildTarget)target).getModule(), classpathKind);
|
||||
if (Utils.intersects(deps, modules)) {
|
||||
if (ContainerUtil.intersects(deps, modules)) {
|
||||
for (BuildTarget<?> buildTarget : targetChunk.getTargets()) {
|
||||
if (buildTarget instanceof ModuleBuildTarget) {
|
||||
dirtyTargets.add((ModuleBuildTarget)buildTarget);
|
||||
|
||||
@@ -22,14 +22,15 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.PathUtilRt;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectLoader;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -122,13 +123,6 @@ public class Utils {
|
||||
return new File(toURI(path));
|
||||
}
|
||||
|
||||
public static boolean intersects(Set<JpsModule> set1, Set<JpsModule> set2) {
|
||||
if (set1.size() < set2.size()) {
|
||||
return new HashSet<JpsModule>(set1).removeAll(set2);
|
||||
}
|
||||
return new HashSet<JpsModule>(set2).removeAll(set1);
|
||||
}
|
||||
|
||||
public static boolean errorsDetected(CompileContext context) {
|
||||
return ERRORS_DETECTED_KEY.get(context, Boolean.FALSE);
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ public class JpsGantProjectBuilder {
|
||||
String.valueOf(sources));
|
||||
if (!myBuildIncrementally && sources > 0) {
|
||||
myBuildInfoPrinter.printStatisticsMessage(JpsGantProjectBuilder.this, "Compilation time per file for '" + message.getBuilderName() + "', ms",
|
||||
String.format("%.2f", (double)message.getElapsedTimeMs() / sources));
|
||||
String.format(Locale.US, "%.2f", (double)message.getElapsedTimeMs() / sources));
|
||||
}
|
||||
}
|
||||
else if (!text.isEmpty()) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Properties;
|
||||
@@ -68,7 +69,10 @@ public abstract class FileTemplateManager{
|
||||
|
||||
public abstract void setCurrentScheme(@NotNull FileTemplatesScheme scheme);
|
||||
|
||||
@NotNull
|
||||
/**
|
||||
* @return Project scheme, or null if manager is created for default project.
|
||||
*/
|
||||
@Nullable
|
||||
public abstract FileTemplatesScheme getProjectScheme();
|
||||
|
||||
public abstract FileTemplate[] getTemplates(String category);
|
||||
|
||||
@@ -46,8 +46,12 @@ public class ChangeSchemaCombo extends ComboBoxAction implements DumbAware {
|
||||
@NotNull
|
||||
@Override
|
||||
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
|
||||
return new DefaultActionGroup(new ChangeSchemaAction(FileTemplatesScheme.DEFAULT),
|
||||
new ChangeSchemaAction(myConfigurable.getManager().getProjectScheme()));
|
||||
DefaultActionGroup group = new DefaultActionGroup(new ChangeSchemaAction(FileTemplatesScheme.DEFAULT));
|
||||
FileTemplatesScheme scheme = myConfigurable.getManager().getProjectScheme();
|
||||
if (scheme != null) {
|
||||
group.add(new ChangeSchemaAction(scheme));
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +68,7 @@ public class ChangeSchemaCombo extends ComboBoxAction implements DumbAware {
|
||||
|
||||
private final FileTemplatesScheme myScheme;
|
||||
|
||||
public ChangeSchemaAction(FileTemplatesScheme scheme) {
|
||||
public ChangeSchemaAction(@NotNull FileTemplatesScheme scheme) {
|
||||
super(scheme.getName());
|
||||
myScheme = scheme;
|
||||
}
|
||||
|
||||
+12
-13
@@ -66,6 +66,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers
|
||||
private final FileTypeManagerEx myTypeManager;
|
||||
private final Project myProject;
|
||||
|
||||
@Nullable
|
||||
private final FileTemplatesScheme myProjectScheme;
|
||||
private FileTemplatesScheme myScheme = FileTemplatesScheme.DEFAULT;
|
||||
|
||||
@@ -88,17 +89,16 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers
|
||||
final Project project) {
|
||||
myTypeManager = typeManager;
|
||||
myProject = project;
|
||||
ExportableFileTemplateSettings templateSettings = ExportableFileTemplateSettings.getInstance();
|
||||
assert templateSettings != null : "Can not instantiate " + ExportableFileTemplateSettings.class.getName();
|
||||
FileTemplatesLoader loader = new FileTemplatesLoader(typeManager);
|
||||
|
||||
myInternalTemplatesManager = templateSettings.getInternalTemplatesManager();
|
||||
myDefaultTemplatesManager = templateSettings.getDefaultTemplatesManager();
|
||||
myPatternsManager = templateSettings.getPatternsManager();
|
||||
myCodeTemplatesManager = templateSettings.getCodeTemplatesManager();
|
||||
myJ2eeTemplatesManager = templateSettings.getJ2eeTemplatesManager();
|
||||
myAllManagers = templateSettings.getAllManagers();
|
||||
myDefaultTemplateDescription = templateSettings.getDefaultTemplateDescription();
|
||||
myDefaultIncludeDescription = templateSettings.getDefaultIncludeDescription();
|
||||
myInternalTemplatesManager = loader.getInternalTemplatesManager();
|
||||
myDefaultTemplatesManager = loader.getDefaultTemplatesManager();
|
||||
myPatternsManager = loader.getPatternsManager();
|
||||
myCodeTemplatesManager = loader.getCodeTemplatesManager();
|
||||
myJ2eeTemplatesManager = loader.getJ2eeTemplatesManager();
|
||||
myAllManagers = loader.getAllManagers();
|
||||
myDefaultTemplateDescription = loader.getDefaultTemplateDescription();
|
||||
myDefaultIncludeDescription = loader.getDefaultIncludeDescription();
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
for (String tname : Arrays.asList("Class", "AnnotationType", "Enum", "Interface")) {
|
||||
@@ -113,7 +113,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers
|
||||
}
|
||||
}
|
||||
|
||||
myProjectScheme = new FileTemplatesScheme("Project") {
|
||||
myProjectScheme = project.isDefault() ? null : new FileTemplatesScheme("Project") {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTemplatesDir() {
|
||||
@@ -143,7 +143,6 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FileTemplatesScheme getProjectScheme() {
|
||||
return myProjectScheme;
|
||||
@@ -434,7 +433,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Pers
|
||||
@Override
|
||||
public void loadState(State state) {
|
||||
XmlSerializerUtil.copyBean(state, myState);
|
||||
setCurrentScheme(myProjectScheme.getName().equals(state.SCHEME) ? myProjectScheme : FileTemplatesScheme.DEFAULT);
|
||||
setCurrentScheme(myProjectScheme != null && myProjectScheme.getName().equals(state.SCHEME) ? myProjectScheme : FileTemplatesScheme.DEFAULT);
|
||||
}
|
||||
|
||||
public static class State {
|
||||
|
||||
@@ -2560,12 +2560,12 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
}
|
||||
for (VirtualFile root : IndexableSetContributor.getRootsToIndex(provider)) {
|
||||
if (visitedRoots.add(root)) {
|
||||
iterateRecursively(root, processor, indicator, visitedRoots);
|
||||
iterateRecursively(root, processor, indicator, visitedRoots, null);
|
||||
}
|
||||
}
|
||||
for (VirtualFile root : IndexableSetContributor.getProjectRootsToIndex(provider, project)) {
|
||||
if (visitedRoots.add(root)) {
|
||||
iterateRecursively(root, processor, indicator, visitedRoots);
|
||||
iterateRecursively(root, processor, indicator, visitedRoots, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2588,7 +2588,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
for (VirtualFile[] roots : new VirtualFile[][]{libSources, libClasses}) {
|
||||
for (VirtualFile root : roots) {
|
||||
if (visitedRoots.add(root)) {
|
||||
iterateRecursively(root, processor, indicator, null);
|
||||
iterateRecursively(root, processor, indicator, null, projectFileIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2601,8 +2601,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
private static void iterateRecursively(@Nullable final VirtualFile root,
|
||||
@NotNull final ContentIterator processor,
|
||||
@Nullable final ProgressIndicator indicator,
|
||||
@Nullable final Set<VirtualFile> visitedRoots
|
||||
) {
|
||||
@Nullable final Set<VirtualFile> visitedRoots,
|
||||
@Nullable final ProjectFileIndex projectFileIndex) {
|
||||
if (root == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2613,6 +2613,9 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
if (visitedRoots != null && !root.equals(file) && file.isDirectory() && !visitedRoots.add(file)) {
|
||||
return false; // avoid visiting files more than once, e.g. additional indexed roots intersect sometimes
|
||||
}
|
||||
if (projectFileIndex != null && projectFileIndex.isExcluded(file)) {
|
||||
return false;
|
||||
}
|
||||
if (indicator != null) indicator.checkCanceled();
|
||||
|
||||
processor.processFile(file);
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.ex.MessagesEx;
|
||||
import com.intellij.openapi.updateSettings.impl.PluginDownloader;
|
||||
@@ -415,7 +416,7 @@ public class InstalledPluginsManagerMain extends PluginManagerMain {
|
||||
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
|
||||
final DefaultActionGroup gr = new DefaultActionGroup();
|
||||
for (final String enabledValue : InstalledPluginsTableModel.ENABLED_VALUES) {
|
||||
gr.add(new AnAction(enabledValue) {
|
||||
gr.add(new DumbAwareAction(enabledValue) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final IdeaPluginDescriptor[] selection = pluginTable.getSelectedObjects();
|
||||
|
||||
@@ -43,6 +43,11 @@ public abstract class AbstractSortByAction extends ToggleAction {
|
||||
return isSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSelected(AnActionEvent e, boolean state) {
|
||||
IdeaPluginDescriptor[] selected = myTable.getSelectedObjects();
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Searches through classes, files, tool windows, actions, settings, and symbols by double pressing
|
||||
<span class="product">&productName;</span> allows you to search through the classes,
|
||||
files, tool windows, actions, settings, and symbols of your project by double pressing
|
||||
the <span class="shortcut">Shift</span> key.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,10 +16,13 @@
|
||||
package com.intellij.ide;
|
||||
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.FileTemplatesScheme;
|
||||
import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable;
|
||||
import com.intellij.ide.fileTemplates.impl.BundledFileTemplate;
|
||||
import com.intellij.ide.fileTemplates.impl.FileTemplateManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
|
||||
@@ -50,6 +53,11 @@ public class LightFileTemplatesTest extends LightPlatformTestCase {
|
||||
assertEquals("good bye", myTemplateManager.getTemplate(TEST_TEMPLATE_TXT).getText());
|
||||
}
|
||||
|
||||
public void testDefaultProject() throws Exception {
|
||||
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
|
||||
assertNull(FileTemplateManager.getInstance(defaultProject).getProjectScheme());
|
||||
}
|
||||
|
||||
public void testConfigurable() throws Exception {
|
||||
AllFileTemplatesConfigurable configurable = new AllFileTemplatesConfigurable(getProject());
|
||||
try {
|
||||
|
||||
@@ -1422,10 +1422,18 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
|
||||
@Contract(pure=true)
|
||||
public static <T> boolean intersects(@NotNull Collection<? extends T> collection1, @NotNull Collection<? extends T> collection2) {
|
||||
for (T t : collection1) {
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (collection2.contains(t)) {
|
||||
return true;
|
||||
if (collection1.size() <= collection2.size()) {
|
||||
for (T t : collection1) {
|
||||
if (collection2.contains(t)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (T t : collection2) {
|
||||
if (collection1.contains(t)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in New Issue
Block a user