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:
+2
-1
@@ -26,6 +26,7 @@ import com.intellij.debugger.ui.DebuggerExpressionTextField;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -217,7 +218,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
myChildrenExpandedEditor.setText(myChildrenExpandedEditor.getText());
|
||||
myListChildrenEditor.setText(myListChildrenEditor.getText());
|
||||
}
|
||||
});
|
||||
}, ModalityState.any());
|
||||
}
|
||||
|
||||
private void updateEnabledState() {
|
||||
|
||||
@@ -184,6 +184,8 @@ public class UserRenderersConfigurable implements SearchableConfigurable, Config
|
||||
public void apply() throws ConfigurationException {
|
||||
myRendererDataConfigurable.apply();
|
||||
flushTo(NodeRendererSettings.getInstance().getCustomRenderers());
|
||||
|
||||
NodeRendererSettings.getInstance().fireRenderersChanged();
|
||||
}
|
||||
|
||||
private void flushTo(final RendererConfiguration rendererConfiguration) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -45,10 +45,7 @@ import com.intellij.psi.search.searches.OverridingMethodsSearch;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.targets.AliasingPsiTarget;
|
||||
import com.intellij.psi.targets.AliasingPsiTargetMapper;
|
||||
import com.intellij.psi.util.MethodSignature;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.psi.xml.XmlAttributeValue;
|
||||
import com.intellij.refactoring.util.JavaNonCodeSearchElementDescriptionProvider;
|
||||
import com.intellij.refactoring.util.NonCodeSearchDescriptionLocation;
|
||||
@@ -127,7 +124,7 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
|
||||
elementsToSearch.add(parameters[idx]);
|
||||
}
|
||||
}
|
||||
return elementsToSearch.toArray(new PsiElement[elementsToSearch.size()]);
|
||||
return PsiUtilCore.toPsiElementArray(elementsToSearch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,6 +101,38 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
GROUPING_RULES.put(DEPENDENT_METHODS, ContainerUtilRt.newArrayList(BREADTH_FIRST, DEPTH_FIRST));
|
||||
}
|
||||
|
||||
private static final StdArrangementSettings DEFAULT_SETTINGS;
|
||||
|
||||
static {
|
||||
List<ArrangementGroupingRule> groupingRules = ContainerUtilRt.newArrayList(new ArrangementGroupingRule(GETTERS_AND_SETTERS));
|
||||
List<StdArrangementMatchRule> matchRules = ContainerUtilRt.newArrayList();
|
||||
ArrangementSettingsToken[] visibility = {PUBLIC, PROTECTED, PACKAGE_PRIVATE, PRIVATE};
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, STATIC, FINAL, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, STATIC, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, FINAL, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, modifier);
|
||||
}
|
||||
and(matchRules, FIELD);
|
||||
and(matchRules, CONSTRUCTOR);
|
||||
and(matchRules, METHOD, STATIC);
|
||||
and(matchRules, METHOD);
|
||||
and(matchRules, ENUM);
|
||||
and(matchRules, INTERFACE);
|
||||
and(matchRules, CLASS, STATIC);
|
||||
and(matchRules, CLASS);
|
||||
|
||||
DEFAULT_SETTINGS = new StdRulePriorityAwareSettings(groupingRules, matchRules);
|
||||
}
|
||||
|
||||
private static final DefaultArrangementSettingsSerializer SETTINGS_SERIALIZER = new DefaultArrangementSettingsSerializer(DEFAULT_SETTINGS);
|
||||
|
||||
@NotNull
|
||||
private static Set<ArrangementSettingsToken> concat(@NotNull Set<ArrangementSettingsToken> base, ArrangementSettingsToken... modifiers) {
|
||||
Set<ArrangementSettingsToken> result = ContainerUtilRt.newHashSet(base);
|
||||
@@ -279,32 +311,14 @@ public class JavaRearranger implements Rearranger<JavaElementArrangementEntry>,
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StdArrangementSettings getDefaultSettings() {
|
||||
List<ArrangementGroupingRule> groupingRules = ContainerUtilRt.newArrayList(new ArrangementGroupingRule(GETTERS_AND_SETTERS));
|
||||
List<StdArrangementMatchRule> matchRules = ContainerUtilRt.newArrayList();
|
||||
ArrangementSettingsToken[] visibility = {PUBLIC, PROTECTED, PACKAGE_PRIVATE, PRIVATE};
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, STATIC, FINAL, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, STATIC, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, FINAL, modifier);
|
||||
}
|
||||
for (ArrangementSettingsToken modifier : visibility) {
|
||||
and(matchRules, FIELD, modifier);
|
||||
}
|
||||
and(matchRules, FIELD);
|
||||
and(matchRules, CONSTRUCTOR);
|
||||
and(matchRules, METHOD, STATIC);
|
||||
and(matchRules, METHOD);
|
||||
and(matchRules, ENUM);
|
||||
and(matchRules, INTERFACE);
|
||||
and(matchRules, CLASS, STATIC);
|
||||
and(matchRules, CLASS);
|
||||
public ArrangementSettingsSerializer getSerializer() {
|
||||
return SETTINGS_SERIALIZER;
|
||||
}
|
||||
|
||||
return new StdRulePriorityAwareSettings(groupingRules, matchRules);
|
||||
@NotNull
|
||||
@Override
|
||||
public StdArrangementSettings getDefaultSettings() {
|
||||
return DEFAULT_SETTINGS;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -31,7 +31,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.ShiftIndentInsideHelper;
|
||||
import com.intellij.psi.impl.source.codeStyle.*;
|
||||
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;
|
||||
@@ -457,7 +457,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
if (childType == JavaElementType.METHOD_CALL_EXPRESSION) {
|
||||
result.add(createMethodCallExpressionBlock(child,
|
||||
arrangeChildWrap(child, defaultWrap),
|
||||
arrangeChildAlignment(child, alignmentStrategy)));
|
||||
arrangeChildAlignment(child, alignmentStrategy), childIndent));
|
||||
}
|
||||
else {
|
||||
IElementType nodeType = myNode.getElementType();
|
||||
@@ -710,10 +710,10 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Block createMethodCallExpressionBlock(@NotNull final ASTNode node, final Wrap blockWrap, final Alignment alignment) {
|
||||
private Block createMethodCallExpressionBlock(@NotNull ASTNode node, Wrap blockWrap, Alignment alignment, Indent indent) {
|
||||
final ArrayList<ASTNode> nodes = new ArrayList<ASTNode>();
|
||||
collectNodes(nodes, node);
|
||||
return new ChainMethodCallsBlockBuilder(alignment, blockWrap).build(nodes);
|
||||
return new ChainMethodCallsBlockBuilder(alignment, blockWrap, indent).build(nodes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1028,6 +1028,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
|
||||
ASTNode prev = child;
|
||||
boolean afterAnonymousClass = false;
|
||||
final boolean enforceIndent = shouldEnforceIndentToChildren();
|
||||
while (child != null) {
|
||||
isAfterIncomplete = isAfterIncomplete || child.getElementType() == TokenType.ERROR_ELEMENT ||
|
||||
child.getElementType() == JavaElementType.EMPTY_EXPRESSION;
|
||||
@@ -1044,7 +1045,6 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
}
|
||||
else {
|
||||
final IElementType elementType = child.getElementType();
|
||||
final boolean enforceIndent = shouldEnforceIndentToChildren(child);
|
||||
Indent indentToUse = enforceIndent ? internalIndentEnforcedToChildren : internalIndent;
|
||||
AlignmentStrategy alignmentStrategyToUse = canUseAnonymousClassAlignment(child) ? anonymousClassStrategy : alignmentStrategy;
|
||||
processChild(result, child, alignmentStrategyToUse.getAlignment(elementType), wrappingStrategy.getWrap(elementType), indentToUse);
|
||||
@@ -1105,7 +1105,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean shouldEnforceIndentToChildren(@NotNull ASTNode node) {
|
||||
private boolean shouldEnforceIndentToChildren() {
|
||||
if (myNode.getElementType() != JavaElementType.EXPRESSION_LIST) {
|
||||
return false;
|
||||
}
|
||||
@@ -1114,9 +1114,9 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
return false;
|
||||
}
|
||||
|
||||
PsiExpressionList methodParamsList = (PsiExpressionList)myNode.getPsi();
|
||||
return JavaFormatterUtil.hasMultilineArguments(methodParamsList)
|
||||
&& JavaFormatterUtil.isMultilineExceptArguments(methodParamsList);
|
||||
PsiExpression[] arguments = ((PsiExpressionList)myNode.getPsi()).getExpressions();
|
||||
return (JavaFormatterUtil.hasMultilineArguments(arguments) || JavaFormatterUtil.canHaveMultilineArgumentsAfterWrap(arguments, mySettings))
|
||||
&& (JavaFormatterUtil.isMultilineExceptArguments(arguments) || JavaFormatterUtil.canBeMultilineExceptArgumentsAfterWrap(arguments, mySettings));
|
||||
}
|
||||
|
||||
private static boolean isAnonymousClass(@Nullable ASTNode node) {
|
||||
@@ -1432,13 +1432,15 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
private class ChainMethodCallsBlockBuilder {
|
||||
private Wrap blockWrap;
|
||||
private Alignment blockAlignment;
|
||||
private Indent blockIndent;
|
||||
|
||||
private Wrap myWrap;
|
||||
private Alignment myChainedCallsAlignment;
|
||||
|
||||
public ChainMethodCallsBlockBuilder(Alignment alignment, Wrap wrap) {
|
||||
public ChainMethodCallsBlockBuilder(Alignment alignment, Wrap wrap, Indent indent) {
|
||||
blockWrap = wrap;
|
||||
blockAlignment = alignment;
|
||||
blockIndent = indent;
|
||||
}
|
||||
|
||||
public Block build(List<ASTNode> nodes) {
|
||||
@@ -1446,8 +1448,8 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo
|
||||
myChainedCallsAlignment = getNewAlignment();
|
||||
|
||||
List<Block> blocks = buildBlocksFrom(nodes);
|
||||
Indent indent = Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS);
|
||||
|
||||
Indent indent = blockIndent != null ? blockIndent : Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS);
|
||||
return new SyntheticCodeBlock(blocks, blockAlignment, mySettings, indent, blockWrap);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiExpressionList;
|
||||
import com.intellij.psi.PsiPolyadicExpression;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -75,10 +73,7 @@ public class JavaFormatterUtil {
|
||||
return expression1.getOperationTokenType() == expression2.getOperationTokenType();
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasMultilineArguments(@NotNull PsiExpressionList list) {
|
||||
PsiExpression[] arguments = list.getExpressions();
|
||||
|
||||
public static boolean hasMultilineArguments(@NotNull PsiExpression[] arguments) {
|
||||
for (PsiExpression argument: arguments) {
|
||||
ASTNode node = argument.getNode();
|
||||
if (node.textContains('\n'))
|
||||
@@ -88,9 +83,21 @@ public class JavaFormatterUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isMultilineExceptArguments(@NotNull PsiExpressionList list) {
|
||||
PsiExpression[] arguments = list.getExpressions();
|
||||
public static boolean canHaveMultilineArgumentsAfterWrap(@NotNull PsiExpression[] arguments, @NotNull CommonCodeStyleSettings settings) {
|
||||
for (PsiExpression argument: arguments) {
|
||||
ASTNode node = argument.getNode();
|
||||
|
||||
if (node instanceof PsiMethodCallExpression) {
|
||||
if (settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE || settings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE) {
|
||||
if (((PsiMethodCallExpression)node).getArgumentList().getExpressions().length > 0) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isMultilineExceptArguments(@NotNull PsiExpression[] arguments) {
|
||||
for (PsiExpression argument : arguments) {
|
||||
ASTNode beforeArgument = argument.getNode().getTreePrev();
|
||||
if (isWhiteSpaceWithLineFeed(beforeArgument))
|
||||
@@ -102,6 +109,11 @@ public class JavaFormatterUtil {
|
||||
return isWhiteSpaceWithLineFeed(afterLastArgument);
|
||||
}
|
||||
|
||||
public static boolean canBeMultilineExceptArgumentsAfterWrap(@NotNull PsiExpression[] arguments, @NotNull CommonCodeStyleSettings settings) {
|
||||
return arguments.length > 0
|
||||
&& (settings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE || settings.CALL_PARAMETERS_RPAREN_ON_NEXT_LINE);
|
||||
}
|
||||
|
||||
private static boolean isWhiteSpaceWithLineFeed(@NotNull ASTNode node) {
|
||||
return node instanceof PsiWhiteSpace
|
||||
&& node.textContains('\n');
|
||||
|
||||
@@ -1151,7 +1151,8 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
|
||||
createParenthSpace(mySettings.CALL_PARAMETERS_LPAREN_ON_NEXT_LINE, mySettings.SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES);
|
||||
}
|
||||
else if (myRole2 == ChildRole.RPARENTH) {
|
||||
if (JavaFormatterUtil.hasMultilineArguments(list) && JavaFormatterUtil.isMultilineExceptArguments(list)) {
|
||||
PsiExpression[] arguments = list.getExpressions();
|
||||
if (JavaFormatterUtil.hasMultilineArguments(arguments) && JavaFormatterUtil.isMultilineExceptArguments(arguments)) {
|
||||
myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, 0);
|
||||
}
|
||||
else {
|
||||
|
||||
+151
-47
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Modifier.PRIVATE
|
||||
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Modifier.PUBLIC
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 11/20/12 3:34 PM
|
||||
@@ -24,51 +27,152 @@ class JavaRearrangerFoldingTest extends AbstractJavaRearrangerTest {
|
||||
void "test dummy"() {
|
||||
}
|
||||
|
||||
// This should be uncommented as soon as cdr pushed fixes for range markers processing.
|
||||
// void "test that doc comment folding is preserved"() {
|
||||
// commonSettings.BLANK_LINES_AROUND_METHOD = 1
|
||||
// doTest(
|
||||
// initial: '''\
|
||||
//import <fold>java.util.List;
|
||||
//import java.util.Set;</fold>
|
||||
//
|
||||
//<fold text="/**...*/">/**
|
||||
// * Class comment
|
||||
// */</fold>
|
||||
//class Test {
|
||||
//
|
||||
// <fold text="/**...*/>/**
|
||||
// * Method comment
|
||||
// */</fold>
|
||||
// private void test(List<String> l) {}
|
||||
//
|
||||
// <fold text="/**...*/>/**
|
||||
// * Another method comment
|
||||
// */</fold>
|
||||
// public void test(Set<String> s) {}
|
||||
//}''',
|
||||
//
|
||||
// rules: [rule(PUBLIC), rule(PRIVATE)],
|
||||
//
|
||||
// expected: '''\
|
||||
//import <fold>java.util.List;
|
||||
//import java.util.Set;</fold>
|
||||
//
|
||||
//<fold text="/**...*/">/**
|
||||
// * Class comment
|
||||
// */</fold>
|
||||
//class Test {
|
||||
//
|
||||
// <fold text="/**...*/>/**
|
||||
// * Another method comment
|
||||
// */</fold>
|
||||
// public void test(Set<String> s) {}
|
||||
//
|
||||
// <fold text="/**...*/>/**
|
||||
// * Method comment
|
||||
// */</fold>
|
||||
// private void test(List<String> l) {}
|
||||
//}'''
|
||||
// )
|
||||
// }
|
||||
void "test that doc comment folding is preserved"() {
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 1
|
||||
doTest(
|
||||
initial: '''\
|
||||
import <fold>java.util.List;
|
||||
import java.util.Set;</fold>
|
||||
|
||||
<fold text="/**...*/">/**
|
||||
* Class comment
|
||||
*/</fold>
|
||||
class Test {
|
||||
|
||||
<fold text="/**...*/>/**
|
||||
* Method comment
|
||||
*/</fold>
|
||||
private void test(List<String> l) {}
|
||||
|
||||
<fold text="/**...*/>/**
|
||||
* Another method comment
|
||||
*/</fold>
|
||||
public void test(Set<String> s) {}
|
||||
}''',
|
||||
|
||||
rules: [rule(PUBLIC), rule(PRIVATE)],
|
||||
|
||||
expected: '''\
|
||||
import <fold>java.util.List;
|
||||
import java.util.Set;</fold>
|
||||
|
||||
<fold text="/**...*/">/**
|
||||
* Class comment
|
||||
*/</fold>
|
||||
class Test {
|
||||
|
||||
<fold text="/**...*/>/**
|
||||
* Another method comment
|
||||
*/</fold>
|
||||
public void test(Set<String> s) {}
|
||||
|
||||
<fold text="/**...*/>/**
|
||||
* Method comment
|
||||
*/</fold>
|
||||
private void test(List<String> l) {}
|
||||
}'''
|
||||
)
|
||||
}
|
||||
|
||||
void "test that doc comment and method folding is preserved"() {
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 1
|
||||
doTest(
|
||||
initial: '''\
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class MyTest {
|
||||
<fold text="/**...*/">/**
|
||||
* comment 1
|
||||
*
|
||||
* @param s
|
||||
*/</fold>
|
||||
private void test(String s) {
|
||||
}
|
||||
|
||||
/**
|
||||
* comment 2
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void test(int i) {
|
||||
}
|
||||
}''',
|
||||
|
||||
rules: [rule(PUBLIC), rule(PRIVATE)],
|
||||
|
||||
expected: '''\
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class MyTest {
|
||||
/**
|
||||
* comment 2
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void test(int i) {
|
||||
}
|
||||
|
||||
<fold text="/**...*/">/**
|
||||
* comment 1
|
||||
*
|
||||
* @param s
|
||||
*/</fold>
|
||||
private void test(String s) {
|
||||
}
|
||||
}'''
|
||||
)
|
||||
}
|
||||
|
||||
void "test that single doc comment folding is preserved"() {
|
||||
commonSettings.BLANK_LINES_AROUND_METHOD = 1
|
||||
doTest(
|
||||
initial: '''\
|
||||
package a.b;
|
||||
|
||||
class MyTest {
|
||||
/**
|
||||
* private comment
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
private void test(String s) {
|
||||
}
|
||||
|
||||
/**
|
||||
* comment 2
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void test(int i) <fold text="{...}">{
|
||||
System.out.println(1);
|
||||
}</fold>
|
||||
}''',
|
||||
|
||||
rules: [rule(PUBLIC), rule(PRIVATE)],
|
||||
|
||||
expected: '''\
|
||||
package a.b;
|
||||
|
||||
class MyTest {
|
||||
/**
|
||||
* comment 2
|
||||
*
|
||||
* @param i
|
||||
*/
|
||||
public void test(int i) <fold text="{...}">{
|
||||
System.out.println(1);
|
||||
}</fold>
|
||||
|
||||
/**
|
||||
* private comment
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
private void test(String s) {
|
||||
}
|
||||
}'''
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,4 +331,66 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
"int j = 2;";
|
||||
doMethodTest(text, text);
|
||||
}
|
||||
|
||||
public void testEnforceIndent_MethodCallParamWrap() throws Exception {
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 140;
|
||||
getSettings().PREFER_PARAMETERS_WRAP = true;
|
||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||
|
||||
String before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, String.format(\"Could not process annotations: %s%n%s\", e.toString(), writer.toString()));";
|
||||
|
||||
String afterFirstReformat = "processingEnv.getMessenger().printMessage(\n" +
|
||||
" Diagnostic.Kind.ERROR, String.format(\n" +
|
||||
" \"Could not process annotations: %s%n%s\",\n" +
|
||||
" e.toString(),\n" +
|
||||
" writer.toString()\n" +
|
||||
")\n" +
|
||||
");";
|
||||
|
||||
String after = "processingEnv.getMessenger().printMessage(\n" +
|
||||
" Diagnostic.Kind.ERROR, String.format(\n" +
|
||||
" \"Could not process annotations: %s%n%s\",\n" +
|
||||
" e.toString(),\n" +
|
||||
" writer.toString()\n" +
|
||||
" )\n" +
|
||||
");";
|
||||
|
||||
doMethodTest(afterFirstReformat, after);
|
||||
|
||||
getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
|
||||
getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
|
||||
doMethodTest(before, after);
|
||||
|
||||
before = "processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, call(\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"));\n";
|
||||
after = "processingEnv.getMessager().printMessage(\n" +
|
||||
" Diagnostic.Kind.ERROR, call(\n" +
|
||||
" \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n" +
|
||||
" )\n" +
|
||||
");\n";
|
||||
|
||||
doMethodTest(before, after);
|
||||
}
|
||||
|
||||
public void testDoNotWrap_MethodsWithMethodCallAsParameters() throws Exception {
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 140;
|
||||
getSettings().PREFER_PARAMETERS_WRAP = true;
|
||||
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
|
||||
getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
|
||||
getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
|
||||
|
||||
String before = " processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";
|
||||
String after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";
|
||||
|
||||
doMethodTest(before, after);
|
||||
|
||||
before = " processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";
|
||||
after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";
|
||||
|
||||
doMethodTest(before, after);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -153,7 +153,12 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
|
||||
visitors.add(visitor);
|
||||
}
|
||||
}
|
||||
//LOG.assertTrue(!visitors.isEmpty(), list);
|
||||
if (visitors.isEmpty()) {
|
||||
LOG.error("No visitors registered. list=" +
|
||||
list +
|
||||
"; all visitors are:" +
|
||||
Arrays.asList(Extensions.getExtensions(HighlightVisitor.EP_HIGHLIGHT_VISITOR, myProject)));
|
||||
}
|
||||
|
||||
HighlightVisitor[] visitorArray = visitors.toArray(new HighlightVisitor[visitors.size()]);
|
||||
Arrays.sort(visitorArray, VISITOR_ORDER_COMPARATOR);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -168,5 +168,5 @@ public abstract class VirtualFileManager implements ModificationTracker {
|
||||
|
||||
public abstract void removeVirtualFileManagerListener(@NotNull VirtualFileManagerListener listener);
|
||||
|
||||
public abstract void notifyPropertyChanged(VirtualFile virtualFile, String property, Object oldValue, Object newValue);
|
||||
public abstract void notifyPropertyChanged(@NotNull VirtualFile virtualFile, @NotNull String property, Object oldValue, Object newValue);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -27,10 +27,7 @@ import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -38,12 +35,14 @@ import java.util.Set;
|
||||
public class FileContentUtilCore {
|
||||
@NonNls public static final String FORCE_RELOAD_REQUESTOR = "FileContentUtilCore.saveOrReload";
|
||||
|
||||
public static void reparseFiles(@NotNull VirtualFile... files) {
|
||||
reparseFiles(Arrays.asList(files));
|
||||
}
|
||||
public static void reparseFiles(@NotNull final Collection<VirtualFile> files) {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// files must be processed under one write action to prevent firing event for invalid files.
|
||||
|
||||
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
|
||||
for (VirtualFile file : files) {
|
||||
saveOrReload(file, events);
|
||||
@@ -57,7 +56,7 @@ public class FileContentUtilCore {
|
||||
});
|
||||
}
|
||||
|
||||
private static void saveOrReload(VirtualFile file, Collection<VFilePropertyChangeEvent> events) {
|
||||
private static void saveOrReload(VirtualFile file, @NotNull Collection<VFilePropertyChangeEvent> events) {
|
||||
if (file == null || file.isDirectory() || !file.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -185,7 +185,7 @@ public class VirtualFileManagerImpl extends VirtualFileManagerEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPropertyChanged(final VirtualFile virtualFile, final String property, final Object oldValue, final Object newValue) {
|
||||
public void notifyPropertyChanged(@NotNull final VirtualFile virtualFile, @NotNull final String property, final Object oldValue, final Object newValue) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class ActionManager implements ApplicationComponent {
|
||||
*
|
||||
* @return An instance of <code>ActionToolbar</code>
|
||||
*/
|
||||
public abstract ActionToolbar createActionToolbar(@NonNls String place, ActionGroup group, boolean horizontal);
|
||||
public abstract ActionToolbar createActionToolbar(@NonNls String place, @NotNull ActionGroup group, boolean horizontal);
|
||||
|
||||
/**
|
||||
* Returns action associated with the specified actionId.
|
||||
@@ -151,7 +151,7 @@ public abstract class ActionManager implements ApplicationComponent {
|
||||
* @return the created panel.
|
||||
* @since 5.1
|
||||
*/
|
||||
public abstract JComponent createButtonToolbar(final String actionPlace, final ActionGroup messageActionGroup);
|
||||
public abstract JComponent createButtonToolbar(final String actionPlace, @NotNull ActionGroup messageActionGroup);
|
||||
|
||||
public abstract AnAction getActionOrStub(@NonNls String id);
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -36,7 +36,7 @@ public class PluginId implements Comparable<PluginId> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PluginId o) {
|
||||
public int compareTo(@NotNull PluginId o) {
|
||||
return myIdString.compareTo(o.myIdString);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ public abstract class AbstractExternalSystemConfigurable<
|
||||
@NotNull
|
||||
protected String getProjectName(@NotNull String path) {
|
||||
File file = new File(path);
|
||||
return file.isDirectory() ? file.getName() : file.getParentFile().getName();
|
||||
return file.isDirectory() || file.getParentFile() == null ? file.getName() : file.getParentFile().getName();
|
||||
}
|
||||
|
||||
private void prepareSystemSettings(@NotNull SystemSettings s) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.codeStyle.arrangement;
|
||||
|
||||
import com.intellij.application.options.codeStyle.arrangement.color.ArrangementColorsProvider;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -40,7 +41,8 @@ import java.util.*;
|
||||
* @since 7/17/12 11:24 AM
|
||||
*/
|
||||
public class ArrangementUtil {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(ArrangementUtil.class);
|
||||
|
||||
private ArrangementUtil() {
|
||||
}
|
||||
|
||||
@@ -49,20 +51,28 @@ public class ArrangementUtil {
|
||||
@Nullable
|
||||
public static ArrangementSettings readExternal(@NotNull Element element, @NotNull Language language) {
|
||||
ArrangementSettingsSerializer serializer = getSerializer(language);
|
||||
if (serializer == null) {
|
||||
LOG.error("Can't find serializer for language: " + language.getDisplayName() + "(" + language.getID() + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
return serializer.deserialize(element);
|
||||
}
|
||||
|
||||
public static void writeExternal(@NotNull Element element, @NotNull ArrangementSettings settings, @NotNull Language language) {
|
||||
ArrangementSettingsSerializer serializer = getSerializer(language);
|
||||
if (serializer == null) {
|
||||
LOG.error("Can't find serializer for language: " + language.getDisplayName() + "(" + language.getID() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
serializer.serialize(settings, element);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ArrangementSettingsSerializer getSerializer(@NotNull Language language) {
|
||||
Rearranger<?> rearranger = Rearranger.EXTENSION.forLanguage(language);
|
||||
if (rearranger instanceof ArrangementSettingsSerializer) {
|
||||
return (ArrangementSettingsSerializer)rearranger;
|
||||
}
|
||||
return DefaultArrangementSettingsSerializer.INSTANCE;
|
||||
return rearranger == null ? null : rearranger.getSerializer();
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
+93
-74
@@ -21,15 +21,14 @@ import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.DefaultArrangementEntryMatcherSerializer;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdRulePriorityAwareSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,9 +39,6 @@ import java.util.List;
|
||||
* @since 7/18/12 10:37 AM
|
||||
*/
|
||||
public class DefaultArrangementSettingsSerializer implements ArrangementSettingsSerializer {
|
||||
|
||||
public static final ArrangementSettingsSerializer INSTANCE = new DefaultArrangementSettingsSerializer(Mixin.NULL);
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + DefaultArrangementSettingsSerializer.class.getName());
|
||||
|
||||
@NotNull @NonNls private static final String GROUPS_ELEMENT_NAME = "groups";
|
||||
@@ -55,10 +51,16 @@ public class DefaultArrangementSettingsSerializer implements ArrangementSettings
|
||||
|
||||
@NotNull private final DefaultArrangementEntryMatcherSerializer myMatcherSerializer;
|
||||
@NotNull private final Mixin myMixin;
|
||||
@NotNull private final ArrangementSettings myDefaultSettings;
|
||||
|
||||
public DefaultArrangementSettingsSerializer(@NotNull Mixin mixin) {
|
||||
public DefaultArrangementSettingsSerializer(@NotNull StdArrangementSettings defaultSettings) {
|
||||
this(Mixin.NULL, defaultSettings);
|
||||
}
|
||||
|
||||
public DefaultArrangementSettingsSerializer(@NotNull Mixin mixin, @NotNull StdArrangementSettings defaultSettings) {
|
||||
myMixin = mixin;
|
||||
myMatcherSerializer = new DefaultArrangementEntryMatcherSerializer(mixin);
|
||||
myDefaultSettings = defaultSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,9 +70,9 @@ public class DefaultArrangementSettingsSerializer implements ArrangementSettings
|
||||
}
|
||||
|
||||
StdArrangementSettings settings = (StdArrangementSettings)s;
|
||||
|
||||
List<ArrangementGroupingRule> groupings = settings.getGroupings();
|
||||
if (!groupings.isEmpty()) {
|
||||
final boolean isDefaultGroupings = groupings.equals(myDefaultSettings.getGroupings());
|
||||
if (!isDefaultGroupings) {
|
||||
Element groupingsElement = new Element(GROUPS_ELEMENT_NAME);
|
||||
holder.addContent(groupingsElement);
|
||||
for (ArrangementGroupingRule group : groupings) {
|
||||
@@ -82,7 +84,8 @@ public class DefaultArrangementSettingsSerializer implements ArrangementSettings
|
||||
}
|
||||
|
||||
List<StdArrangementMatchRule> rules = settings.getRules();
|
||||
if (!rules.isEmpty()) {
|
||||
final boolean isDefaultRules = rules.equals(myDefaultSettings.getRules());
|
||||
if (!isDefaultRules) {
|
||||
Element rulesElement = new Element(RULES_ELEMENT_NAME);
|
||||
holder.addContent(rulesElement);
|
||||
for (StdArrangementMatchRule rule : rules) {
|
||||
@@ -94,79 +97,95 @@ public class DefaultArrangementSettingsSerializer implements ArrangementSettings
|
||||
@Nullable
|
||||
@Override
|
||||
public ArrangementSettings deserialize(@NotNull Element element) {
|
||||
StdArrangementSettings result = new StdRulePriorityAwareSettings();
|
||||
Element groups = element.getChild(GROUPS_ELEMENT_NAME);
|
||||
if (groups != null) {
|
||||
for (Object group : groups.getChildren(GROUP_ELEMENT_NAME)) {
|
||||
Element groupElement = (Element)group;
|
||||
final List<ArrangementGroupingRule> groupingRules = deserializeGropings(element, myDefaultSettings);
|
||||
final List<StdArrangementMatchRule> rules = deserializeRules(element, myDefaultSettings);
|
||||
return new StdRulePriorityAwareSettings(groupingRules, rules);
|
||||
}
|
||||
|
||||
// Grouping type.
|
||||
String groupingTypeId = groupElement.getChildText(TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken groupingType = StdArrangementTokens.byId(groupingTypeId);
|
||||
if (groupingType == null) {
|
||||
groupingType = myMixin.deserializeToken(groupingTypeId);
|
||||
@NotNull
|
||||
private List<ArrangementGroupingRule> deserializeGropings(@NotNull Element element, @Nullable ArrangementSettings defaultSettings) {
|
||||
Element groups = element.getChild(GROUPS_ELEMENT_NAME);
|
||||
if (groups == null) {
|
||||
return defaultSettings == null ? ContainerUtil.<ArrangementGroupingRule>newSmartList() : defaultSettings.getGroupings();
|
||||
}
|
||||
|
||||
final List<ArrangementGroupingRule> groupings = new ArrayList<ArrangementGroupingRule>();
|
||||
for (Object group : groups.getChildren(GROUP_ELEMENT_NAME)) {
|
||||
Element groupElement = (Element)group;
|
||||
|
||||
// Grouping type.
|
||||
String groupingTypeId = groupElement.getChildText(TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken groupingType = StdArrangementTokens.byId(groupingTypeId);
|
||||
if (groupingType == null) {
|
||||
groupingType = myMixin.deserializeToken(groupingTypeId);
|
||||
}
|
||||
if (groupingType == null) {
|
||||
LOG.warn(String.format("Can't deserialize grouping type token by id '%s'", groupingTypeId));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Order type.
|
||||
String orderTypeId = groupElement.getChildText(ORDER_TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken orderType = StdArrangementTokens.byId(orderTypeId);
|
||||
if (orderType == null) {
|
||||
orderType = myMixin.deserializeToken(orderTypeId);
|
||||
}
|
||||
if (orderType == null) {
|
||||
LOG.warn(String.format("Can't deserialize grouping order type token by id '%s'", orderTypeId));
|
||||
continue;
|
||||
}
|
||||
groupings.add(new ArrangementGroupingRule(groupingType, orderType));
|
||||
}
|
||||
return groupings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<StdArrangementMatchRule> deserializeRules(@NotNull Element element, @Nullable ArrangementSettings defaultSettings) {
|
||||
Element rulesElement = element.getChild(RULES_ELEMENT_NAME);
|
||||
if (rulesElement == null) {
|
||||
return defaultSettings instanceof StdArrangementSettings ? ((StdArrangementSettings)defaultSettings).getRules() :
|
||||
ContainerUtil.<StdArrangementMatchRule>newSmartList();
|
||||
}
|
||||
|
||||
final List<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>();
|
||||
for (Object o : rulesElement.getChildren(RULE_ELEMENT_NAME)) {
|
||||
Element ruleElement = (Element)o;
|
||||
Element matcherElement = ruleElement.getChild(MATCHER_ELEMENT_NAME);
|
||||
if (matcherElement == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StdArrangementEntryMatcher matcher = null;
|
||||
for (Object c : matcherElement.getChildren()) {
|
||||
matcher = myMatcherSerializer.deserialize((Element)c);
|
||||
if (matcher != null) {
|
||||
break;
|
||||
}
|
||||
if (groupingType == null) {
|
||||
LOG.warn(String.format("Can't deserialize grouping type token by id '%s'", groupingTypeId));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Order type.
|
||||
String orderTypeId = groupElement.getChildText(ORDER_TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken orderType = StdArrangementTokens.byId(orderTypeId);
|
||||
}
|
||||
|
||||
if (matcher == null) {
|
||||
return ContainerUtil.newSmartList();
|
||||
}
|
||||
|
||||
Element orderTypeElement = ruleElement.getChild(ORDER_TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken orderType = null;
|
||||
if (orderTypeElement != null) {
|
||||
String orderTypeId = orderTypeElement.getText();
|
||||
orderType = StdArrangementTokens.byId(orderTypeId);
|
||||
if (orderType == null) {
|
||||
orderType = myMixin.deserializeToken(orderTypeId);
|
||||
}
|
||||
if (orderType == null) {
|
||||
LOG.warn(String.format("Can't deserialize grouping order type token by id '%s'", orderTypeId));
|
||||
continue;
|
||||
LOG.warn(String.format("Can't deserialize matching rule order type for id '%s'. Falling back to default (%s)",
|
||||
orderTypeId, ArrangementMatchRule.DEFAULT_ORDER_TYPE.getId()));
|
||||
}
|
||||
result.addGrouping(new ArrangementGroupingRule(groupingType, orderType));
|
||||
}
|
||||
}
|
||||
|
||||
Element rulesElement = element.getChild(RULES_ELEMENT_NAME);
|
||||
if (rulesElement != null) {
|
||||
for (Object o : rulesElement.getChildren(RULE_ELEMENT_NAME)) {
|
||||
Element ruleElement = (Element)o;
|
||||
Element matcherElement = ruleElement.getChild(MATCHER_ELEMENT_NAME);
|
||||
if (matcherElement == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StdArrangementEntryMatcher matcher = null;
|
||||
for (Object c : matcherElement.getChildren()) {
|
||||
matcher = myMatcherSerializer.deserialize((Element)c);
|
||||
if (matcher != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matcher == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element orderTypeElement = ruleElement.getChild(ORDER_TYPE_ELEMENT_NAME);
|
||||
ArrangementSettingsToken orderType = null;
|
||||
if (orderTypeElement != null) {
|
||||
String orderTypeId = orderTypeElement.getText();
|
||||
orderType = StdArrangementTokens.byId(orderTypeId);
|
||||
if (orderType == null) {
|
||||
orderType = myMixin.deserializeToken(orderTypeId);
|
||||
}
|
||||
if (orderType == null) {
|
||||
LOG.warn(String.format("Can't deserialize matching rule order type for id '%s'. Falling back to default (%s)",
|
||||
orderTypeId, ArrangementMatchRule.DEFAULT_ORDER_TYPE.getId()));
|
||||
}
|
||||
}
|
||||
if (orderType == null) {
|
||||
orderType = ArrangementMatchRule.DEFAULT_ORDER_TYPE;
|
||||
}
|
||||
result.addRule(new StdArrangementMatchRule(matcher, orderType));
|
||||
if (orderType == null) {
|
||||
orderType = ArrangementMatchRule.DEFAULT_ORDER_TYPE;
|
||||
}
|
||||
rules.add(new StdArrangementMatchRule(matcher, orderType));
|
||||
}
|
||||
|
||||
return result;
|
||||
return rules;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -90,4 +90,15 @@ public interface Rearranger<E extends ArrangementEntry> {
|
||||
* negative as an indication that no blank lines adjustment is necessary
|
||||
*/
|
||||
int getBlankLines(@NotNull CodeStyleSettings settings, @Nullable E parent, @Nullable E previous, @NotNull E target);
|
||||
|
||||
|
||||
/**
|
||||
* @return serializer to save {@link com.intellij.psi.codeStyle.arrangement.ArrangementSettings arrangement settings}.
|
||||
* Serializer is expected to be lazy and don't save
|
||||
* {@link com.intellij.psi.codeStyle.arrangement.std.ArrangementStandardSettingsAware.getDefaultSettings() default settings}.
|
||||
* <p/>
|
||||
* @see com.intellij.psi.codeStyle.arrangement.DefaultArrangementSettingsSerializer
|
||||
*/
|
||||
@NotNull
|
||||
ArrangementSettingsSerializer getSerializer();
|
||||
}
|
||||
|
||||
+101
-9
@@ -22,12 +22,13 @@ import com.intellij.psi.codeStyle.arrangement.model.ArrangementAtomMatchConditio
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdArrangementSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdRulePriorityAwareSettings;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.EntryType.FIELD;
|
||||
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Grouping.OVERRIDDEN_METHODS;
|
||||
import static com.intellij.psi.codeStyle.arrangement.std.StdArrangementTokens.Order.BY_NAME;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -35,17 +36,108 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
public class ArrangementSettingsSerializationTest {
|
||||
|
||||
@Test
|
||||
public void all() {
|
||||
StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
|
||||
ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
|
||||
|
||||
private static Element doSerializationTest(@NotNull StdArrangementSettings settings, @NotNull StdArrangementSettings defaultSettings) {
|
||||
Element holder = new Element("holder");
|
||||
ArrangementSettingsSerializer instance = DefaultArrangementSettingsSerializer.INSTANCE;
|
||||
ArrangementSettingsSerializer instance = new TestArrangementSettingsSerializer(defaultSettings);
|
||||
instance.serialize(settings, holder);
|
||||
ArrangementSettings restored = instance.deserialize(holder);
|
||||
assertEquals(settings, restored);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void all() {
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
|
||||
doSerializationTest(settings, new StdArrangementSettings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultFilter() {
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
|
||||
|
||||
final Element holder = doSerializationTest(settings, settings);
|
||||
assertTrue(holder.getChildren().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultGroupingFilter() {
|
||||
final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME);
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);
|
||||
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(groupingRule);
|
||||
settings.addRule(rule);
|
||||
final StdArrangementSettings defaultSettings = new StdRulePriorityAwareSettings();
|
||||
defaultSettings.addGrouping(groupingRule);
|
||||
|
||||
final Element holder = doSerializationTest(settings, defaultSettings);
|
||||
assertTrue(holder.getChildren().size() == 1);
|
||||
assertNull(holder.getChild("groups"));
|
||||
assertNotNull(holder.getChild("rules"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultRulesFilter() {
|
||||
final ArrangementGroupingRule groupingRule = new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME);
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);
|
||||
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(groupingRule);
|
||||
settings.addRule(rule);
|
||||
final StdArrangementSettings defaultSettings = new StdRulePriorityAwareSettings();
|
||||
defaultSettings.addRule(rule);
|
||||
|
||||
final Element holder = doSerializationTest(settings, defaultSettings);
|
||||
assertTrue(holder.getChildren().size() == 1);
|
||||
assertNotNull(holder.getChild("groups"));
|
||||
assertNull(holder.getChild("rules"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyGroupings() throws Exception {
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
settings.addRule(new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME));
|
||||
|
||||
final StdArrangementSettings defaultSettings = new StdRulePriorityAwareSettings();
|
||||
defaultSettings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
|
||||
|
||||
final Element holder = doSerializationTest(settings, defaultSettings);
|
||||
assertTrue(holder.getChildren().size() == 2);
|
||||
final Element groups = holder.getChild("groups");
|
||||
assertNotNull(groups);
|
||||
assertTrue(groups.getChildren().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyRules() throws Exception {
|
||||
final StdArrangementSettings settings = new StdRulePriorityAwareSettings();
|
||||
settings.addGrouping(new ArrangementGroupingRule(OVERRIDDEN_METHODS, BY_NAME));
|
||||
|
||||
final StdArrangementSettings defaultSettings = new StdRulePriorityAwareSettings();
|
||||
final ArrangementAtomMatchCondition condition = new ArrangementAtomMatchCondition(FIELD);
|
||||
final StdArrangementMatchRule rule = new StdArrangementMatchRule(new StdArrangementEntryMatcher(condition), BY_NAME);
|
||||
defaultSettings.addRule(rule);
|
||||
|
||||
final Element holder = doSerializationTest(settings, defaultSettings);
|
||||
assertTrue(holder.getChildren().size() == 2);
|
||||
final Element rules = holder.getChild("rules");
|
||||
assertNotNull(rules);
|
||||
assertTrue(rules.getChildren().isEmpty());
|
||||
}
|
||||
|
||||
private static class TestArrangementSettingsSerializer extends DefaultArrangementSettingsSerializer {
|
||||
|
||||
public TestArrangementSettingsSerializer(@NotNull StdArrangementSettings defaultSettings) {
|
||||
super(defaultSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware {
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
engine.arrange(finalFile, Collections.singleton(rangeToUse));
|
||||
engine.arrange(editor, finalFile, Collections.singleton(rangeToUse));
|
||||
}
|
||||
}, getTemplatePresentation().getText(), null);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -87,7 +87,7 @@ public class ImplementationViewComponent extends JPanel {
|
||||
private final ActionToolbar myToolbar;
|
||||
private JLabel myLabel;
|
||||
|
||||
public void setHint(final JBPopup hint, final String title) {
|
||||
public void setHint(final JBPopup hint, @NotNull String title) {
|
||||
myHint = hint;
|
||||
myTitle = title;
|
||||
}
|
||||
|
||||
+3
-2
@@ -70,8 +70,9 @@ public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotion
|
||||
return;
|
||||
}
|
||||
|
||||
KeyListener keyListener = editor.getUserData(EDITOR_LISTENER_ADDED);
|
||||
KeyListener keyListener = EDITOR_LISTENER_ADDED.get(editor);
|
||||
if (keyListener != null) {
|
||||
EDITOR_LISTENER_ADDED.set(editor, null);
|
||||
editor.getContentComponent().removeKeyListener(keyListener);
|
||||
editor.removeEditorMouseMotionListener(ImageOrColorPreviewManager.this);
|
||||
}
|
||||
@@ -112,7 +113,7 @@ public class ImageOrColorPreviewManager implements Disposable, EditorMouseMotion
|
||||
};
|
||||
editor.getContentComponent().addKeyListener(keyListener);
|
||||
|
||||
editor.putUserData(EDITOR_LISTENER_ADDED, keyListener);
|
||||
EDITOR_LISTENER_ADDED.set(editor, keyListener);
|
||||
}
|
||||
|
||||
private static boolean isSupportedFile(PsiFile psiFile) {
|
||||
|
||||
@@ -27,10 +27,7 @@ import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.ListPopupStep;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -1107,7 +1104,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationType type) {
|
||||
return type != null ? type.getDisplayName() : "(" + hiddenCount + " more items)";
|
||||
return type != null ? type.getDisplayName() : hiddenCount + " items more (unused)...";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1199,7 +1196,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
applicableTypes.add(type);
|
||||
}
|
||||
}
|
||||
if (applicableTypes.size() < allTypes.length - 1) {
|
||||
if (applicableTypes.size() < allTypes.length - 3) {
|
||||
return applicableTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -29,7 +29,6 @@ import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lexer.LayeredLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.lexer.LexerUtil;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -55,7 +54,6 @@ import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.fileTypes.impl.AbstractFileType;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -1056,7 +1054,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public FindUsagesManager getFindUsagesManager() {
|
||||
return myFindUsagesManager;
|
||||
}
|
||||
|
||||
+16
-3
@@ -53,12 +53,25 @@ import java.util.*;
|
||||
*/
|
||||
public class ArrangementEngine {
|
||||
|
||||
/**
|
||||
* Arranges given PSI root contents that belong to the given ranges.
|
||||
* <b>Note:</b> After arrangement editor foldings we'll be preserved.
|
||||
*
|
||||
* @param editor
|
||||
* @param file target PSI root
|
||||
* @param ranges target ranges to use within the given root
|
||||
*/
|
||||
public void arrange(@NotNull final Editor editor, @NotNull PsiFile file, Collection<TextRange> ranges) {
|
||||
arrange(file, ranges, null);
|
||||
// This should be uncommented as soon as cdr pushed fixes for range markers processing.
|
||||
//arrange(file, ranges, new RestoreFoldArrangementCallback(editor));
|
||||
arrange(file, ranges, new RestoreFoldArrangementCallback(editor));
|
||||
}
|
||||
|
||||
/**
|
||||
* Arranges given PSI root contents that belong to the given ranges.
|
||||
* <b>Note:</b> Editor foldings are not expected to be preserved.
|
||||
*
|
||||
* @param file target PSI root
|
||||
* @param ranges target ranges to use within the given root
|
||||
*/
|
||||
public void arrange(@NotNull PsiFile file, @NotNull Collection<TextRange> ranges) {
|
||||
arrange(file, ranges, null);
|
||||
}
|
||||
|
||||
+27
-19
@@ -18,16 +18,10 @@ package com.intellij.psi.codeStyle.arrangement.engine;
|
||||
import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.fileEditor.impl.text.CodeFoldingState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -37,34 +31,48 @@ import java.util.List;
|
||||
public class RestoreFoldArrangementCallback implements ArrangementCallback {
|
||||
|
||||
@NotNull private final Editor myEditor;
|
||||
@Nullable private final CodeFoldingState myCodeFoldingState;
|
||||
|
||||
public RestoreFoldArrangementCallback(@NotNull Editor editor) {
|
||||
myEditor = editor;
|
||||
|
||||
Project project = editor.getProject();
|
||||
if (project == null) {
|
||||
myCodeFoldingState = null;
|
||||
}
|
||||
else {
|
||||
final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(editor.getProject());
|
||||
myCodeFoldingState = foldingManager.saveFoldingState(editor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterArrangement(@NotNull final List<ArrangementMoveInfo> moveInfos) {
|
||||
// Restore state for the PSI elements not affected by arrangement.
|
||||
Project project = myEditor.getProject();
|
||||
if (myCodeFoldingState != null && project != null) {
|
||||
if (project != null) {
|
||||
final FoldRegion[] regions = myEditor.getFoldingModel().getAllFoldRegions();
|
||||
final List<FoldRegionInfo> foldRegionsInfo = new ArrayList<FoldRegionInfo>();
|
||||
for (FoldRegion region : regions) {
|
||||
final FoldRegionInfo info = new FoldRegionInfo(region.getStartOffset(), region.getEndOffset(), region.isExpanded());
|
||||
foldRegionsInfo.add(info);
|
||||
}
|
||||
|
||||
final CodeFoldingManager foldingManager = CodeFoldingManager.getInstance(project);
|
||||
foldingManager.updateFoldRegions(myEditor);
|
||||
myEditor.getFoldingModel().runBatchFoldingOperation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
foldingManager.restoreFoldingState(myEditor, myCodeFoldingState);
|
||||
for (FoldRegionInfo info : foldRegionsInfo) {
|
||||
final FoldRegion foldRegion = foldingManager.findFoldRegion(myEditor, info.myStart, info.myEnd);
|
||||
if (foldRegion != null) {
|
||||
foldRegion.setExpanded(info.myIsExpanded);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static class FoldRegionInfo {
|
||||
private int myStart;
|
||||
private int myEnd;
|
||||
private boolean myIsExpanded;
|
||||
|
||||
private FoldRegionInfo(int start, int end, boolean expanded) {
|
||||
myStart = start;
|
||||
myEnd = end;
|
||||
myIsExpanded = expanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2470,6 +2470,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
|
||||
@Override
|
||||
public void removeIndexableSet(@NotNull IndexableFileSet set) {
|
||||
if (!myIndexableSetToProjectMap.containsKey(set)) return; // avoid second unfiltered forceUpdate
|
||||
myChangedFilesCollector.forceUpdate(myIndexableSetToProjectMap.get(set), null, null, true);
|
||||
IndexingStamp.flushCaches();
|
||||
myIndexableSets.remove(set);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem.ex;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -31,7 +32,7 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
return (ActionManagerEx)getInstance();
|
||||
}
|
||||
|
||||
public abstract ActionToolbar createActionToolbar(String place, ActionGroup group, boolean horizontal, boolean decorateButtons);
|
||||
public abstract ActionToolbar createActionToolbar(String place, @NotNull ActionGroup group, boolean horizontal, boolean decorateButtons);
|
||||
|
||||
public abstract void fireBeforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event);
|
||||
|
||||
@@ -88,6 +89,7 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public abstract String[] getPluginActions(PluginId pluginId);
|
||||
|
||||
public abstract void queueActionPerformedEvent(final AnAction action, DataContext context, AnActionEvent event);
|
||||
@@ -96,10 +98,12 @@ public abstract class ActionManagerEx extends ActionManager {
|
||||
|
||||
public abstract boolean isTransparentOnlyActionsUpdateNow();
|
||||
|
||||
@NotNull
|
||||
public List<String> getAbbreviations() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> findActionIdsByAbbreviation(String abbreviation) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -426,13 +426,7 @@ public class Messages {
|
||||
*/
|
||||
@OkCancelResult
|
||||
public static int showOkCancelDialog(Project project, String message, @NotNull String title, @NotNull String okText, @NotNull String cancelText, Icon icon) {
|
||||
if (canShowMacSheetPanel()) {
|
||||
int result = MacMessages.getInstance()
|
||||
.showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project));
|
||||
return result == YES ? OK : CANCEL;
|
||||
}
|
||||
|
||||
return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon) == 0 ? OK : CANCEL;
|
||||
return showOkCancelDialog(project, message, title, okText, cancelText, icon, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1218,22 +1212,12 @@ public class Messages {
|
||||
actions[i].putValue(FOCUSED_ACTION, Boolean.TRUE);
|
||||
}
|
||||
|
||||
assignMnemonic(option, actions[i]);
|
||||
UIUtil.assignMnemonic(option, actions[i]);
|
||||
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
private static void assignMnemonic(@NotNull String option, Action action) {
|
||||
int mnemoPos = option.indexOf("&");
|
||||
if (mnemoPos >= 0 && mnemoPos < option.length() - 2) {
|
||||
String mnemoChar = option.substring(mnemoPos + 1, mnemoPos + 2).trim();
|
||||
if (mnemoChar.length() == 1) {
|
||||
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemoChar.charAt(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
close(-1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -457,6 +457,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
return UIUtil.isUnderAlloyLookAndFeel()
|
||||
|| UIUtil.isUnderNativeMacLookAndFeel()
|
||||
|| UIUtil.isUnderDarcula()
|
||||
|| UIUtil.isUnderIntelliJLaF()
|
||||
|| UIUtil.isUnderNimbusLookAndFeel()
|
||||
|| UIUtil.isUnderWindowsLookAndFeel();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui.table;
|
||||
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.ListTableModel;
|
||||
@@ -28,7 +29,6 @@ import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -71,7 +71,7 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
@Override
|
||||
public TableCellRenderer getCellRenderer(int row, int column) {
|
||||
final ColumnInfo<Item, ?> columnInfo = getListTableModel().getColumnInfos()[convertColumnIndexToModel(column)];
|
||||
final Item item = getListTableModel().getItems().get(convertRowIndexToModel(row));
|
||||
final Item item = getRow(row);
|
||||
final TableCellRenderer renderer = columnInfo.getCustomizedRenderer(item, columnInfo.getRenderer(item));
|
||||
if (renderer == null) {
|
||||
return super.getCellRenderer(row, column);
|
||||
@@ -186,45 +186,42 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
|
||||
@Override
|
||||
public Collection<Item> getSelection() {
|
||||
ArrayList<Item> result = new ArrayList<Item>();
|
||||
int[] selectedRows = getSelectedRows();
|
||||
if (selectedRows == null) return result;
|
||||
final List<Item> items = getItems();
|
||||
if (! items.isEmpty()) {
|
||||
for (int selectedRow : selectedRows) {
|
||||
final int modelIndex = convertRowIndexToModel(selectedRow);
|
||||
if (modelIndex >= 0 && modelIndex < items.size()) {
|
||||
result.add(items.get(modelIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return getSelectedObjects();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Item getSelectedObject() {
|
||||
final int row = getSelectedRow();
|
||||
final List<Item> list = getItems();
|
||||
return row >= 0 && row < list.size() ? list.get(convertRowIndexToModel(row)) : null;
|
||||
ListTableModel<Item> model = getListTableModel();
|
||||
return row >= 0 && row < model.getRowCount() ? model.getRowValue(convertRowIndexToModel(row)) : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Item> getSelectedObjects() {
|
||||
final int[] selectedRows = getSelectedRows();
|
||||
if (selectedRows == null || (selectedRows.length == 0)) return Collections.emptyList();
|
||||
final List<Item> items = getItems();
|
||||
final List<Item> result = new ArrayList<Item>();
|
||||
if (selectedRows == null || selectedRows.length == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Item> result = new SmartList<Item>();
|
||||
ListTableModel<Item> model = getListTableModel();
|
||||
for (int selectedRow : selectedRows) {
|
||||
result.add(items.get(convertRowIndexToModel(selectedRow)));
|
||||
int modelIndex = convertRowIndexToModel(selectedRow);
|
||||
if (modelIndex >= 0 && modelIndex < model.getRowCount()) {
|
||||
result.add(model.getRowValue(modelIndex));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelection(Object item) {
|
||||
List items = getItems();
|
||||
if (!items.contains(item)) return;
|
||||
int index = items.indexOf(item);
|
||||
@SuppressWarnings("unchecked")
|
||||
int index = getListTableModel().indexOf((Item)item);
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSelectionModel().addSelectionInterval(convertRowIndexToView(index), convertRowIndexToView(index));
|
||||
// fix cell selection case
|
||||
getColumnModel().getSelectionModel().addSelectionInterval(0, getColumnCount()-1);
|
||||
@@ -232,8 +229,8 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
|
||||
@Override
|
||||
public TableCellEditor getCellEditor(int row, int column) {
|
||||
final ColumnInfo<Item, ?> columnInfo = getListTableModel().getColumnInfos()[convertColumnIndexToModel(column)];
|
||||
final TableCellEditor editor = columnInfo.getEditor(getListTableModel().getItems().get(convertRowIndexToModel(row)));
|
||||
@SuppressWarnings("unchecked")
|
||||
TableCellEditor editor = getListTableModel().getColumnInfos()[convertColumnIndexToModel(column)].getEditor(getRow(row));
|
||||
return editor == null ? super.getCellEditor(row, column) : editor;
|
||||
}
|
||||
|
||||
@@ -243,7 +240,7 @@ public class TableView<Item> extends BaseTableView implements ItemsProvider, Sel
|
||||
}
|
||||
|
||||
public Item getRow(int row) {
|
||||
return getItems().get(convertRowIndexToModel(row));
|
||||
return getListTableModel().getRowValue(convertRowIndexToModel(row));
|
||||
}
|
||||
|
||||
public void setMinRowHeight(int i) {
|
||||
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -203,12 +203,12 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionToolbar createActionToolbar(final String place, final ActionGroup group, final boolean horizontal) {
|
||||
public ActionToolbar createActionToolbar(final String place, @NotNull final ActionGroup group, final boolean horizontal) {
|
||||
return createActionToolbar(place, group, horizontal, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionToolbar createActionToolbar(final String place, final ActionGroup group, final boolean horizontal, final boolean decorateButtons) {
|
||||
public ActionToolbar createActionToolbar(final String place, @NotNull final ActionGroup group, final boolean horizontal, final boolean decorateButtons) {
|
||||
return new ActionToolbarImpl(place, group, horizontal, decorateButtons, myDataManager, this, (KeymapManagerEx)myKeymapManager);
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createButtonToolbar(final String actionPlace, final ActionGroup messageActionGroup) {
|
||||
public JComponent createButtonToolbar(final String actionPlace, @NotNull final ActionGroup messageActionGroup) {
|
||||
return new ButtonToolbarImpl(actionPlace, messageActionGroup, myDataManager, this);
|
||||
}
|
||||
|
||||
@@ -1030,6 +1030,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getPluginActions(PluginId pluginName) {
|
||||
if (myPlugin2Id.containsKey(pluginName)){
|
||||
|
||||
+4
-3
@@ -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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -40,7 +41,7 @@ public class ButtonToolbarImpl extends JPanel {
|
||||
private final ArrayList<ActionJButton> myActions = new ArrayList<ActionJButton>();
|
||||
|
||||
public ButtonToolbarImpl(final String place,
|
||||
final ActionGroup actionGroup,
|
||||
@NotNull ActionGroup actionGroup,
|
||||
DataManager dataManager,
|
||||
ActionManagerEx actionManager) {
|
||||
super(new GridBagLayout());
|
||||
@@ -57,7 +58,7 @@ public class ButtonToolbarImpl extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
private void initButtons(final ActionGroup actionGroup) {
|
||||
private void initButtons(@NotNull ActionGroup actionGroup) {
|
||||
final AnAction[] actions = actionGroup.getChildren(null);
|
||||
|
||||
if (actions.length > 0) {
|
||||
|
||||
@@ -19,11 +19,9 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.FileContentUtilCore;
|
||||
import com.intellij.util.UriUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,7 +29,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collections;
|
||||
|
||||
class VirtualFileImpl extends HttpVirtualFile {
|
||||
private final HttpFileSystemBase myFileSystem;
|
||||
@@ -55,9 +52,7 @@ class VirtualFileImpl extends HttpVirtualFile {
|
||||
VirtualFileImpl file = VirtualFileImpl.this;
|
||||
FileDocumentManager.getInstance().reloadFiles(file);
|
||||
if (!localFile.getFileType().equals(myInitialFileType)) {
|
||||
VFilePropertyChangeEvent event = new VFilePropertyChangeEvent(this, file, PROP_NAME, file.getName(), file.getName(), false);
|
||||
BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
|
||||
publisher.after(Collections.singletonList(event));
|
||||
FileContentUtilCore.reparseFiles(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -210,11 +210,11 @@ final class Stripe extends JPanel{
|
||||
|
||||
private LayoutData recomputeBounds(boolean setBounds, Dimension toFitWith, boolean noDrop) {
|
||||
final LayoutData data = new LayoutData();
|
||||
final int horizontaloffset = getHeight();
|
||||
final int horizontaloffset = getHeight() - 2;
|
||||
|
||||
data.eachY = 0;
|
||||
data.size = new Dimension();
|
||||
data.gap = 1;
|
||||
data.gap = 0;
|
||||
data.horizontal = isHorizontal();
|
||||
data.dragInsertPosition = -1;
|
||||
if (data.horizontal) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -94,6 +95,16 @@ public class TableModelEditor<T> implements ElementProducer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public TableModelEditor<T> modelListener(@NotNull TableModelListener listener) {
|
||||
model.addTableModelListener(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ListTableModel<T> getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public static abstract class ItemEditor<T> {
|
||||
/**
|
||||
* Used for "add" and "in place edit" actions.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.io;
|
||||
|
||||
import com.google.gson.annotations.Since;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
|
||||
@@ -102,7 +102,7 @@ find.progress.search.completed=Search completed
|
||||
find.scope.project.title=Project
|
||||
find.scope.module.title=Module {0}
|
||||
find.scope.directory.title=Directory {0}
|
||||
find.scope.files.with.mask={0} Files with Mask {1}
|
||||
find.scope.files.with.mask={0} Files with mask {1}
|
||||
find.usage.target.string.text=String ''{0}''
|
||||
find.replace.invalid.replacement.string=You have entered malformed replacement string: ''{0}''
|
||||
find.replace.invalid.replacement.string.title=Replace Error
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
[
|
||||
{
|
||||
"updateId": 11696,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "121.12"
|
||||
},
|
||||
{
|
||||
"updateId": 11749,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "121.62"
|
||||
},
|
||||
{
|
||||
"updateId": 11879,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "121.215"
|
||||
},
|
||||
{
|
||||
"updateId": 12109,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "121.390"
|
||||
},
|
||||
{
|
||||
"updateId": 12215,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "122.875"
|
||||
},
|
||||
{
|
||||
"updateId": 12290,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "123.66"
|
||||
},
|
||||
{
|
||||
"updateId": 12766,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "126.334"
|
||||
},
|
||||
{
|
||||
"updateId": 12851,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "127.67"
|
||||
},
|
||||
{
|
||||
"updateId": 12895,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "127.100"
|
||||
},
|
||||
{
|
||||
"updateId": 12992,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "129.91"
|
||||
},
|
||||
{
|
||||
"updateId": 13260,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "129.362"
|
||||
},
|
||||
{
|
||||
"updateId": 13473,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "129.672"
|
||||
},
|
||||
{
|
||||
"updateId": 13636,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "129.814"
|
||||
},
|
||||
{
|
||||
"updateId": 13711,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "130.1176"
|
||||
},
|
||||
{
|
||||
"updateId": 13843,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "130.1481"
|
||||
},
|
||||
{
|
||||
"updateId": 13933,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "130.1639"
|
||||
},
|
||||
{
|
||||
"updateId": 14135,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "131.98"
|
||||
},
|
||||
{
|
||||
"updateId": 14236,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "131.205"
|
||||
},
|
||||
{
|
||||
"updateId": 14260,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "131.235"
|
||||
},
|
||||
{
|
||||
"updateId": 14350,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "131.332"
|
||||
},
|
||||
{
|
||||
"updateId": 14379,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "131.374"
|
||||
},
|
||||
{
|
||||
"updateId": 14616,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "133.51"
|
||||
},
|
||||
{
|
||||
"updateId": 14858,
|
||||
"pluginId": "com.jetbrains.php",
|
||||
"version": "133.326"
|
||||
},
|
||||
{
|
||||
"updateId": 8976,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.407"
|
||||
},
|
||||
{
|
||||
"updateId": 9009,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.442"
|
||||
},
|
||||
{
|
||||
"updateId": 9041,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.472"
|
||||
},
|
||||
{
|
||||
"updateId": 9214,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.589"
|
||||
},
|
||||
{
|
||||
"updateId": 9343,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.748"
|
||||
},
|
||||
{
|
||||
"updateId": 9470,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.820"
|
||||
},
|
||||
{
|
||||
"updateId": 9473,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.833"
|
||||
},
|
||||
{
|
||||
"updateId": 9669,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.1084"
|
||||
},
|
||||
{
|
||||
"updateId": 9968,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.4.1371"
|
||||
},
|
||||
{
|
||||
"updateId": 10010,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.5.16"
|
||||
},
|
||||
{
|
||||
"updateId": 14027,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.18.39"
|
||||
},
|
||||
{
|
||||
"updateId": 14075,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.21.45"
|
||||
},
|
||||
{
|
||||
"updateId": 14130,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.21.50"
|
||||
},
|
||||
{
|
||||
"updateId": 14289,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.23.252"
|
||||
},
|
||||
{
|
||||
"updateId": 14440,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.23.282"
|
||||
},
|
||||
{
|
||||
"updateId": 14493,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.23.289"
|
||||
},
|
||||
{
|
||||
"updateId": 14574,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.23.308"
|
||||
},
|
||||
{
|
||||
"updateId": 14612,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.23.311"
|
||||
},
|
||||
{
|
||||
"updateId": 14666,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.308"
|
||||
},
|
||||
{
|
||||
"updateId": 14672,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.310"
|
||||
},
|
||||
{
|
||||
"updateId": 14697,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.314"
|
||||
},
|
||||
{
|
||||
"updateId": 14711,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.315"
|
||||
},
|
||||
{
|
||||
"updateId": 14728,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.318"
|
||||
},
|
||||
{
|
||||
"updateId": 14743,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.321"
|
||||
},
|
||||
{
|
||||
"updateId": 14767,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.323"
|
||||
},
|
||||
{
|
||||
"updateId": 14779,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.327"
|
||||
},
|
||||
{
|
||||
"updateId": 14845,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.331"
|
||||
},
|
||||
{
|
||||
"updateId": 14859,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.333"
|
||||
},
|
||||
{
|
||||
"updateId": 14863,
|
||||
"pluginId": "org.intellij.scala",
|
||||
"version": "0.26.335"
|
||||
},
|
||||
{
|
||||
"updateId": 14627,
|
||||
"pluginId": "org.jetbrains.plugins.ruby",
|
||||
"version": "6.0.0.20131121"
|
||||
},
|
||||
{
|
||||
"updateId": 14812,
|
||||
"pluginId": "org.jetbrains.plugins.ruby",
|
||||
"version": "6.0.0.20131207"
|
||||
}
|
||||
]
|
||||
+19
-3
@@ -94,14 +94,17 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor extends GeneralTestEventsP
|
||||
|
||||
// We don't know whether process was destroyed by user
|
||||
// or it finished after all tests have been run
|
||||
// Lets assume, if at finish all suites except root suite are passed
|
||||
// Lets assume, if at finish all nodes except root suite have final state (passed, failed or ignored),
|
||||
// then all is ok otherwise process was terminated by user
|
||||
if (myRunningTestNodes.isEmpty()) {
|
||||
boolean completeTree = isTreeComplete();
|
||||
if (completeTree) {
|
||||
myTestsRootProxy.setFinished();
|
||||
} else {
|
||||
logProblem("Unexpected running nodes: " + myRunningTestNodes);
|
||||
myTestsRootProxy.setTerminated();
|
||||
}
|
||||
if (!myRunningTestNodes.isEmpty()) {
|
||||
logProblem("Unexpected running nodes: " + myRunningTestNodes);
|
||||
}
|
||||
myNodeByIdMap.clear();
|
||||
myRunningTestNodes.clear();
|
||||
|
||||
@@ -110,6 +113,19 @@ public class GeneralIdBasedToSMTRunnerEventsConvertor extends GeneralTestEventsP
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isTreeComplete() {
|
||||
if (!myRunningTestNodes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
List<? extends SMTestProxy> children = myTestsRootProxy.getChildren();
|
||||
for (SMTestProxy child : children) {
|
||||
if (!child.isFinal() || child.wasTerminated()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrinterProvider(@NotNull TestProxyPrinterProvider printerProvider) {
|
||||
myTestProxyPrinterProvider = printerProvider;
|
||||
|
||||
@@ -143,6 +143,13 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the state is final (PASSED, FAILED, IGNORED, TERMINATED)
|
||||
*/
|
||||
public boolean isFinal() {
|
||||
return myState.isFinal();
|
||||
}
|
||||
|
||||
private void setStacktraceIfNotSet(@Nullable String stacktrace) {
|
||||
if (myStacktrace == null) myStacktrace = stacktrace;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.usages;
|
||||
|
||||
import com.intellij.usageView.UsageViewBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -96,19 +97,21 @@ public class UsageViewPresentation {
|
||||
myShowCancelButton = showCancelButton;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getNonCodeUsagesString() {
|
||||
return myNonCodeUsagesString;
|
||||
}
|
||||
|
||||
public void setNonCodeUsagesString(String nonCodeUsagesString) {
|
||||
public void setNonCodeUsagesString(@NotNull String nonCodeUsagesString) {
|
||||
myNonCodeUsagesString = nonCodeUsagesString;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCodeUsagesString() {
|
||||
return myCodeUsagesString;
|
||||
}
|
||||
|
||||
public void setCodeUsagesString(String codeUsagesString) {
|
||||
public void setCodeUsagesString(@NotNull String codeUsagesString) {
|
||||
myCodeUsagesString = codeUsagesString;
|
||||
}
|
||||
|
||||
@@ -137,11 +140,12 @@ public class UsageViewPresentation {
|
||||
return myNotFoundActions;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getUsagesWord() {
|
||||
return myUsagesWord;
|
||||
}
|
||||
|
||||
public void setUsagesWord(final String usagesWord) {
|
||||
public void setUsagesWord(@NotNull String usagesWord) {
|
||||
myUsagesWord = usagesWord;
|
||||
}
|
||||
|
||||
@@ -177,11 +181,12 @@ public class UsageViewPresentation {
|
||||
return myDynamicCodeUsagesString;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getUsagesInGeneratedCodeString() {
|
||||
return myUsagesInGeneratedCodeString;
|
||||
}
|
||||
|
||||
public void setUsagesInGeneratedCodeString(String usagesInGeneratedCodeString) {
|
||||
public void setUsagesInGeneratedCodeString(@NotNull String usagesInGeneratedCodeString) {
|
||||
myUsagesInGeneratedCodeString = usagesInGeneratedCodeString;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ContainerUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static <T> ArrayList<T> newArrayList(@NotNull T... elements) {
|
||||
ArrayList<T> list = newArrayListWithCapacity(elements.length);
|
||||
ArrayList<T> list = new ArrayList<T>(elements.length);
|
||||
Collections.addAll(list, elements);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,14 @@ public abstract class NotNullLazyValue<T> {
|
||||
}
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public static <T> NotNullLazyValue<T> createConstantValue(@NotNull final T value) {
|
||||
return new NotNullLazyValue<T>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected T compute() {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -880,7 +880,7 @@ class LockFreeCopyOnWriteArrayList<E> implements List<E>, RandomAccess {
|
||||
Object[] elements = array;
|
||||
if (elements.length == 0) return EmptyIterator.getInstance();
|
||||
|
||||
return new COWIterator<E>(elements, 0);
|
||||
return new COWIterator(elements, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -916,10 +916,10 @@ class LockFreeCopyOnWriteArrayList<E> implements List<E>, RandomAccess {
|
||||
throw new IndexOutOfBoundsException("Index: " + index);
|
||||
}
|
||||
|
||||
return elements.length == 0 ? EmptyListIterator.<E>getInstance() : new COWIterator<E>(elements, index);
|
||||
return elements.length == 0 ? EmptyListIterator.<E>getInstance() : new COWIterator(elements, index);
|
||||
}
|
||||
|
||||
private static class COWIterator<E> implements ListIterator<E> {
|
||||
private class COWIterator implements ListIterator<E> {
|
||||
/**
|
||||
* Snapshot of the array
|
||||
*/
|
||||
@@ -928,6 +928,7 @@ class LockFreeCopyOnWriteArrayList<E> implements List<E>, RandomAccess {
|
||||
* Index of element to be returned by subsequent call to next.
|
||||
*/
|
||||
private int cursor;
|
||||
private int lastRet = -1; // index of last element returned; -1 if no such
|
||||
|
||||
private COWIterator(@NotNull Object[] elements, int initialCursor) {
|
||||
cursor = initialCursor;
|
||||
@@ -950,6 +951,7 @@ class LockFreeCopyOnWriteArrayList<E> implements List<E>, RandomAccess {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
lastRet = cursor;
|
||||
return (E)snapshot[cursor++];
|
||||
}
|
||||
|
||||
@@ -974,7 +976,13 @@ class LockFreeCopyOnWriteArrayList<E> implements List<E>, RandomAccess {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
if (lastRet < 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
E e = (E)snapshot[lastRet];
|
||||
lastRet = -1;
|
||||
LockFreeCopyOnWriteArrayList.this.remove(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ListTableModel<Item> extends TableViewModel<Item> implements ItemRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRowValue(int row) {
|
||||
public Item getRowValue(int row) {
|
||||
return myItems.get(row);
|
||||
}
|
||||
|
||||
|
||||
@@ -433,18 +433,22 @@ public class UIUtil {
|
||||
return ArrayUtil.toStringArray(lines);
|
||||
}
|
||||
|
||||
public static void setActionNameAndMnemonic(String text, Action action) {
|
||||
int mnemoPos = text.indexOf('&');
|
||||
if (mnemoPos >= 0 && mnemoPos < text.length() - 2) {
|
||||
String mnemoChar = text.substring(mnemoPos + 1, mnemoPos + 2).trim();
|
||||
if (mnemoChar.length() == 1) {
|
||||
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf((int)mnemoChar.charAt(0)));
|
||||
}
|
||||
}
|
||||
public static void setActionNameAndMnemonic(@NotNull String text, @NotNull Action action) {
|
||||
assignMnemonic(text, action);
|
||||
|
||||
text = text.replaceAll("&", "");
|
||||
action.putValue(Action.NAME, text);
|
||||
}
|
||||
public static void assignMnemonic(@NotNull String text, @NotNull Action action) {
|
||||
int mnemoPos = text.indexOf('&');
|
||||
if (mnemoPos >= 0 && mnemoPos < text.length() - 2) {
|
||||
String mnemoChar = text.substring(mnemoPos + 1, mnemoPos + 2).trim();
|
||||
if (mnemoChar.length() == 1) {
|
||||
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemoChar.charAt(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Font getLabelFont(@NotNull FontSize size) {
|
||||
return getFont(size, null);
|
||||
|
||||
@@ -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.
|
||||
@@ -234,4 +234,42 @@ public class ContainerUtilTest extends TestCase {
|
||||
Iterator<Object> iterator = my.iterator();
|
||||
assertSame(EmptyIterator.getInstance(), iterator);
|
||||
}
|
||||
|
||||
public void testLockFreeCOWIteratorRemove() {
|
||||
List<String> seq = Arrays.asList("0", "1", "2", "3", "4");
|
||||
LockFreeCopyOnWriteArrayList<String> my = (LockFreeCopyOnWriteArrayList<String>)ContainerUtil.createLockFreeCopyOnWriteList(seq);
|
||||
{
|
||||
Iterator<String> iterator = my.iterator();
|
||||
try {
|
||||
iterator.remove();
|
||||
fail("must not be able to remove before next() call");
|
||||
}
|
||||
catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
int size = my.size();
|
||||
Iterator<String> iterator = my.iterator();
|
||||
for (int i = 0; i<size; i++) {
|
||||
assertTrue(iterator.hasNext());
|
||||
String next = iterator.next();
|
||||
assertEquals(next, String.valueOf(i));
|
||||
iterator.remove();
|
||||
assertEquals(my.size(), size - i-1);
|
||||
if (i == size-1) {
|
||||
assertTrue(my.isEmpty());
|
||||
}
|
||||
else {
|
||||
assertEquals(my.toArray()[0], String.valueOf(i+1));
|
||||
assertEquals(my.toString(), seq.subList(i+1,seq.size()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
iterator.remove();
|
||||
fail("must not be able to double remove()");
|
||||
}
|
||||
catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -174,10 +174,7 @@ public class JavaLanguageInjectionSupport extends AbstractLanguageInjectionSuppo
|
||||
}
|
||||
|
||||
public BaseInjection createInjection(final Element element) {
|
||||
if (element.getName().equals(MethodParameterInjection.class.getSimpleName())) {
|
||||
return new MethodParameterInjection();
|
||||
}
|
||||
else return new BaseInjection(JAVA_SUPPORT_ID);
|
||||
return new BaseInjection(JAVA_SUPPORT_ID);
|
||||
}
|
||||
|
||||
private static boolean doInjectInJava(final Project project,
|
||||
|
||||
+7
-12
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.intellij.plugins.intelliLang.inject.config.ui;
|
||||
|
||||
import com.intellij.openapi.editor.event.DocumentAdapter;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
|
||||
@@ -73,7 +71,6 @@ public abstract class AbstractInjectionPanel<T extends BaseInjection> implements
|
||||
final InjectionPanel p = getField(panel);
|
||||
p.init(copy);
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
public final boolean isModified() {
|
||||
@@ -95,18 +92,22 @@ public abstract class AbstractInjectionPanel<T extends BaseInjection> implements
|
||||
|
||||
// auto-generated name should go last
|
||||
apply(myOrigInjection);
|
||||
myOrigInjection.generatePlaces();
|
||||
myEditCopy.copyFrom(myOrigInjection);
|
||||
if (!myOtherPanels.isEmpty()) {
|
||||
myOrigInjection.generatePlaces();
|
||||
myEditCopy.copyFrom(myOrigInjection);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void apply(T other);
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public final void reset() {
|
||||
if (!myOtherPanels.isEmpty()) {
|
||||
myEditCopy.copyFrom(myOrigInjection);
|
||||
}
|
||||
for (Field panel : myOtherPanels) {
|
||||
getField(panel).reset();
|
||||
}
|
||||
myEditCopy.copyFrom(myOrigInjection);
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
resetImpl();
|
||||
@@ -139,10 +140,4 @@ public abstract class AbstractInjectionPanel<T extends BaseInjection> implements
|
||||
updater.run();
|
||||
}
|
||||
}
|
||||
|
||||
protected class TreeUpdateListener extends DocumentAdapter {
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
updateTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -102,14 +102,6 @@ public class XmlAttributeInjection extends AbstractTagInjection {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void readExternalImpl(Element e) {
|
||||
super.readExternalImpl(e);
|
||||
}
|
||||
|
||||
protected void writeExternalImpl(Element e) {
|
||||
super.writeExternalImpl(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"RedundantIfStatement"})
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
-1
@@ -49,7 +49,6 @@ public class TagPanel extends AbstractInjectionPanel<AbstractTagInjection> {
|
||||
$$$setupUI$$$();
|
||||
|
||||
myNamespace.setModel(createNamespaceUriModel(myProject));
|
||||
myLocalName.getDocument().addDocumentListener(new TreeUpdateListener());
|
||||
}
|
||||
|
||||
public static ComboBoxModel createNamespaceUriModel(Project project) {
|
||||
|
||||
-3
@@ -48,9 +48,6 @@ public class XmlAttributePanel extends AbstractInjectionPanel<XmlAttributeInject
|
||||
myNamespace.setModel(TagPanel.createNamespaceUriModel(project));
|
||||
|
||||
init(injection.copy());
|
||||
|
||||
// be sure to add the listener after initializing the textfield's value
|
||||
myLocalName.getDocument().addDocumentListener(new TreeUpdateListener());
|
||||
}
|
||||
|
||||
public JPanel getComponent() {
|
||||
|
||||
+3
-2
@@ -268,10 +268,11 @@ public class XmlLanguageInjectionSupport extends AbstractLanguageInjectionSuppor
|
||||
}
|
||||
|
||||
public BaseInjection createInjection(Element element) {
|
||||
if (element.getName().equals(XmlAttributeInjection.class.getSimpleName())) {
|
||||
String place = StringUtil.notNullize(element.getChildText("place"), "");
|
||||
if (place.startsWith("xmlAttribute")) {
|
||||
return new XmlAttributeInjection();
|
||||
}
|
||||
else if (element.getName().equals(XmlTagInjection.class.getSimpleName())) {
|
||||
else if (place.startsWith("xmlTag")) {
|
||||
return new XmlTagInjection();
|
||||
}
|
||||
else {
|
||||
|
||||
+28
@@ -24,6 +24,7 @@ import org.gradle.plugins.ide.idea.IdeaPlugin;
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
||||
import org.gradle.plugins.ide.internal.IdeDependenciesExtractor;
|
||||
import org.gradle.tooling.model.idea.IdeaDependency;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.model.GradleDependencyScope;
|
||||
import org.jetbrains.plugins.gradle.model.ModelBuilderService;
|
||||
@@ -148,6 +149,7 @@ public class ModelDependenciesBuilderImpl implements ModelBuilderService {
|
||||
versionId.getClassifier()
|
||||
);
|
||||
libraryDependency.setFile(fileDependency.getFile());
|
||||
attachGradleSdkSources(libraryDependency, fileDependency);
|
||||
dependencies.add(libraryDependency);
|
||||
}
|
||||
}
|
||||
@@ -156,6 +158,32 @@ public class ModelDependenciesBuilderImpl implements ModelBuilderService {
|
||||
return new ProjectDependenciesModelImpl(project.getPath(), dependencies);
|
||||
}
|
||||
|
||||
private static void attachGradleSdkSources(IdeaSingleEntryLibraryDependencyImpl libraryDependency,
|
||||
IdeDependenciesExtractor.IdeLocalFileDependency localFileDependency) {
|
||||
final String libName = localFileDependency.getFile().getName();
|
||||
if (localFileDependency.getFile() == null || !libName.startsWith("gradle-")) return;
|
||||
|
||||
File libOrPluginsFile = localFileDependency.getFile().getParentFile();
|
||||
if (libOrPluginsFile != null && ("plugins".equals(libOrPluginsFile.getName()))) {
|
||||
libOrPluginsFile = libOrPluginsFile.getParentFile();
|
||||
}
|
||||
|
||||
if (libOrPluginsFile != null && "lib".equals(libOrPluginsFile.getName()) && libOrPluginsFile.getParentFile() != null) {
|
||||
File srcDir = new File(libOrPluginsFile.getParentFile(), "src");
|
||||
if (GradleVersion.current().compareTo(GradleVersion.version("1.9")) >= 0) {
|
||||
int endIndex = libName.indexOf(GradleVersion.current().getVersion() + ".jar");
|
||||
if (endIndex != -1) {
|
||||
String srcDirChild = libName.substring("gradle-".length(), endIndex - 1);
|
||||
srcDir = new File(srcDir, srcDirChild);
|
||||
}
|
||||
}
|
||||
|
||||
if (srcDir.isDirectory()) {
|
||||
libraryDependency.setSource(srcDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String findDeDuplicatedModuleName(Project project) {
|
||||
if (project.hasProperty(MODULE_PROPERTY)) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
allprojects { project ->
|
||||
if(project.name == 'buildSrc') {
|
||||
apply plugin: 'groovy'
|
||||
dependencies {
|
||||
compile gradleApi()
|
||||
compile localGroovy()
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
-2
@@ -355,22 +355,46 @@ public class GradleExecutionHelper {
|
||||
}
|
||||
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
public static void setInitScript(LongRunningOperation longRunningOperation) {
|
||||
public static boolean setInitScript(@NotNull LongRunningOperation longRunningOperation, boolean isBuildSrcProject) {
|
||||
try {
|
||||
InputStream stream = GradleProjectResolver.class.getResourceAsStream("/org/jetbrains/plugins/gradle/model/internal/init.gradle");
|
||||
if (stream == null) return;
|
||||
if (stream == null) return isBuildSrcProject;
|
||||
|
||||
String jarPath = PathUtil.getCanonicalPath(PathUtil.getJarPathForClass(GradleProjectResolver.class));
|
||||
String s = FileUtil.loadTextAndClose(stream).replace("${JAR_PATH}", jarPath);
|
||||
|
||||
if(isBuildSrcProject) {
|
||||
String buildSrcDefaultInitScript = getBuildSrcDefaultInitScript();
|
||||
if(buildSrcDefaultInitScript == null) return false;
|
||||
s += buildSrcDefaultInitScript;
|
||||
}
|
||||
|
||||
final File tempFile = FileUtil.createTempFile("ijinit", '.' + GradleConstants.EXTENSION, true);
|
||||
FileUtil.writeToFile(tempFile, s);
|
||||
|
||||
String[] buildExecutorArgs = new String[]{"--init-script", tempFile.getAbsolutePath()};
|
||||
longRunningOperation.withArguments(buildExecutorArgs);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.warn("Can't use IJ gradle init script", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
public static String getBuildSrcDefaultInitScript() {
|
||||
try {
|
||||
InputStream stream = GradleProjectResolver.class.getResourceAsStream("/org/jetbrains/plugins/gradle/model/internal/buildSrcInit.gradle");
|
||||
if (stream == null) return null;
|
||||
|
||||
return FileUtil.loadTextAndClose(stream);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.warn("Can't use IJ gradle init script", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+90
-15
@@ -32,6 +32,7 @@ import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemDebugEnvironment;
|
||||
import com.intellij.openapi.util.KeyValue;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
@@ -110,19 +111,19 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
projectResolverChain = new BaseGradleProjectResolverExtension();
|
||||
}
|
||||
|
||||
return myHelper.execute(projectPath, settings, new Function<ProjectConnection, DataNode<ProjectData>>() {
|
||||
@Override
|
||||
public DataNode<ProjectData> fun(ProjectConnection connection) {
|
||||
try {
|
||||
return doResolveProjectInfo(
|
||||
new ProjectResolverContext(id, projectPath, settings, connection, listener, isPreviewMode), projectResolverChain);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
LOG.info("Gradle project resolve error", e);
|
||||
throw projectResolverChain.getUserFriendlyError(e, projectPath, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
final DataNode<ProjectData> resultProjectDataNode = myHelper.execute(
|
||||
projectPath, settings,
|
||||
new ProjectConnectionDataNodeFunction(
|
||||
id, projectPath, settings, listener, isPreviewMode, projectResolverChain, false)
|
||||
);
|
||||
|
||||
// auto-discover buildSrc project if needed
|
||||
final String buildSrcProjectPath = projectPath + "/buildSrc";
|
||||
handleBuildSrcProject(
|
||||
resultProjectDataNode,
|
||||
new ProjectConnectionDataNodeFunction(id, buildSrcProjectPath, settings, listener, isPreviewMode, projectResolverChain, true)
|
||||
);
|
||||
return resultProjectDataNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +134,8 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
|
||||
@NotNull
|
||||
private DataNode<ProjectData> doResolveProjectInfo(@NotNull final ProjectResolverContext resolverCtx,
|
||||
@NotNull final GradleProjectResolverExtension projectResolverChain)
|
||||
@NotNull final GradleProjectResolverExtension projectResolverChain,
|
||||
boolean isBuildSrcProject)
|
||||
throws IllegalArgumentException, IllegalStateException {
|
||||
|
||||
final ProjectImportAction projectImportAction = new ProjectImportAction(resolverCtx.isPreviewMode());
|
||||
@@ -165,7 +167,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
|
||||
// TODO [vlad] remove the check
|
||||
if (!GradleEnvironment.DISABLE_ENHANCED_TOOLING_API) {
|
||||
GradleExecutionHelper.setInitScript(buildActionExecutor);
|
||||
GradleExecutionHelper.setInitScript(buildActionExecutor, isBuildSrcProject);
|
||||
}
|
||||
|
||||
ProjectImportAction.AllModels allModels;
|
||||
@@ -278,4 +280,77 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBuildSrcProject(@NotNull final DataNode<ProjectData> resultProjectDataNode,
|
||||
@NotNull final ProjectConnectionDataNodeFunction projectConnectionDataNodeFunction) {
|
||||
|
||||
if (projectConnectionDataNodeFunction.myIsPreviewMode || GradleEnvironment.DISABLE_ENHANCED_TOOLING_API) return;
|
||||
|
||||
final DataNode<ModuleData> buildSrcModuleDataNode =
|
||||
ExternalSystemApiUtil.find(resultProjectDataNode, ProjectKeys.MODULE, new BooleanFunction<DataNode<ModuleData>>() {
|
||||
@Override
|
||||
public boolean fun(DataNode<ModuleData> node) {
|
||||
return projectConnectionDataNodeFunction.myProjectPath.equals(node.getData().getLinkedExternalProjectPath());
|
||||
}
|
||||
});
|
||||
|
||||
// check if buildSrc project was already exposed in settings.gradle file
|
||||
if (buildSrcModuleDataNode != null) return;
|
||||
|
||||
final DataNode<ProjectData> buildSrcProjectDataDataNode = myHelper.execute(
|
||||
projectConnectionDataNodeFunction.myProjectPath, projectConnectionDataNodeFunction.mySettings, projectConnectionDataNodeFunction);
|
||||
|
||||
if (buildSrcProjectDataDataNode != null) {
|
||||
final DataNode<ModuleData> moduleDataNode = ExternalSystemApiUtil.find(buildSrcProjectDataDataNode, ProjectKeys.MODULE);
|
||||
if (moduleDataNode != null) {
|
||||
for (DataNode<LibraryData> libraryDataNode : ExternalSystemApiUtil.findAll(buildSrcProjectDataDataNode, ProjectKeys.LIBRARY)) {
|
||||
resultProjectDataNode.createChild(libraryDataNode.getKey(), libraryDataNode.getData());
|
||||
}
|
||||
|
||||
final DataNode<ModuleData> newModuleDataNode = resultProjectDataNode.createChild(ProjectKeys.MODULE, moduleDataNode.getData());
|
||||
for (DataNode node : moduleDataNode.getChildren()) {
|
||||
newModuleDataNode.createChild(node.getKey(), node.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ProjectConnectionDataNodeFunction implements Function<ProjectConnection, DataNode<ProjectData>> {
|
||||
@NotNull private final ExternalSystemTaskId myId;
|
||||
@NotNull private final String myProjectPath;
|
||||
@Nullable private final GradleExecutionSettings mySettings;
|
||||
@NotNull private final ExternalSystemTaskNotificationListener myListener;
|
||||
private final boolean myIsPreviewMode;
|
||||
@NotNull private final GradleProjectResolverExtension myProjectResolverChain;
|
||||
private final boolean myIsBuildSrcProject;
|
||||
|
||||
public ProjectConnectionDataNodeFunction(@NotNull ExternalSystemTaskId id,
|
||||
@NotNull String projectPath,
|
||||
@Nullable GradleExecutionSettings settings,
|
||||
@NotNull ExternalSystemTaskNotificationListener listener,
|
||||
boolean isPreviewMode,
|
||||
@NotNull GradleProjectResolverExtension projectResolverChain,
|
||||
boolean isBuildSrcProject) {
|
||||
myId = id;
|
||||
myProjectPath = projectPath;
|
||||
mySettings = settings;
|
||||
myListener = listener;
|
||||
myIsPreviewMode = isPreviewMode;
|
||||
myProjectResolverChain = projectResolverChain;
|
||||
myIsBuildSrcProject = isBuildSrcProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataNode<ProjectData> fun(ProjectConnection connection) {
|
||||
try {
|
||||
return doResolveProjectInfo(
|
||||
new ProjectResolverContext(myId, myProjectPath, mySettings, connection, myListener, myIsPreviewMode),
|
||||
myProjectResolverChain, myIsBuildSrcProject);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
LOG.info("Gradle project resolve error", e);
|
||||
throw myProjectResolverChain.getUserFriendlyError(e, myProjectPath, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public abstract class AbstractModelBuilderTest {
|
||||
final ProjectImportAction projectImportAction = new ProjectImportAction(true);
|
||||
projectImportAction.addExtraProjectModelClasses(getModels());
|
||||
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
|
||||
GradleExecutionHelper.setInitScript(buildActionExecutor);
|
||||
GradleExecutionHelper.setInitScript(buildActionExecutor, false);
|
||||
|
||||
allModels = buildActionExecutor.run();
|
||||
assertNotNull(allModels);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PyNames {
|
||||
public static final String NEW = "__new__";
|
||||
public static final String GETATTR = "__getattr__";
|
||||
public static final String GETATTRIBUTE = "__getattribute__";
|
||||
public static final String CLASS = "__class__";
|
||||
public static final String __CLASS__ = "__class__";
|
||||
public static final String DUNDER_METACLASS = "__metaclass__";
|
||||
public static final String METACLASS = "metaclass";
|
||||
public static final String TYPE = "type";
|
||||
@@ -136,7 +136,7 @@ public class PyNames {
|
||||
public static final String COLLECTIONS_NAMEDTUPLE = COLLECTIONS + "." + NAMEDTUPLE;
|
||||
|
||||
public static final String FORMAT = "format";
|
||||
|
||||
|
||||
public static final String ABSTRACTMETHOD = "abc.abstractmethod";
|
||||
public static final String ABSTRACTPROPERTY = "abc.abstractproperty";
|
||||
|
||||
@@ -156,7 +156,7 @@ public class PyNames {
|
||||
|
||||
public static final String TEST_CASE = "TestCase";
|
||||
|
||||
public static final String PYCACHE = "__pycache__";
|
||||
public static final String PYCACHE = "__pycache__";
|
||||
|
||||
public static final String NOT_IMPLEMENTED_ERROR = "NotImplementedError";
|
||||
|
||||
@@ -166,7 +166,7 @@ public class PyNames {
|
||||
* Contains all known predefined names of "__foo__" form.
|
||||
*/
|
||||
public static ImmutableSet<String> UnderscoredAttributes = ImmutableSet.of(
|
||||
"__all__",
|
||||
"__all__",
|
||||
"__author__",
|
||||
"__bases__",
|
||||
"__defaults__",
|
||||
@@ -227,38 +227,38 @@ public class PyNames {
|
||||
.put("__abs__", _only_self_descr)
|
||||
.put("__add__", _self_other_descr)
|
||||
.put("__and__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__all__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__author__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__bases__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__all__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__author__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__bases__", _only_self_descr);
|
||||
.put("__call__", new BuiltinDescription("(self, *args, **kwargs)"))
|
||||
//_BuiltinMethods.put("__class__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__class__", _only_self_descr);
|
||||
.put("__cmp__", _self_other_descr)
|
||||
.put("__coerce__", _self_other_descr)
|
||||
.put("__complex__", _only_self_descr)
|
||||
.put("__contains__", _self_item_descr)
|
||||
//_BuiltinMethods.put("__debug__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__debug__", _only_self_descr);
|
||||
.put("__del__", _only_self_descr)
|
||||
.put("__delete__", new BuiltinDescription("(self, instance)"))
|
||||
.put("__delattr__", _self_item_descr)
|
||||
.put("__delitem__", _self_key_descr)
|
||||
.put("__delslice__", new BuiltinDescription("(self, i, j)"))
|
||||
//_BuiltinMethods.put("__dict__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__dict__", _only_self_descr);
|
||||
.put("__divmod__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__doc__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__docformat__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__doc__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__docformat__", _only_self_descr);
|
||||
.put("__enter__", _only_self_descr)
|
||||
.put("__exit__", new BuiltinDescription("(self, exc_type, exc_val, exc_tb)"))
|
||||
.put("__eq__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__file__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__file__", _only_self_descr);
|
||||
.put("__float__", _only_self_descr)
|
||||
.put("__floordiv__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__future__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__future__", _only_self_descr);
|
||||
.put("__ge__", _self_other_descr)
|
||||
.put("__get__", new BuiltinDescription("(self, instance, owner)"))
|
||||
.put("__getattr__", _self_item_descr)
|
||||
.put("__getattribute__", _self_item_descr)
|
||||
.put("__getitem__", _self_item_descr)
|
||||
//_BuiltinMethods.put("__getslice__", new BuiltinDescription("(self, i, j)"));
|
||||
//_BuiltinMethods.put("__getslice__", new BuiltinDescription("(self, i, j)"));
|
||||
.put("__gt__", _self_other_descr)
|
||||
.put("__hash__", _only_self_descr)
|
||||
.put("__hex__", _only_self_descr)
|
||||
@@ -266,7 +266,7 @@ public class PyNames {
|
||||
.put("__iand__", _self_other_descr)
|
||||
.put("__idiv__", _self_other_descr)
|
||||
.put("__ifloordiv__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__import__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__import__", _only_self_descr);
|
||||
.put("__ilshift__", _self_other_descr)
|
||||
.put("__imod__", _self_other_descr)
|
||||
.put("__imul__", _self_other_descr)
|
||||
@@ -286,18 +286,18 @@ public class PyNames {
|
||||
.put("__long__", _only_self_descr)
|
||||
.put("__lshift__", _self_other_descr)
|
||||
.put("__lt__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__members__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__metaclass__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__members__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__metaclass__", _only_self_descr);
|
||||
.put("__mod__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__mro__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__mro__", _only_self_descr);
|
||||
.put("__mul__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__name__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__name__", _only_self_descr);
|
||||
.put("__ne__", _self_other_descr)
|
||||
.put("__neg__", _only_self_descr)
|
||||
.put(NEW, new BuiltinDescription("(cls, *args, **kwargs)"))
|
||||
.put("__oct__", _only_self_descr)
|
||||
.put("__or__", _self_other_descr)
|
||||
//_BuiltinMethods.put("__path__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__path__", _only_self_descr);
|
||||
.put("__pos__", _only_self_descr)
|
||||
.put("__pow__", new BuiltinDescription("(self, power, modulo=None)"))
|
||||
.put("__radd__", _self_other_descr)
|
||||
@@ -322,13 +322,13 @@ public class PyNames {
|
||||
.put("__setattr__", new BuiltinDescription("(self, key, value)"))
|
||||
.put("__setitem__", new BuiltinDescription("(self, key, value)"))
|
||||
.put("__setslice__", new BuiltinDescription("(self, i, j, sequence)"))
|
||||
//_BuiltinMethods.put("__self__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__slots__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__self__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__slots__", _only_self_descr);
|
||||
.put("__str__", _only_self_descr)
|
||||
.put("__sub__", _self_other_descr)
|
||||
.put("__truediv__", _self_other_descr)
|
||||
.put("__unicode__", _only_self_descr)
|
||||
//_BuiltinMethods.put("__version__", _only_self_descr);
|
||||
//_BuiltinMethods.put("__version__", _only_self_descr);
|
||||
.put("__xor__", _self_other_descr)
|
||||
.build();
|
||||
|
||||
@@ -355,56 +355,92 @@ public class PyNames {
|
||||
public static final String CANONICAL_CLS = "cls";
|
||||
public static final String BASESTRING = "basestring";
|
||||
|
||||
/*
|
||||
Python keywords
|
||||
*/
|
||||
|
||||
public static final String CLASS = "class";
|
||||
public static final String DEF = "def";
|
||||
public static final String IF = "if";
|
||||
public static final String ELSE = "else";
|
||||
public static final String ELIF = "elif";
|
||||
public static final String TRY = "try";
|
||||
public static final String EXCEPT = "except";
|
||||
public static final String FINALLY = "finally";
|
||||
public static final String WHILE = "while";
|
||||
public static final String FOR = "for";
|
||||
public static final String WITH = "with";
|
||||
public static final String AS = "as";
|
||||
public static final String ASSERT = "assert";
|
||||
public static final String DEL = "del";
|
||||
public static final String EXEC = "exec";
|
||||
public static final String FROM = "from";
|
||||
public static final String IMPORT = "import";
|
||||
public static final String RAISE = "raise";
|
||||
public static final String PRINT = "print";
|
||||
public static final String BREAK = "break";
|
||||
public static final String CONTINUE = "continue";
|
||||
public static final String GLOBAL = "global";
|
||||
public static final String RETURN = "return";
|
||||
public static final String YIELD = "yield";
|
||||
public static final String NONLOCAL = "nonlocal";
|
||||
public static final String AND = "and";
|
||||
public static final String OR = "or";
|
||||
public static final String IS = "is";
|
||||
public static final String IN = "in";
|
||||
public static final String NOT = "not";
|
||||
public static final String LAMBDA = "lambda";
|
||||
|
||||
/**
|
||||
* Contains keywords as of CPython 2.5.
|
||||
*/
|
||||
public static ImmutableSet<String> Keywords = ImmutableSet.of(
|
||||
"and",
|
||||
"del",
|
||||
"from",
|
||||
"not",
|
||||
"while",
|
||||
"as",
|
||||
"elif",
|
||||
"global",
|
||||
"or",
|
||||
"with",
|
||||
"assert",
|
||||
"else",
|
||||
"if",
|
||||
"pass",
|
||||
"yield",
|
||||
"break",
|
||||
"except",
|
||||
"import",
|
||||
"print",
|
||||
"class",
|
||||
"exec",
|
||||
"in",
|
||||
"raise",
|
||||
"continue",
|
||||
"finally",
|
||||
"is",
|
||||
"return",
|
||||
"def",
|
||||
"for",
|
||||
"lambda",
|
||||
"try"
|
||||
AND,
|
||||
DEL,
|
||||
FROM,
|
||||
NOT,
|
||||
WHILE,
|
||||
AS,
|
||||
ELIF,
|
||||
GLOBAL,
|
||||
OR,
|
||||
WITH,
|
||||
ASSERT,
|
||||
ELSE,
|
||||
IF,
|
||||
PASS,
|
||||
YIELD,
|
||||
BREAK,
|
||||
EXCEPT,
|
||||
IMPORT,
|
||||
PRINT,
|
||||
__CLASS__,
|
||||
EXEC,
|
||||
IN,
|
||||
RAISE,
|
||||
CONTINUE,
|
||||
FINALLY,
|
||||
IS,
|
||||
RETURN,
|
||||
DEF,
|
||||
FOR,
|
||||
LAMBDA,
|
||||
TRY
|
||||
);
|
||||
|
||||
public static Set<String> BuiltinInterfaces = ImmutableSet.of(
|
||||
CALLABLE, HASHABLE, ITERABLE, ITERATOR, SIZED, CONTAINER, SEQUENCE, MAPPING, ABC_COMPLEX, ABC_REAL, ABC_RATIONAL, ABC_INTEGRAL,
|
||||
ABC_NUMBER
|
||||
CALLABLE, HASHABLE, ITERABLE, ITERATOR, SIZED, CONTAINER, SEQUENCE, MAPPING, ABC_COMPLEX, ABC_REAL, ABC_RATIONAL, ABC_INTEGRAL,
|
||||
ABC_NUMBER
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO: dependency on language level.
|
||||
*
|
||||
* @param name what to check
|
||||
* @return true iff the name is either a keyword or a reserved name, like None.
|
||||
*
|
||||
*/
|
||||
public static boolean isReserved(@NonNls String name) {
|
||||
return Keywords.contains(name) || NONE.equals(name) || "as".equals(name) || "with".equals(name);
|
||||
return Keywords.contains(name) || NONE.equals(name);
|
||||
}
|
||||
|
||||
// NOTE: includes unicode only good for py3k
|
||||
@@ -412,6 +448,7 @@ public class PyNames {
|
||||
|
||||
/**
|
||||
* TODO: dependency on language level.
|
||||
*
|
||||
* @param name what to check
|
||||
* @return true iff name is not reserved and is a well-formed identifier.
|
||||
*/
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* 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.jetbrains.python.codeInsight;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
*/
|
||||
public class PyKeywords {
|
||||
public static final String DEF = "def";
|
||||
public static final String CLASS = "class";
|
||||
|
||||
public static final String IF = "if";
|
||||
public static final String ELSE = "else";
|
||||
public static final String ELIF = "elif";
|
||||
|
||||
public static final String TRY = "try";
|
||||
public static final String EXCEPT = "except";
|
||||
public static final String FINALLY = "finally";
|
||||
|
||||
public static final String WHILE = "while";
|
||||
|
||||
public static final String FOR = "for";
|
||||
public static final String WITH = "with";
|
||||
public static final String AS = "as";
|
||||
|
||||
public static final String ASSERT = "assert";
|
||||
public static final String DEL = "del";
|
||||
public static final String EXEC = "exec";
|
||||
public static final String FROM = "from";
|
||||
public static final String IMPORT = "import";
|
||||
public static final String RAISE = "raise";
|
||||
public static final String PRINT = "print";
|
||||
public static final String BREAK = "break";
|
||||
public static final String CONTINUE = "continue";
|
||||
public static final String GLOBAL = "global";
|
||||
public static final String RETURN = "return";
|
||||
public static final String YIELD = "yield";
|
||||
public static final String NONLOCAL = "nonlocal";
|
||||
|
||||
public static final String AND = "and";
|
||||
public static final String OR = "or";
|
||||
public static final String IS = "is";
|
||||
public static final String IN = "in";
|
||||
public static final String NOT = "not";
|
||||
|
||||
public static final String LAMBDA = "lambda";
|
||||
|
||||
public static final String TRUE = "True";
|
||||
public static final String FALSE = "False";
|
||||
public static final String NONE = "None";
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.codeInsight.completion.PythonLookupElement;
|
||||
import com.jetbrains.python.psi.PyStatementWithElse;
|
||||
import com.jetbrains.python.psi.PyTryExceptStatement;
|
||||
@@ -67,28 +68,28 @@ public class PyUnindentingInsertHandler implements InsertHandler<PythonLookupEle
|
||||
|
||||
Class<? extends PsiElement> parentClass = null;
|
||||
|
||||
int last_offset = nonspace_offset + PyKeywords.FINALLY.length(); // the longest of all
|
||||
int last_offset = nonspace_offset + PyNames.FINALLY.length(); // the longest of all
|
||||
if (last_offset > offset) last_offset = offset;
|
||||
int local_length = last_offset - nonspace_offset + 1;
|
||||
if (local_length > 0) {
|
||||
String piece = text.subSequence(nonspace_offset, last_offset + 1).toString();
|
||||
final int else_len = PyKeywords.ELSE.length();
|
||||
final int else_len = PyNames.ELSE.length();
|
||||
if (local_length >= else_len) {
|
||||
if ((piece.startsWith(PyKeywords.ELSE) || piece.startsWith(PyKeywords.ELIF)) &&
|
||||
if ((piece.startsWith(PyNames.ELSE) || piece.startsWith(PyNames.ELIF)) &&
|
||||
(else_len == piece.length() || piece.charAt(else_len) < 'a' || piece.charAt(else_len) > 'z')) {
|
||||
parentClass = PyStatementWithElse.class;
|
||||
}
|
||||
}
|
||||
final int except_len = PyKeywords.EXCEPT.length();
|
||||
final int except_len = PyNames.EXCEPT.length();
|
||||
if (local_length >= except_len) {
|
||||
if (piece.startsWith(PyKeywords.EXCEPT) &&
|
||||
if (piece.startsWith(PyNames.EXCEPT) &&
|
||||
(except_len == piece.length() || piece.charAt(except_len) < 'a' || piece.charAt(except_len) > 'z')) {
|
||||
parentClass = PyTryExceptStatement.class;
|
||||
}
|
||||
}
|
||||
final int finally_len = PyKeywords.FINALLY.length();
|
||||
final int finally_len = PyNames.FINALLY.length();
|
||||
if (local_length >= finally_len) {
|
||||
if (piece.startsWith(PyKeywords.FINALLY) &&
|
||||
if (piece.startsWith(PyNames.FINALLY) &&
|
||||
(finally_len == piece.length() || piece.charAt(finally_len) < 'a' || piece.charAt(finally_len) > 'z')) {
|
||||
parentClass = PyTryExceptStatement.class;
|
||||
}
|
||||
|
||||
+26
-27
@@ -33,7 +33,6 @@ import com.intellij.util.ProcessingContext;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.codeInsight.PyKeywords;
|
||||
import com.jetbrains.python.codeInsight.PyUnindentingInsertHandler;
|
||||
import com.jetbrains.python.documentation.doctest.PyDocstringFile;
|
||||
import com.jetbrains.python.psi.*;
|
||||
@@ -287,9 +286,9 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
psiElement()
|
||||
.inside(PyConditionalStatementPart.class)
|
||||
.andOr(
|
||||
psiElement().afterLeaf(psiElement().withText(PyKeywords.IF)),
|
||||
psiElement().afterLeaf(psiElement().withText(PyKeywords.ELIF)),
|
||||
psiElement().afterLeaf(psiElement().withText(PyKeywords.WHILE))
|
||||
psiElement().afterLeaf(psiElement().withText(PyNames.IF)),
|
||||
psiElement().afterLeaf(psiElement().withText(PyNames.ELIF)),
|
||||
psiElement().afterLeaf(psiElement().withText(PyNames.WHILE))
|
||||
);
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_IMPORT_STMT =
|
||||
@@ -379,8 +378,8 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
protected void addCompletions(
|
||||
@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
|
||||
) {
|
||||
putKeywords(result, TailType.NONE, PyKeywords.DEF, PyKeywords.CLASS, PyKeywords.FOR, PyKeywords.IF, PyKeywords.WHILE, PyKeywords.WITH);
|
||||
putKeywords(result, TailType.CASE_COLON, PyKeywords.TRY);
|
||||
putKeywords(result, TailType.NONE, PyNames.DEF, PyNames.CLASS, PyNames.FOR, PyNames.IF, PyNames.WHILE, PyNames.WITH);
|
||||
putKeywords(result, TailType.CASE_COLON, PyNames.TRY);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -403,13 +402,13 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
protected void addCompletions(
|
||||
@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
|
||||
) {
|
||||
putKeywords(result, TailType.SPACE, PyKeywords.ASSERT, PyKeywords.DEL, PyKeywords.EXEC, PyKeywords.FROM, PyKeywords.IMPORT, PyKeywords.RAISE);
|
||||
putKeywords(result, TailType.SPACE, PyNames.ASSERT, PyNames.DEL, PyNames.EXEC, PyNames.FROM, PyNames.IMPORT, PyNames.RAISE);
|
||||
putKeywords(result, TailType.NONE, PyNames.PASS);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
extend(CompletionType.BASIC, inStatement.andNot(PY3K), new PyKeywordCompletionProvider(TailType.SPACE, PyKeywords.PRINT));
|
||||
extend(CompletionType.BASIC, inStatement.andNot(PY3K), new PyKeywordCompletionProvider(TailType.SPACE, PyNames.PRINT));
|
||||
}
|
||||
|
||||
private void addBreak() {
|
||||
@@ -422,7 +421,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(IN_ARG_LIST)
|
||||
.and(IN_LOOP)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyKeywords.BREAK)
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyNames.BREAK)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -437,7 +436,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(IN_FINALLY_NO_LOOP)
|
||||
.and(IN_LOOP)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyKeywords.CONTINUE)
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyNames.CONTINUE)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -449,7 +448,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.and(IN_BEGIN_STMT)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.GLOBAL, PyKeywords.RETURN, PyKeywords.YIELD)
|
||||
new PyKeywordCompletionProvider(PyNames.GLOBAL, PyNames.RETURN, PyNames.YIELD)
|
||||
);
|
||||
|
||||
extend(
|
||||
@@ -460,7 +459,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.and(PY3K)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.NONLOCAL)
|
||||
new PyKeywordCompletionProvider(PyNames.NONLOCAL)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -472,7 +471,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andOr(IN_IF_BODY, AFTER_IF)
|
||||
.andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyUnindentingInsertHandler.INSTANCE, PyKeywords.ELIF));
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyUnindentingInsertHandler.INSTANCE, PyNames.ELIF));
|
||||
}
|
||||
|
||||
private void addWithinTry() {
|
||||
@@ -488,8 +487,8 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
protected void addCompletions(
|
||||
@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
|
||||
) {
|
||||
putKeyword(PyKeywords.EXCEPT, PyUnindentingInsertHandler.INSTANCE, TailType.NONE, result);
|
||||
putKeyword(PyKeywords.FINALLY, PyUnindentingInsertHandler.INSTANCE, TailType.CASE_COLON, result);
|
||||
putKeyword(PyNames.EXCEPT, PyUnindentingInsertHandler.INSTANCE, TailType.NONE, result);
|
||||
putKeyword(PyNames.FINALLY, PyUnindentingInsertHandler.INSTANCE, TailType.CASE_COLON, result);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -503,7 +502,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andOr(IN_COND_STMT, IN_EXCEPT_BODY, AFTER_COND_STMT_NO_ELSE, AFTER_LOOP_NO_ELSE, AFTER_EXCEPT)
|
||||
.andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.CASE_COLON, PyUnindentingInsertHandler.INSTANCE, PyKeywords.ELSE));
|
||||
new PyKeywordCompletionProvider(TailType.CASE_COLON, PyUnindentingInsertHandler.INSTANCE, PyNames.ELSE));
|
||||
}
|
||||
|
||||
private void addInfixOperators() {
|
||||
@@ -517,7 +516,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(AFTER_QUALIFIER).
|
||||
andNot(IN_STRING_LITERAL).and(IN_BEGIN_STMT)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.AND, PyKeywords.OR, PyKeywords.IS, PyKeywords.IN)
|
||||
new PyKeywordCompletionProvider(PyNames.AND, PyNames.OR, PyNames.IS, PyNames.IN)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -531,7 +530,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(IN_FUNCTION_HEADER)
|
||||
.andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.NOT, PyKeywords.LAMBDA)
|
||||
new PyKeywordCompletionProvider(PyNames.NOT, PyNames.LAMBDA)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -546,7 +545,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
.andNot(IN_FUNCTION_HEADER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyKeywords.TRUE, PyKeywords.FALSE, PyKeywords.NONE)
|
||||
new PyKeywordCompletionProvider(TailType.NONE, PyNames.TRUE, PyNames.FALSE, PyNames.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -557,7 +556,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andOr(IN_IMPORT_AFTER_REF, IN_WITH_AFTER_REF, IN_EXCEPT_AFTER_REF)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.AS)
|
||||
new PyKeywordCompletionProvider(PyNames.AS)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -568,7 +567,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.and(IN_FROM_IMPORT_AFTER_REF)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(PyKeywords.IMPORT)
|
||||
new PyKeywordCompletionProvider(PyNames.IMPORT)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -604,9 +603,9 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.afterLeafSkipping(psiElement().whitespace(),
|
||||
psiElement().inside(psiElement(PyConditionalExpression.class))
|
||||
.and(psiElement().afterLeaf(PyKeywords.IF)))
|
||||
.and(psiElement().afterLeaf(PyNames.IF)))
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.SPACE, PyKeywords.ELSE));
|
||||
new PyKeywordCompletionProvider(TailType.SPACE, PyNames.ELSE));
|
||||
}
|
||||
|
||||
private void addRaiseFrom() {
|
||||
@@ -615,7 +614,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.and(PY3K)
|
||||
.afterLeaf(psiElement().inside(PyRaiseStatement.class)),
|
||||
new PyKeywordCompletionProvider(PyKeywords.FROM));
|
||||
new PyKeywordCompletionProvider(PyNames.FROM));
|
||||
}
|
||||
|
||||
private void addYieldFrom() {
|
||||
@@ -624,7 +623,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.and(PY3K)
|
||||
.afterLeaf(psiElement().withElementType(PyTokenTypes.YIELD_KEYWORD)),
|
||||
new PyKeywordCompletionProvider(PyKeywords.FROM));
|
||||
new PyKeywordCompletionProvider(PyNames.FROM));
|
||||
}
|
||||
|
||||
public PyKeywordCompletionContributor() {
|
||||
@@ -655,14 +654,14 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.inside(psiElement(PySequenceExpression.class))
|
||||
.andNot(psiElement().afterLeaf(or(psiElement(PyTokenTypes.LBRACE), psiElement(PyTokenTypes.LBRACKET), psiElement(PyTokenTypes.LPAR)))),
|
||||
new PyKeywordCompletionProvider(PyKeywords.FOR));
|
||||
new PyKeywordCompletionProvider(PyNames.FOR));
|
||||
}
|
||||
|
||||
private void addInToFor() {
|
||||
extend(CompletionType.BASIC,
|
||||
psiElement()
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.and(psiElement()).afterLeaf(psiElement().afterLeaf(PyKeywords.FOR)),
|
||||
.and(psiElement()).afterLeaf(psiElement().afterLeaf(PyNames.FOR)),
|
||||
new PyKeywordCompletionProvider("in"));
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.types.*;
|
||||
import com.jetbrains.python.psi.types.PyClassType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyTypeChecker;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -89,7 +92,7 @@ public class PyCallingNonCallableInspection extends PyInspection {
|
||||
|
||||
@Nullable
|
||||
private static Boolean isCallable(@NotNull PyExpression element, @NotNull TypeEvalContext context) {
|
||||
if (element instanceof PyQualifiedExpression && PyNames.CLASS.equals(element.getName())) {
|
||||
if (element instanceof PyQualifiedExpression && PyNames.__CLASS__.equals(element.getName())) {
|
||||
return true;
|
||||
}
|
||||
return PyTypeChecker.isCallable(context.getType(element));
|
||||
|
||||
@@ -139,7 +139,7 @@ public class PyMissingConstructorInspection extends PyInspection {
|
||||
if (args.length > 0) {
|
||||
String firstArg = args[0].getText();
|
||||
final String qualifiedName = cl.getQualifiedName();
|
||||
if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ CLASS) ||
|
||||
if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ __CLASS__) ||
|
||||
(qualifiedName != null && qualifiedName.endsWith(firstArg)))
|
||||
return true;
|
||||
for (PyClass s : cl.getAncestorClasses(myTypeEvalContext)) {
|
||||
|
||||
@@ -984,6 +984,10 @@ public class PyUnresolvedReferencesInspection extends PyInspection {
|
||||
final PyImportElement importElement = (PyImportElement)unusedImport;
|
||||
final PsiElement element = importElement.resolve();
|
||||
if (element == null) {
|
||||
if (importElement.getImportedQName() != null) {
|
||||
//Mark import as unused even if it can't be resolved
|
||||
result.add(importElement.getParent());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (dunderAll != null && dunderAll.contains(importElement.getVisibleName())) {
|
||||
|
||||
@@ -415,7 +415,7 @@ public class PyUtil {
|
||||
PyExpression qualifier = ref.getQualifier();
|
||||
if (qualifier != null) {
|
||||
String attr_name = ref.getReferencedName();
|
||||
if (PyNames.CLASS.equals(attr_name)) {
|
||||
if (PyNames.__CLASS__.equals(attr_name)) {
|
||||
PyType qualifierType = context.getType(qualifier);
|
||||
if (qualifierType instanceof PyClassType) {
|
||||
return new PyClassTypeImpl(((PyClassType)qualifierType).getPyClass(), true); // always as class, never instance
|
||||
@@ -1114,7 +1114,7 @@ public class PyUtil {
|
||||
PyExpression[] args = node.getArguments();
|
||||
if (args.length > 0) {
|
||||
String firstArg = args[0].getText();
|
||||
if (firstArg.equals(klass.getName()) || firstArg.equals(PyNames.CANONICAL_SELF + "." + PyNames.CLASS)) {
|
||||
if (firstArg.equals(klass.getName()) || firstArg.equals(PyNames.CANONICAL_SELF + "." + PyNames.__CLASS__)) {
|
||||
return true;
|
||||
}
|
||||
for (PyClass s : klass.getAncestorClasses()) {
|
||||
|
||||
@@ -490,7 +490,7 @@ public class PyCallExpressionHelper {
|
||||
if (first_arg instanceof PyReferenceExpression) {
|
||||
final PyReferenceExpression firstArgRef = (PyReferenceExpression)first_arg;
|
||||
final PyExpression qualifier = firstArgRef.getQualifier();
|
||||
if (qualifier != null && PyNames.CLASS.equals(firstArgRef.getReferencedName())) {
|
||||
if (qualifier != null && PyNames.__CLASS__.equals(firstArgRef.getReferencedName())) {
|
||||
final PsiReference qRef = qualifier.getReference();
|
||||
final PsiElement element = qRef == null ? null : qRef.resolve();
|
||||
if (element instanceof PyParameter) {
|
||||
|
||||
+2
@@ -1 +1,3 @@
|
||||
from importSource import <error descr="Unresolved reference 'len'">len</error>
|
||||
|
||||
len()
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
<warning descr="Unused import statement">from my_module import <error descr="Unresolved reference 'eggs'">eggs</error></warning>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def my_func():
|
||||
pass
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
<warning descr="Unused import statement">from my_module import <error descr="Unresolved reference 'eggs'">eggs</error></warning>
|
||||
<warning descr="Unused import statement">from my_module import <error descr="Unresolved reference 'eggs'">eggs</error></warning>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def my_func():
|
||||
pass
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
from my_package.my_module import <error descr="Unresolved reference 'eggs'">eggs</error>
|
||||
from my_package.my_module import <error descr="Unresolved reference 'eggs'">eggs</error>
|
||||
|
||||
eggs()
|
||||
+1
@@ -0,0 +1 @@
|
||||
__author__ = 'Ilya.Kazakevich'
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def my_func():
|
||||
pass
|
||||
@@ -1 +1,3 @@
|
||||
import collections.<warning descr="No module named OrderedDict">OrderedDict</warning>
|
||||
|
||||
collections.OrderedDict()
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
import <error descr="No module named wurm">wurm</error>
|
||||
|
||||
wurm()
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
<warning descr="Unused import statement">import <error descr="No module named spam">spam</error></warning>
|
||||
+1
@@ -0,0 +1 @@
|
||||
<warning descr="Unused import statement">import <error descr="No module named spam">spam</error>.eggs</warning>
|
||||
@@ -8,3 +8,4 @@ from bar import *
|
||||
|
||||
sys.path
|
||||
datetime.datetime
|
||||
foo.bar()
|
||||
@@ -7,3 +7,4 @@ from bar import *
|
||||
|
||||
sys.path
|
||||
datetime.datetime
|
||||
foo.bar()
|
||||
@@ -8,3 +8,4 @@ from bar import *
|
||||
|
||||
sys.path
|
||||
datetime.datetime
|
||||
foo.bar()
|
||||
@@ -6,3 +6,4 @@ import datetime
|
||||
|
||||
sys.path
|
||||
datetime.datetime
|
||||
foo.bar()
|
||||
@@ -1 +1 @@
|
||||
import xyzzy_shazam
|
||||
|
||||
|
||||
@@ -24,11 +24,28 @@ public abstract class PyInspectionTestCase extends PyTestCase {
|
||||
* Launches test. To be called by test author
|
||||
*/
|
||||
protected void doTest() {
|
||||
myFixture.configureByFile("inspections/" + getInspectionClass().getSimpleName() + "/" + getTestName(true) + ".py");
|
||||
myFixture.configureByFile(getTestDirectory(true) + ".py");
|
||||
configureInspection();
|
||||
}
|
||||
|
||||
protected void doMultiFileTest() {
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
protected void doMultiFileTest(@NotNull String filename) {
|
||||
myFixture.copyDirectoryToProject(getTestDirectory(false), "");
|
||||
myFixture.configureFromTempProjectFile(filename);
|
||||
configureInspection();
|
||||
}
|
||||
|
||||
private void configureInspection() {
|
||||
myFixture.enableInspections(getInspectionClass());
|
||||
myFixture.checkHighlighting(isWarning(), isInfo(), isWeakWarning());
|
||||
}
|
||||
|
||||
private String getTestDirectory(boolean lowercaseFirstLetter) {
|
||||
return "inspections/" + getInspectionClass().getSimpleName() + "/" + getTestName(lowercaseFirstLetter);
|
||||
}
|
||||
|
||||
|
||||
protected boolean isWeakWarning() {
|
||||
return true;
|
||||
|
||||
+32
-16
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.fixtures.PyInspectionTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
private static final String TEST_DIRECTORY = "inspections/PyUnresolvedReferencesInspection/";
|
||||
public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase {
|
||||
|
||||
public void testSelfReference() {
|
||||
doTest();
|
||||
@@ -77,11 +76,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
public void testTypeAssertions() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testUnresolvedImportedModule() { // PY-2075
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testSuperType() { // PY-2320
|
||||
doTest();
|
||||
}
|
||||
@@ -89,7 +88,7 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
public void testImportFunction() { // PY-1896
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testSuperclassAsLocal() { // PY-5427
|
||||
doTest();
|
||||
}
|
||||
@@ -336,17 +335,34 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
// PY-6955
|
||||
public void testUnusedUnresolvedModuleImported() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doMultiFileTest(@NotNull String filename) {
|
||||
final String testName = getTestName(false);
|
||||
myFixture.copyDirectoryToProject(TEST_DIRECTORY + testName, "");
|
||||
myFixture.configureFromTempProjectFile(filename);
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
myFixture.checkHighlighting(true, false, false);
|
||||
// PY-6955
|
||||
public void testUnusedUnresolvedNameImported() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-6955
|
||||
public void testUnusedUnresolvedNameImportedSeveralTimes() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-6955
|
||||
public void testUsedUnresolvedNameImportedSeveralTimes() {
|
||||
doMultiFileTest();
|
||||
}
|
||||
|
||||
// PY-6955
|
||||
public void testUnusedUnresolvedPackageImported() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
return PyUnresolvedReferencesInspection.class;
|
||||
}
|
||||
}
|
||||
|
||||
+76
-37
@@ -26,7 +26,9 @@ import com.intellij.navigation.GotoRelatedItem;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.SmartPointerManager;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
@@ -64,7 +66,7 @@ public class NavigationGutterIconBuilder<T> {
|
||||
private final Icon myIcon;
|
||||
private final NotNullFunction<T,Collection<? extends PsiElement>> myConverter;
|
||||
|
||||
private NotNullLazyValue<Collection<? extends T>> myTargets;
|
||||
private NotNullLazyValue<Collection<T>> myTargets;
|
||||
private boolean myLazy;
|
||||
private String myTooltipText;
|
||||
private String myPopupTitle;
|
||||
@@ -134,18 +136,15 @@ public class NavigationGutterIconBuilder<T> {
|
||||
}
|
||||
|
||||
public NavigationGutterIconBuilder<T> setTargets(@NotNull final NotNullLazyValue<Collection<? extends T>> targets) {
|
||||
myTargets = targets;
|
||||
//noinspection unchecked
|
||||
myTargets = (NotNullLazyValue)targets;
|
||||
myLazy = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NavigationGutterIconBuilder<T> setTargets(@NotNull final Collection<? extends T> targets) {
|
||||
myTargets = new NotNullLazyValue<Collection<? extends T>>() {
|
||||
@NotNull
|
||||
public Collection<? extends T> compute() {
|
||||
return targets;
|
||||
}
|
||||
};
|
||||
//noinspection unchecked
|
||||
myTargets = NotNullLazyValue.createConstantValue((Collection<T>)targets);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -206,46 +205,55 @@ public class NavigationGutterIconBuilder<T> {
|
||||
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element) {
|
||||
final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject());
|
||||
final String tooltip = renderer.getTooltipText();
|
||||
NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Collection<? extends GotoRelatedItem> compute() {
|
||||
if (myGotoRelatedItemProvider != null) {
|
||||
return ContainerUtil.concat(myTargets.getValue(), myGotoRelatedItemProvider);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = createGotoTargetsThunk(myLazy, myGotoRelatedItemProvider,
|
||||
evaluateAndForget(myTargets));
|
||||
return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS,
|
||||
tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip),
|
||||
renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(),
|
||||
gotoTargets);
|
||||
}
|
||||
|
||||
private static <T> NotNullLazyValue<Collection<? extends GotoRelatedItem>> createGotoTargetsThunk(boolean lazy,
|
||||
final NotNullFunction<T, Collection<? extends GotoRelatedItem>> gotoRelatedItemProvider,
|
||||
final Factory<Collection<T>> factory) {
|
||||
if (gotoRelatedItemProvider == null) {
|
||||
return NotNullLazyValue.<Collection<? extends GotoRelatedItem>>createConstantValue(Collections.<GotoRelatedItem>emptyList());
|
||||
}
|
||||
|
||||
if (lazy) {
|
||||
return new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Collection<? extends GotoRelatedItem> compute() {
|
||||
return ContainerUtil.concat(factory.create(), gotoRelatedItemProvider);
|
||||
}
|
||||
};
|
||||
}
|
||||
Collection<GotoRelatedItem> concat = ContainerUtil.concat(factory.create(), gotoRelatedItemProvider);
|
||||
return NotNullLazyValue.<Collection<? extends GotoRelatedItem>>createConstantValue(concat);
|
||||
}
|
||||
|
||||
private void checkBuilt() {
|
||||
assert myTargets != null : "Must have called .setTargets() before calling create()";
|
||||
}
|
||||
|
||||
private MyNavigationGutterIconRenderer createGutterIconRenderer(@NotNull Project project) {
|
||||
checkBuilt();
|
||||
final SmartPointerManager manager = SmartPointerManager.getInstance(project);
|
||||
|
||||
NotNullLazyValue<List<SmartPsiElementPointer>> pointers = new NotNullLazyValue<List<SmartPsiElementPointer>>() {
|
||||
@NotNull
|
||||
public List<SmartPsiElementPointer> compute() {
|
||||
Set<PsiElement> elements = new THashSet<PsiElement>();
|
||||
Collection<? extends T> targets = myTargets.getValue();
|
||||
final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
|
||||
for (final T target : targets) {
|
||||
for (final PsiElement psiElement : myConverter.fun(target)) {
|
||||
if (elements.add(psiElement) && psiElement.isValid()) {
|
||||
list.add(manager.createSmartPsiElementPointer(psiElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
private static <T> Factory<T> evaluateAndForget(NotNullLazyValue<T> lazyValue) {
|
||||
final Ref<NotNullLazyValue<T>> ref = Ref.create(lazyValue);
|
||||
return new Factory<T>() {
|
||||
@Override
|
||||
public T create() {
|
||||
T result = ref.get().getValue();
|
||||
ref.set(null);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private MyNavigationGutterIconRenderer createGutterIconRenderer(@NotNull final Project project) {
|
||||
checkBuilt();
|
||||
|
||||
NotNullLazyValue<List<SmartPsiElementPointer>> pointers = createPointersThunk(myLazy, project, evaluateAndForget(myTargets),
|
||||
myConverter);
|
||||
|
||||
final boolean empty = isEmpty();
|
||||
|
||||
@@ -278,6 +286,37 @@ public class NavigationGutterIconBuilder<T> {
|
||||
return new MyNavigationGutterIconRenderer(this, myAlignment, myIcon, myTooltipText, pointers, renderer, empty);
|
||||
}
|
||||
|
||||
private static <T> NotNullLazyValue<List<SmartPsiElementPointer>> createPointersThunk(boolean lazy,
|
||||
final Project project,
|
||||
final Factory<Collection<T>> targets,
|
||||
final NotNullFunction<T, Collection<? extends PsiElement>> converter) {
|
||||
if (!lazy) {
|
||||
return NotNullLazyValue.createConstantValue(calcPsiTargets(project, targets.create(), converter));
|
||||
}
|
||||
|
||||
return new NotNullLazyValue<List<SmartPsiElementPointer>>() {
|
||||
@NotNull
|
||||
public List<SmartPsiElementPointer> compute() {
|
||||
return calcPsiTargets(project, targets.create(), converter);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static <T> List<SmartPsiElementPointer> calcPsiTargets(Project project, Collection<? extends T> targets,
|
||||
NotNullFunction<T, Collection<? extends PsiElement>> converter) {
|
||||
SmartPointerManager manager = SmartPointerManager.getInstance(project);
|
||||
Set<PsiElement> elements = new THashSet<PsiElement>();
|
||||
final List<SmartPsiElementPointer> list = new ArrayList<SmartPsiElementPointer>(targets.size());
|
||||
for (final T target : targets) {
|
||||
for (final PsiElement psiElement : converter.fun(target)) {
|
||||
if (elements.add(psiElement) && psiElement.isValid()) {
|
||||
list.add(manager.createSmartPsiElementPointer(psiElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean isEmpty() {
|
||||
if (myLazy) {
|
||||
return false;
|
||||
|
||||
+6
-4
@@ -206,9 +206,11 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
|
||||
|
||||
@Override
|
||||
public boolean showHint(@NotNull final Editor editor) {
|
||||
if (myToken == null) return false;
|
||||
XmlToken token = (XmlToken)myToken.retrieve();
|
||||
if (token == null) return false;
|
||||
XmlToken token = null;
|
||||
if (myToken != null) {
|
||||
token = (XmlToken)myToken.retrieve();
|
||||
if (token == null) return false;
|
||||
}
|
||||
if (!XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS || myNamespacePrefix.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -219,7 +221,7 @@ public class CreateNSDeclarationIntentionFix implements HintAction, LocalQuickFi
|
||||
final String message = ShowAutoImportPass.getMessage(namespaces.size() > 1, namespaces.iterator().next());
|
||||
final String title = getTitle();
|
||||
final ImportNSAction action = new ImportNSAction(namespaces, getFile(), element, editor, title);
|
||||
if (element instanceof XmlTag) {
|
||||
if (element instanceof XmlTag && token != null) {
|
||||
if (VisibleHighlightingPassFactory.calculateVisibleRange(editor).contains(token.getTextRange())) {
|
||||
HintManager.getInstance().showQuestionHint(editor, message,
|
||||
token.getTextOffset(),
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="95daa" class="com.intellij.openapi.ui.ComboBox" binding="defaultBrowser">
|
||||
<component id="95daa" class="com.intellij.openapi.ui.ComboBox" binding="defaultBrowserComboBox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="41" height="28"/>
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.ListTableModel;
|
||||
import com.intellij.util.ui.LocalPathCellEditor;
|
||||
import com.intellij.util.ui.table.ComboBoxTableCellEditor;
|
||||
import com.intellij.util.ui.table.IconTableCellRenderer;
|
||||
@@ -40,10 +41,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -141,10 +146,12 @@ public class BrowserSettingsPanel {
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private JComponent browsersTable;
|
||||
|
||||
private ComboBox defaultBrowser;
|
||||
private ComboBox defaultBrowserComboBox;
|
||||
|
||||
private TableModelEditor<ConfigurableWebBrowser> browsersEditor;
|
||||
|
||||
private String customPathValue;
|
||||
|
||||
public BrowserSettingsPanel() {
|
||||
defaultBrowserPanel.setBorder(IdeBorderFactory.createTitledBorder("Default Browser", false));
|
||||
|
||||
@@ -152,30 +159,40 @@ public class BrowserSettingsPanel {
|
||||
APP_FILE_CHOOSER_DESCRIPTOR);
|
||||
|
||||
//noinspection unchecked
|
||||
defaultBrowser.setModel(new EnumComboBoxModel<DefaultBrowser>(DefaultBrowser.class));
|
||||
defaultBrowserComboBox.setModel(new EnumComboBoxModel<DefaultBrowser>(DefaultBrowser.class));
|
||||
if (BrowserUtil.canStartDefaultBrowser()) {
|
||||
defaultBrowser.addActionListener(new ActionListener() {
|
||||
defaultBrowserComboBox.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
alternativeBrowserPathField.setEnabled(getDefaultBrowser() == DefaultBrowser.ALTERNATIVE);
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean customPathEnabled = e.getItem() == DefaultBrowser.ALTERNATIVE;
|
||||
if (e.getStateChange() == ItemEvent.DESELECTED) {
|
||||
if (customPathEnabled) {
|
||||
customPathValue = alternativeBrowserPathField.getText();
|
||||
}
|
||||
}
|
||||
else if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
alternativeBrowserPathField.setEnabled(customPathEnabled);
|
||||
updateCustomPathTextFieldValue((DefaultBrowser)e.getItem());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
defaultBrowser.setRenderer(new ListCellRendererWrapper<DefaultBrowser>() {
|
||||
defaultBrowserComboBox.setRenderer(new ListCellRendererWrapper<DefaultBrowser>() {
|
||||
@Override
|
||||
public void customize(JList list, DefaultBrowser value, int index, boolean selected, boolean hasFocus) {
|
||||
String name;
|
||||
switch (value) {
|
||||
case SYSTEM:
|
||||
name = "System";
|
||||
name = "System default";
|
||||
break;
|
||||
case FIRST:
|
||||
name = "First";
|
||||
name = "First listed";
|
||||
break;
|
||||
case ALTERNATIVE:
|
||||
name = "Command";
|
||||
name = "Custom path";
|
||||
break;
|
||||
default: throw new IllegalStateException();
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
setText(name);
|
||||
@@ -183,7 +200,7 @@ public class BrowserSettingsPanel {
|
||||
});
|
||||
}
|
||||
else {
|
||||
defaultBrowser.setVisible(false);
|
||||
defaultBrowserComboBox.setVisible(false);
|
||||
}
|
||||
|
||||
clearExtractedFiles.addActionListener(new ActionListener() {
|
||||
@@ -194,6 +211,18 @@ public class BrowserSettingsPanel {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateCustomPathTextFieldValue(DefaultBrowser browser) {
|
||||
if (browser == DefaultBrowser.ALTERNATIVE) {
|
||||
alternativeBrowserPathField.setText(customPathValue);
|
||||
}
|
||||
else if (browser == DefaultBrowser.FIRST) {
|
||||
setCustomPathToFirstListed();
|
||||
}
|
||||
else {
|
||||
alternativeBrowserPathField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
TableModelEditor.DialogItemEditor<ConfigurableWebBrowser> itemEditor = new TableModelEditor.DialogItemEditor<ConfigurableWebBrowser>() {
|
||||
@NotNull
|
||||
@@ -237,10 +266,23 @@ public class BrowserSettingsPanel {
|
||||
};
|
||||
browsersEditor = new TableModelEditor<ConfigurableWebBrowser>(Collections.<ConfigurableWebBrowser>emptyList(), COLUMNS,
|
||||
itemEditor, "No web browsers configured"
|
||||
);
|
||||
).modelListener(new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent event) {
|
||||
// todo support inline editing (TableModelEvent is not triggered in this case)
|
||||
if (event.getFirstRow() == 0 && getDefaultBrowser() == DefaultBrowser.FIRST) {
|
||||
setCustomPathToFirstListed();
|
||||
}
|
||||
}
|
||||
});
|
||||
browsersTable = browsersEditor.createComponent();
|
||||
}
|
||||
|
||||
private void setCustomPathToFirstListed() {
|
||||
ListTableModel<ConfigurableWebBrowser> model = browsersEditor.getModel();
|
||||
alternativeBrowserPathField.setText(model.getRowCount() == 0 ? "" : model.getRowValue(0).getPath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JPanel getComponent() {
|
||||
return root;
|
||||
@@ -261,7 +303,11 @@ public class BrowserSettingsPanel {
|
||||
GeneralSettings settings = GeneralSettings.getInstance();
|
||||
|
||||
settings.setUseDefaultBrowser(getDefaultBrowser() == DefaultBrowser.SYSTEM);
|
||||
settings.setBrowserPath(alternativeBrowserPathField.getText());
|
||||
|
||||
if (alternativeBrowserPathField.isEnabled()) {
|
||||
settings.setBrowserPath(alternativeBrowserPathField.getText());
|
||||
}
|
||||
|
||||
settings.setConfirmExtractFiles(confirmExtractFiles.isSelected());
|
||||
|
||||
WebBrowserManager browserManager = WebBrowserManager.getInstance();
|
||||
@@ -270,17 +316,20 @@ public class BrowserSettingsPanel {
|
||||
}
|
||||
|
||||
private DefaultBrowser getDefaultBrowser() {
|
||||
return (DefaultBrowser)defaultBrowser.getSelectedItem();
|
||||
return (DefaultBrowser)defaultBrowserComboBox.getSelectedItem();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
GeneralSettings settings = GeneralSettings.getInstance();
|
||||
alternativeBrowserPathField.setText(settings.getBrowserPath());
|
||||
|
||||
defaultBrowser.setSelectedItem(WebBrowserManager.getInstance().defaultBrowser);
|
||||
alternativeBrowserPathField.setEnabled(getDefaultBrowser() == DefaultBrowser.ALTERNATIVE);
|
||||
DefaultBrowser defaultBrowser = WebBrowserManager.getInstance().getDefaultBrowser();
|
||||
defaultBrowserComboBox.setSelectedItem(defaultBrowser);
|
||||
|
||||
confirmExtractFiles.setSelected(settings.isConfirmExtractFiles());
|
||||
browsersEditor.reset(WebBrowserManager.getInstance().getList());
|
||||
|
||||
customPathValue = settings.getBrowserPath();
|
||||
alternativeBrowserPathField.setEnabled(defaultBrowser == DefaultBrowser.ALTERNATIVE);
|
||||
updateCustomPathTextFieldValue(defaultBrowser);
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,7 @@ public class StartBrowserPanel {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Url virtualFileToUrl(VirtualFile file, Project project) {
|
||||
PsiFile psiFile;
|
||||
AccessToken token = ReadAction.start();
|
||||
@@ -139,7 +140,8 @@ public class StartBrowserPanel {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
|
||||
return virtualFileToUrl(chosenFile, project).toDecodedForm();
|
||||
Url url = virtualFileToUrl(chosenFile, project);
|
||||
return url == null ? chosenFile.getUrl() : url.toDecodedForm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementSettings;
|
||||
import com.intellij.psi.codeStyle.arrangement.ArrangementUtil;
|
||||
import com.intellij.psi.codeStyle.arrangement.Rearranger;
|
||||
import com.intellij.psi.codeStyle.arrangement.*;
|
||||
import com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementEntryMatcher;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.StdArrangementEntryMatcher;
|
||||
@@ -46,6 +44,8 @@ public class XmlRearranger
|
||||
Collections.<ArrangementGroupingRule>emptyList(), DEFAULT_MATCH_RULES);
|
||||
}
|
||||
|
||||
private static final DefaultArrangementSettingsSerializer SETTINGS_SERIALIZER = new DefaultArrangementSettingsSerializer(DEFAULT_SETTINGS);
|
||||
|
||||
@NotNull
|
||||
public static StdArrangementMatchRule attrArrangementRule(@NotNull String nameFilter,
|
||||
@NotNull String namespaceFilter,
|
||||
@@ -56,6 +56,12 @@ public class XmlRearranger
|
||||
)), orderType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrangementSettingsSerializer getSerializer() {
|
||||
return SETTINGS_SERIALIZER;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public StdArrangementSettings getDefaultSettings() {
|
||||
|
||||
Reference in New Issue
Block a user