Merge remote branch 'origin/master'

This commit is contained in:
irengrig
2011-12-01 15:17:10 +04:00
9 changed files with 125 additions and 58 deletions
@@ -67,13 +67,14 @@ public class IdeNotificationArea implements StatusBarWidget, StatusBarWidget.Ico
new Runnable() {
@Override
public void run() {
LogModel logModel = EventLog.getLogModel(getProject());
ToolWindow eventLog = EventLog.getEventLog(getProject());
final Project project = getProject();
LogModel logModel = EventLog.getLogModel(project);
ToolWindow eventLog = EventLog.getEventLog(project);
if (eventLog != null && eventLog.isVisible()) {
logModel.logShown();
}
updateStatus();
myLogAlarm.addRequest(this, 50);
updateStatus(logModel);
myLogAlarm.addRequest(this, 100);
}
}.run();
@@ -111,8 +112,8 @@ public class IdeNotificationArea implements StatusBarWidget, StatusBarWidget.Ico
return WIDGET_ID;
}
private void updateStatus() {
myCurrentIcon = getPendingNotificationsIcon(EMPTY_ICON, NotificationModel.getMaximumType(EventLog.getLogModel(getProject()).getNotifications()));
private void updateStatus(final LogModel model) {
myCurrentIcon = getPendingNotificationsIcon(EMPTY_ICON, NotificationModel.getMaximumType(model.getNotifications()));
myStatusBar.updateWidget(ID());
}
@@ -46,10 +46,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileFilter;
import com.intellij.util.Alarm;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.*;
import com.intellij.util.containers.HashMap;
import com.intellij.util.io.ZipUtil;
import com.intellij.util.ui.UIUtil;
@@ -120,13 +117,27 @@ public class PlatformTestUtil {
public static String print(JTree tree, boolean withSelection, Condition<String> nodePrintCondition) {
StringBuilder buffer = new StringBuilder();
Object root = tree.getModel().getRoot();
printImpl(tree, root, buffer, 0, withSelection, nodePrintCondition);
final Collection<String> strings = printAsList(tree, withSelection, nodePrintCondition);
for (String string : strings) {
buffer.append(string).append("\n");
}
return buffer.toString();
}
private static void printImpl(JTree tree, Object root, StringBuilder buffer, int level, boolean withSelection, @Nullable Condition<String> nodePrintCondition) {
public static Collection<String> printAsList(JTree tree, boolean withSelection, Condition<String> nodePrintCondition) {
Collection<String> strings = new ArrayList<String>();
Object root = tree.getModel().getRoot();
printImpl(tree, root, strings, 0, withSelection, nodePrintCondition);
return strings;
}
private static void printImpl(JTree tree,
Object root,
Collection<String> strings,
int level,
boolean withSelection,
@Nullable Condition<String> nodePrintCondition) {
DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)root;
@@ -143,34 +154,42 @@ public class PlatformTestUtil {
if (nodePrintCondition != null && !nodePrintCondition.value(nodeText)) return;
boolean expanded = tree.isExpanded(new TreePath(defaultMutableTreeNode.getPath()));
StringUtil.repeatSymbol(buffer, ' ', level);
if (expanded && !defaultMutableTreeNode.isLeaf()) {
buffer.append("-");
}
if (!expanded && !defaultMutableTreeNode.isLeaf()) {
buffer.append("+");
}
final boolean selected = tree.getSelectionModel().isPathSelected(new TreePath(defaultMutableTreeNode.getPath()));
if (withSelection && selected) {
buffer.append("[");
}
buffer.append(nodeText);
if (withSelection && selected) {
buffer.append("]");
}
buffer.append("\n");
int childCount = tree.getModel().getChildCount(root);
if (expanded) {
for (int i = 0; i < childCount; i++) {
printImpl(tree, tree.getModel().getChild(root, i), buffer, level + 1, withSelection, nodePrintCondition);
final StringBuilder buff = StringBuilderSpinAllocator.alloc();
try {
StringUtil.repeatSymbol(buff, ' ', level);
if (expanded && !defaultMutableTreeNode.isLeaf()) {
buff.append("-");
}
if (!expanded && !defaultMutableTreeNode.isLeaf()) {
buff.append("+");
}
final boolean selected = tree.getSelectionModel().isPathSelected(new TreePath(defaultMutableTreeNode.getPath()));
if (withSelection && selected) {
buff.append("[");
}
buff.append(nodeText);
if (withSelection && selected) {
buff.append("]");
}
//buff.append("\n");
strings.add(buff.toString());
int childCount = tree.getModel().getChildCount(root);
if (expanded) {
for (int i = 0; i < childCount; i++) {
printImpl(tree, tree.getModel().getChild(root, i), strings, level + 1, withSelection, nodePrintCondition);
}
}
} finally {
StringBuilderSpinAllocator.dispose(buff);
}
}
@@ -178,11 +197,21 @@ public class PlatformTestUtil {
assertTreeEqual(tree, expected, false);
}
public static void assertTreeEqualIgnoringNodesOrder(JTree tree, @NonNls String expected) {
assertTreeEqualIgnoringNodesOrder(tree, expected, false);
}
public static void assertTreeEqual(JTree tree, String expected, boolean checkSelected) {
String treeStringPresentation = print(tree, checkSelected);
Assert.assertEquals(expected, treeStringPresentation);
}
public static void assertTreeEqualIgnoringNodesOrder(JTree tree, String expected, boolean checkSelected) {
final Collection<String> actualNodesPresentation = printAsList(tree, checkSelected, null);
final List<String> expectedNodes = StringUtil.split(expected, "\n");
UsefulTestCase.assertSameElements(actualNodesPresentation, expectedNodes);
}
@TestOnly
public static void waitForAlarm(final int delay) throws InterruptedException {
assert !ApplicationManager.getApplication().isWriteAccessAllowed(): "It's a bad idea to wait for an alarm under the write action. Somebody creates an alarm which requires read action and you are deadlocked.";
+5 -3
View File
@@ -1005,8 +1005,10 @@
<action id="ConvertGroovyToJava"
class="org.jetbrains.plugins.groovy.actions.ConvertToJavaAction"
text="Convert to Java"
description="Convert Groovy files to Java">
<add-to-group group-id="RefactoringMenu" anchor="after" relative-to-action="ExtractMethod"/>
description="Convert Groovy files to Java"
internal = "true">
<add-to-group group-id="Internal" anchor="after" relative-to-action="GetPsiTypeAction"/>
</action>
<action id="GetPsiTypeAction" class="org.jetbrains.plugins.groovy.actions.GrGetPsiTypeAction" text="get PsiType" description="" internal = "true">
@@ -1014,7 +1016,7 @@
</action>
<action id="DumpGroovyControlFlowAction" class="org.jetbrains.plugins.groovy.actions.DumpGroovyControlFlowAction" text="dump groovy control flow" description="" internal="true">
<add-to-group group-id="Internal" anchor="last"/>
<add-to-group group-id="Internal" anchor="after" relative-to-action="ConvertGroovyToJava"/>
</action>
<action id="RenameJavaFileToGroovyFileAction"
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementVisitor;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
@@ -66,7 +67,13 @@ public class GroovyExpectedTypesProvider {
expression.putUserData(CACHED_EXPECTED_TYPES, cached = CachedValuesManager.getManager(expression.getProject()).createCachedValue(new CachedValueProvider<TypeConstraint[]>() {
public Result<TypeConstraint[]> compute() {
MyCalculator calculator = new MyCalculator(expression);
((GroovyPsiElement)expression.getParent()).accept(calculator);
final PsiElement parent = expression.getParent();
if (parent instanceof GroovyPsiElement) {
((GroovyPsiElement)parent).accept(calculator);
}
else {
parent.accept(new GroovyPsiElementVisitor(calculator));
}
final TypeConstraint[] result = calculator.getResult();
List<TypeConstraint> custom = new ArrayList<TypeConstraint>();
@@ -248,7 +255,7 @@ public class GroovyExpectedTypesProvider {
final IElementType type = expression.getOperationTokenType();
final GrExpression left = expression.getLeftOperand();
final GrExpression right = expression.getRightOperand();
if (type == mREGEX_FIND || type == mREGEX_MATCH) {
final PsiClassType string = TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, expression);
@@ -260,7 +267,7 @@ public class GroovyExpectedTypesProvider {
final PsiType otherType = other != null ? other.getType() : null;
if (otherType == null) return;
if (type== mPLUS && otherType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
final PsiClassType obj = TypesUtil.getJavaLangObject(expression);
myResult = new TypeConstraint[]{new SubtypeConstraint(obj, obj)};
@@ -347,7 +354,13 @@ public class GroovyExpectedTypesProvider {
@Override
public void visitParenthesizedExpression(GrParenthesizedExpression expression) {
((GroovyPsiElement)expression.getParent()).accept(this);
final PsiElement parent = expression.getParent();
if (parent instanceof GroovyPsiElement) {
((GroovyPsiElement)parent).accept(this);
}
else {
parent.accept(new GroovyPsiElementVisitor(this));
}
}
@Override
@@ -100,7 +100,7 @@ public class MethodResolverProcessor extends ResolverProcessor {
boolean isAccessible = isAccessible(method);
GroovyPsiElement resolveContext = state.get(RESOLVE_CONTEXT);
boolean isStaticsOK = isStaticsOK(method, resolveContext, true);
if (!myAllVariants && isStaticsOK &&
if (!myAllVariants && isStaticsOK && isAccessible &&
PsiUtil.isApplicable(myArgumentTypes, method, substitutor, (GroovyPsiElement)myPlace, myByShape)) {
addCandidate(new GroovyResolveResultImpl(method, resolveContext, substitutor, isAccessible, isStaticsOK));
} else {
@@ -23,19 +23,19 @@ import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.ClasspathEditor;
import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
import com.intellij.openapi.roots.ui.configuration.ClasspathEditor;
import com.intellij.openapi.project.Project;
import com.intellij.util.ObjectUtils;
import org.jetbrains.plugins.groovy.util.LibrariesUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.util.LibrariesUtil;
import java.nio.charset.Charset;
@@ -77,7 +77,7 @@ public class DefaultGroovyScriptRunner extends GroovyScriptRunner {
}
params.getProgramParametersList().add(FileUtil.toSystemDependentName(configuration.getScriptPath()));
params.getProgramParametersList().addParametersString(configuration.getProgramParameters());
params.getProgramParametersList().addParametersString(configuration.getScriptParameters());
}
public static void configureGenericGroovyRunner(JavaParameters params, Module module, String mainClass) {
@@ -27,8 +27,8 @@ import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.roots.ui.configuration.ModulesAlphaComparator;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ComboboxSpeedSearch;
import com.intellij.ui.PanelWithAnchor;
import com.intellij.ui.FieldPanel;
import com.intellij.ui.PanelWithAnchor;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.ui.components.JBLabel;
import org.jetbrains.annotations.NotNull;
@@ -36,7 +36,8 @@ import org.jetbrains.plugins.groovy.GroovyFileType;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class GroovyRunConfigurationEditor extends SettingsEditor<GroovyScriptRunConfiguration> implements PanelWithAnchor {
@@ -86,7 +87,7 @@ public class GroovyRunConfigurationEditor extends SettingsEditor<GroovyScriptRun
myVMParameters.setText(configuration.getVMParameters());
myParameters.setDialogCaption("Script Parameters");
myParameters.setText(configuration.getProgramParameters());
myParameters.setText(configuration.getScriptParameters());
scriptPathField.setText(configuration.getScriptPath());
workDirField.setText(configuration.getWorkDir());
@@ -109,7 +110,7 @@ public class GroovyRunConfigurationEditor extends SettingsEditor<GroovyScriptRun
configuration.setModule((Module) myModulesBox.getSelectedItem());
configuration.setVMParameters(myVMParameters.getText());
configuration.setDebugEnabled(myDebugCB.isSelected());
configuration.setProgramParameters(myParameters.getText());
configuration.setScriptParameters(myParameters.getText());
configuration.setScriptPath(scriptPathField.getText());
configuration.setWorkDir(workDirField.getText());
configuration.setEnvs(myEnvVariables.getEnvs());
@@ -24,6 +24,7 @@ import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.util.ProgramParametersUtil;
import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.SettingsEditor;
@@ -64,6 +65,8 @@ import java.util.Map;
*/
public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration<RunConfigurationModule>
implements CommonJavaRunConfigurationParameters {
private static final Logger LOG = Logger.getInstance(GroovyScriptRunConfiguration.class);
private String vmParams;
private String workDir;
private boolean isDebugEnabled;
@@ -191,6 +194,10 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration<RunCo
}
public void setScriptParameters(String scriptParameters) {
scriptParams = scriptParameters;
}
public static JavaParameters createJavaParametersWithSdk(Module module) {
JavaParameters params = new JavaParameters();
params.setCharset(null);
@@ -292,11 +299,16 @@ public class GroovyScriptRunConfiguration extends ModuleBasedConfiguration<RunCo
@Override
public void setProgramParameters(@Nullable String value) {
scriptParams = value;
LOG.assertTrue(false, "Don't add program parameters to Groovy script run configuration. Use Script parameters instead");
}
@Override
public String getProgramParameters() {
return null;
}
@Nullable
public String getScriptParameters() {
return scriptParams;
}
@@ -815,4 +815,13 @@ def test() {
""")
assertNotNull(ref.resolve())
}
public void testPublicVsPrivateConstructor() {
def resolved = (configureByText('throw new Assertion<caret>Error("foo")').element.parent as GrNewExpression).resolveMethod()
assertNotNull resolved
PsiParameter[] parameters = resolved.parameterList.parameters
assertTrue parameters.length == 1
assertEquals "java.lang.Object", parameters[0].type.canonicalText
}
}