Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
nik
2009-11-24 09:32:16 +03:00
93 changed files with 1431 additions and 526 deletions
@@ -33,11 +33,12 @@ import com.intellij.execution.configurations.RemoteState;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentListener;
import com.intellij.execution.ui.RunContentManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.EditorColorsListener;
@@ -45,7 +46,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.Disposable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -121,7 +121,7 @@ public class DebuggerPanelsManager implements ProjectComponent {
debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);
}
final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, debuggerSession.getSessionName());
final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, debuggerSession.getSessionName(), environment.getRunProfile().getIcon());
Disposer.register(myProject, sessionTab);
RunContentDescriptor runContentDescriptor =
sessionTab.attachToSession(debuggerSession, runner, environment);
@@ -99,10 +99,12 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements
public static final String BREAKPOINT_CONDITION = "breakpoint";
private final ThreadsPanel myThreadsPanel;
private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump";
private Icon myIcon;
public DebuggerSessionTab(Project project, String sessionName) {
public DebuggerSessionTab(final Project project, final String sessionName, @Nullable final Icon icon) {
super(project);
myIcon = icon;
myUi = RunnerLayoutUi.Factory.getInstance(project).create("JavaDebugger", DebuggerBundle.message("title.generic.debug.dialog"), sessionName, this);
@@ -253,7 +255,7 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements
private RunContentDescriptor initUI(ExecutionResult executionResult) {
myConsole = executionResult.getExecutionConsole();
myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName());
myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(), myIcon);
if (ApplicationManager.getApplication().isUnitTestMode()) {
return myRunContentDescriptor;
@@ -34,6 +34,8 @@ import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author spleaner
*/
@@ -41,14 +43,14 @@ public class JavaExecutionUtil {
private JavaExecutionUtil() {
}
public static boolean executeRun(@NotNull final Project project, String contentName,
public static boolean executeRun(@NotNull final Project project, String contentName, Icon icon,
final DataContext dataContext) throws ExecutionException {
return executeRun(project, contentName, dataContext, null);
return executeRun(project, contentName, icon, dataContext, null);
}
public static boolean executeRun(@NotNull final Project project, String contentName, DataContext dataContext, Filter[] filters) throws ExecutionException {
public static boolean executeRun(@NotNull final Project project, String contentName, Icon icon, DataContext dataContext, Filter[] filters) throws ExecutionException {
final JavaParameters cmdLine = JavaParameters.JAVA_PARAMETERS.getData(dataContext);
final DefaultRunProfile profile = new DefaultRunProfile(project, cmdLine, contentName, filters);
final DefaultRunProfile profile = new DefaultRunProfile(project, cmdLine, contentName, icon, filters);
final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID, profile);
if (runner != null) {
runner.execute(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironment(profile, dataContext));
@@ -63,12 +65,18 @@ public class JavaExecutionUtil {
private final String myContentName;
private final Filter[] myFilters;
private final Project myProject;
private Icon myIcon;
public DefaultRunProfile(final Project project, final JavaParameters parameters, String contentName, Filter[] filters) {
public DefaultRunProfile(final Project project, final JavaParameters parameters, final String contentName, final Icon icon, Filter[] filters) {
myProject = project;
myParameters = parameters;
myContentName = contentName;
myFilters = filters;
myIcon = icon;
}
public Icon getIcon() {
return myIcon;
}
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
@@ -37,14 +37,14 @@ public class ExtendsListFix implements IntentionAction, LocalQuickFix {
private final boolean myToAdd;
private final PsiClassType myTypeToExtendFrom;
public ExtendsListFix(PsiClass aClass, PsiClassType typeToExtendFrom, boolean toAdd) {
public ExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd) {
myClass = aClass;
myClassToExtendFrom = typeToExtendFrom.resolve();
myTypeToExtendFrom = typeToExtendFrom;
myToAdd = toAdd;
}
public ExtendsListFix(PsiClass aClass, PsiClass classToExtendFrom, boolean toAdd) {
public ExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClass classToExtendFrom, boolean toAdd) {
myClass = aClass;
myClassToExtendFrom = classToExtendFrom;
myTypeToExtendFrom = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(classToExtendFrom);
@@ -126,7 +126,7 @@ public class ExtendsListFix implements IntentionAction, LocalQuickFix {
PsiJavaCodeReferenceElement[] referenceElements = extendsList.getReferenceElements();
boolean alreadyExtends = false;
for (PsiJavaCodeReferenceElement referenceElement : referenceElements) {
if (referenceElement.resolve() == myClassToExtendFrom) {
if (referenceElement.getManager().areElementsEquivalent(myClassToExtendFrom, referenceElement.resolve())) {
alreadyExtends = true;
if (!add) {
referenceElement.delete();
@@ -15,12 +15,13 @@
*/
package com.intellij.ide.fileTemplates;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
import com.intellij.util.IncorrectOperationException;
import java.util.Properties;
@@ -56,6 +57,18 @@ public class JavaCreateFromTemplateHandler implements CreateFromTemplateHandler
else{
JavaDirectoryService.getInstance().checkCreateClass(directory, className);
}
final LanguageLevel ll = JavaDirectoryService.getInstance().getLanguageLevel(directory);
if (ll.compareTo(LanguageLevel.JDK_1_5) < 0) {
if (createdClass.isAnnotationType()) {
throw new IncorrectOperationException("Annotations only supported at language level 1.5 and higher");
}
if (createdClass.isEnum()) {
throw new IncorrectOperationException("Enums only supported at language level 1.5 and higher");
}
}
psiJavaFile = (PsiJavaFile)psiJavaFile.setName(fileName);
PsiElement addedElement = directory.add(psiJavaFile);
if (addedElement instanceof PsiJavaFile) {
@@ -49,6 +49,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@@ -117,6 +118,10 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl
return new JavadocConfigurable(this);
}
public Icon getIcon() {
return null;
}
@NotNull
public Module[] getModules() {
return Module.EMPTY_ARRAY;
@@ -22,6 +22,7 @@ package com.intellij.refactoring.move.moveClassesOrPackages;
import com.intellij.codeInsight.ChangeContextUtil;
import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler;
@@ -35,6 +36,7 @@ import java.util.List;
import java.util.Map;
public class MoveJavaFileHandler extends MoveFileHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.move.moveClassesOrPackages.MoveJavaFileHandler");
@Override
public boolean canProcessElement(PsiFile element) {
return element instanceof PsiJavaFile && !JspPsiUtil.isInJspFile(element) && !CollectHighlightsUtil.isOutsideSourceRootJavaFile(element);
@@ -69,7 +71,11 @@ public class MoveJavaFileHandler extends MoveFileHandler {
final PsiElement newElement = oldToNewMap.get(oldElement);
final PsiReference reference = moveRenameUsage.getReference();
if (reference != null) {
reference.bindToElement(newElement);
try {
reference.bindToElement(newElement);
} catch (IncorrectOperationException ex) {
LOG.error(ex);
}
}
}
}
@@ -28,15 +28,13 @@ import java.util.regex.Pattern;
* @author Konstantin Bulenkov
*/
public class UnscrambleListener extends ApplicationAdapter {
private static final int MAX_STACKTRACE_SIZE = 15*1024; //15Kb
private static final int MAX_STACKTRACE_SIZE = 15 * 1024; //15Kb
private String stacktrace = null;
@Override
public void applicationActivated(IdeFrame ideFrame) {
final String clipboard = getClipboardContents();
if (clipboard != null
&& clipboard.length() < MAX_STACKTRACE_SIZE
&& !clipboard.equals(stacktrace)) {
if (clipboard != null && clipboard.length() < MAX_STACKTRACE_SIZE && !clipboard.equals(stacktrace)) {
stacktrace = clipboard;
if (isStacktrace(stacktrace)) {
new UnscrambleDialog(ideFrame.getProject()).doOKAction();
@@ -51,20 +49,22 @@ public class UnscrambleListener extends ApplicationAdapter {
public static String getClipboardContents() {
String result = "";
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
final Transferable contents = clipboard.getContents(null);
final boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
if (hasTransferableText) {
try {
try {
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
final Transferable contents = clipboard.getContents(null);
final boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
if (hasTransferableText) {
result = (String)contents.getTransferData(DataFlavor.stringFlavor);
}
catch (Exception ex){//
}
}
catch (Exception e) {//
}
return result;
}
private static final Pattern STACKTRACE_LINE = Pattern.compile("[\t]*at [[a-zA-Z0-9]+\\.]+[a-zA-Z$0-9]+\\.[a-zA-Z0-9_]+\\([A-Za-z0-9_]+\\.java:[\\d]+\\)");
private static final Pattern STACKTRACE_LINE =
Pattern.compile("[\t]*at [[a-zA-Z0-9]+\\.]+[a-zA-Z$0-9]+\\.[a-zA-Z0-9_]+\\([A-Za-z0-9_]+\\.java:[\\d]+\\)");
public static boolean isStacktrace(String stacktrace) {
int linesCount = 0;
for (String line : stacktrace.split("\n")) {
@@ -74,7 +74,8 @@ public class UnscrambleListener extends ApplicationAdapter {
}
if (STACKTRACE_LINE.matcher(line).matches()) {
linesCount++;
} else {
}
else {
linesCount = 0;
}
if (linesCount > 2) return true;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@@ -42,11 +43,13 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
private ArrayList<PredefinedLogFile> myPredefinedLogFiles = new ArrayList<PredefinedLogFile>();
@NonNls private static final String LOG_FILE = "log_file";
@NonNls private static final String PREDEFINED_LOG_FILE_ELEMENT = "predefined_log_file";
private Icon myIcon;
protected RunConfigurationBase(Project project, ConfigurationFactory factory, String name) {
protected RunConfigurationBase(final Project project, final ConfigurationFactory factory, final String name) {
myProject = project;
myFactory = factory;
myName = name;
myIcon = factory.getIcon();
}
public int getUniqueID() {
@@ -70,6 +73,10 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements
return myFactory.getType();
}
public Icon getIcon() {
return myIcon;
}
public final String getName() {
return myName;
}
@@ -21,6 +21,8 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public interface RunProfile {
/**
* todo - javadoc
@@ -30,6 +32,9 @@ public interface RunProfile {
String getName();
@Nullable
Icon getIcon();
void checkConfiguration() throws RuntimeConfigurationException;
}
@@ -24,6 +24,8 @@ import com.intellij.openapi.util.JDOMExternalizable;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public abstract class RuntimeConfiguration extends RunConfigurationBase implements LocatableConfiguration, Cloneable, ModuleRunConfiguration {
protected RuntimeConfiguration(final String name, final Project project, final ConfigurationFactory factory) {
super(project, factory, name);
@@ -29,6 +29,7 @@ import com.intellij.openapi.util.WriteExternalException;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.List;
@@ -55,6 +56,11 @@ public class UnknownRunConfiguration implements RunConfiguration {
myDoNotStore = b;
}
@Nullable
public Icon getIcon() {
return null;
}
public boolean isDoNotStore() {
return myDoNotStore;
}
@@ -34,18 +34,21 @@ public class RunContentDescriptor {
private final ProcessHandler myProcessHandler;
private final JComponent myComponent;
private final String myDisplayName;
private final Icon myIcon;
/**
* Used to hack {@link com.intellij.execution.runners.RestartAction}
*/
private Content myContent;
public RunContentDescriptor(final ExecutionConsole executionConsole,
final ProcessHandler processHandler, final JComponent component, final String displayName) {
final ProcessHandler processHandler, final JComponent component, final String displayName, final Icon icon) {
LOG.assertTrue(executionConsole != null || ApplicationManager.getApplication().isUnitTestMode());
myExecutionConsole = executionConsole;
myProcessHandler = processHandler;
myComponent = component;
myDisplayName = displayName;
myIcon = icon;
myComponent.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, new DataProvider() {
public Object getData(@NonNls final String dataId) {
@@ -55,7 +58,11 @@ public class RunContentDescriptor {
return null;
}
});
}
public RunContentDescriptor(final ExecutionConsole executionConsole,
final ProcessHandler processHandler, final JComponent component, final String displayName) {
this(executionConsole, processHandler, component, displayName, null);
}
public ExecutionConsole getExecutionConsole() {
@@ -66,6 +73,11 @@ public class RunContentDescriptor {
Disposer.dispose(myExecutionConsole);
}
@Nullable
public Icon getIcon() {
return myIcon;
}
@Nullable
public ProcessHandler getProcessHandler() {
return myProcessHandler;
@@ -65,6 +65,24 @@ public class VirtualFilePattern extends TreeElementPattern<VirtualFile, VirtualF
}
});
}
public VirtualFilePattern xmlWithRootTagNamespace(final String... namespace) {
StringPattern namespacePattern = StandardPatterns.string().oneOf(namespace);
return xmlWithRootTagNamespace(namespacePattern);
}
public VirtualFilePattern xmlWithRootTagNamespace(final ElementPattern<String> namespacePattern) {
return with(new PatternCondition<VirtualFile>("xmlWithRootTagNamespace") {
public boolean accepts(@NotNull final VirtualFile virtualFile, final ProcessingContext context) {
try {
String rootTagNamespace = NanoXmlUtil.parseHeaderWithException(virtualFile).getRootTagNamespace();
return rootTagNamespace != null && namespacePattern.getCondition().accepts(rootTagNamespace, context);
}
catch (IOException e) {
return false;
}
}
});
}
protected VirtualFile getParent(@NotNull final VirtualFile t) {
return t.getParent();
@@ -43,6 +43,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -66,7 +68,17 @@ public class ChooseRunConfigurationAction extends AnAction {
final Executor executor = getDefaultExecutor();
assert executor != null;
final RunListPopup popup = new RunListPopup(project, new ConfigurationListPopupStep(this, project, String.format("%s", executor.getActionName())));
final RunListPopup popup = new RunListPopup(project, new ConfigurationListPopupStep(this, project, String.format("%s", executor.getActionName()))) {
@Override
protected void handleShiftClick(final boolean handleFinalChoices, final InputEvent inputEvent, final RunListPopup popup) {
try {
myCurrentExecutor = getAlternateExecutor();
popup._handleSelect(handleFinalChoices, inputEvent);
} finally {
myCurrentExecutor = null;
}
}
};
registerActions(popup);
final String adText = getAdText(getAlternateExecutor());
@@ -792,7 +804,7 @@ public class ChooseRunConfigurationAction extends AnAction {
}
}
private static class RunListPopup extends ListPopupImpl {
private static abstract class RunListPopup extends ListPopupImpl {
private Project myProject_;
public RunListPopup(final Project project, ListPopupStep step) {
@@ -800,6 +812,28 @@ public class ChooseRunConfigurationAction extends AnAction {
myProject_ = project;
}
@Override
public void handleSelect(boolean handleFinalChoices, InputEvent e) {
if (e instanceof MouseEvent && e.isShiftDown()) {
handleShiftClick(handleFinalChoices, e, this);
return;
}
_handleSelect(handleFinalChoices, e);
}
protected void _handleSelect(boolean handleFinalChoices, InputEvent e) {
super.handleSelect(handleFinalChoices, e);
}
protected abstract void handleShiftClick(boolean handleFinalChoices, final InputEvent inputEvent, final RunListPopup popup);
@Override
protected boolean isActionClick(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2 || e.isPopupTrigger() || e.getID() != MouseEvent.MOUSE_PRESSED) return false;
return e.getButton() == MouseEvent.BUTTON1;
}
@Override
protected ListCellRenderer getListElementRenderer() {
return new RunListElementRenderer(this);
@@ -276,7 +276,7 @@ public class RunContentBuilder implements LogConsoleManager, Disposable {
private final Disposable[] myAdditionalDisposables;
public MyRunContentDescriptor(final RunProfile profile, final ExecutionResult executionResult, final boolean reuseProhibited, final JComponent component, final Disposable... additionalDisposables) {
super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName());
super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName(), profile.getIcon());
myReuseProhibited = reuseProhibited;
myAdditionalDisposables = additionalDisposables;
}
@@ -15,10 +15,7 @@
*/
package com.intellij.execution.ui;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.Executor;
import com.intellij.execution.ExecutorRegistry;
import com.intellij.execution.TerminateRemoteProcessDialog;
import com.intellij.execution.*;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
@@ -39,6 +36,7 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowAnchor;
@@ -47,6 +45,7 @@ import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.ui.content.*;
import com.intellij.util.EventDispatcher;
import com.intellij.util.IconUtil;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
@@ -249,7 +248,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) {
if(ApplicationManager.getApplication().isUnitTestMode()) return;
final ContentManager contentManager = getContentManagerForRunner(executor);
final ContentManager contentManager = getContentManagerForRunner(executor);
RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor);
final Content content;
@@ -261,7 +260,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
else {
content = createNewContent(contentManager, descriptor, executor.getToolWindowId());
content.setIcon(executor.getToolWindowIcon());
final Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getToolWindowIcon() : icon);
}
content.setComponent(descriptor.getComponent());
@@ -272,7 +272,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
public void startNotified(final ProcessEvent event) {
LaterInvocator.invokeLater(new Runnable() {
public void run() {
content.setIcon(executor.getToolWindowIcon());
final Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getToolWindowIcon() : icon);
}
});
}
@@ -280,7 +281,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
public void processTerminated(final ProcessEvent event) {
LaterInvocator.invokeLater(new Runnable() {
public void run() {
content.setIcon(executor.getDisabledIcon());
final Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getDisabledIcon() : IconLoader.getTransparentIcon(icon));
}
});
}
@@ -62,6 +62,7 @@ import com.intellij.util.Icons;
import com.intellij.util.Processor;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.Table;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -334,12 +335,7 @@ public class ShowUsagesAction extends AnAction {
addUsageNodes(usageView.getRoot(), usageView, new ArrayList<UsageNode>());
final JTable table = new Table(){
@Override
public boolean getScrollableTracksViewportWidth() {
return true;
}
};
final JTable table = new MyTable();
TableScrollingUtil.installActions(table);
final Vector<Object> data = new Vector<Object>();
setModel(table, usages, visibleNodes, usageView, data);
@@ -411,6 +407,8 @@ public class ShowUsagesAction extends AnAction {
}
};
KeyboardShortcut shortcut = getSettingsShortcut();
if (shortcut != null) {
builder.registerKeyboardAction(shortcut.getFirstKeyStroke(), editSettings);
@@ -635,4 +633,30 @@ public class ShowUsagesAction extends AnAction {
});
}
}
static class MyTable extends Table implements DataProvider {
@Override
public boolean getScrollableTracksViewportWidth() {
return true;
}
public Object getData(@NonNls String dataId) {
if (LangDataKeys.PSI_ELEMENT.getName().equals(dataId)) {
final int[] selected = getSelectedRows();
if (selected.length == 1) {
final Object at = getValueAt(selected[0], 0);
if (at instanceof UsageNode) {
final Usage usage = ((UsageNode)at).getUsage();
if (usage instanceof UsageInfo2UsageAdapter) {
final PsiElement element = ((UsageInfo2UsageAdapter)usage).getElement();
if (element != null) {
return element.getContainingFile();
}
}
}
}
}
return null;
}
}
}
@@ -16,15 +16,16 @@
package com.intellij.openapi.roots.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.OrderedSet;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.util.*;
import java.util.Collections;
import java.util.List;
public class DirectoryInfo {
public Module module; // module to which content it belongs or null
@@ -36,11 +37,15 @@ public class DirectoryInfo {
public VirtualFile sourceRoot;
/**
* orderEntry to (classes of) which a directory belongs
* orderEntry to (classes of) which a directory belongs
*/
private List<OrderEntry> orderEntries = null;
@TestOnly
@SuppressWarnings({"unchecked"})
public boolean equals(Object o) {
assert ApplicationManager.getApplication().isUnitTestMode() : "DirectoryInfo.equals should only be used in tests";
if (this == o) return true;
if (!(o instanceof DirectoryInfo)) return false;
@@ -50,7 +55,7 @@ public class DirectoryInfo {
if (isInModuleSource != info.isInModuleSource) return false;
if (isTestSource != info.isTestSource) return false;
if (module != null ? !module.equals(info.module) : info.module != null) return false;
if (orderEntries != null ? !orderEntries.equals(info.orderEntries) : info.orderEntries != null) return false;
if (orderEntries != null ? !new HashSet(orderEntries).equals(new HashSet(info.orderEntries)) : info.orderEntries != null) return false;
if (!Comparing.equal(libraryClassRoot, info.libraryClassRoot)) return false;
if (!Comparing.equal(contentRoot, info.contentRoot)) return false;
if (!Comparing.equal(sourceRoot, info.sourceRoot)) return false;
@@ -80,20 +85,23 @@ public class DirectoryInfo {
}
@SuppressWarnings({"unchecked"})
public void addOrderEntries(final List<OrderEntry> orderEntries,
final DirectoryInfo parentInfo,
final List<OrderEntry> oldParentEntries) {
if (this.orderEntries == null) {
public void addOrderEntries(List<OrderEntry> orderEntries,
@Nullable final DirectoryInfo parentInfo,
@Nullable final List<OrderEntry> oldParentEntries) {
if (orderEntries.isEmpty()) {
this.orderEntries = null;
}
else if (this.orderEntries == null) {
this.orderEntries = orderEntries;
}
else if (parentInfo != null && oldParentEntries == this.orderEntries) {
this.orderEntries = parentInfo.getOrderEntries();
this.orderEntries = parentInfo.orderEntries;
}
else {
List<OrderEntry> tmp = new OrderedSet<OrderEntry>(TObjectHashingStrategy.CANONICAL);
LinkedHashSet tmp = new LinkedHashSet(this.orderEntries.size() + orderEntries.size());
tmp.addAll(this.orderEntries);
tmp.addAll(orderEntries);
this.orderEntries = tmp;
this.orderEntries = new ArrayList<OrderEntry>(tmp);
}
}
}
@@ -151,9 +151,9 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
final VcsRoot[] vcsRoots = plVcsManager.getAllVcsRoots();
for (VcsRoot root : vcsRoots) {
if (! root.path.equals(baseDir)) {
//if (! root.path.equals(baseDir)) {
builder.addDirtyDirRecursively(root);
}
//}
}
}
}
@@ -35,6 +35,8 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Mar 30, 2005
@@ -57,6 +59,10 @@ public class ToolRunProfile implements ModuleRunProfile{
return myTool.getName();
}
public Icon getIcon() {
return null;
}
public void checkConfiguration() throws RuntimeConfigurationException {
}
@@ -229,7 +229,7 @@ public class AbstractTreeUi {
private void initClearanceServiceIfNeeded() {
if (ourClearanceService != null) return;
ourClearanceService = ConcurrencyUtil.newSingleScheduledThreadExecutor("AbstractTreeBuilder's janitor");
ourClearanceService = ConcurrencyUtil.newSingleScheduledThreadExecutor("AbstractTreeBuilder's janitor", Thread.MIN_PRIORITY + 1);
ourClearanceService.scheduleWithFixedDelay(new Runnable() {
public void run() {
cleanUpAll();
@@ -16,13 +16,11 @@
package com.intellij.openapi.project;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.ui.popup.BalloonHandler;
import com.intellij.openapi.util.NotNullLazyKey;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -57,22 +55,7 @@ public abstract class DumbService {
*/
public abstract void runWhenSmart(Runnable runnable);
public void waitForSmartMode() {
final Application application = ApplicationManager.getApplication();
if (!application.isUnitTestMode()) {
assert !application.isDispatchThread();
assert !application.isReadAccessAllowed();
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
runWhenSmart(new Runnable() {
public void run() {
semaphore.up();
}
});
semaphore.waitFor();
}
public abstract void waitForSmartMode();
/**
* Invoke the runnable later on EventDispatchThread AND when IDEA isn't in dumb mode
@@ -21,7 +21,7 @@ import java.util.*;
* Simple timer that keeps order of scheduled tasks
*/
public class SimpleTimer {
private final Timer ourTimer = new Timer(THREAD_NAME, true);
private final Timer ourTimer;
private static final SimpleTimer ourInstance = new SimpleTimer();
private static final String THREAD_NAME = "SimpleTimer";
@@ -32,6 +32,16 @@ public class SimpleTimer {
private final Map<Long, ArrayList<SimpleTimerTask>> myTime2Task = new TreeMap<Long, ArrayList<SimpleTimerTask>>();
private SimpleTimer() {
final Thread thread = Thread.currentThread();
final int currentPrio = thread.getPriority();
try {
// need this becase the timer's thread will inherit the priority on creation
thread.setPriority(Thread.MIN_PRIORITY + 1);
ourTimer = new Timer(THREAD_NAME, true);
}
finally {
thread.setPriority(currentPrio);
}
}
public static SimpleTimer getInstance() {
@@ -47,7 +57,7 @@ public class SimpleTimer {
ArrayList<SimpleTimerTask> tasks = myTime2Task.get(targetTime);
if (tasks == null) {
tasks = new ArrayList<SimpleTimerTask>(2);
tasks = new ArrayList<SimpleTimerTask>(2);
myTime2Task.put(targetTime, tasks);
}
tasks.add(result);
@@ -45,7 +45,7 @@ public class Alarm implements Disposable {
private final ThreadPoolExecutor myExecutorService;
private static final ThreadPoolExecutor ourSharedExecutorService = ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(shared)");
private static final ThreadPoolExecutor ourSharedExecutorService = ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(shared)", Thread.NORM_PRIORITY - 2);
private final Object LOCK = new Object();
private final ThreadToUse myThreadToUse;
@@ -84,7 +84,7 @@ public class Alarm implements Disposable {
}
public Alarm(@NotNull ThreadToUse threadToUse, Disposable parentDisposable) {
myThreadToUse = threadToUse;
myExecutorService = threadToUse == ThreadToUse.OWN_THREAD ? ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(own)") : ourSharedExecutorService;
myExecutorService = threadToUse == ThreadToUse.OWN_THREAD ? ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(own)", Thread.NORM_PRIORITY - 2) : ourSharedExecutorService;
if (parentDisposable != null) {
Disposer.register(parentDisposable, this);
@@ -23,7 +23,10 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.impl.ApplicationImpl;
import org.jetbrains.annotations.NonNls;
import java.util.concurrent.*;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -34,7 +37,9 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable {
private static final ThreadFactory WORKERS_FACTORY = new ThreadFactory() {
int i;
public Thread newThread(final Runnable r) {
return new Thread(r, "JobScheduler pool "+i+++"/"+CORES_COUNT);
final Thread thread = new Thread(r, "JobScheduler pool " + i++ + "/" + CORES_COUNT);
thread.setPriority(Thread.NORM_PRIORITY);
return thread;
}
};
@@ -106,6 +106,7 @@ public class PerformanceWatcher implements ApplicationComponent {
checkEDTResponsiveness();
}
}, "Performance watcher");
myThread.setPriority(Thread.MIN_PRIORITY);
myThread.start();
}
@@ -15,9 +15,9 @@
*/
package com.intellij.ide;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.application.ApplicationManager;
import org.apache.xmlrpc.IdeaAwareWebServer;
import org.apache.xmlrpc.IdeaAwareXmlRpcServer;
import org.apache.xmlrpc.WebServer;
@@ -46,8 +46,10 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
public void initComponent() {
if (ApplicationManager.getApplication().isUnitTestMode() || !checkPort()) return;
final Thread thread = Thread.currentThread();
final int currentPrio = thread.getPriority();
try {
thread.setPriority(Thread.NORM_PRIORITY - 2);
myWebServer = new IdeaAwareWebServer(getPortNumber(), null, new IdeaAwareXmlRpcServer());
myWebServer.start();
}
@@ -55,6 +57,9 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
LOG.error(e);
myWebServer = null;
}
finally {
thread.setPriority(currentPrio);
}
}
public int getPortNumber() {
@@ -162,7 +162,9 @@ public class SocketLock {
}
}
new Thread(new MyRunnable(), LOCK_THREAD_NAME).start();
final Thread thread = new Thread(new MyRunnable(), LOCK_THREAD_NAME);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
@@ -25,7 +25,6 @@ import com.intellij.ide.IdeRepaintManager;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.*;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
@@ -112,8 +111,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
new SynchronousQueue<Runnable>(),
new ThreadFactory() {
public Thread newThread(Runnable r) {
return new Thread(r, "ApplicationImpl pooled thread")
{
final Thread thread = new Thread(r, "ApplicationImpl pooled thread") {
public void interrupt() {
if (LOG.isDebugEnabled()) {
LOG.debug("Interrupted worker, will remove from pool");
@@ -124,13 +122,16 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
public void run() {
try {
super.run();
} catch(Throwable t) {
}
catch (Throwable t) {
if (LOG.isDebugEnabled()) {
LOG.debug("Worker exits due to exception", t);
}
}
}
};
thread.setPriority(Thread.NORM_PRIORITY - 1);
return thread;
}
}
);
@@ -515,8 +515,11 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
if (rangeMarker != null && rangeMarker.isValid()) {
if (event.getOffset() <= rangeMarker.getEndOffset()) {
rangeMarker.documentChanged(event);
if (!rangeMarker.isValid() && myGuardedBlocks.remove(rangeMarker)) {
LOG.error("Guarded blocks should stay valid: "+rangeMarker);
if (!rangeMarker.isValid()) {
rangeMarkerIterator.remove();
if (myGuardedBlocks.remove(rangeMarker)) {
LOG.error("Guarded blocks should stay valid: "+rangeMarker);
}
}
}
}
@@ -52,6 +52,14 @@ public abstract class HighlighterList {
super.sort(delegate);
}
}
@Override
public boolean remove(Object o) {
if (o instanceof RangeHighlighterImpl) {
if (!((RangeHighlighterImpl)o).isValid()) return false;
}
return super.remove(o);
}
};
private boolean myIsDirtied = false;
@@ -26,6 +26,7 @@ public class DefaultBundledKeymaps implements BundledKeymapProvider {
public List<String> getKeymapFileNames() {
return Arrays.asList(
"Keymap_Default.xml",
"Keymap_Mac.xml",
"Keymap_MacClassic.xml",
"Keymap_Emacs.xml",
"Keymap_VisualStudio.xml",
@@ -66,7 +66,7 @@ public class DefaultKeymap {
for (Element child : (List<Element>)element.getChildren()) {
if (KEY_MAP.equals(child.getName())) {
String keymapName = child.getAttributeValue(NAME_ATTRIBUTE);
DefaultKeymapImpl keymap = KeymapManager.MAC_OS_X_KEYMAP.equals(keymapName) ? new MacOSDefaultKeymap() : new DefaultKeymapImpl();
DefaultKeymapImpl keymap = keymapName.startsWith(KeymapManager.MAC_OS_X_KEYMAP) ? new MacOSDefaultKeymap() : new DefaultKeymapImpl();
keymap.readExternal(child, myKeymaps.toArray(new Keymap[myKeymaps.size()]));
keymap.setName(keymapName);
myKeymaps.add(keymap);
@@ -54,7 +54,7 @@ public class ProgressManagerImpl extends ProgressManager {
public ProgressManagerImpl(Application application) {
if (!application.isUnitTestMode() && !DISABLED) {
new Thread(NAME) {
final Thread thread = new Thread(NAME) {
public void run() {
while (true) {
try {
@@ -65,7 +65,9 @@ public class ProgressManagerImpl extends ProgressManager {
ourNeedToCheckCancel = true;
}
}
}.start();
};
thread.setPriority(Thread.MIN_PRIORITY + 1);
thread.start();
}
}
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.popup.BalloonHandler;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.ex.StatusBarEx;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.Queue;
import com.intellij.util.messages.MessageBus;
import org.jetbrains.annotations.NotNull;
@@ -184,7 +185,25 @@ public class DumbServiceImpl extends DumbService {
}
private static final Ref<CacheUpdateRunner> NULL_ACTION = new Ref<CacheUpdateRunner>(null);
public void waitForSmartMode() {
final Application application = ApplicationManager.getApplication();
if (!application.isUnitTestMode()) {
assert !application.isDispatchThread();
assert !application.isReadAccessAllowed();
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
runWhenSmart(new Runnable() {
public void run() {
semaphore.up();
}
});
semaphore.waitFor();
LOG.assertTrue(!isDumb());
}
private class IndexUpdateRunnable implements Runnable {
private final CacheUpdateRunner myAction;
private double myProcessedItems;
@@ -29,13 +29,13 @@ import java.util.List;
public class BuildInfo implements Comparable<BuildInfo> {
private final BuildNumber myNumber;
private final String myName;
private final String myVersion;
private final String myMessage;
private final List<PatchInfo> myPatches;
public BuildInfo(Element node) {
myNumber = BuildNumber.fromString(node.getAttributeValue("number"));
myName = node.getAttributeValue("name");
myVersion = node.getAttributeValue("version");
myPatches = new ArrayList<PatchInfo>();
for (Object patchNode : node.getChildren("patch")) {
@@ -54,8 +54,8 @@ public class BuildInfo implements Comparable<BuildInfo> {
return myNumber;
}
public String getName() {
return myName != null ? myName : "";
public String getVersion() {
return myVersion != null ? myVersion : "";
}
public String getMessage() {
@@ -66,7 +66,7 @@ public class BuildInfo implements Comparable<BuildInfo> {
public PatchInfo findPatchForCurrentBuild() {
BuildNumber currentBuild = ApplicationInfo.getInstance().getBuild();
for (PatchInfo each : myPatches) {
if (each.getFromBuild().equals(currentBuild)) return each;
if (each.getFromBuild().asStringWithoutProductCode().equals(currentBuild.asStringWithoutProductCode())) return each;
}
return null;
}
@@ -383,7 +383,7 @@ public final class UpdateChecker {
PatchInfo patch = newVersion.findPatchForCurrentBuild();
if (patch == null) throw new IOException("No patch is available for current version");
String platform = System.getProperty("idea.platform.prefix", "idea");
String productCode = ApplicationInfo.getInstance().getBuild().getProductCode();
String osSuffix = "";
if (SystemInfo.isWindows) {
@@ -394,12 +394,14 @@ public final class UpdateChecker {
}
else if (SystemInfo.isUnix) osSuffix = "-unix";
String fileName = platform + "-" + patch.getFromBuild().asString() + "-" + newVersion.getNumber().asString() + "-patch" + osSuffix + ".jar";
String fromBuildNumber = patch.getFromBuild().asStringWithoutProductCode();
String toBuildNumber = newVersion.getNumber().asStringWithoutProductCode();
String fileName = productCode + "-" + fromBuildNumber + "-" + toBuildNumber + "-patch" + osSuffix + ".jar";
URLConnection connection = null;
InputStream in = null;
OutputStream out = null;
String patchFileName = "jetbrains.patch.jar." + platform;
String patchFileName = "jetbrains.patch.jar." + productCode;
File patchFile = new File(FileUtil.getTempDirectory(), patchFileName);
try {
@@ -121,7 +121,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
public UpdateInfoPanel() {
ApplicationInfo appInfo = ApplicationInfo.getInstance();
myBuildNumber.setText(appInfo.getBuild().asString() + ")");
myBuildNumber.setText(appInfo.getBuild().asStringWithoutProductCode() + ")");
final String majorVersion = appInfo.getMajorVersion();
final String version;
if (majorVersion != null && majorVersion.trim().length() > 0) {
@@ -138,8 +138,8 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
}
myVersionNumber.setText(version);
myNewBuildNumber.setText(myLatestBuild.getNumber().asString() + ")");
myNewVersionNumber.setText(myLatestBuild.getName());
myNewBuildNumber.setText(myLatestBuild.getNumber().asStringWithoutProductCode() + ")");
myNewVersionNumber.setText(myLatestBuild.getVersion());
if (myLatestBuild.getMessage() != null) {
myUpdateMessageLabel.setText("<html><body><br>" + myLatestBuild.getMessage() + "</body></html>");
}
@@ -15,11 +15,12 @@
*/
package com.intellij.openapi.wm.impl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.wm.impl.commands.FinalizableCommand;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -43,7 +44,7 @@ public final class CommandProcessor implements Runnable {
* commands with BlockFocusEventsCmd - UnbockFocusEventsCmd. It's required to
* prevent focus handling of events which is caused by the commands to be executed.
*/
public final void execute(final List<FinalizableCommand> commandList, Condition expired) {
public final void execute(@NotNull List<FinalizableCommand> commandList, @NotNull Condition expired) {
synchronized (myLock) {
final boolean isBusy = myCommandCount > 0;
@@ -60,32 +61,28 @@ public final class CommandProcessor implements Runnable {
public final void run() {
synchronized (myLock) {
final CommandGroup commandGroup = getNextCommandGroup();
if (commandGroup == null) {
return;
}
if (commandGroup == null || commandGroup.isEmpty()) return;
final Condition conditionForGroup = commandGroup.getExpireCondition();
if (!commandGroup.isEmpty()) {
final FinalizableCommand command = commandGroup.takeNextCommand();
myCommandCount--;
final FinalizableCommand command = commandGroup.takeNextCommand();
myCommandCount--;
final Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup;
final Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup;
if (LOG.isDebugEnabled()) {
LOG.debug("CommandProcessor.run " + command);
}
// max. I'm not actually quite sure this should have NON_MODAL modality but it should
// definitely have some since runnables in command list may (and do) request some PSI activity
final boolean queueNext = myCommandCount > 0;
ApplicationManager.getApplication().getInvokator().invokeLater(command, ModalityState.NON_MODAL, expire == null ? Condition.FALSE : expire).doWhenDone(new Runnable() {
public void run() {
if (queueNext) {
CommandProcessor.this.run();
}
}
});
if (LOG.isDebugEnabled()) {
LOG.debug("CommandProcessor.run " + command);
}
// max. I'm not actually quite sure this should have NON_MODAL modality but it should
// definitely have some since runnables in command list may (and do) request some PSI activity
final boolean queueNext = myCommandCount > 0;
ApplicationManager.getApplication().getInvokator().invokeLater(command, ModalityState.NON_MODAL, expire == null ? Condition.FALSE : expire).doWhenDone(new Runnable() {
public void run() {
if (queueNext) {
CommandProcessor.this.run();
}
}
});
}
}
@@ -104,9 +101,9 @@ public final class CommandProcessor implements Runnable {
private static class CommandGroup {
private final List<FinalizableCommand> myList;
private final Condition myExpireCondition;
private Condition myExpireCondition;
private CommandGroup(final List<FinalizableCommand> list, final Condition expireCondition) {
private CommandGroup(@NotNull List<FinalizableCommand> list, @NotNull Condition expireCondition) {
myList = list;
myExpireCondition = expireCondition;
}
@@ -120,7 +117,12 @@ public final class CommandProcessor implements Runnable {
}
public FinalizableCommand takeNextCommand() {
return myList.remove(0);
FinalizableCommand command = myList.remove(0);
if (isEmpty()) {
// memory leak otherwise
myExpireCondition = Condition.TRUE;
}
return command;
}
}
}
@@ -34,7 +34,13 @@ public class EditorComboBoxEditor implements ComboBoxEditor{
@NonNls protected static final String NAME = "ComboBox.textField";
public EditorComboBoxEditor(Project project, FileType fileType) {
myTextField = new EditorTextField((Document)null, project, fileType);
myTextField = new EditorTextField((Document)null, project, fileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
myTextField.setName(NAME);
}
@@ -356,11 +356,15 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
}
}
protected boolean isActionClick(MouseEvent e) {
return UIUtil.isActionClick(e);
}
private class MyMouseListener extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
if (!UIUtil.isActionClick(e)) return;
if (!isActionClick(e)) return;
boolean handleFinalChoices = true;
final Object selectedValue = myList.getSelectedValue();
@@ -904,9 +904,9 @@ updates.download.and.install.patch.button=&Download Patch and Shutdown
updates.download.and.install.patch.button.restart=&Download Patch and Restart
updates.more.info.button=&More Info...
updates.new.version.available=<html><h4>A new version of $FULLNAME$ is available.</h4></html>
updates.available.idea.version=Available $PRODUCT$ version:
updates.available.idea.version=New version:
updates.build.number=(Build number:
updates.current.idea.version=Your current $PRODUCT$ version:
updates.current.idea.version=Current version:
updates.press.more.info.label=<html><br>Press <b>More Info...</b> to open a web page where you can download $PRODUCT$ manually or learn more about its new version.</HTML>
updates.check.manually.label=<html><br>To check for new updates manually, use the <b>Help | Check for Updates</b> command.</html>
updates.settings.title=Updates
@@ -0,0 +1,412 @@
<component>
<keymap name="Mac OS X 10.5+" parent="$default" version="1" disable-mnemonics="true">
<action id="FileChooser.TogglePathShowing">
<keyboard-shortcut first-keystroke="meta P"/>
</action>
<action id="Debugger.PreviousContent">
<keyboard-shortcut first-keystroke="control alt shift LEFT" />
</action>
<action id="Debugger.NextContent">
<keyboard-shortcut first-keystroke="control alt shift RIGHT" />
</action>
<action id="Debugger.MaximizeContent">
<keyboard-shortcut first-keystroke="control alt shift UP" />
</action>
<action id="Debugger.RestoreContent">
<keyboard-shortcut first-keystroke="control alt shift DOWN" />
</action>
<action id="Debugger.HideContent">
<keyboard-shortcut first-keystroke="control alt shift BACK_SPACE" />
</action>
<action id="Debugger.DetachContent">
<keyboard-shortcut first-keystroke="control alt shift ENTER" />
</action>
<action id="NextSplitter">
<keyboard-shortcut first-keystroke="alt TAB"/>
</action>
<action id="PrevSplitter">
<keyboard-shortcut first-keystroke="alt shift TAB"/>
</action>
<action id="ShowSettings">
<keyboard-shortcut first-keystroke="meta COMMA"/>
</action>
<action id="ShowProjectStructureSettings">
<keyboard-shortcut first-keystroke="meta SEMICOLON"/>
</action>
<action id="CodeCompletion">
<keyboard-shortcut first-keystroke="control SPACE"/>
</action>
<action id="ClassNameCompletion">
<keyboard-shortcut first-keystroke="control alt SPACE"/>
</action>
<action id="SmartTypeCompletion">
<keyboard-shortcut first-keystroke="control shift SPACE"/>
</action>
<action id="EditorScrollUp">
<keyboard-shortcut first-keystroke="meta UP"/>
</action>
<action id="EditorScrollDown">
<keyboard-shortcut first-keystroke="meta DOWN"/>
</action>
<action id="PreviousTab">
<keyboard-shortcut first-keystroke="control LEFT"/>
</action>
<action id="PreviousEditorTab">
<keyboard-shortcut first-keystroke="control shift LEFT"/>
</action>
<action id="EditorPreviousWord">
<keyboard-shortcut first-keystroke="alt LEFT"/>
</action>
<action id="QuickJavaDoc">
<keyboard-shortcut first-keystroke="control J"/>
<mouse-shortcut keystroke="control button2"/>
</action>
<action id="SafeDelete">
<keyboard-shortcut first-keystroke="meta DELETE"/>
</action>
<action id="RemoveFromFavorites">
<keyboard-shortcut first-keystroke="control DELETE"/>
</action>
<action id="EditorDeleteToWordStart">
<keyboard-shortcut first-keystroke="alt BACK_SPACE"/>
</action>
<action id="EditorDeleteToWordEnd">
<keyboard-shortcut first-keystroke="alt DELETE"/>
</action>
<action id="DebugClass"/>
<action id="EditorStartNewLine">
<keyboard-shortcut first-keystroke="shift ENTER"/>
</action>
<action id="ExternalJavaDoc">
<keyboard-shortcut first-keystroke="shift F1"/>
</action>
<action id="EditorContextInfo">
<keyboard-shortcut first-keystroke="control shift Q"/>
</action>
<action id="MethodDown">
<keyboard-shortcut first-keystroke="control DOWN"/>
</action>
<action id="EditorPreviousWordWithSelection">
<keyboard-shortcut first-keystroke="alt shift LEFT"/>
</action>
<action id="RunGc"/>
<action id="RunClass"/>
<action id="GotoBookmark0">
<keyboard-shortcut first-keystroke="control 0"/>
</action>
<action id="GotoBookmark1">
<keyboard-shortcut first-keystroke="control 1"/>
</action>
<action id="GotoBookmark2">
<keyboard-shortcut first-keystroke="control 2"/>
</action>
<action id="GotoBookmark3">
<keyboard-shortcut first-keystroke="control 3"/>
</action>
<action id="GotoBookmark4">
<keyboard-shortcut first-keystroke="control 4"/>
</action>
<action id="GotoBookmark5">
<keyboard-shortcut first-keystroke="control 5"/>
</action>
<action id="GotoBookmark6">
<keyboard-shortcut first-keystroke="control 6"/>
</action>
<action id="GotoBookmark7">
<keyboard-shortcut first-keystroke="control 7"/>
</action>
<action id="GotoBookmark8">
<keyboard-shortcut first-keystroke="control 8"/>
</action>
<action id="GotoBookmark9">
<keyboard-shortcut first-keystroke="control 9"/>
</action>
<action id="MethodUp">
<keyboard-shortcut first-keystroke="control UP"/>
</action>
<action id="NextTab">
<keyboard-shortcut first-keystroke="control RIGHT"/>
</action>
<action id="ShowContent">
<keyboard-shortcut first-keystroke="control DOWN"/>
</action>
<action id="NextEditorTab">
<keyboard-shortcut first-keystroke="control shift RIGHT"/>
</action>
<action id="TogglePopupHints"/>
<action id="EditorNextWordWithSelection">
<keyboard-shortcut first-keystroke="alt shift RIGHT"/>
</action>
<action id="EditorNextWord">
<keyboard-shortcut first-keystroke="alt RIGHT"/>
</action>
<action id="EditorLineStart">
<keyboard-shortcut first-keystroke="HOME"/>
<keyboard-shortcut first-keystroke="meta LEFT"/>
</action>
<action id="ValidateXml"/>
<action id="TypeHierarchy">
<keyboard-shortcut first-keystroke="control H"/>
</action>
<action id="ToggleReadOnlyAttribute"/>
<action id="ShowPopupMenu"/>
<action id="EditorLineStartWithSelection">
<keyboard-shortcut first-keystroke="shift HOME"/>
<keyboard-shortcut first-keystroke="meta shift LEFT"/>
</action>
<action id="ContextHelp">
<keyboard-shortcut first-keystroke="F1"/>
</action>
<action id="ActivateMessagesToolWindow">
<keyboard-shortcut first-keystroke="meta 0"/>
</action>
<action id="ActivateProjectToolWindow">
<keyboard-shortcut first-keystroke="meta 1"/>
</action>
<action id="ActivateCommanderToolWindow">
<keyboard-shortcut first-keystroke="meta 2"/>
</action>
<action id="ActivateFindToolWindow">
<keyboard-shortcut first-keystroke="meta 3"/>
</action>
<action id="ActivateRunToolWindow">
<keyboard-shortcut first-keystroke="meta 4"/>
</action>
<action id="ActivateDebugToolWindow">
<keyboard-shortcut first-keystroke="meta 5"/>
</action>
<action id="ActivateTODOToolWindow">
<keyboard-shortcut first-keystroke="meta 6"/>
</action>
<action id="ActivateStructureToolWindow">
<keyboard-shortcut first-keystroke="meta 7"/>
</action>
<action id="ActivateHierarchyToolWindow">
<keyboard-shortcut first-keystroke="meta 8"/>
</action>
<action id="ActivateChangesToolWindow">
<keyboard-shortcut first-keystroke="meta 9"/>
</action>
<action id="NewElement">
<keyboard-shortcut first-keystroke="meta N"/>
<keyboard-shortcut first-keystroke="control N"/>
<keyboard-shortcut first-keystroke="control ENTER"/>
</action>
<action id="Generate">
<keyboard-shortcut first-keystroke="meta N"/>
<keyboard-shortcut first-keystroke="control N"/>
<keyboard-shortcut first-keystroke="control ENTER"/>
</action>
<action id="EditorToggleColumnMode">
<keyboard-shortcut first-keystroke="meta shift MULTIPLY"/>
</action>
<action id="EditorLineEndWithSelection">
<keyboard-shortcut first-keystroke="shift END"/>
<keyboard-shortcut first-keystroke="meta shift RIGHT"/>
</action>
<action id="ExportToTextFile">
<keyboard-shortcut first-keystroke="control O"/>
</action>
<action id="EditorLineEnd">
<keyboard-shortcut first-keystroke="END"/>
<keyboard-shortcut first-keystroke="meta RIGHT"/>
</action>
<action id="CreateConfiguration"/>
<action id="CloseWindow"/>
<action id="Exit">
<keyboard-shortcut first-keystroke="meta Q"/>
</action>
<action id="NextSplitter">
<keyboard-shortcut first-keystroke="control TAB"/>
</action>
<action id="PrevSplitter">
<keyboard-shortcut first-keystroke="control shift TAB"/>
</action>
<action id="GotoTypeDeclaration">
<keyboard-shortcut first-keystroke="control shift B"/>
<mouse-shortcut keystroke="meta shift button1"/>
<mouse-shortcut keystroke="shift button2"/>
</action>
<action id="EditorJoinLines">
<keyboard-shortcut first-keystroke="control shift J"/>
</action>
<action id="FindNext">
<keyboard-shortcut first-keystroke="F3"/>
<keyboard-shortcut first-keystroke="control L"/>
</action>
<action id="FindPrevious">
<keyboard-shortcut first-keystroke="shift F3"/>
<keyboard-shortcut first-keystroke="control shift L"/>
</action>
<action id="VcsShowNextChangeMarker">
<keyboard-shortcut first-keystroke="shift control alt DOWN"/>
</action>
<action id="VcsShowPrevChangeMarker">
<keyboard-shortcut first-keystroke="shift control alt UP"/>
</action>
<action id="CallHierarchy">
<keyboard-shortcut first-keystroke="control alt H"/>
</action>
<action id="CommentByBlockComment">
<keyboard-shortcut first-keystroke="meta alt SLASH"/>
<keyboard-shortcut first-keystroke="meta alt DIVIDE"/>
<keyboard-shortcut first-keystroke="control shift SLASH"/>
<keyboard-shortcut first-keystroke="control shift DIVIDE"/>
<keyboard-shortcut first-keystroke="meta shift SLASH"/>
<keyboard-shortcut first-keystroke="meta shift DIVIDE"/>
</action>
<action id="Refresh">
<keyboard-shortcut first-keystroke="control F5"/>
</action>
<action id="Rerun">
<keyboard-shortcut first-keystroke="control F5"/>
</action>
<action id="RunClass">
<keyboard-shortcut first-keystroke="control shift F10"/>
</action>
<action id="DebugClass">
<keyboard-shortcut first-keystroke="control shift F9"/>
</action>
<action id="TestGestureAction">
<keyboard-gesture-shortcut keystroke="meta 1" modifier="dblClick"/>
</action>
<action id="ToolWindowSwitcher">
<keyboard-shortcut first-keystroke="ctrl TAB"/>
<keyboard-shortcut first-keystroke="ctrl shift TAB"/>
</action>
<action id="Vcs.QuickListPopupAction">
<keyboard-shortcut first-keystroke="ctrl V" />
</action>
<action id="GuiDesigner.ExpandSelection">
<keyboard-shortcut first-keystroke="alt UP"/>
</action>
<action id="GuiDesigner.ShrinkSelection">
<keyboard-shortcut first-keystroke="alt DOWN"/>
</action>
<action id="EditorSelectWord">
<keyboard-shortcut first-keystroke="alt UP"/>
</action>
<action id="EditorUnSelectWord">
<keyboard-shortcut first-keystroke="alt DOWN"/>
</action>
<action id="EditorDeleteToWordStart">
<keyboard-shortcut first-keystroke="alt BACK_SPACE"/>
</action>
<action id="EditorDeleteToWordEnd">
<keyboard-shortcut first-keystroke="alt DELETE"/>
</action>
<action id="EditorDeleteLine">
<keyboard-shortcut first-keystroke="meta BACK_SPACE"/>
</action>
<action id="CloseEditor">
<keyboard-shortcut first-keystroke="meta W"/>
</action>
<action id="CloseActiveTab">
<keyboard-shortcut first-keystroke="control shift F4"/> <!-- TODO? -->
</action>
<action id="ReplaceInPath">
<keyboard-shortcut first-keystroke="meta shift R"/>
</action>
<action id="FindInPath">
<keyboard-shortcut first-keystroke="meta shift F"/>
</action>
<action id="Find">
<keyboard-shortcut first-keystroke="meta F"/>
</action>
<action id="FindNext">
<keyboard-shortcut first-keystroke="meta G"/>
</action>
<action id="FindPrevious">
<keyboard-shortcut first-keystroke="meta shift G"/>
</action>
<action id="Run">
<keyboard-shortcut first-keystroke="control R"/>
</action>
<action id="Debug">
<keyboard-shortcut first-keystroke="control D"/>
</action>
<action id="Resume">
<keyboard-shortcut first-keystroke="meta alt R"/>
</action>
<action id="ChooseRunConfiguration">
<keyboard-shortcut first-keystroke="control alt R"/>
</action>
<action id="ChooseDebugConfiguration">
<keyboard-shortcut first-keystroke="control alt D"/>
</action>
<action id="RunClass">
<keyboard-shortcut first-keystroke="control shift R"/>
</action>
<action id="DebugClass">
<keyboard-shortcut first-keystroke="control shift D"/>
</action>
<action id="GotoClass">
<keyboard-shortcut first-keystroke="meta O"/>
</action>
<action id="GotoSymbol">
<keyboard-shortcut first-keystroke="meta alt O"/>
</action>
<action id="GotoFile">
<keyboard-shortcut first-keystroke="meta shift O"/>
</action>
<action id="GotoLine">
<keyboard-shortcut first-keystroke="meta L"/>
</action>
<action id="QuickImplementations">
<keyboard-shortcut first-keystroke="alt SPACE"/>
<keyboard-shortcut first-keystroke="meta Y"/>
</action>
<action id="EditSource">
<keyboard-shortcut first-keystroke="meta DOWN"/>
<keyboard-shortcut first-keystroke="F4"/>
</action>
<action id="ToggleBookmark">
<keyboard-shortcut first-keystroke="F3"/>
</action>
<action id="ToggleBookmarkWithMnemonic">
<keyboard-shortcut first-keystroke="alt F3"/>
</action>
<action id="ShowBookmarks">
<keyboard-shortcut first-keystroke="meta F3"/>
</action>
<action id="ImplementMethods">
<keyboard-shortcut first-keystroke="control I"/>
</action>
<action id="OverrideMethods">
<keyboard-shortcut first-keystroke="control O"/>
</action>
<action id="OptimizeImports">
<keyboard-shortcut first-keystroke="control alt O"/>
</action>
<action id="AutoIndentLines">
<keyboard-shortcut first-keystroke="control alt I"/>
</action>
<action id="EditorScrollUp"/> <!-- Disables meta up -->
<action id="EditorScrollDown"/> <!-- Disables meta down -->
<action id="FindWordAtCaret"/> <!-- Disables meta F3 -->
</keymap>
</component>
@@ -17,7 +17,6 @@ package com.intellij.usages;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.*;
import com.intellij.util.containers.ContainerUtil;
@@ -27,18 +26,14 @@ import java.util.List;
* @author max
*/
public class UsageModelTracker implements Disposable {
private final PsiTreeChangeListener myPsiListener;
public interface UsageModelTrackerListener {
void modelChanged(boolean isPropertyChange);
}
private final Project myProject;
private final List<UsageModelTrackerListener> myListeners = ContainerUtil.createEmptyCOWList();
public UsageModelTracker(Project project, Disposable parentDisposable) {
myProject = project;
myPsiListener = new PsiTreeChangeAdapter() {
public UsageModelTracker(Project project) {
final PsiTreeChangeListener myPsiListener = new PsiTreeChangeAdapter() {
public void childAdded(PsiTreeChangeEvent event) {
doFire(event, false);
}
@@ -63,8 +58,7 @@ public class UsageModelTracker implements Disposable {
doFire(event, true);
}
};
PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener);
Disposer.register(parentDisposable, this);
PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener, this);
}
private void doFire(final PsiTreeChangeEvent event, boolean propertyChange) {
@@ -76,7 +70,6 @@ public class UsageModelTracker implements Disposable {
}
public void dispose() {
PsiManager.getInstance(myProject).removePsiTreeChangeListener(myPsiListener);
}
public void addListener(UsageModelTrackerListener listener) {
@@ -135,7 +135,6 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
@NotNull UsageViewPresentation presentation,
@NotNull UsageTarget[] targets,
Factory<UsageSearcher> usageSearcherFactory) {
myPresentation = presentation;
myTargets = targets;
myUsageSearcherFactory = usageSearcherFactory;
@@ -159,7 +158,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
}
};
myRootPanel = new MyPanel(myTree);
myModelTracker = new UsageModelTracker(project, this);
myModelTracker = new UsageModelTracker(project);
Disposer.register(this, myModelTracker);
myModel = new UsageViewTreeModelBuilder(myPresentation, targets);
myRoot = (GroupNode)myModel.getRoot();
@@ -33,9 +33,19 @@ public class BuildNumber implements Comparable<BuildNumber> {
}
public String asString() {
return asString(true);
}
public String asStringWithoutProductCode() {
return asString(false);
}
private String asString(boolean includeProductCode) {
StringBuilder builder = new StringBuilder();
if (!StringUtil.isEmpty(myProductCode)) {
builder.append(myProductCode).append('-');
if (includeProductCode) {
if (!StringUtil.isEmpty(myProductCode)) {
builder.append(myProductCode).append('-');
}
}
builder.append(myBaselineVersion).append('.');
@@ -50,15 +60,10 @@ public class BuildNumber implements Comparable<BuildNumber> {
return builder.toString();
}
@Override
public String toString() {
return asString();
}
public static BuildNumber fromString(String version) {
if (version == null) return null;
if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("", 92, Integer.MAX_VALUE);
if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("IU", 92, Integer.MAX_VALUE);
String code = version;
int productSeparator = code.indexOf('-');
@@ -114,6 +119,11 @@ public class BuildNumber implements Comparable<BuildNumber> {
return new BuildNumber(productCode, baselineVersion, buildNumber);
}
@Override
public String toString() {
return asString();
}
public int compareTo(BuildNumber o) {
if (myBaselineVersion == o.myBaselineVersion) return myBuildNumber - o.myBuildNumber;
return myBaselineVersion - o.myBaselineVersion;
@@ -16,8 +16,8 @@
package com.intellij.util;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@@ -84,19 +84,33 @@ public class ConcurrencyUtil {
V prev = map.putIfAbsent(key, defaultValue);
return prev == null ? defaultValue : prev;
}
public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls final String threadFactoryName) {
return newSingleThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
}
public static ThreadPoolExecutor newSingleThreadExecutor(final String threadFactoryName, final int threadPriority) {
return new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
public Thread newThread(final Runnable r) {
return new Thread(r, threadFactoryName);
final Thread thread = new Thread(r, threadFactoryName);
thread.setPriority(threadPriority);
return thread;
}
});
}
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls final String threadFactoryName) {
return newSingleScheduledThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY);
}
public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(final String threadFactoryName, final int threadPriority) {
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
public Thread newThread(final Runnable r) {
return new Thread(r, threadFactoryName);
final Thread thread = new Thread(r, threadFactoryName);
thread.setPriority(threadPriority);
return thread;
}
});
executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
@@ -74,7 +74,7 @@ abstract class Timed<T> implements Disposable {
static {
ScheduledExecutorService service = ConcurrencyUtil.newSingleScheduledThreadExecutor("timed reference disposer");
ScheduledExecutorService service = ConcurrencyUtil.newSingleScheduledThreadExecutor("timed reference disposer", Thread.MIN_PRIORITY + 1);
service.scheduleWithFixedDelay(new Runnable() {
public void run() {
try {
@@ -123,6 +123,10 @@ public class ContainerUtil {
return EmptyIterator.getInstance();
}
public static <T> Iterable<T> emptyIterable() {
return EmptyIterable.getInstance();
}
@Nullable
public static <T> T find(T[] array, Condition<T> condition) {
for (T element : array) {
@@ -297,6 +301,42 @@ public class ContainerUtil {
};
}
public static <T> Iterable<T> iterate(final Collection<? extends T> collection, final Condition<? super T> condition) {
if (collection.isEmpty()) return emptyIterable();
return new Iterable<T>() {
public Iterator<T> iterator() {
return new Iterator<T>() {
Iterator<? extends T> impl = collection.iterator();
T next = findNext();
public boolean hasNext() {
return next != null;
}
public T next() {
T result = next;
next = findNext();
return result;
}
private T findNext() {
while (impl.hasNext()) {
T each = impl.next();
if (condition.value(each)) {
return each;
}
}
return null;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
public static <E> void swapElements(final List<E> list, final int index1, final int index2) {
E e1 = list.get(index1);
E e2 = list.get(index2);
@@ -0,0 +1,31 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.containers;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class EmptyIterable<T> implements Iterable<T> {
private static final EmptyIterable INSTANCE = new EmptyIterable();
public static <T> EmptyIterable<T> getInstance() {
return INSTANCE;
}
public Iterator<T> iterator() {
return EmptyIterator.getInstance();
}
}
@@ -29,6 +29,11 @@ public class OrderedSet<T> extends AbstractSet<T> implements List<T> {
myElements = new ArrayList<T>();
}
public OrderedSet(TObjectHashingStrategy<T> hashingStrategy, int capacity) {
myHashSet = new THashSet<T>(capacity, hashingStrategy);
myElements = new ArrayList<T>(capacity);
}
public OrderedSet() {
myHashSet = new THashSet<T>();
myElements = new ArrayList<T>();
@@ -62,6 +62,7 @@ public abstract class Timer implements Disposable {
myDisposed = true;
}
};
myThread.setPriority(Thread.MIN_PRIORITY + 1);
}
public void setTakeInitialDelay(final boolean take) {
@@ -16,12 +16,15 @@
package com.intellij.util.containers;
import com.intellij.openapi.util.Condition;
import java.util.*;
public class ContainerUtilTest extends junit.framework.TestCase {
public void testFindInstanceOf() {
Iterator<Object> iterator = Arrays.asList(new Object[]{new Integer(1), new ArrayList(), "1"}).iterator();
String string = (String)com.intellij.util.containers.ContainerUtil.find(iterator, com.intellij.util.containers.FilteringIterator.instanceOf(String.class));
String string = (String)com.intellij.util.containers.ContainerUtil
.find(iterator, com.intellij.util.containers.FilteringIterator.instanceOf(String.class));
junit.framework.Assert.assertEquals("1", string);
}
@@ -32,17 +35,41 @@ public class ContainerUtilTest extends junit.framework.TestCase {
assertEquals(2, l.get(1));
assertEquals(3, l.get(2));
assertEquals(4, l.get(3));
try {
l.get(-1);
fail();
} catch(IndexOutOfBoundsException ignore) {
}
catch (IndexOutOfBoundsException ignore) {
}
try {
l.get(4);
fail();
} catch(IndexOutOfBoundsException ignore) {
}
catch (IndexOutOfBoundsException ignore) {
}
}
public void testIterateWithCondition() throws Exception {
Condition<Integer> cond = new Condition<Integer>() {
public boolean value(Integer integer) {
return integer > 2;
}
};
asserIterating(Arrays.asList(1, 4, 2, 5), cond, 4, 5);
asserIterating(Arrays.asList(1, 2), cond);
asserIterating(Collections.<Integer>emptyList(), cond);
asserIterating(Arrays.asList(4), cond, 4);
}
private void asserIterating(List<Integer> collection, Condition<Integer> condition, Integer... expected) {
Iterable<Integer> it = ContainerUtil.iterate(collection, condition);
List<Integer> actual = new ArrayList<Integer>();
for (Integer each : it) {
actual.add(each);
}
assertEquals(Arrays.asList(expected), actual);
}
}
@@ -50,7 +50,9 @@ public class SlowlyClosingAlarm implements AtomicSectionsAware, Disposable {
private static ThreadFactory threadFactory(@NonNls final String threadsName) {
return new ThreadFactory() {
public Thread newThread(final Runnable r) {
return new Thread(r, threadsName);
final Thread thread = new Thread(r, threadsName);
thread.setPriority(Thread.MIN_PRIORITY);
return thread;
}
};
}
@@ -34,8 +34,8 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.ui.CommitHelper;
import com.intellij.openapi.vcs.changes.conflicts.ChangelistConflictTracker;
import com.intellij.openapi.vcs.changes.ui.CommitHelper;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vcs.checkin.CheckinHandler;
import com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl;
@@ -69,7 +69,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
private final UpdateRequestsQueue myUpdater;
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
private static final ScheduledExecutorService ourUpdateAlarm = ConcurrencyUtil.newSingleScheduledThreadExecutor("Change List Updater");
private static final ScheduledExecutorService ourUpdateAlarm = ConcurrencyUtil.newSingleScheduledThreadExecutor("Change List Updater", Thread.MIN_PRIORITY + 1);
private final Modifier myModifier;
@@ -60,10 +60,11 @@ public class CompositeCheckoutListener implements CheckoutProvider.Listener {
result.set(vDir);
if (vDir != null) {
final LocalFileSystem.WatchRequest watchRequest = lfs.addRootToWatch(vDir.getPath(), true);
assert watchRequest != null;
((NewVirtualFile)vDir).markDirtyRecursively();
vDir.refresh(false, true);
lfs.removeWatchedRoot(watchRequest);
if (watchRequest != null) {
lfs.removeWatchedRoot(watchRequest);
}
}
}
});
@@ -172,6 +172,10 @@
<value-pattern>[^:]*:[\s]*([^\}]*)</value-pattern>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("value").withParameters().definedInClass("javax.ws.rs.Path"))]]></place>
</injection>
<injection language="XPath" injector-id="xml">
<display-name>JAXB attribute node</display-name>
<place><![CDATA[xmlAttribute().withLocalName(string().matches("node")).inside(xmlTag().withLocalName(string().matches("bindings")).withNamespace(string().matches("http://java.sun.com/xml/ns/jaxb")))]]></place>
</injection>
<injection language="RegExp" injector-id="java">
<display-name>Pattern (java.util.regex)</display-name>
<place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("compile").withParameters("java.lang.String").definedInClass("java.util.regex.Pattern"))]]></place>
@@ -27,6 +27,7 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.Pair;
@@ -36,6 +37,7 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.FileContentUtil;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import com.intellij.util.ui.EmptyIcon;
@@ -45,7 +47,9 @@ import org.jetbrains.annotations.Nullable;
import org.intellij.plugins.intelliLang.Configuration;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
public class InjectLanguageAction implements IntentionAction {
@NonNls protected static final String INJECT_LANGUAGE_FAMILY = "Inject Language";
@@ -108,23 +112,31 @@ public class InjectLanguageAction implements IntentionAction {
final String[] langIds = InjectedLanguage.getAvailableLanguageIDs();
Arrays.sort(langIds);
final Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
buildLanguageTree(langIds, map);
final BaseListPopupStep<String> step = new MyPopupStep(map, new ArrayList<String>(map.keySet()), onChosen);
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
listPopup.showInBestPositionFor(DataManager.getInstance().getDataContext());
return true;
}
private static void buildLanguageTree(String[] langIds, Map<String, List<String>> map) {
for (final String id : langIds) {
if (!map.containsKey(id)) {
map.put(id, new ArrayList<String>());
final JList list = new JList(langIds);
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
final String aValue = (String)value;
final Language language = InjectedLanguage.findLanguageById(aValue);
assert language != null;
final FileType ft = language.getAssociatedFileType();
setIcon(ft != null ? ft.getIcon() : new EmptyIcon(16));
setText(value + (ft != null ? " (" + ft.getDescription() + ")" : ""));
return this;
}
}
});
new PopupChooserBuilder(list).setItemChoosenCallback(new Runnable() {
public void run() {
final String string = (String)list.getSelectedValue();
onChosen.process(string);
}
}).setFilteringEnabled(new Function<Object, String>() {
public String fun(Object o) {
return (String)o;
}
}).createPopup().showInBestPositionFor(DataManager.getInstance().getDataContext());
return true;
}
public boolean startInWriteAction() {
@@ -134,50 +146,4 @@ public class InjectLanguageAction implements IntentionAction {
public static boolean doEditConfigurable(final Project project, final Configurable configurable) {
return true; //ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
}
private static class MyPopupStep extends BaseListPopupStep<String> {
private final Map<String, List<String>> myMap;
private final Processor<String> myFinalStepProcessor;
public MyPopupStep(final Map<String, List<String>> map, final List<String> values, final Processor<String> finalStepProcessor) {
super("Choose Language", values);
myMap = map;
myFinalStepProcessor = finalStepProcessor;
}
@Override
public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
if (finalChoice) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
myFinalStepProcessor.process(selectedValue);
}
});
return FINAL_CHOICE;
}
return new MyPopupStep(myMap, myMap.get(selectedValue), myFinalStepProcessor);
}
@Override
public boolean hasSubstep(String selectedValue) {
return myMap.containsKey(selectedValue) && !myMap.get(selectedValue).isEmpty();
}
@Override
public Icon getIconFor(String aValue) {
final Language language = InjectedLanguage.findLanguageById(aValue);
assert language != null;
final FileType ft = language.getAssociatedFileType();
return ft != null ? ft.getIcon() : new EmptyIcon(16);
}
@NotNull
@Override
public String getTextFor(String value) {
final Language language = InjectedLanguage.findLanguageById(value);
assert language != null;
final FileType ft = language.getAssociatedFileType();
return value + (ft != null ? " ("+ft.getDescription()+")" : "");
}
}
}
@@ -146,10 +146,12 @@ class ExceptionUtils{
final PsiElement[] elements =
declarationStatement.getDeclaredElements();
for(PsiElement element : elements){
final PsiVariable var = (PsiVariable) element;
final PsiExpression initializer = var.getInitializer();
if(initializer != null){
calculateExceptionsThrown(initializer, exceptionTypes);
if (element instanceof PsiVariable) {
final PsiVariable var = (PsiVariable) element;
final PsiExpression initializer = var.getInitializer();
if(initializer != null){
calculateExceptionsThrown(initializer, exceptionTypes);
}
}
}
}
@@ -511,4 +513,4 @@ class ExceptionUtils{
calculateExceptionsThrownForStatement(statement, exceptionTypes);
}
}
}
}
@@ -20,13 +20,16 @@ import com.intellij.lang.ant.config.AntBuildFile;
import com.intellij.lang.ant.config.AntConfiguration;
import com.intellij.lang.ant.config.AntNoFileException;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
public class AddAntBuildFile extends AnAction {
public void actionPerformed(AnActionEvent event) {
@@ -48,36 +51,60 @@ public class AddAntBuildFile extends AnAction {
public void update(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Presentation presentation = e.getPresentation();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
disable(presentation);
return;
}
boolean isXml = StdFileTypes.XML.equals(FileTypeManager.getInstance().getFileTypeByFile(file));
if (!isXml) {
presentation.setEnabled(false);
presentation.setVisible(false);
final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) {
disable(presentation);
return;
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
disable(presentation);
return;
}
final XmlFile xmlFile = (XmlFile)psiFile;
final XmlDocument document = xmlFile.getDocument();
if (document == null) {
disable(presentation);
return;
}
final XmlTag rootTag = document.getRootTag();
if (rootTag == null) {
disable(presentation);
return;
}
if (!"project".equals(rootTag.getName())) {
disable(presentation);
return;
}
for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) {
if (file.equals(buildFile.getVirtualFile())) {
presentation.setEnabled(false);
presentation.setVisible(false);
disable(presentation);
return;
}
}
enable(presentation);
}
private static void enable(Presentation presentation) {
presentation.setEnabled(true);
presentation.setVisible(true);
}
private static void disable(Presentation presentation) {
presentation.setEnabled(false);
presentation.setVisible(false);
}
}
@@ -88,7 +88,7 @@ public class AntCommandLineBuilder {
}
myCommandLine.setJdk(jdk);
ParametersList vmParametersList = myCommandLine.getVMParametersList();
final ParametersList vmParametersList = myCommandLine.getVMParametersList();
vmParametersList.add("-Xmx" + AntBuildFileImpl.MAX_HEAP_SIZE.get(container) + "m");
vmParametersList.add("-Xss" + AntBuildFileImpl.MAX_STACK_SIZE.get(container) + "m");
@@ -125,7 +125,22 @@ public class AntCommandLineBuilder {
myCommandLine.setMainClass(AntMain2.class.getName());
final ParametersList programParameters = myCommandLine.getProgramParametersList();
programParameters.addParametersString(AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.get(container));
final String additionalParams = AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.get(container);
if (additionalParams != null) {
for (String param : ParametersList.parse(additionalParams)) {
if (param.startsWith("-J")) {
final String cutParam = param.substring("-J".length());
if (cutParam.length() > 0) {
vmParametersList.add(cutParam);
}
}
else {
programParameters.add(param);
}
}
}
if (!(programParameters.getList().contains(LOGFILE_SHORT_PARAMETER) || programParameters.getList().contains(LOGFILE_PARAMETER)) ) {
programParameters.add("-logger", IdeaAntLogger2.class.getName());
}
@@ -47,9 +47,9 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ArrayUtil;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -95,6 +95,10 @@ public class AntExplorer extends JPanel implements DataProvider {
return canExpand();
}
};
private static final Icon ICON_RUN = IconLoader.getIcon("/actions/execute.png");
private static final Icon ICON_REMOVE = IconLoader.getIcon("/general/remove.png");
private static final Icon ICON_ADD = IconLoader.getIcon("/general/add.png");
private static final Icon ICON_FILTER = IconLoader.getIcon("/ant/filter.png");
public AntExplorer(final Project project) {
super(new BorderLayout(0, 2));
@@ -495,8 +499,7 @@ public class AntExplorer extends JPanel implements DataProvider {
private final class AddAction extends AnAction {
public AddAction() {
super(AntBundle.message("add.ant.file.action.name"), AntBundle.message("add.ant.file.action.description"),
IconLoader.getIcon("/general/add.png"));
super(AntBundle.message("add.ant.file.action.name"), AntBundle.message("add.ant.file.action.description"), ICON_ADD);
}
public void actionPerformed(AnActionEvent e) {
@@ -506,8 +509,7 @@ public class AntExplorer extends JPanel implements DataProvider {
private final class RemoveAction extends AnAction {
public RemoveAction() {
super(AntBundle.message("remove.ant.file.action.name"), AntBundle.message("remove.ant.file.action.description"),
IconLoader.getIcon("/general/remove.png"));
super(AntBundle.message("remove.ant.file.action.name"), AntBundle.message("remove.ant.file.action.description"), ICON_REMOVE);
}
public void actionPerformed(AnActionEvent e) {
@@ -521,8 +523,7 @@ public class AntExplorer extends JPanel implements DataProvider {
private final class RunAction extends AnAction {
public RunAction() {
super(AntBundle.message("run.ant.file.or.target.action.name"), AntBundle.message("run.ant.file.or.target.action.description"),
IconLoader.getIcon("/actions/execute.png"));
super(AntBundle.message("run.ant.file.or.target.action.name"), AntBundle.message("run.ant.file.or.target.action.description"), ICON_RUN);
}
public void actionPerformed(AnActionEvent e) {
@@ -557,8 +558,7 @@ public class AntExplorer extends JPanel implements DataProvider {
private final class ShowAllTargetsAction extends ToggleAction {
public ShowAllTargetsAction() {
super(AntBundle.message("filter.ant.targets.action.name"), AntBundle.message("filter.ant.targets.action.description"),
IconLoader.getIcon("/ant/filter.png"));
super(AntBundle.message("filter.ant.targets.action.name"), AntBundle.message("filter.ant.targets.action.description"), ICON_FILTER);
}
public boolean isSelected(AnActionEvent event) {
@@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.lang.ant.config.impl.configuration.BuildFilePropertiesPanel.ExecutionTab">
<grid id="81309" binding="myWholePanel" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="81309" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="6" left="6" bottom="6" right="6"/>
<constraints>
<xy x="78" y="8" width="412" height="245"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<xy x="78" y="8" width="425" height="245"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="a6828" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="a6828" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="6" y="6" width="400" height="78"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/AntBundle" title-key="run.execution.tab.run.with.ant.border"/>
<children>
<component id="c77b" class="javax.swing.JRadioButton" binding="myUseDefaultAnt">
<constraints>
<xy x="6" y="21" width="138" height="22"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.use.project.default.ant.radio"/>
@@ -29,8 +26,7 @@
</component>
<component id="cb2b8" class="javax.swing.JRadioButton" binding="myUseCastomAnt">
<constraints>
<xy x="6" y="50" width="101" height="22"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.use.custom.ant.radio"/>
@@ -38,24 +34,21 @@
</component>
<component id="a12d2" class="com.intellij.ui.ComboboxWithBrowseButton" binding="myAnts">
<constraints>
<xy x="154" y="50" width="240" height="22"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<grid id="22941" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="22941" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="4" bottom="0" right="0"/>
<constraints>
<xy x="154" y="20" width="240" height="25"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="86b9b" class="javax.swing.JButton" binding="mySetDefaultAnt">
<constraints>
<xy x="137" y="0" width="103" height="25"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.set.default.button"/>
@@ -63,8 +56,7 @@
</component>
<component id="b934a" class="com.intellij.ui.SimpleColoredComponent" binding="myDefaultAnt">
<constraints>
<xy x="4" y="3" width="6" height="18"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0"/>
<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"/>
</constraints>
<properties/>
</component>
@@ -72,27 +64,25 @@
</grid>
</children>
</grid>
<grid id="8185" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="8185" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="3" bottom="0" right="3"/>
<constraints>
<xy x="6" y="89" width="400" height="150"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3d591" class="com.intellij.ui.RawCommandLineEditor" binding="myAntCommandLine">
<constraints>
<xy x="105" y="0" width="292" height="20"/>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="98550" class="javax.swing.JLabel" binding="myJDKLabel">
<constraints>
<xy x="3" y="29" width="79" height="14"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.run.under.jdk.label"/>
@@ -100,26 +90,42 @@
</component>
<component id="d2390" class="com.intellij.ui.ComboboxWithBrowseButton" binding="myJDKs">
<constraints>
<xy x="105" y="25" width="292" height="22"/>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1"/>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<vspacer id="a2aa8">
<constraints>
<xy x="245" y="47" width="11" height="103"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="411e3" class="javax.swing.JLabel" binding="myAntCmdLineLabel">
<constraints>
<xy x="3" y="3" width="92" height="14"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.ant.command.line.label"/>
</properties>
</component>
<component id="7e40b" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AntBundle" key="run.execution.tab.ant.command.line.hint"/>
</properties>
</component>
<grid id="be9a3" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="10"/>
</grid>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</children>
@@ -0,0 +1,59 @@
/*
* Copyright 2000-2009 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 git4idea.history;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import git4idea.i18n.GitBundle;
import java.awt.datatransfer.StringSelection;
/**
* The action that copies a revision number text to clipboard
*/
public class GitCopyHistoryRevisionNumberAction extends AnAction implements DumbAware {
/**
* The constructor
*/
public GitCopyHistoryRevisionNumberAction() {
super(GitBundle.getString("history.copy.revsion.number"));
}
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(AnActionEvent e) {
VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
if (revision != null) {
CopyPasteManager.getInstance().setContents(new StringSelection(revision.getRevisionNumber().asString()));
}
}
/**
* {@inheritDoc}
*/
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled((e.getData(VcsDataKeys.VCS_FILE_REVISION) != null));
}
}
@@ -62,7 +62,7 @@ public class GitHistoryProvider implements VcsHistoryProvider {
* {@inheritDoc}
*/
public AnAction[] getAdditionalActions(FileHistoryPanel panel) {
return new AnAction[]{new GitShowAllSubmittedFilesAction()};
return new AnAction[]{new GitShowAllSubmittedFilesAction(), new GitCopyHistoryRevisionNumberAction()};
}
/**
@@ -138,6 +138,7 @@ git.vcs.config.ssh.mode.tooltip=<html>Specify which version of SSH to be used wi
git.vcs.config.ssh.mode=&SSH executable:
git.vcs.config.test.label=Test
git.vcs.config.test=&Test
history.copy.revsion.number=Copy Revision Number
index.file.error=Updating file in the index failed
init.add.root.message=Do you want to add this directory as vcs root?
init.add.root.title=Git Init
@@ -26,9 +26,6 @@ import com.intellij.openapi.command.CommandAdapter;
import com.intellij.openapi.command.CommandEvent;
import com.intellij.openapi.command.CommandListener;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootEvent;
import com.intellij.openapi.roots.ModuleRootListener;
@@ -43,6 +40,8 @@ import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.ex.VirtualFileManagerAdapter;
import com.intellij.openapi.vfs.ex.VirtualFileManagerEx;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import git4idea.GitUtil;
import git4idea.GitVcs;
import git4idea.i18n.GitBundle;
@@ -50,7 +49,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -91,7 +93,7 @@ public class GitRootTracker implements VcsListener {
*/
private final AtomicBoolean myNotificationPosted = new AtomicBoolean(false);
private final Object myCheckRootsLock = new Object();
private final MergingUpdateQueue myQueue;
private Notification myNotification;
@@ -129,12 +131,14 @@ public class GitRootTracker implements VcsListener {
* @param multicaster the listeners to notify
*/
public GitRootTracker(GitVcs vcs, @NotNull Project project, @NotNull GitRootsListener multicaster) {
myMulticaster = multicaster;
if (project.isDefault()) {
throw new IllegalArgumentException("The project must not be default");
}
myProject = project;
myProjectRoots = ProjectRootManager.getInstance(myProject);
myQueue = new MergingUpdateQueue("queue", 500, true, null, project, null, false);
myVcs = vcs;
myVcsManager = ProjectLevelVcsManager.getInstance(project);
myVcsManager.addVcsListener(this);
@@ -208,12 +212,10 @@ public class GitRootTracker implements VcsListener {
doCheckRoots(rootsChanged);
return;
}
ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Checking Git roots...") {
public void run(@NotNull ProgressIndicator indicator) {
synchronized (myCheckRootsLock) {
if (myProject.isDisposed()) return;
doCheckRoots(rootsChanged);
}
myQueue.queue(new Update("root check") {
public void run() {
if (myProject.isDisposed()) return;
doCheckRoots(rootsChanged);
}
});
}
@@ -250,7 +252,6 @@ public class GitRootTracker implements VcsListener {
return false;
}
});
if (!hasInvalidRoots && rootSet.isEmpty()) {
myHasGitRoots.set(false);
return;
@@ -306,12 +307,11 @@ public class GitRootTracker implements VcsListener {
*
* @param directory the content root to check
* @param rootSet the mapped root set
* @return true if there are unmapped subroots
*/
private static boolean hasUnmappedSubroots(final VirtualFile directory, final @Nullable HashSet<VirtualFile> rootSet) {
VirtualFile[] children = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile[]>() {
public VirtualFile[] compute() {
return directory.getChildren();
return directory.isValid() ? directory.getChildren() : VirtualFile.EMPTY_ARRAY;
}
});
@@ -218,7 +218,7 @@ public class GroovyAnnotator implements Annotator {
private static void checkLabeledStatement(GrLabeledStatement statement, AnnotationHolder holder) {
final String name = statement.getLabelName();
if (ResolveUtil.resolveLabeledStatement(name, statement, true) != null) {
holder.createErrorAnnotation(statement.getLabel(), GroovyBundle.message("label.already.used", name));
holder.createWarningAnnotation(statement.getLabel(), GroovyBundle.message("label.already.used", name));
}
}
@@ -232,20 +232,18 @@ public class GroovyAnnotator implements Annotator {
}
}
final PsiElement targetStatement = statement.findTargetStatement();
final GrStatement targetStatement = statement.findTargetStatement();
if (targetStatement == null) {
if (statement instanceof GrContinueStatement && label == null) {
holder.createErrorAnnotation(statement, GroovyBundle.message("continue.outside.loop"));
}
else if (statement instanceof GrBreakStatement) {
if (label == null) {
holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop.or.switch"));
}
else if (findFirstLoop(statement) == null) {
holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop"));
}
else if (statement instanceof GrBreakStatement && label == null) {
holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop.or.switch"));
}
}
if (statement instanceof GrBreakStatement && label != null && findFirstLoop(statement) == null) {
holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop"));
}
}
@Nullable
@@ -19,6 +19,8 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.arguments;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
@@ -55,7 +57,9 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum
}
public PsiReference getReference() {
return this;
PsiReference[] otherReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this, GrArgumentLabel.class);
PsiReference[] thisReference = {this};
return new PsiMultiReference(otherReferences.length == 0 ? thisReference : ArrayUtil.mergeArrays(thisReference, otherReferences, PsiReference.class), this);
}
public String getName() {
@@ -166,6 +170,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum
}
@NotNull
public Object[] getVariants() {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
@@ -241,8 +241,8 @@ public class ResolveUtil {
do {
PsiElement last = element;
element = element.getParent();
if (element == null || element instanceof GrMember || element instanceof GrClosableBlock || element instanceof GroovyFile) break;
if (element instanceof GrStatement) {
if (element == null || element instanceof GrMember || element instanceof GroovyFile) break;
if (element instanceof GrStatement && !(element instanceof GrClosableBlock)) {
statement = (GrStatement)element;
}
PsiElement sibling = element;
@@ -253,6 +253,7 @@ public class ResolveUtil {
}
sibling = sibling.getPrevSibling();
}
if (element instanceof GrClosableBlock) break;
}
while (true);
return new Pair<GrStatement, GrLabeledStatement>(null, null);
@@ -21,9 +21,11 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiReference;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
import java.io.File;
import java.io.IOException;
/**
* @author ven
@@ -39,7 +41,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase {
}
}
protected PsiReference configureByFile(@NonNls String filePath) throws Exception{
protected PsiReference configureByFile(@NonNls String filePath, @Nullable String newFilePath) throws IOException {
filePath = StringUtil.trimStart(filePath, getTestName(true) + "/");
final VirtualFile vFile = myFixture.getTempDirFixture().getFile(filePath);
assertNotNull("file " + filePath + " not found", vFile);
@@ -50,11 +52,20 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase {
assertTrue(offset >= 0);
fileText = fileText.substring(0, offset) + fileText.substring(offset + MARKER.length());
myFixture.configureByText(vFile.getFileType(), fileText);
if (newFilePath == null) {
myFixture.configureByText(vFile.getName(), fileText);
}
else {
myFixture.configureByText(newFilePath, fileText);
}
PsiReference ref = myFixture.getFile().findReferenceAt(offset);
assertNotNull(ref);
return ref;
}
protected PsiReference configureByFile(@NonNls String filePath) throws Exception {
return configureByFile(filePath, null);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ oo:
for (s in ['a', 'b']) {
oo1:
for (s1 in ['a', 'b']) {
<error descr="Label 'oo' is already in use">oo</error>:
<warning descr="Label 'oo' is already in use">oo</warning>:
for (s2 in ['a', 'b']) {
}
}
@@ -19,9 +19,6 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.LocalQuickFixProvider;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.io.FileUtil;
@@ -134,7 +131,7 @@ public class MavenModulePsiReference extends MavenPsiReference implements LocalQ
myWithParent ? id : null);
}
catch (IOException e) {
Notifications.Bus.notify(new Notification("Maven", "Cannot create a module", e.getMessage(), NotificationType.ERROR), project);
MavenUtil.showError(project, "Cannot create a module", e);
}
}
@@ -18,6 +18,9 @@ package org.jetbrains.idea.maven.execution;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.openapi.module.Module;
@@ -69,6 +72,18 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat
return MavenExternalParameters
.createJavaParameters(mySettings.myRunnerParameters, mySettings.myGeneralSettings, mySettings.myRunnerSettings);
}
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
OSProcessHandler result = super.startProcess();
result.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
updateProjectsFolders();
}
});
return result;
}
};
state.setConsoleBuilder(MavenConsoleImpl.createConsoleBuilder(getProject()));
return state;
@@ -81,6 +96,10 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat
}
}
private void updateProjectsFolders() {
MavenProjectsManager.getInstance(getProject()).updateProjectTargetFolders();
}
@NotNull
public Module[] getModules() {
return Module.EMPTY_ARRAY;
@@ -125,7 +144,7 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat
if (mySettings.myGeneralSettings == null) mySettings.myGeneralSettings = new MavenGeneralSettings();
if (mySettings.myRunnerSettings == null) mySettings.myRunnerSettings = new MavenRunnerSettings();
if (mySettings.myRunnerParameters == null) mySettings.myRunnerParameters = new MavenRunnerParameters();
if (mySettings.myRunnerParameters == null) mySettings.myRunnerParameters = new MavenRunnerParameters();
}
}
@@ -158,8 +177,7 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat
}
public MavenSettings(Project project) {
this(MavenProjectsManager.getInstance(project).getGeneralSettings(),
MavenRunner.getInstance(project).getState(),
this(MavenProjectsManager.getInstance(project).getGeneralSettings(), MavenRunner.getInstance(project).getState(),
new MavenRunnerParameters());
}
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.maven.execution;
import com.intellij.compiler.options.CompileStepBeforeRun;
import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationTypeUtil;
@@ -31,12 +32,13 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.compiler.options.CompileStepBeforeRun;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.utils.MavenUtil;
import javax.swing.*;
import java.util.List;
@@ -143,7 +145,7 @@ public class MavenRunConfigurationType implements LocatableConfigurationType {
public RunnerAndConfigurationSettings createConfigurationByLocation(Location l) {
final MavenRunnerParameters params = createBuildParameters(l);
if (params == null) return null;
return createRunnerAndConfigurationSettings(null, null, params, l.getProject(), false);
return createRunnerAndConfigurationSettings(null, null, params, l.getProject());
}
public boolean isConfigurationByLocation(RunConfiguration configuration, Location location) {
@@ -161,24 +163,42 @@ public class MavenRunConfigurationType implements LocatableConfigurationType {
return new MavenRunnerParameters(true, f.getParent().getPath(), goals, profiles);
}
public static void runConfiguration(Project project, MavenRunnerParameters params, DataContext dataContext) throws ExecutionException {
doRunConfiguration(dataContext, createRunnerAndConfigurationSettings(MavenProjectsManager.getInstance(project).getGeneralSettings(),
MavenRunner.getInstance(project).getState(),
params,
project,
true));
public static void runConfiguration(Project project,
MavenRunnerParameters params,
DataContext dataContext,
@Nullable ProgramRunner.Callback callback) {
MavenGeneralSettings settings = MavenProjectsManager.getInstance(project).getGeneralSettings();
MavenRunnerSettings runnerSettings = MavenRunner.getInstance(project).getState();
runConfiguration(project, params, settings, runnerSettings, dataContext, callback);
}
private static void doRunConfiguration(DataContext dataContext, RunnerAndConfigurationSettings settings) throws ExecutionException {
public static void runConfiguration(Project project,
MavenRunnerParameters params,
MavenGeneralSettings settings,
MavenRunnerSettings runnerSettings,
DataContext context,
@Nullable ProgramRunner.Callback callback) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(settings,
runnerSettings,
params,
project);
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID);
runner.execute(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironment(runner, settings, dataContext));
ExecutionEnvironment env = new ExecutionEnvironment(runner, configSettings, context);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
try {
runner.execute(executor, env, callback);
}
catch (ExecutionException e) {
MavenUtil.showError(project, "Failed to execute Maven goal", e);
}
}
private static RunnerAndConfigurationSettings createRunnerAndConfigurationSettings(MavenGeneralSettings generalSettings,
MavenRunnerSettings runnerSettings,
MavenRunnerParameters params,
Project project,
boolean diableMakeBeforeRun) {
Project project) {
MavenRunConfigurationType type = ConfigurationTypeUtil.findConfigurationType(MavenRunConfigurationType.class);
final RunnerAndConfigurationSettingsImpl settings = RunManagerEx.getInstanceEx(project)
@@ -188,12 +208,6 @@ public class MavenRunConfigurationType implements LocatableConfigurationType {
if (generalSettings != null) runConfiguration.setGeneralSettings(generalSettings);
if (runnerSettings != null) runConfiguration.setRunnerSettings(runnerSettings);
if (diableMakeBeforeRun) disableMakeBeforeRun(RunManager.getInstance(project), runConfiguration);
return settings;
}
private static void disableMakeBeforeRun(RunManager runManager, MavenRunConfiguration runConfiguration) {
//((RunManagerEx)runManager).getBeforeRunTask(runConfiguration, CompileStepBeforeRun.ID).setEnabled(false);
}
}
@@ -62,10 +62,6 @@ public class MavenRunner extends SimpleProjectComponent implements PersistentSta
mySettings = settings;
}
public void run(MavenRunnerParameters parameters, MavenRunnerSettings settings) {
run(parameters, settings, null);
}
public void run(final MavenRunnerParameters parameters, final MavenRunnerSettings settings, final Runnable onComplete) {
FileDocumentManager.getInstance().saveAllDocuments();
@@ -21,7 +21,6 @@ import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ProjectRootManager;
import org.jetbrains.idea.maven.importing.MavenImporter;
import org.jetbrains.idea.maven.project.MavenImportingSettings;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
@@ -15,9 +15,6 @@
*/
package org.jetbrains.idea.maven.project.actions;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.Result;
@@ -84,7 +81,7 @@ public abstract class MavenOpenOrCreateFilesAction extends MavenAction {
MavenUtil.runFileTemplate(project, newFile, getFileTemplate());
}
catch (IOException ex) {
Notifications.Bus.notify(new Notification("Maven", "Cannot create " + file.getName(), ex.getMessage(), NotificationType.ERROR), project);
MavenUtil.showError(project, "Cannot create " + file.getName(), ex);
}
}
}.execute();
@@ -15,15 +15,13 @@
*/
package org.jetbrains.idea.maven.project.actions;
import com.intellij.execution.ExecutionException;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.utils.MavenDataKeys;
import org.jetbrains.idea.maven.utils.actions.MavenAction;
import org.jetbrains.idea.maven.utils.actions.MavenActionUtil;
import org.jetbrains.idea.maven.utils.MavenDataKeys;
import org.jetbrains.idea.maven.utils.MavenLog;
import org.jetbrains.idea.maven.project.MavenProject;
import java.util.List;
@@ -47,14 +45,9 @@ public class RunBuildAction extends MavenAction {
if (!perform) return true;
try {
MavenRunnerParameters params = new MavenRunnerParameters(
true, project.getDirectory(), goals, MavenActionUtil.getProjectsManager(e).getActiveProfiles());
MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext());
}
catch (ExecutionException ex) {
MavenLog.LOG.warn(ex);
}
MavenRunnerParameters params = new MavenRunnerParameters(
true, project.getDirectory(), goals, MavenActionUtil.getProjectsManager(e).getActiveProfiles());
MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext(), null);
return true;
}
@@ -15,7 +15,6 @@
*/
package org.jetbrains.idea.maven.tasks;
import com.intellij.execution.ExecutionException;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
@@ -28,17 +27,16 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.idea.maven.embedder.MavenEmbedderFactory;
import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.project.MavenPlugin;
import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.utils.MavenArtifactUtil;
import org.jetbrains.idea.maven.utils.MavenIcons;
import org.jetbrains.idea.maven.utils.MavenPluginInfo;
import org.jetbrains.idea.maven.utils.actions.MavenAction;
import org.jetbrains.idea.maven.utils.actions.MavenActionUtil;
import org.jetbrains.idea.maven.utils.MavenArtifactUtil;
import org.jetbrains.idea.maven.utils.MavenLog;
import org.jetbrains.idea.maven.utils.MavenPluginInfo;
import org.jetbrains.idea.maven.utils.MavenIcons;
import java.io.File;
import java.util.*;
@@ -184,16 +182,11 @@ public class MavenKeymapExtension implements KeymapExtension {
}
public void actionPerformed(AnActionEvent e) {
try {
MavenRunnerParameters params = new MavenRunnerParameters(true,
myMavenProject.getDirectory(),
Arrays.asList(myGoal),
MavenActionUtil.getProjectsManager(e).getActiveProfiles());
MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext());
}
catch (ExecutionException ex) {
MavenLog.LOG.warn(ex);
}
MavenRunnerParameters params = new MavenRunnerParameters(true,
myMavenProject.getDirectory(),
Arrays.asList(myGoal),
MavenActionUtil.getProjectsManager(e).getActiveProfiles());
MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext(), null);
}
public MavenProject getMavenProject() {
@@ -19,6 +19,9 @@ import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.TemplateImpl;
import com.intellij.ide.fileTemplates.FileTemplate;
import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.PathManager;
@@ -150,6 +153,11 @@ public class MavenUtil {
return LaterInvocator.isInModalContext();
}
public static void showError(Project project, String title, Throwable e) {
MavenLog.LOG.error(e);
Notifications.Bus.notify(new Notification("Maven", title, e.getMessage(), NotificationType.ERROR), project);
}
public static Properties getSystemProperties() {
Properties result = (Properties)System.getProperties().clone();
for (String each : new THashSet<String>((Set)result.keySet())) {
@@ -15,14 +15,16 @@
*/
package org.jetbrains.idea.maven.wizards;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.DataManager;
import com.intellij.ide.util.EditorHelper;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import com.intellij.ide.util.projectWizard.SourcePathsBuilder;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.notification.Notifications;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
@@ -46,6 +48,7 @@ import com.intellij.psi.xml.XmlElement;
import org.jetbrains.idea.maven.dom.MavenDomUtil;
import org.jetbrains.idea.maven.dom.model.MavenDomModule;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
import org.jetbrains.idea.maven.execution.MavenRunConfigurationType;
import org.jetbrains.idea.maven.execution.MavenRunner;
import org.jetbrains.idea.maven.execution.MavenRunnerParameters;
import org.jetbrains.idea.maven.execution.MavenRunnerSettings;
@@ -107,9 +110,7 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
result.setResult(file);
}
catch (IOException e) {
MavenLog.LOG.warn(e);
Notifications.Bus.notify(new Notification("Maven", "Cannot create " + MavenConstants.POM_XML + " " + root.getPath(),
e.getMessage(), NotificationType.ERROR), project);
showError(project, e);
return;
}
@@ -185,7 +186,7 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
workingDir.deleteOnExit();
}
catch (IOException e) {
MavenLog.LOG.warn("Cannot generate archetype", e);
showError(project, e);
return;
}
@@ -208,24 +209,32 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
runner.run(params, settings, new Runnable() {
public void run() {
try {
FileUtil.copyDir(new File(workingDir, myProjectId.getArtifactId()), new File(myContentRootPath));
}
catch (IOException e) {
MavenLog.LOG.warn("Cannot generate archetype", e);
return;
}
FileUtil.delete(workingDir);
pom.refresh(false, false);
updateProjectPom(project, pom);
LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
copyGeneratedFiles(workingDir, pom, project);
}
});
}
private void copyGeneratedFiles(File workingDir, VirtualFile pom, Project project) {
try {
FileUtil.copyDir(new File(workingDir, myProjectId.getArtifactId()), new File(myContentRootPath));
}
catch (IOException e) {
showError(project, e);
return;
}
FileUtil.delete(workingDir);
pom.refresh(false, false);
updateProjectPom(project, pom);
LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
}
private void showError(Project project, Throwable e) {
MavenUtil.showError(project, "Failed to create a Maven project", e);
}
@Override
public String getBuilderId() {
return getClass().getName();
@@ -77,11 +77,15 @@ public abstract class MavenTestCase extends UsefulTestCase {
MavenWorkspaceSettingsComponent.getInstance(myProject).loadState(new MavenWorkspaceSettings());
String home = getTestMavenHome();
if (home != null) {
getMavenGeneralSettings().setMavenHome(home);
}
restoreSettingsFile();
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
try {
setUpInWriteAction();
}
@@ -153,11 +157,20 @@ public abstract class MavenTestCase extends UsefulTestCase {
@Override
protected void runTest() throws Throwable {
new WriteAction() {
protected void run(Result result) throws Throwable {
MavenTestCase.super.runTest();
}
}.executeSilently().throwException();
if (runInWriteAction()) {
new WriteAction() {
protected void run(Result result) throws Throwable {
MavenTestCase.super.runTest();
}
}.executeSilently().throwException();
}
else {
MavenTestCase.super.runTest();
}
}
protected boolean runInWriteAction() {
return true;
}
protected MavenGeneralSettings getMavenGeneralSettings() {
@@ -409,8 +422,12 @@ public abstract class MavenTestCase extends UsefulTestCase {
}
protected boolean hasMavenInstallation() {
boolean result = "true".equals(System.getProperty("idea.maven.test.has.installation"));
boolean result = getTestMavenHome() != null;
if (!result) System.out.println("Ignored, because Maven installation not found: " + getClass().getSimpleName() + "." + getName());
return result;
}
private String getTestMavenHome() {
return System.getProperty("idea.maven.test.home");
}
}
@@ -0,0 +1,116 @@
/*
* Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.testFramework.MapDataContext;
import com.intellij.util.concurrency.Semaphore;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import java.io.File;
import java.util.Arrays;
@SuppressWarnings({"ConstantConditions"})
public class MavenExecutionTest extends MavenImportingTestCase {
@Override
protected boolean runInWriteAction() {
return false;
}
public void testExternalExecutor() throws Exception {
if (!hasMavenInstallation()) return;
VfsUtil.saveText(createProjectSubFile("src/main/java/A.java"), "public class A {}");
new WriteAction<Object>() {
@Override
protected void run(Result<Object> objectResult) throws Throwable {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
}
}.execute();
assertFalse(new File(getProjectPath(), "target").exists());
execute(new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null));
assertTrue(new File(getProjectPath(), "target").exists());
}
public void testUpdatingExcludedFoldersAfterExecution() throws Exception {
if (!hasMavenInstallation()) return;
new WriteAction<Object>() {
@Override
protected void run(Result<Object> objectResult) throws Throwable {
createStdProjectFolders();
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
createProjectSubDirs("target/generated-sources/foo",
"target/bar");
}
}.execute();
assertModules("project");
assertExcludes("project", "target");
MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null);
execute(params);
assertSources("project",
"src/main/java",
"src/main/resources",
"target/generated-sources/foo");
assertExcludes("project",
"target/bar",
"target/classes",
"target/classes"); // output dirs are collected twice for exclusion and for compiler output
}
private void execute(MavenRunnerParameters params) {
final Semaphore sema = new Semaphore();
sema.down();
MapDataContext context = new MapDataContext();
context.put(PlatformDataKeys.PROJECT, myProject);
MavenRunConfigurationType.runConfiguration(myProject, params, getMavenGeneralSettings(),
new MavenRunnerSettings(),
context, new ProgramRunner.Callback() {
public void processStarted(final RunContentDescriptor descriptor) {
descriptor.getProcessHandler().addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
sema.up();
descriptor.dispose();
}
});
}
});
sema.waitFor();
}
}
@@ -1,48 +0,0 @@
/*
* Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.vfs.VfsUtil;
import org.jetbrains.idea.maven.MavenTestCase;
import java.io.File;
import java.util.Arrays;
public class MavenExecutorsTest extends MavenTestCase {
public void testExternalExecutor() throws Exception {
if (!hasMavenInstallation()) return;
VfsUtil.saveText(createProjectSubFile("src/main/java/A.java"), "public class A {}");
createProjectPom("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
assertFalse(new File(getProjectPath(), "target").exists());
MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null);
MavenRunnerSettings settings = new MavenRunnerSettings();
MavenExecutor e;
settings.setJreName(MavenRunnerSettings.USE_INTERNAL_JAVA);
e = new MavenExternalExecutor(params, getMavenGeneralSettings(), settings, NULL_MAVEN_CONSOLE);
assertTrue(e.execute(new EmptyProgressIndicator()));
assertTrue(new File(getProjectPath(), "target").exists());
}
}
@@ -1,53 +0,0 @@
/*
* Copyright 2000-2009 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 org.jetbrains.idea.maven.execution;
import org.jetbrains.idea.maven.MavenImportingTestCase;
import java.util.Arrays;
public class MavenRunnerTest extends MavenImportingTestCase {
public void testUpdatingExcludedFoldersAfterRun() throws Exception {
if (!hasMavenInstallation()) return;
createStdProjectFolders();
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
assertModules("project");
assertExcludes("project", "target");
createProjectSubDirs("target/generated-sources/foo",
"target/bar");
MavenRunner runner = new MavenRunner(myProject);
MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null);
MavenRunnerSettings settings = new MavenRunnerSettings();
runner.run(params, settings);
assertSources("project",
"src/main/java",
"src/main/resources",
"target/generated-sources/foo");
assertExcludes("project",
"target/bar",
"target/classes",
"target/classes"); // output dirs are collected twice for exclusion and for compiler output
}
}
@@ -321,6 +321,10 @@ public final class PreviewFormAction extends AnAction{
myStatusbarMessage = statusbarMessage;
}
public Icon getIcon() {
return null;
}
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
final JavaCommandLineState state = new JavaCommandLineState(env) {
protected JavaParameters createJavaParameters() {
@@ -184,3 +184,4 @@ loading.ant.config.progress=Loading ant configuration...
intention.configure.highlighting.family.name=Configure highlighting
intention.configure.highlighting.text=Configure highlighting
build.file.properties.maximum.stack.size.label=Maximum &stack size (Mb):
run.execution.tab.ant.command.line.hint=Use "-J" prefix to specify JVM arguments