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

This commit is contained in:
Kirill Kalishev
2009-12-03 15:54:59 +03:00
60 changed files with 896 additions and 631 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
# path to IDEA config folder
idea.config.path=${idea.home}/config
idea.config.path=${user.home}/.IdeaIC90/config
# path to IDEA system folder
idea.system.path=${idea.home}/system
idea.system.path=${user.home}/.IdeaIC90/system
# path to user installed plugins folder
idea.plugins.path=${idea.home}/config/plugins
idea.plugins.path=${user.home}/.IdeaIC90/config/plugins
#---------------------------------------------------------------------
# Maximum file size (kilobytes) IDEA should provide intellisense for.
@@ -65,7 +65,9 @@ public class PaletteManager implements ProjectComponent {
myPaletteWindow = new PaletteWindow(myProject);
myPaletteToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(IdeBundle.message("toolwindow.palette"),
myPaletteWindow,
ToolWindowAnchor.RIGHT);
ToolWindowAnchor.RIGHT,
myProject,
true);
myPaletteToolWindow.setIcon(IconLoader.getIcon("/general/toolWindowPalette.png"));
myPaletteToolWindow.setAvailable(false, null);
final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener();
@@ -75,10 +77,6 @@ public class PaletteManager implements ProjectComponent {
}
public void projectClosed() {
if (myPaletteWindow != null) {
ToolWindowManager.getInstance(myProject).unregisterToolWindow(IdeBundle.message("toolwindow.palette"));
myPaletteWindow = null;
}
}
@NotNull
@@ -896,7 +896,7 @@ public class ClasspathPanel extends JPanel {
if (columnIndex == EXPORT_COLUMN) {
item.setExported(((Boolean)aValue).booleanValue());
}
else if (columnIndex == SCOPE_COLUMN) {
else if (columnIndex == SCOPE_COLUMN && aValue instanceof DependencyScope) {
item.setScope((DependencyScope) aValue);
}
}
@@ -24,7 +24,7 @@ import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.actions.OptimizeImportsProcessor;
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInsight.hint.PriorityQuestionAction;
import com.intellij.codeInsight.hint.QuestionAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
@@ -52,7 +52,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AddImportAction implements PriorityQuestionAction {
public class AddImportAction implements QuestionAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.actions.AddImportAction");
private final Project myProject;
@@ -246,8 +246,4 @@ public class AddImportAction implements PriorityQuestionAction {
protected void bindReference(PsiReference ref, PsiClass targetClass) {
ref.bindToElement(targetClass);
}
public int getPriority() {
return 10;
}
}
@@ -49,6 +49,7 @@ import com.intellij.util.IncorrectOperationException;
import com.intellij.util.VisibilityUtil;
import com.intellij.util.ui.Table;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
@@ -132,6 +133,7 @@ public class ChangeSignatureDialog extends RefactoringDialog {
}
}
@Nullable
private CanonicalTypes.Type getReturnType() {
if (myReturnTypeField != null) {
try {
@@ -220,16 +222,6 @@ public class ChangeSignatureDialog extends RefactoringDialog {
namePrompt.setText(RefactoringBundle.message("name.prompt"));
panel.add(namePrompt);
panel.add(myNameField);
JLabel typePrompt = new JLabel();
panel.add(typePrompt);
final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
myReturnTypeCodeFragment = factory.createTypeCodeFragment(myMethod.getReturnTypeElement().getText(), myMethod.getParameterList(), true, true);
final Document document = PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment);
myReturnTypeField = new EditorTextField(document, myProject, StdFileTypes.JAVA);
typePrompt.setText(RefactoringBundle.message("changeSignature.return.type.prompt"));
panel.add(myReturnTypeField);
final DocumentListener documentListener = new DocumentListener() {
public void beforeDocumentChange(DocumentEvent event) {
}
@@ -238,8 +230,21 @@ public class ChangeSignatureDialog extends RefactoringDialog {
updateSignature();
}
};
myNameField.addDocumentListener(documentListener);
JLabel typePrompt = new JLabel();
panel.add(typePrompt);
final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory();
final PsiTypeElement typeElement = myMethod.getReturnTypeElement();
if (typeElement == null) {
LOG.assertTrue(false, myMethod.getClass().getName());
return panel;
}
myReturnTypeCodeFragment = factory.createTypeCodeFragment(typeElement.getText(), myMethod.getParameterList(), true, true);
final Document document = PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment);
myReturnTypeField = new EditorTextField(document, myProject, StdFileTypes.JAVA);
typePrompt.setText(RefactoringBundle.message("changeSignature.return.type.prompt"));
panel.add(myReturnTypeField);
myReturnTypeField.addDocumentListener(documentListener);
}
@@ -260,8 +265,8 @@ public class ChangeSignatureDialog extends RefactoringDialog {
JPanel subPanel = new JPanel(new BorderLayout());
subPanel.add(createParametersPanel(), BorderLayout.CENTER);
if (myMethod.getContainingClass() != null
&& !myMethod.getContainingClass().isInterface()) {
final PsiClass containingClass = myMethod.getContainingClass();
if (containingClass != null && !containingClass.isInterface()) {
myVisibilityPanel = new VisibilityPanel(false, false);
myVisibilityPanel.setVisibility(VisibilityUtil.getVisibilityModifier(myMethod.getModifierList()));
myVisibilityPanel.addStateChangedListener(new VisibilityPanel.StateChanged() {
@@ -88,7 +88,7 @@ public class ExtractMethodHandler implements RefactoringActionHandler {
IntroduceVariableBase.showChooser(editor, expressions, new Pass<PsiExpression>() {
@Override
public void pass(PsiExpression psiExpression) {
callback.pass(new PsiExpression[]{psiExpression});
callback.pass(new PsiElement[]{psiExpression});
}
});
return;
@@ -334,11 +334,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
tempExpr.putUserData(ElementToWorkOn.PARENT, parent);
final String fakeInitializer = "intellijidearulezzz";
final PsiExpression toBeExpression = createReplacement(fakeInitializer, project, prefix, suffix, parent, rangeMarker);
final int[] refIdx = new int[1];
final PsiExpression toBeExpression = createReplacement(fakeInitializer, project, prefix, suffix, parent, rangeMarker, refIdx);
toBeExpression.accept(errorsVisitor);
if (hasErrors[0]) return null;
final PsiReferenceExpression refExpr = PsiTreeUtil.getParentOfType(toBeExpression.findElementAt(toBeExpression.getText().indexOf(fakeInitializer)), PsiReferenceExpression.class);
final PsiReferenceExpression refExpr = PsiTreeUtil.getParentOfType(toBeExpression.findElementAt(refIdx[0]), PsiReferenceExpression.class);
assert refExpr != null;
if (ReplaceExpressionUtil.isNeedParenthesis(refExpr.getNode(), tempExpr.getNode())) {
return null;
@@ -602,14 +603,14 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
final PsiElement parent = expr1.getUserData(ElementToWorkOn.PARENT);
final RangeMarker rangeMarker = expr1.getUserData(ElementToWorkOn.TEXT_RANGE);
return parent.replace(createReplacement(ref.getText(), project, prefix, suffix, parent, rangeMarker));
return parent.replace(createReplacement(ref.getText(), project, prefix, suffix, parent, rangeMarker, new int[1]));
}
}
private static PsiExpression createReplacement(final String refText, final Project project,
final String prefix,
final String suffix,
final PsiElement parent, final RangeMarker rangeMarker) {
final PsiElement parent, final RangeMarker rangeMarker, int[] refIdx) {
final String allText = parent.getContainingFile().getText();
final TextRange parentRange = parent.getTextRange();
@@ -619,7 +620,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme
String end = allText.substring(rangeMarker.getEndOffset(), parentRange.getEndOffset());
if (StringUtil.stripQuotesAroundValue(end).trim().length() == 0 && suffix == null) end = "";
final String text = beg + (prefix != null ? prefix : "") + refText + (suffix != null ? suffix : "") + end;
final String start = beg + (prefix != null ? prefix : "");
refIdx[0] = start.length();
final String text = start + refText + (suffix != null ? suffix : "") + end;
return JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(text, parent);
}
@@ -0,0 +1,6 @@
class A {
public void test() {
String str = "sintellijidearulezzzs";
String s = "intellijidearulezzz" + str + "sintellijidearulezzz";
}
}
@@ -0,0 +1,5 @@
class A {
public void test() {
String s = "intellijidearulezzz<selection>sintellijidearulezzzs</selection>sintellijidearulezzz";
}
}
@@ -174,6 +174,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
}
public void testSubExpressionFromIntellijidearulezzz() throws Exception {
doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
}
public void testSubPrimitiveLiteral() throws Exception {
doTest(new MockIntroduceVariableHandler("str", false, false, false, "boolean"));
}
@@ -42,7 +42,7 @@ public abstract class IntentionManager {
*/
@Deprecated
public static IntentionManager getInstance(Project project) {
return ServiceManager.getService(IntentionManager.class);
return getInstance();
}
public static IntentionManager getInstance() {
@@ -54,15 +54,25 @@ public abstract class IntentionManager {
*
* @param action the intention action to register.
*/
public abstract void addAction(IntentionAction action);
public abstract void addAction(@NotNull IntentionAction action);
/**
* Returns all registered intention actions.
*
* @return array of registered actions.
*/
@NotNull
public abstract IntentionAction[] getIntentionActions();
/**
* Returns all registered intention actions which are available now
* (not disabled via Settings|Intentions or Alt-Enter|Disable intention quick fix)
*
* @return array of actions.
*/
@NotNull
public abstract IntentionAction[] getAvailableIntentionActions();
/**
* Registers an intention action which can be enabled or disabled through the "Intention
* Settings" dialog. To provide the description and the example code for the intention,
@@ -79,25 +89,32 @@ public abstract class IntentionManager {
* @param category the name of the category or categories under which the intention will be shown
* in the "Intention Settings" dialog.
*/
public abstract void registerIntentionAndMetaData(IntentionAction action, String... category);
public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action, @NotNull String... category);
/**
* @deprecated custom directory name causes problem with internationalization of inspection descriptions.
* @deprecated custom directory name causes problem with internationalization of intention descriptions.
* Register intention class via extension point {@link IntentionManager.EP_INTENTION_ACTIONS} instead.
*/
@Deprecated
public abstract void registerIntentionAndMetaData(IntentionAction action, String[] category, String descriptionDirectoryName);
public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action,
@NotNull String[] category,
@NotNull String descriptionDirectoryName);
public abstract void registerIntentionAndMetaData(IntentionAction action, String[] category,
String description, String exampleFileExtension,
String[] exampleTextBefore, String[] exampleTextAfter);
public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action,
@NotNull String[] category,
@NotNull String description,
@NotNull String exampleFileExtension,
@NotNull String[] exampleTextBefore,
@NotNull String[] exampleTextAfter);
public abstract void unregisterIntention(IntentionAction intentionAction);
public abstract void unregisterIntention(@NotNull IntentionAction intentionAction);
/**
* @return actions used as additional options for the given problem.
* E.g. actions for suppress the problem via comment, javadoc or annotation,
* and edit corresponding inspection settings.
*/
@NotNull
public abstract List<IntentionAction> getStandardIntentionOptions(@NotNull HighlightDisplayKey displayKey, @NotNull PsiElement context);
/**
@@ -105,5 +122,6 @@ public abstract class IntentionManager {
* @param action action to convert.
* @return quick fix instance.
*/
public abstract LocalQuickFix convertToFix(IntentionAction action);
@NotNull
public abstract LocalQuickFix convertToFix(@NotNull IntentionAction action);
}
@@ -190,7 +190,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
int offset = editor.getCaretModel().getOffset();
Project project = psiFile.getProject();
for (IntentionAction action : IntentionManager.getInstance().getIntentionActions()) {
for (IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) {
Pair<PsiFile,Editor> place = ShowIntentionActionsHandler.availableFor(psiFile, editor, action, psiElement);
if (place != null) {
List<IntentionAction> enableDisableIntentionAction = new ArrayList<IntentionAction>();
@@ -156,6 +156,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
myComponentHint.setShouldDelay(delay);
HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
PriorityQuestionAction action = new PriorityQuestionAction() {
public boolean execute() {
showPopup();
@@ -163,7 +164,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
}
public int getPriority() {
return 0;
return -10;
}
};
if (hintManager.canShowQuestionAction(action)) {
@@ -26,23 +26,23 @@ import com.intellij.codeInspection.actions.RunInspectionIntention;
import com.intellij.codeInspection.ex.DisableInspectionToolAction;
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsInSuppressedPlaceIntention;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.ExtensionPointListener;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.Alarm;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -51,7 +51,7 @@ import java.util.List;
public class IntentionManagerImpl extends IntentionManager {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.config.IntentionManagerImpl");
private final List<IntentionAction> myActions = Collections.synchronizedList(new ArrayList<IntentionAction>());
private final List<IntentionAction> myActions = ContainerUtil.createEmptyCOWList();
private final IntentionManagerSettings mySettings;
private final Alarm myInitActionsAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD);
@@ -108,7 +108,7 @@ public class IntentionManagerImpl extends IntentionManager {
return new IntentionActionWrapper(intentionActionBean,categories);
}
public void registerIntentionAndMetaData(IntentionAction action, String... category) {
public void registerIntentionAndMetaData(@NotNull IntentionAction action, @NotNull String... category) {
registerIntentionAndMetaData(action, category, getDescriptionDirectoryName(action));
}
@@ -132,12 +132,12 @@ public class IntentionManagerImpl extends IntentionManager {
mySettings.registerIntentionMetaData(action, category, descriptionDirectoryName);
}
public void registerIntentionAndMetaData(final IntentionAction action,
final String[] category,
final String description,
final String exampleFileExtension,
final String[] exampleTextBefore,
final String[] exampleTextAfter) {
public void registerIntentionAndMetaData(@NotNull final IntentionAction action,
@NotNull final String[] category,
@NotNull final String description,
@NotNull final String exampleFileExtension,
@NotNull final String[] exampleTextBefore,
@NotNull final String[] exampleTextAfter) {
addAction(action);
IntentionActionMetaData metaData = new IntentionActionMetaData(action, category,
@@ -148,19 +148,20 @@ public class IntentionManagerImpl extends IntentionManager {
}
@Override
public void unregisterIntention(IntentionAction intentionAction) {
public void unregisterIntention(@NotNull IntentionAction intentionAction) {
myActions.remove(intentionAction);
mySettings.unregisterMetaData(intentionAction);
}
private static TextDescriptor[] mapToDescriptors(String[] texts, String fileName) {
private static TextDescriptor[] mapToDescriptors(String[] texts, @NonNls String fileName) {
TextDescriptor[] result = new TextDescriptor[texts.length];
for (int i = 0; i < texts.length; i++) {
result [i] = new PlainTextDescriptor(texts [i], fileName);
result [i] = new PlainTextDescriptor(texts[i], fileName);
}
return result;
}
@NotNull
public List<IntentionAction> getStandardIntentionOptions(@NotNull final HighlightDisplayKey displayKey, @NotNull final PsiElement context) {
List<IntentionAction> options = new ArrayList<IntentionAction>(9);
options.add(new EditInspectionToolsSettingsAction(displayKey));
@@ -169,7 +170,8 @@ public class IntentionManagerImpl extends IntentionManager {
return options;
}
public LocalQuickFix convertToFix(final IntentionAction action) {
@NotNull
public LocalQuickFix convertToFix(@NotNull final IntentionAction action) {
if (action instanceof LocalQuickFix) {
return (LocalQuickFix)action;
}
@@ -196,12 +198,24 @@ public class IntentionManagerImpl extends IntentionManager {
};
}
public void addAction(IntentionAction action) {
public void addAction(@NotNull IntentionAction action) {
myActions.add(action);
}
@NotNull
public IntentionAction[] getIntentionActions() {
return myActions.toArray(new IntentionAction[myActions.size()]);
}
@NotNull
@Override
public IntentionAction[] getAvailableIntentionActions() {
List<IntentionAction> list = new ArrayList<IntentionAction>(myActions.size());
for (IntentionAction action : myActions) {
if (mySettings.isEnabled(action)) {
list.add(action);
}
}
return list.toArray(new IntentionAction[list.size()]);
}
}
@@ -16,6 +16,9 @@
package com.intellij.codeInsight.intention.impl.config;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
/**
@@ -25,15 +28,17 @@ public class PlainTextDescriptor implements TextDescriptor {
private final String myText;
private final String myFileName;
public PlainTextDescriptor(final String text, final String fileName) {
public PlainTextDescriptor(@NotNull String text, @NonNls @NotNull String fileName) {
myText = text;
myFileName = fileName;
}
@NotNull
public String getText() throws IOException {
return myText;
}
@NotNull
public String getFileName() {
return myFileName;
}
@@ -597,9 +597,9 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo
return getTemplateFromManager(templateName, myJ2eeTemplatesManager);
}
private FileTemplate getTemplateFromManager(@NotNull @NonNls String templateName, @NotNull FileTemplateManagerImpl templatesManager) {
private static FileTemplate getTemplateFromManager(@NotNull @NonNls String templateName, @NotNull FileTemplateManagerImpl templatesManager) {
String name = templateName;
String extension = myTypeManager.getExtension(name);
String extension = templatesManager.myTypeManager.getExtension(name);
if (extension.length() > 0) {
name = name.substring(0, name.length() - extension.length() - 1);
}
@@ -612,24 +612,39 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo
else {
if (ApplicationManager.getApplication().isUnitTestMode() && templateName.endsWith("ForTest")) return null;
String message = templateNotFound(templateName, templatesManager);
String message = templatesManager.templateNotFoundMessage(templateName);
LOG.error(message);
}
return null;
}
private static String templateNotFound(String templateName, FileTemplateManagerImpl templatesManager) {
Collection<VirtualFile> defaultTemplates = templatesManager.getDefaultTemplates();
private String templateNotFoundMessage(String templateName) {
Collection<VirtualFile> defaultTemplates = getDefaultTemplates();
@NonNls String message =
"Unable to find template '" + templateName + "' in " + templatesManager + " in '"+templatesManager.myDefaultTemplatesDir+"'" +
"\n" +
"Default templates are: ";
message += StringUtil.join(defaultTemplates, new Function<VirtualFile, String>() {
"Unable to find template '" + templateName + "' in " + this +
"\n Default templates are: " + toString(defaultTemplates);
message+= "\n Default template dir: '"+ myDefaultTemplatesDir+"'";
for (VirtualFile topDir : getTopTemplatesDir()) {
VirtualFile parentDir = myDefaultTemplatesDir.equals(".") ? topDir : topDir.findChild(myDefaultTemplatesDir);
if (parentDir == null) {
message += "\n No templates in '" + topDir.getPath() + "'";
}
else {
message += "\n " + parentDir.getPath() + ": " + toString(listDir(parentDir));
}
}
message += "\n Deleted templates: " + myDeletedTemplatesManager.DELETED_DEFAULT_TEMPLATES;
return message;
}
private static String toString(Collection<VirtualFile> defaultTemplates) {
return StringUtil.join(defaultTemplates, new Function<VirtualFile, String>() {
public String fun(VirtualFile virtualFile) {
return virtualFile.getPresentableUrl();
}
}, ",");
return message;
}, ", ");
}
@@ -722,7 +737,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo
if (file == null) {
String message = "";
for (FileTemplateManagerImpl child : ArrayUtil.append(myChildren,this)) {
message += templateNotFound(name, child) + "\n";
message += child.templateNotFoundMessage(name) + "\n";
}
LOG.error(message);
return null;
@@ -16,15 +16,16 @@
package com.intellij.ide.structureView.impl;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.project.Project;
import com.intellij.ide.structureView.StructureViewFactory;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
/**
* @author yole
*/
public class StructureViewToolWindowFactory implements ToolWindowFactory {
public class StructureViewToolWindowFactory implements ToolWindowFactory, DumbAware {
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
StructureViewFactoryImpl factory = (StructureViewFactoryImpl)StructureViewFactory.getInstance(project);
factory.initToolWindow(toolWindow);
@@ -21,8 +21,9 @@ import com.intellij.ide.util.treeView.smartTree.TreeAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
public class TreeActionWrapper extends ToggleAction{
public class TreeActionWrapper extends ToggleAction implements DumbAware {
private final TreeAction myAction;
private final TreeActionsOwner myStructureView;
@@ -18,6 +18,7 @@ package com.intellij.refactoring.rename;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -66,11 +67,13 @@ public class RenameHandlerRegistry {
final Map<String, RenameHandler> availableHandlers = new TreeMap<String, RenameHandler>();
for (RenameHandler renameHandler : Extensions.getExtensions(RenameHandler.EP_NAME)) {
if (renameHandler.isRenaming(dataContext)) {
if (ApplicationManager.getApplication().isUnitTestMode()) return renameHandler;
availableHandlers.put(getHandlerTitle(renameHandler), renameHandler);
}
}
for (RenameHandler renameHandler : myHandlers) {
if (renameHandler.isRenaming(dataContext)) {
if (ApplicationManager.getApplication().isUnitTestMode()) return renameHandler;
availableHandlers.put(getHandlerTitle(renameHandler), renameHandler);
}
}
@@ -19,6 +19,7 @@ package com.intellij.ui;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
@@ -42,16 +43,22 @@ public abstract class AutoScrollFromSourceHandler implements Disposable {
public abstract void install();
public ToggleAction createToggleAction() {
return new ToggleAction(UIBundle.message("autoscroll.from.source.action.name"),
UIBundle.message("autoscroll.from.source.action.description"), IconLoader.getIcon("/general/autoscrollFromSource.png")) {
public boolean isSelected(AnActionEvent event) {
return isAutoScrollMode();
}
return new AutoScrollFromSourceAction();
}
public void setSelected(AnActionEvent event, boolean flag) {
setAutoScrollMode(flag);
}
};
private class AutoScrollFromSourceAction extends ToggleAction implements DumbAware {
public AutoScrollFromSourceAction() {
super(UIBundle.message("autoscroll.from.source.action.name"), UIBundle.message("autoscroll.from.source.action.description"),
IconLoader.getIcon("/general/autoscrollFromSource.png"));
}
public boolean isSelected(AnActionEvent event) {
return isAutoScrollMode();
}
public void setSelected(AnActionEvent event, boolean flag) {
setAutoScrollMode(flag);
}
}
}
@@ -67,10 +67,13 @@ public class HintManagerImpl extends HintManager implements Disposable {
private Editor myLastEditor = null;
private final Alarm myHideAlarm = new Alarm();
public boolean canShowQuestionAction(PriorityQuestionAction action) {
private static int getPriority(QuestionAction action) {
return action instanceof PriorityQuestionAction ? ((PriorityQuestionAction)action).getPriority() : 0;
}
public boolean canShowQuestionAction(QuestionAction action) {
ApplicationManager.getApplication().assertIsDispatchThread();
return !(myQuestionAction instanceof PriorityQuestionAction) ||
((PriorityQuestionAction)myQuestionAction).getPriority() <= action.getPriority();
return myQuestionAction == null || getPriority(myQuestionAction) <= getPriority(action);
}
public interface ActionToIgnore {
@@ -244,7 +247,7 @@ public class HintManagerImpl extends HintManager implements Disposable {
hideAllHints();
}
if (!editor.getContentComponent().isShowing()) return;
if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
updateLastEditor(editor);
@@ -338,13 +341,18 @@ public class HintManagerImpl extends HintManager implements Disposable {
}
private static void doShowInGivenLocation(final LightweightHint hint, final Editor editor, final Point p) {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
JLayeredPane layeredPane = editor.getComponent().getRootPane().getLayeredPane();
Dimension size = hint.getComponent().getPreferredSize();
if(layeredPane.getWidth() < p.x + size.width) {
p.x = Math.max(0, layeredPane.getWidth() - size.width);
}
if (!hint.isVisible()) hint.show(layeredPane, p.x, p.y, editor.getContentComponent());
else hint.setLocation(p.x, p.y);
if (hint.isVisible()) {
hint.setLocation(p.x, p.y);
}
else {
hint.show(layeredPane, p.x, p.y, editor.getContentComponent());
}
}
public static void adjustEditorHintPosition(final LightweightHint hint, final Editor editor, final Point p) {
@@ -61,30 +61,13 @@ public class LineTooltipRenderer implements TooltipRenderer {
//setup text
myText = myText.replaceAll(String.valueOf(UIUtil.MNEMONIC), "");
final boolean [] expanded = new boolean[] { myCurrentWidth > 0 && dressDescription(editor)};
final boolean expanded = myCurrentWidth > 0 && dressDescription(editor);
//pane
final JEditorPane pane = initPane(myText);
pane.setCaretPosition(0);
final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
final JComponent contentComponent = editor.getContentComponent();
// This listener makes hint transparent for mouse events. It means that hint is closed
// by MousePressed and this MousePressed goes into the underlying editor component.
pane.addMouseListener(new MouseAdapter() {
public void mouseReleased(final MouseEvent e) {
if (!myActiveLink) {
MouseEvent newMouseEvent = SwingUtilities.convertMouseEvent(e.getComponent(), e, contentComponent);
hintManager.hideAllHints();
contentComponent.dispatchEvent(newMouseEvent);
}
}
public void mouseExited(final MouseEvent e) {
if (!expanded[0]) {
hintManager.hideAllHints();
}
}
});
final JComponent editorComponent = editor.getComponent();
final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
@@ -94,8 +77,8 @@ public class LineTooltipRenderer implements TooltipRenderer {
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
scrollPane.setBorder(null);
int width = expanded[0] ? 3 * myCurrentWidth / 2 : pane.getPreferredSize().width;
int height = expanded[0] ? Math.max(pane.getPreferredSize().height, 150) : pane.getPreferredSize().height;
int width = expanded ? 3 * myCurrentWidth / 2 : pane.getPreferredSize().width;
int height = expanded ? Math.max(pane.getPreferredSize().height, 150) : pane.getPreferredSize().height;
if (alignToRight) {
p.x -= width;
@@ -166,7 +149,7 @@ public class LineTooltipRenderer implements TooltipRenderer {
return;
}
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (!expanded[0]) { // more -> less
if (!expanded) { // more -> less
for (final TooltipLinkHandlerEP handlerEP : Extensions.getExtensions(TooltipLinkHandlerEP.EP_NAME)) {
if (handlerEP.handleLink(e.getDescription(), editor, pane)) {
myText = convertTextOnLinkHandled(myText);
@@ -189,6 +172,25 @@ public class LineTooltipRenderer implements TooltipRenderer {
}
}
});
// This listener makes hint transparent for mouse events. It means that hint is closed
// by MousePressed and this MousePressed goes into the underlying editor component.
pane.addMouseListener(new MouseAdapter() {
public void mouseReleased(final MouseEvent e) {
if (!myActiveLink) {
MouseEvent newMouseEvent = SwingUtilities.convertMouseEvent(e.getComponent(), e, contentComponent);
hint.hide();
contentComponent.dispatchEvent(newMouseEvent);
}
}
public void mouseExited(final MouseEvent e) {
if (!expanded) {
hint.hide();
}
}
});
hintManager.showEditorHint(hint, editor, p,
HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE | HintManagerImpl.HIDE_BY_OTHER_HINT |
HintManagerImpl.HIDE_BY_SCROLLING, 0, false);
@@ -260,9 +262,7 @@ public class LineTooltipRenderer implements TooltipRenderer {
final LineTooltipRenderer lineTooltipRenderer = (LineTooltipRenderer)o;
if (myText != null ? !myText.equals(lineTooltipRenderer.myText) : lineTooltipRenderer.myText != null) return false;
return true;
return myText == null ? lineTooltipRenderer.myText == null : myText.equals(lineTooltipRenderer.myText);
}
public int hashCode() {
@@ -0,0 +1,22 @@
/*
* 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.openapi.command.impl;
import com.intellij.openapi.diagnostic.Logger;
public class CommandLog {
public static final Logger LOG = Logger.getInstance("#" + CommandLog.class.getPackage().getName());
}
@@ -38,8 +38,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
*
*/
public class CommandProcessorImpl extends CommandProcessorEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.command.impl.CommandProcessorImpl");
private static class CommandDescriptor {
public final Runnable myCommand;
public final Project myProject;
@@ -97,8 +95,8 @@ public class CommandProcessorImpl extends CommandProcessorEx {
ApplicationManager.getApplication().assertIsDispatchThread();
if (project != null && project.isDisposed()) return;
if (LOG.isDebugEnabled()) {
LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId);
if (CommandLog.LOG.isDebugEnabled()) {
CommandLog.LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId);
}
if (myCurrentCommand != null) {
@@ -127,8 +125,8 @@ public class CommandProcessorImpl extends CommandProcessorEx {
ApplicationManager.getApplication().assertIsDispatchThread();
if (project != null && project.isDisposed()) return null;
if (LOG.isDebugEnabled()) {
LOG.debug("startCommand: name = " + name + ", groupId = " + groupId);
if (CommandLog.LOG.isDebugEnabled()) {
CommandLog.LOG.debug("startCommand: name = " + name + ", groupId = " + groupId);
}
if (myCurrentCommand != null) {
@@ -143,7 +141,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
public void finishCommand(final Project project, final Object command, final Throwable throwable) {
ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(myCurrentCommand != null, "no current command in progress");
CommandLog.LOG.assertTrue(myCurrentCommand != null, "no current command in progress");
if (myCurrentCommand != command) return;
final boolean failed;
try {
@@ -160,7 +158,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
throw (Error)throwable;
}
else if (throwable instanceof RuntimeException) throw (RuntimeException)throwable;
LOG.error(throwable);
CommandLog.LOG.error(throwable);
}
else {
failed = false;
@@ -194,7 +192,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
listener.beforeCommandFinished(event);
}
catch (Throwable e) {
LOG.error(e);
CommandLog.LOG.error(e);
}
}
}
@@ -205,7 +203,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
listener.commandFinished(event);
}
catch (Throwable e) {
LOG.error(e);
CommandLog.LOG.error(e);
}
}
}
@@ -219,7 +217,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
}
public void leaveModal() {
LOG.assertTrue(myCurrentCommand == null);
CommandLog.LOG.assertTrue(myCurrentCommand == null);
myCurrentCommand = myInterruptedCommands.pop();
if (myCurrentCommand != null) {
fireCommandStarted();
@@ -227,12 +225,12 @@ public class CommandProcessorImpl extends CommandProcessorEx {
}
public void setCurrentCommandName(String name) {
LOG.assertTrue(myCurrentCommand != null);
CommandLog.LOG.assertTrue(myCurrentCommand != null);
myCurrentCommand.myName = name;
}
public void setCurrentCommandGroupId(Object groupId) {
LOG.assertTrue(myCurrentCommand != null);
CommandLog.LOG.assertTrue(myCurrentCommand != null);
myCurrentCommand.myGroupId = groupId;
}
@@ -317,7 +315,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
listener.commandStarted(event);
}
catch (Throwable e) {
LOG.error(e);
CommandLog.LOG.error(e);
}
}
}
@@ -328,7 +326,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
listener.undoTransparentActionStarted();
}
catch (Throwable e) {
LOG.error(e);
CommandLog.LOG.error(e);
}
}
}
@@ -339,7 +337,7 @@ public class CommandProcessorImpl extends CommandProcessorEx {
listener.undoTransparentActionFinished();
}
catch (Throwable e) {
LOG.error(e);
CommandLog.LOG.error(e);
}
}
}
@@ -260,7 +260,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
clearUndoRedoQueue(DocumentReferenceManager.getInstance().create(file));
}
public void compact() {
protected void compact() {
if (myCurrentOperationState == NONE && myCommandTimestamp % COMMAND_TO_RUN_COMPACT == 0) {
doCompact();
}
@@ -314,6 +314,8 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
}
public void undoableActionPerformed(UndoableAction action) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myCurrentOperationState != NONE) return;
if (myCommandLevel == 0) {
@@ -330,6 +332,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
@Override
public void nonundoableActionPerformed(final DocumentReference ref, final boolean isGlobal) {
ApplicationManager.getApplication().assertIsDispatchThread();
undoableActionPerformed(new NonUndoableAction(ref, isGlobal));
}
@@ -342,13 +345,17 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
}
public void undo(@Nullable FileEditor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(isUndoAvailable(editor));
myCurrentOperationState = UNDO;
undoOrRedo(editor);
}
public void redo(@Nullable FileEditor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(isRedoAvailable(editor));
myCurrentOperationState = REDO;
undoOrRedo(editor);
}
@@ -381,12 +388,16 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
}
public boolean isUndoAvailable(@Nullable FileEditor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
Collection<DocumentReference> refs = getDocRefs(editor);
if (refs == null) return false;
return isUndoOrRedoAvailable(refs, true);
}
public boolean isRedoAvailable(@Nullable FileEditor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
Collection<DocumentReference> refs = getDocRefs(editor);
if (refs == null) return false;
return isUndoOrRedoAvailable(refs, false);
@@ -1113,7 +1113,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
target.y = 0;
}
else if (ToolWindowAnchor.BOTTOM == anchor) {
target.y = bounds.height;
target.y = bounds.height - 3;
}
else if (ToolWindowAnchor.LEFT == anchor) {
target.x = 0;
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.popup.BalloonHandler;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.MultiValuesMap;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.components.labels.LinkLabel;
@@ -33,6 +34,7 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.Alarm;
import com.intellij.util.ui.AbstractLayoutManager;
import com.intellij.util.ui.AsyncProcessIcon;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import org.jetbrains.annotations.NotNull;
@@ -87,7 +89,7 @@ public class InfoAndProgressPanel extends JPanel implements StatusBarPatch {
}
}
});
myProgressIcon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
StatusBarTooltipper.install(this, myProgressIcon, statusBar);
@@ -279,9 +281,20 @@ public class InfoAndProgressPanel extends JPanel implements StatusBarPatch {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Component comp = InfoAndProgressPanel.this;
int offset = comp.getHeight() / 2;
Point point = new Point(comp.getWidth() - offset, comp.getHeight() - offset);
balloon.show(new RelativePoint(comp, point), Balloon.Position.above);
if (comp.isShowing()) {
int offset = comp.getHeight() / 2;
Point point = new Point(comp.getWidth() - offset, comp.getHeight() - offset);
balloon.show(new RelativePoint(comp, point), Balloon.Position.above);
} else {
final JRootPane rootPane = SwingUtilities.getRootPane(comp);
if (rootPane != null && rootPane.isShowing()) {
final Container contentPane = rootPane.getContentPane();
final Rectangle bounds = contentPane.getBounds();
final Point target = UIUtil.getCenterPoint(bounds, new Dimension(1, 1));
target.y = bounds.height - 3;
balloon.show(new RelativePoint(contentPane, target), Balloon.Position.above);
}
}
}
});
@@ -226,4 +226,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint {
hide();
}
}
@Override
public String toString() {
return getComponent().toString();
}
}
@@ -83,6 +83,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.cache.impl.todo.TodoIndex;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.resolve.FileContextUtil;
@@ -1082,8 +1083,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@NotNull
public static List<HighlightInfo> instantiateAndRun(PsiFile file, Editor editor, int[] toIgnore, boolean allowDirt) {
Project project = file.getProject();
FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null);
assertTrue(!DumbServiceImpl.getInstance(project).isDumb());
ensureIndexesUpToDate(project);
FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).getFileStatusMap();
for (int ignoreId : toIgnore) {
fileStatusMap.markFileUpToDate(editor.getDocument(), file, ignoreId);
@@ -1111,6 +1111,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
}
}
private static void ensureIndexesUpToDate(Project project) {
FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null);
FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null);
assertTrue(!DumbServiceImpl.getInstance(project).isDumb());
}
public String getTestDataPath() {
return myTestDataPath;
}
@@ -301,6 +301,10 @@ public class ContainerUtil {
};
}
public static <T> Iterable<T> iterate(T[] arrays, final Condition<? super T> condition) {
return iterate(Arrays.asList(arrays), condition);
}
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>() {
@@ -50,8 +50,8 @@ public class CachesHolder {
/**
* Returns all paths that will be used to collect committed changes about. ideally, for one checkout there should be one file
*/
public List<VirtualFile> getAllRootsUnderVcs(final AbstractVcs vcs) {
final RootsCalculator calculator = new RootsCalculator(myProject, vcs);
public Map<VirtualFile, RepositoryLocation> getAllRootsUnderVcs(final AbstractVcs vcs) {
final RootsCalculator calculator = new RootsCalculator(myProject, vcs, myLocationCache);
return calculator.getRoots();
}
@@ -60,14 +60,12 @@ public class CachesHolder {
for (AbstractVcs vcs : vcses) {
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
if (provider instanceof CachingCommittedChangesProvider) {
final List<VirtualFile> roots = getAllRootsUnderVcs(vcs);
for (VirtualFile root : roots) {
final RepositoryLocation location = myLocationCache.getLocation(vcs, new FilePathImpl(root), false);
if (location != null) {
final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location);
if (Boolean.TRUE.equals(consumer.fun(cacheFile))) {
return;
}
final Map<VirtualFile, RepositoryLocation> map = getAllRootsUnderVcs(vcs);
for (VirtualFile root : map.keySet()) {
final RepositoryLocation location = map.get(root);
final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location);
if (Boolean.TRUE.equals(consumer.fun(cacheFile))) {
return;
}
}
}
@@ -224,13 +224,12 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
}
boolean zipSupported = zipper != null;
final List<VirtualFile> roots = myCachesHolder.getAllRootsUnderVcs(vcs);
final Map<VirtualFile, RepositoryLocation> map = myCachesHolder.getAllRootsUnderVcs(vcs);
for (VirtualFile root : roots) {
for (VirtualFile root : map.keySet()) {
if (myProject.isDisposed()) return;
final RepositoryLocation location = myLocationCache.getLocation(vcs, new FilePathImpl(root), false);
if (location == null) continue;
final RepositoryLocation location = map.get(root);
try {
final List<CommittedChangeList> lists = getChanges(mySettings, root, vcs, myMaxCount, myCacheOnly, provider, location);
@@ -17,14 +17,12 @@ package com.intellij.openapi.vcs.changes.committed;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class RootsCalculator {
private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.committed.RootsCalculator");
@@ -32,14 +30,16 @@ public class RootsCalculator {
private final AbstractVcs myVcs;
private final ProjectLevelVcsManager myPlManager;
private VirtualFile[] myContentRoots;
private final RepositoryLocationCache myLocationCache;
public RootsCalculator(final Project project, final AbstractVcs vcs) {
public RootsCalculator(final Project project, final AbstractVcs vcs, final RepositoryLocationCache locationCache) {
myProject = project;
myLocationCache = locationCache;
myPlManager = ProjectLevelVcsManager.getInstance(myProject);
myVcs = vcs;
}
public List<VirtualFile> getRoots() {
public Map<VirtualFile, RepositoryLocation> getRoots() {
myContentRoots = myPlManager.getRootsUnderVcs(myVcs);
List<VirtualFile> roots = new ArrayList<VirtualFile>();
@@ -59,13 +59,22 @@ public class RootsCalculator {
}
}
}
for (VirtualFile contentRoot : myContentRoots) {
roots.add(contentRoot);
roots.addAll(Arrays.asList(myContentRoots));
final Map<VirtualFile, RepositoryLocation> result = new HashMap<VirtualFile, RepositoryLocation>();
for (Iterator<VirtualFile> iterator = roots.iterator(); iterator.hasNext();) {
final VirtualFile vf = iterator.next();
final RepositoryLocation location = myLocationCache.getLocation(myVcs, new FilePathImpl(vf), false);
if (location != null) {
result.put(vf, location);
} else {
iterator.remove();
}
}
roots = myVcs.filterUniqueRoots(roots, IntoSelfVirtualFileConvertor.getInstance());
result.keySet().retainAll(roots);
logRoots(roots);
return roots;
return result;
}
private void logRoots(final List<VirtualFile> roots) {
@@ -153,6 +153,9 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
extends BaseInspectionVisitor {
@Override public void visitVariable(@NotNull PsiVariable variable) {
if (isOnTheFly() && variable.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
if (ignoreLocalVariables && variable instanceof PsiLocalVariable) {
return;
}
@@ -228,8 +231,11 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
method.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
if (isOnTheFly() && method.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
final PsiType type = method.getReturnType();
if (!CollectionUtils.isCollectionClass(type)) {
if (type == null || !CollectionUtils.isCollectionClass(type)) {
return;
}
if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
@@ -263,7 +269,10 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection {
final PsiClass objectClass = javaLangObject.resolve();
weaklingList.remove(objectClass);
if (weaklingList.isEmpty()) {
registerError(nameElement, "java.util.Collection");
final String typeText = type.getCanonicalText();
final String interfaceText =
CollectionUtils.getInterfaceForClass(typeText);
registerError(nameElement, interfaceText);
} else {
final PsiClass weakling = weaklingList.get(0);
registerError(nameElement, weakling.getQualifiedName());
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,22 +31,22 @@ public class CollectionUtils{
* @noinspection StaticCollection
*/
@NonNls private static final Set<String> s_collectionClassesRequiringCapacity =
new HashSet<String>(10);
new HashSet<String>();
/**
* @noinspection StaticCollection
*/
@NonNls private static final Set<String> s_allCollectionClasses =
new HashSet<String>(10);
new HashSet<String>();
/**
* @noinspection StaticCollection
*/
@NonNls private static final Set<String> s_allCollectionClassesAndInterfaces =
new HashSet<String>(10);
new HashSet<String>();
/**
* @noinspection StaticCollection
*/
@NonNls private static final Map<String, String> s_interfaceForCollection =
new HashMap<String, String>(10);
new HashMap<String, String>();
static {
s_collectionClassesRequiringCapacity.add("java.util.BitSet");
@@ -1,5 +1,5 @@
/*
* Copyright 2008 Bas Leijdekkers
* Copyright 2008-2009 Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,9 +46,9 @@ public class WeakestTypeFinder {
} else if (variableOrMethod instanceof PsiMethod) {
final PsiMethod method = (PsiMethod) variableOrMethod;
variableOrMethodType = method.getReturnType();
if (PsiType.VOID.equals(variableOrMethodType)) {
return Collections.EMPTY_LIST;
}
if (PsiType.VOID.equals(variableOrMethodType)) {
return Collections.EMPTY_LIST;
}
} else {
throw new IllegalArgumentException(
"PsiMethod or PsiVariable expected: " +
@@ -4,33 +4,33 @@ import java.util.*;
public class DeclareCollectionsAsInterfaceInspection
{
private HashSet<String> m_setThree = new HashSet<String>(2);
private HashSet m_setOne = new HashSet(2);
private Set m_setTwo = new HashSet(2);
private HashMap<String, String> m_mapThree = new HashMap<String, String>(2);
private HashMap m_setOne = new HashMap(2);
private Map m_setTwo = new HashMap(2);
public DeclareCollectionsAsInterfaceInspection()
{
m_setOne.add("foo");
m_setTwo.add("bar");
m_setOne.put("foo", "foo");
m_setTwo.put("bar", "bar");
}
public void fooBar()
{
final HashSet set1 = new HashSet(2);
final Set set2 = new HashSet(2);
set1.add("foo");
set2.add("bar");
final HashMap map1 = new HashMap(2);
final Map map2 = new HashMap(2);
map1.put("foo", "foo");
map2.put("bar", "bar");
}
public void fooBaz(TreeSet set1, Set set2)
public void fooBaz(HashMap set1, Map set2)
{
set1.add("foo");
set2.add("bar");
set1.put("foo", "foo");
set2.put("bar", "bar");
}
public HashSet fooBaz()
public HashMap fooBaz()
{
return new HashSet();
return new HashMap();
}
void writeContent() {
@@ -39,4 +39,12 @@ public class DeclareCollectionsAsInterfaceInspection
}
void processTemplate(Object o) {}
void foo() {
Object o = theRoad();
}
HashMap theRoad() {
return null;
}
}
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>DeclareCollectionsAsInterfaceInspection.java</file>
<line>8</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Collection declared by class, not interface</problem_class>
<description>Declaration of &lt;code&gt;HashSet&lt;/code&gt; should probably be weakened to 'java.util.Collection' #loc</description>
<description>Declaration of &lt;code&gt;HashMap&lt;/code&gt; should probably be weakened to 'java.util.Map' #loc</description>
</problem>
<problem>
<file>DeclareCollectionsAsInterfaceInspection.java</file>
<line>25</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Collection declared by class, not interface</problem_class>
<description>Declaration of &lt;code&gt;TreeSet&lt;/code&gt; should probably be weakened to 'java.util.Collection' #loc</description>
<description>Declaration of &lt;code&gt;HashMap&lt;/code&gt; should probably be weakened to 'java.util.Map' #loc</description>
</problem>
<problem>
<file>DeclareCollectionsAsInterfaceInspection.java</file>
<line>19</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Collection declared by class, not interface</problem_class>
<description>Declaration of &lt;code&gt;HashSet&lt;/code&gt; should probably be weakened to 'java.util.Collection' #loc</description>
<description>Declaration of &lt;code&gt;HashMap&lt;/code&gt; should probably be weakened to 'java.util.Map' #loc</description>
</problem>
<problem>
@@ -28,4 +28,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Collection declared by class, not interface</problem_class>
<description>Declaration of &lt;code&gt;HashMap&lt;/code&gt; should probably be weakened to 'java.util.Map' #loc</description>
</problem>
<problem>
<file>DeclareCollectionsAsInterfaceInspection.java</file>
<line>47</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Collection declared by class, not interface</problem_class>
<description>Declaration of &lt;code&gt;HashMap&lt;/code&gt; should probably be weakened to 'java.util.Map' #loc</description>
</problem>
</problems>
@@ -5,7 +5,7 @@ import com.IGInspectionTestCase;
public class DeclareCollectionAsInterfaceInspectionTest extends IGInspectionTestCase {
public void test() throws Exception {
//doTest("com/siyeh/igtest/abstraction/declare_collection_as_interface",
// new DeclareCollectionAsInterfaceInspection());
doTest("com/siyeh/igtest/abstraction/declare_collection_as_interface",
new DeclareCollectionAsInterfaceInspection());
}
}
@@ -308,7 +308,7 @@ public class GitRootTracker implements VcsListener {
* @param directory the content root to check
* @param rootSet the mapped root set
*/
private static boolean hasUnmappedSubroots(final VirtualFile directory, final @Nullable HashSet<VirtualFile> rootSet) {
private static boolean hasUnmappedSubroots(final VirtualFile directory, final @NotNull HashSet<VirtualFile> rootSet) {
VirtualFile[] children = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile[]>() {
public VirtualFile[] compute() {
return directory.isValid() ? directory.getChildren() : VirtualFile.EMPTY_ARRAY;
@@ -319,8 +319,8 @@ public class GitRootTracker implements VcsListener {
if (!child.isDirectory()) {
continue;
}
if (child.getName().equals(".git") && (rootSet == null || !rootSet.contains(child.getParent()))) {
return true;
if (child.getName().equals(".git")) {
return !rootSet.contains(child.getParent());
}
if (hasUnmappedSubroots(child, rootSet)) {
return true;
@@ -21,6 +21,7 @@ import com.intellij.javaee.StandardResourceProvider;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.utils.MavenLog;
public class MavenSchemaProvider implements StandardResourceProvider {
public static final String MAVEN_PROJECT_SCHEMA_URL = "http://maven.apache.org/xsd/maven-4.0.0.xsd";
@@ -37,7 +38,12 @@ public class MavenSchemaProvider implements StandardResourceProvider {
@NotNull
public static VirtualFile getSchemaFile(@NotNull String url) {
return VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null);
String location = ExternalResourceManager.getInstance().getResourceLocation(url);
VirtualFile result = VfsUtil.findRelativeFile(location, null);
if (result == null) {
MavenLog.LOG.error("Cannot find a schema file for URL: " + url + " location: " + location);
}
return result;
}
}
@@ -23,10 +23,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.psi.ElementManipulators;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
@@ -368,7 +365,10 @@ public class MavenPropertyPsiReference extends MavenPsiReference {
@Nullable
private <T> T processSchema(String schema, SchemaProcessor<T> processor) {
VirtualFile file = MavenSchemaProvider.getSchemaFile(schema);
XmlFile xmlFile = (XmlFile)PsiManager.getInstance(myProject).findFile(file);
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
if (!(psiFile instanceof XmlFile)) return null;
XmlFile xmlFile = (XmlFile)psiFile;
XmlDocument document = xmlFile.getDocument();
XmlNSDescriptor desc = (XmlNSDescriptor)document.getMetaData();
XmlElementDescriptor[] descriptors = desc.getRootElementsDescriptors(document);
@@ -18,8 +18,10 @@ package org.jetbrains.idea.maven.indices;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.*;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
@@ -397,7 +399,10 @@ public class MavenIndex {
myUpdateTimestamp = System.currentTimeMillis();
oldData.close();
FileUtil.delete(getDataDir(oldDataDir));
for (File each : getAllDataDirs()) {
if (each.getName().equals(newDataDirName)) continue;
FileUtil.delete(each);
}
}
}
@@ -493,6 +498,14 @@ public class MavenIndex {
return MavenIndices.findAvailableDir(myDir, DATA_DIR_PREFIX, 100).getName();
}
private Iterable<File> getAllDataDirs() {
return ContainerUtil.iterate(myDir.listFiles(), new Condition<File>() {
public boolean value(File file) {
return file.getName().startsWith(DATA_DIR_PREFIX);
}
});
}
public synchronized void addArtifact(final File artifactFile) {
doIndexTask(new IndexTask<Object>() {
public Object doTask() throws Exception {
@@ -68,7 +68,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
myTree.addMouseListener(new PopupHandler() {
public void invokePopup(final Component comp, final int x, final int y) {
final String id = getMenuId(getSelectedNodes(MavenProjectsStructure.CustomNode.class));
final String id = getMenuId(getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class));
if (id != null) {
final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(id);
if (actionGroup != null) {
@@ -78,9 +78,9 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
}
@Nullable
private String getMenuId(Collection<? extends MavenProjectsStructure.CustomNode> nodes) {
private String getMenuId(Collection<? extends MavenProjectsStructure.MavenSimpleNode> nodes) {
String id = null;
for (MavenProjectsStructure.CustomNode node : nodes) {
for (MavenProjectsStructure.MavenSimpleNode node : nodes) {
String menuId = node.getMenuId();
if (menuId == null) {
return null;
@@ -124,7 +124,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
}
private VirtualFile extractVirtualFile() {
for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) {
for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) {
VirtualFile file = each.getVirtualFile();
if (file != null) return file;
}
@@ -138,7 +138,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
private Object extractVirtualFiles() {
final List<VirtualFile> files = new ArrayList<VirtualFile>();
for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) {
for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) {
VirtualFile file = each.getVirtualFile();
if (file != null) files.add(file);
}
@@ -147,7 +147,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
private Object extractNavigatables() {
final List<Navigatable> navigatables = new ArrayList<Navigatable>();
for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) {
for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) {
Navigatable navigatable = each.getNavigatable();
if (navigatable != null) navigatables.add(navigatable);
}
@@ -195,7 +195,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
return profiles;
}
private <T extends MavenProjectsStructure.CustomNode> List<T> getSelectedNodes(Class<T> aClass) {
private <T extends MavenProjectsStructure.MavenSimpleNode> List<T> getSelectedNodes(Class<T> aClass) {
return MavenProjectsStructure.getSelectedNodes(myTree, aClass);
}
@@ -213,7 +213,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement
private MavenProjectsStructure.ProjectNode getContextProjectNode() {
MavenProjectsStructure.ProjectNode projectNode = getSelectedProjectNode();
if (projectNode != null) return projectNode;
return MavenProjectsStructure.getCommonProjectNode(getSelectedNodes(MavenProjectsStructure.CustomNode.class));
return MavenProjectsStructure.getCommonProjectNode(getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class));
}
private int getStandardGoalOrder(String goal) {
@@ -36,7 +36,7 @@ public class SelectFromMavenProjectsDialog extends DialogWrapper {
public SelectFromMavenProjectsDialog(Project project,
String title,
final Class<? extends MavenProjectsStructure.CustomNode> nodeClass,
final Class<? extends MavenProjectsStructure.MavenSimpleNode> nodeClass,
NodeSelector selector) {
super(project, false);
myProject = project;
@@ -53,7 +53,7 @@ public class SelectFromMavenProjectsDialog extends DialogWrapper {
MavenProjectsNavigator.getInstance(myProject),
myTree) {
@Override
protected Class<? extends CustomNode>[] getVisibleNodesClasses() {
protected Class<? extends MavenSimpleNode>[] getVisibleNodesClasses() {
return new Class[]{nodeClass};
}
@@ -57,7 +57,7 @@ public class SelectMavenProjectDialog extends SelectFromMavenProjectsDialog {
if (node != null) {
if (!(node instanceof MavenProjectsStructure.ProjectNode)) {
((MavenProjectsStructure.CustomNode)node).getParent(MavenProjectsStructure.ProjectNode.class);
((MavenProjectsStructure.MavenSimpleNode)node).findParent(MavenProjectsStructure.ProjectNode.class);
}
}
myResult = node != null ? ((MavenProjectsStructure.ProjectNode)node).getMavenProject() : null;
@@ -30,6 +30,7 @@ import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.project.ProjectBundle;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
@@ -119,24 +120,17 @@ public class MavenImportNotifier extends SimpleProjectComponent {
private JLabel myLabel;
private NotifierPanel() {
super(new BorderLayout());
super(new GridBagLayout());
setBackground(LightColors.YELLOW);
setBorder(BorderFactory.createEmptyBorder(7, 15, 7, 15));
myLabel = new JLabel(MavenIcons.MAVEN_ICON);
add(myLabel, BorderLayout.WEST);
myLabel = new JLabel(MavenIcons.MAVEN_ICON, JLabel.LEFT);
JComponent importChangedButton = createButton(ProjectBundle.message("maven.project.import.changed"), new Runnable() {
public void run() {
myMavenProjectsManager.performScheduledImport();
}
});
JComponent importAllButton = createButton(ProjectBundle.message("maven.project.import.all"), new Runnable() {
public void run() {
myMavenProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles();
}
});
JComponent enableAutoImportButton = createButton(ProjectBundle.message("maven.project.import.enable.auto"), new Runnable() {
public void run() {
myMavenProjectsManager.getImportingSettings().setImportAutomatically(true);
@@ -146,12 +140,23 @@ public class MavenImportNotifier extends SimpleProjectComponent {
JPanel buttonsPanel = new JPanel();
buttonsPanel.setOpaque(false);
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
buttonsPanel.add(myLabel);
buttonsPanel.add(importChangedButton);
buttonsPanel.add(importAllButton);
buttonsPanel.add(Box.createHorizontalStrut(10));
buttonsPanel.add(enableAutoImportButton);
add(buttonsPanel, BorderLayout.EAST);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.anchor = GridBagConstraints.WEST;
c.weightx = 1;
add(myLabel, c);
c.gridx = 1;
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
add(buttonsPanel, c);
}
private JComponent createButton(String text, final Runnable action) {
@@ -174,9 +179,10 @@ public class MavenImportNotifier extends SimpleProjectComponent {
s = ProjectBundle.message("maven.project.something.changed");
}
else {
s = ProjectBundle.message("maven.project.changed", projectsCount, projectsCount == 1 ? " has" : "s have");
s = ProjectBundle.message("maven.project.changed", projectsCount, projectsCount == 1 ? " is" : "s are");
}
myLabel.setText(s);
myLabel.setToolTipText(s);
}
}
}
@@ -70,9 +70,11 @@ public class MavenActionUtil {
MavenProject project = getProjectsManager(e).findProject(each);
if (project != null) result.add(project);
}
for (Module each : getModules(e)) {
MavenProject project = getProjectsManager(e).findProject(each);
if (project != null) result.add(project);
if (result.isEmpty()) {
for (Module each : getModules(e)) {
MavenProject project = getProjectsManager(e).findProject(each);
if (project != null) result.add(project);
}
}
return new ArrayList<MavenProject>(result);
}
@@ -18,8 +18,8 @@ maven.downloading.artifact=Downloading {0}
maven.transfer.progress={0}/{1}K [{2}] {3}
maven.transfer.start=Checking [{0}] {1}
maven.project.changed={0} Maven project{1} been changed.
maven.project.something.changed=Some settings have been changed that require reimport.
maven.project.changed={0} Maven project{1} ready to be imported
maven.project.something.changed=Changes have been made that require reimport
maven.project.import.changed=Import Changes
maven.project.import.all=Force Reimport All
maven.project.import.enable.auto=Enable Auto-Import
@@ -83,7 +83,6 @@ maven.select.maven.settings.file=Select Maven settings file
maven.select.local.repository=Select Maven local repository
maven.file.type.descr=Maven project files
view.node.root=Maven Projects
view.node.lifecycle=Lifecycle
view.node.profiles=Profiles
view.node.plugins=Plugins
@@ -423,6 +423,12 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
FileUtil.delete(new File(getRepositoryPath(), relativePath));
}
protected void setupJdkForModules(String... moduleNames) {
for (String each : moduleNames) {
setupJdkForModule(each);
}
}
protected Sdk setupJdkForModule(String moduleName) {
ModifiableRootModel m = ModuleRootManager.getInstance(getModule(moduleName)).getModifiableModel();
Sdk sdk = createJdk("Java 1.5");
@@ -74,20 +74,17 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase {
assertModuleModuleDeps("m1", "m2", "m3");
assertModuleModuleDeps("m2", "m3", "m4");
setupJdkForModule("m1");
setupJdkForModule("m2");
setupJdkForModule("m3");
setupJdkForModule("m4");
setupJdkForModules("m1", "m2", "m3", "m4");
assertModuleClasspath("m1",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getProjectPath() + "/m3/target/classes");
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getProjectPath() + "/m3/target/classes");
assertModuleClasspath("m2",
getProjectPath() + "/m2/target/classes",
getProjectPath() + "/m3/target/classes",
getProjectPath() + "/m4/target/classes");
getProjectPath() + "/m2/target/classes",
getProjectPath() + "/m3/target/classes",
getProjectPath() + "/m4/target/classes");
}
public void testOptionalLibraryDependencies() throws Exception {
@@ -128,18 +125,17 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase {
assertModuleLibDeps("m1", "Maven: jmock:jmock:1.0");
assertModuleLibDeps("m2", "Maven: jmock:jmock:1.0", "Maven: junit:junit:4.0");
setupJdkForModule("m1");
setupJdkForModule("m2");
setupJdkForModules("m1", "m2");
assertModuleClasspath("m1",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar");
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar");
assertModuleClasspath("m2",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
}
public void testDoNotChangeClasspathForRegularModules() throws Exception {
@@ -184,20 +180,18 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase {
assertModuleModuleDeps("user", "m1");
assertModuleLibDeps("user");
setupJdkForModule("user");
setupJdkForModule("m1");
setupJdkForModule("m2");
setupJdkForModules("m1", "m2", "user");
assertModuleClasspath("user",
getProjectPath() + "/user/output",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
getProjectPath() + "/user/output",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
assertModuleClasspath("m1",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
}
public void testDoNotIncludeProvidedAndTestTransitiveDependencies() throws Exception {
@@ -239,17 +233,72 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase {
assertModuleLibDeps("m1");
assertModuleLibDeps("m2", "Maven: jmock:jmock:1.0", "Maven: junit:junit:4.0");
setupJdkForModule("m1");
setupJdkForModule("m2");
setupJdkForModules("m1", "m2");
assertModuleClasspath("m1",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes");
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes");
assertModuleClasspath("m2",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar");
}
public void testDoNotIncludeConflictingTransitiveDependenciesInTheClasspath() throws Exception {
VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" +
"<artifactId>m1</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>m2</artifactId>" +
" <version>1</version>" +
" </dependency>" +
" <dependency>" +
" <groupId>test</groupId>" +
" <artifactId>m3</artifactId>" +
" <version>1</version>" +
" </dependency>" +
"</dependencies>");
VirtualFile m2 = createModulePom("m2", "<groupId>test</groupId>" +
"<artifactId>m2</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>junit</groupId>" +
" <artifactId>junit</artifactId>" +
" <version>4.0</version>" +
" </dependency>" +
"</dependencies>");
VirtualFile m3 = createModulePom("m3", "<groupId>test</groupId>" +
"<artifactId>m3</artifactId>" +
"<version>1</version>" +
"<dependencies>" +
" <dependency>" +
" <groupId>junit</groupId>" +
" <artifactId>junit</artifactId>" +
" <version>4.5</version>" +
" </dependency>" +
"</dependencies>");
importProjects(m1, m2, m3);
assertModules("m1", "m2", "m3");
assertModuleModuleDeps("m1", "m2", "m3");
assertModuleLibDeps("m1", "Maven: junit:junit:4.0");
setupJdkForModules("m1", "m2", "m3");
assertModuleClasspath("m1",
getProjectPath() + "/m1/target/classes",
getProjectPath() + "/m2/target/classes",
getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar",
getProjectPath() + "/m3/target/classes");
}
private void assertModuleClasspath(String moduleName, String... paths) throws CantRunException {
@@ -55,7 +55,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
myProjectsManager.fireActivatedInTests();
assertEquals(1, getRootNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
}
public void testReconnectingModulesWhenModuleRead() throws Exception {
@@ -72,7 +72,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
assertEquals(1, getRootNodes().size());
assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile());
assertEquals(0, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(0, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
VirtualFile m = createModulePom("m", "<groupId>test</groupId>" +
"<artifactId>m</artifactId>" +
@@ -81,8 +81,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
assertEquals(1, getRootNodes().size());
assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile());
}
public void testReconnectingModulesWhenParentRead() throws Exception {
@@ -107,8 +107,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
assertEquals(1, getRootNodes().size());
assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile());
}
public void testReconnectingModulesWhenProjectBecomesParent() throws Exception {
@@ -136,8 +136,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
assertEquals(1, getRootNodes().size());
assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile());
}
public void testUpdatingWhenManagedFilesChange() throws Exception {
@@ -180,16 +180,16 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
readFiles(myProjectPom, m, mm);
assertEquals(1, getRootNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getModulesNode().getProjectNodesInTests().size());
myNavigator.setGroupModules(false);
assertEquals(3, getRootNodes().size());
myNavigator.setGroupModules(true);
assertEquals(1, getRootNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getModulesNode().getProjectNodesInTests().size());
}
public void testIgnoringProjects() throws Exception {
@@ -242,14 +242,14 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
assertEquals(1, myStructure.getRootElement().getChildren().length);
MavenProjectsStructure.ProjectNode projectNode = (MavenProjectsStructure.ProjectNode)myStructure.getRootElement().getChildren()[0];
assertEquals(myProjectPom, projectNode.getVirtualFile());
assertEquals(1, projectNode.getModulesNode().getProjectNodes().size());
assertEquals(1, projectNode.getModulesNode().getProjectNodesInTests().size());
myNavigator.setShowIgnored(false);
assertEquals(2, getRootNodes().size());
assertEquals(1, myStructure.getRootElement().getChildren().length); // only one of them is visible
projectNode = (MavenProjectsStructure.ProjectNode)myStructure.getRootElement().getChildren()[0];
assertEquals(m, projectNode.getVirtualFile());
assertEquals(0, projectNode.getModulesNode().getProjectNodes().size());
assertEquals(0, projectNode.getModulesNode().getProjectNodesInTests().size());
}
public void testReorderingProjectsWhenNameChanges() throws Exception {
@@ -295,7 +295,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
readFiles(myProjectPom, m);
assertEquals(1, getRootNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size());
assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size());
MavenProjectsNavigatorState newState = new MavenProjectsNavigatorState();
newState.groupStructurally = false;
@@ -321,6 +321,6 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase {
}
private List<MavenProjectsStructure.ProjectNode> getRootNodes() {
return myStructure.getRootElement().getProjectNodes();
return myStructure.getRootElement().getProjectNodesInTests();
}
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -31,7 +32,7 @@ import com.intellij.psi.PsiManager;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider {
public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider, DumbAware {
private static final ResourceBundleFileType RESOURCE_BUNDLE_FILE_TYPE = new ResourceBundleFileType();
public boolean accept(@NotNull Project project, @NotNull VirtualFile file){
@@ -136,6 +136,11 @@ public class SvnMapDialog extends DialogWrapper {
});
}
@Override
protected String getHelpId() {
return "reference.vcs.svn.working.copies.information";
}
private void subscribeToUpdates(final SvnVcs vcs) {
if (myMessageBusConnection == null) {
myMessageBusConnection = myProject.getMessageBus().connect(getDisposable());
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
@@ -40,7 +41,7 @@ import java.io.InputStream;
/**
* @author yole
*/
public abstract class AbstractCreateFormAction extends CreateElementActionBase {
public abstract class AbstractCreateFormAction extends CreateElementActionBase implements DumbAware {
public AbstractCreateFormAction(String text, String description, Icon icon) {
super(text, description, icon);
}
@@ -19,9 +19,10 @@ package com.intellij.uiDesigner.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.uiDesigner.FormEditingUtil;
import com.intellij.uiDesigner.radComponents.RadComponent;
import com.intellij.uiDesigner.designSurface.GuiEditor;
import com.intellij.uiDesigner.radComponents.RadComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,7 +32,7 @@ import java.util.List;
/**
* @author yole
*/
public abstract class AbstractGuiEditorAction extends AnAction {
public abstract class AbstractGuiEditorAction extends AnAction implements DumbAware {
private final boolean myModifying;
protected AbstractGuiEditorAction() {
@@ -18,6 +18,7 @@ package com.intellij.uiDesigner.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.Ref;
import com.intellij.uiDesigner.FormEditingUtil;
import com.intellij.uiDesigner.designSurface.GuiEditor;
@@ -27,14 +28,14 @@ import com.intellij.uiDesigner.radComponents.RadContainer;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.Point;
import java.awt.*;
import java.util.ArrayList;
/**
* @author Anton Katilin
* @author Vladimir Kondratyev
*/
abstract class AbstractMoveSelectionAction extends AnAction{
abstract class AbstractMoveSelectionAction extends AnAction implements DumbAware {
private static final Logger LOG=Logger.getInstance("#com.intellij.uiDesigner.actions.MoveSelectionToRightAction");
private final GuiEditor myEditor;
@@ -24,6 +24,7 @@ import com.intellij.openapi.fileEditor.FileEditorState;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -31,7 +32,7 @@ import com.intellij.util.ArrayUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
public final class UIFormEditorProvider implements FileEditorProvider {
public final class UIFormEditorProvider implements FileEditorProvider, DumbAware {
private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.editor.UIFormEditorProvider");
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file){
@@ -93,7 +93,7 @@ public class UIDesignerToolWindowManager implements ProjectComponent {
myToolWindowPanel.setSecondComponent(myPropertyInspector);
myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer"),
myToolWindowPanel,
ToolWindowAnchor.LEFT, myProject);
ToolWindowAnchor.LEFT, myProject, true);
myToolWindow.setIcon(IconLoader.getIcon("/com/intellij/uiDesigner/icons/toolWindowUIDesigner.png"));
myToolWindow.setAvailable(false, null);
}