Merge remote-tracking branch 'origin/master'

This commit is contained in:
Liana Bakradze
2014-08-27 16:42:05 +04:00
53 changed files with 555 additions and 582 deletions
@@ -55,7 +55,7 @@ import java.util.*;
public class CompileContextImpl extends UserDataHolderBase implements CompileContextEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompileContextImpl");
private final Project myProject;
private final CompilerTask myTask;
private final CompilerTask myBuildSession;
private final Map<CompilerMessageCategory, Collection<CompilerMessage>> myMessages = new EnumMap<CompilerMessageCategory, Collection<CompilerMessage>>(CompilerMessageCategory.class);
private final boolean myShouldUpdateProblemsView;
private CompileScope myCompileScope;
@@ -77,7 +77,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
CompileScope compileScope,
boolean isMake, boolean isRebuild) {
myProject = project;
myTask = compilerSession;
myBuildSession = compilerSession;
myCompileScope = compileScope;
myMake = isMake;
myIsRebuild = isRebuild;
@@ -99,6 +99,10 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myShouldUpdateProblemsView = workspaceConfig.MAKE_PROJECT_ON_SAVE;
}
public CompilerTask getBuildSession() {
return myBuildSession;
}
public boolean shouldUpdateProblemsView() {
return myShouldUpdateProblemsView;
}
@@ -154,7 +158,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
myMessages.put(msg.getCategory(), messages);
}
if (messages.add(msg)) {
myTask.addMessage(msg);
myBuildSession.addMessage(msg);
}
if (myShouldUpdateProblemsView && msg.getCategory() == CompilerMessageCategory.ERROR) {
ProblemsView.SERVICE.getInstance(myProject).addMessage(msg, mySessionId);
@@ -200,7 +204,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
}
public ProgressIndicator getProgressIndicator() {
return myTask.getIndicator();
return myBuildSession.getIndicator();
}
public Module getModuleByFile(VirtualFile file) {
@@ -29,6 +29,8 @@ import com.intellij.compiler.ProblemsView;
import com.intellij.compiler.progress.CompilerTask;
import com.intellij.compiler.server.BuildManager;
import com.intellij.compiler.server.DefaultMessageHandler;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.compiler.*;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
@@ -53,10 +55,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.*;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.impl.compiler.ArtifactCompilerUtil;
import com.intellij.packaging.impl.compiler.ArtifactsCompiler;
@@ -68,6 +67,7 @@ import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.text.DateFormatUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -79,7 +79,9 @@ import org.jetbrains.jps.api.RequestFuture;
import org.jetbrains.jps.model.java.JavaSourceRootType;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -502,9 +504,24 @@ public class CompileDriver {
if (duration > ONE_MINUTE_MS && CompilerWorkspaceConfiguration.getInstance(myProject).DISPLAY_NOTIFICATION_POPUP) {
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.MESSAGES_WINDOW, messageType, statusMessage);
}
CompilerManager.NOTIFICATION_GROUP.createNotification(statusMessage, messageType).notify(myProject);
final String wrappedMessage = _status != ExitStatus.UP_TO_DATE? "<a href='#'>" + statusMessage + "</a>" : statusMessage;
final Notification notification = CompilerManager.NOTIFICATION_GROUP.createNotification(
"", wrappedMessage,
messageType.toNotificationType(),
new MessagesActivationListener(compileContext)
);
compileContext.getBuildSession().registerCloseAction(new Runnable() {
@Override
public void run() {
notification.expire();
}
});
notification.notify(myProject);
if (_status != ExitStatus.UP_TO_DATE && compileContext.getMessageCount(null) > 0) {
compileContext.addMessage(CompilerMessageCategory.INFORMATION, statusMessage, null, -1, -1);
final String msg = DateFormatUtil.formatDateTime(new Date()) + " - " + statusMessage;
compileContext.addMessage(CompilerMessageCategory.INFORMATION, msg, null, -1, -1);
}
}
}
@@ -785,4 +802,28 @@ public class CompileDriver {
private void showConfigurationDialog(String moduleNameToSelect, String tabNameToSelect) {
ProjectSettingsService.getInstance(myProject).showModuleConfigurationDialog(moduleNameToSelect, tabNameToSelect);
}
private static class MessagesActivationListener extends NotificationListener.Adapter {
private final WeakReference<Project> myProjectRef;
private final Object myContentId;
public MessagesActivationListener(CompileContextImpl compileContext) {
myProjectRef = new WeakReference<Project>(compileContext.getProject());
myContentId = compileContext.getBuildSession().getContentId();
}
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
final Project project = myProjectRef.get();
if (project != null && !project.isDisposed() && CompilerTask.showCompilerContent(project, myContentId)) {
final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
if (tw != null) {
tw.activate(null, false);
}
}
else {
notification.expire();
}
}
}
}
@@ -22,12 +22,11 @@
package com.intellij.compiler.progress;
import com.intellij.compiler.CompilerManagerImpl;
import com.intellij.compiler.CompilerMessageImpl;
import com.intellij.compiler.impl.CompilerErrorTreeView;
import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel;
import com.intellij.ide.errorTreeView.impl.ErrorTreeViewConfiguration;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.compiler.*;
@@ -42,6 +41,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
@@ -120,6 +120,26 @@ public class CompilerTask extends Task.Backgroundable {
mySessionId = sessionId;
}
@NotNull
public Object getContentId() {
return myContentId;
}
public void registerCloseAction(final Runnable onClose) {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
Disposer.register(myErrorTreeView, new Disposable() {
@Override
public void dispose() {
onClose.run();
}
});
return;
}
}
onClose.run();
}
@Override
public String getProcessId() {
return "compilation";
@@ -221,13 +241,15 @@ public class CompilerTask extends Task.Backgroundable {
private void addIndicatorDelegate() {
ProgressIndicator indicator = myIndicator;
if (!(indicator instanceof ProgressIndicatorEx)) return;
if (!(indicator instanceof ProgressIndicatorEx)) {
return;
}
((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() {
@Override
public void cancel() {
super.cancel();
closeUI();
selectFirstMessage();
stopAppIconProgress();
}
@@ -235,11 +257,26 @@ public class CompilerTask extends Task.Backgroundable {
public void stop() {
super.stop();
if (!isCanceled()) {
closeUI();
selectFirstMessage();
}
stopAppIconProgress();
}
private void selectFirstMessage() {
if (!isHeadlessMode()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
myErrorTreeView.selectFirstMessage();
}
}
}
});
}
}
private void stopAppIconProgress() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
@@ -249,7 +286,8 @@ public class CompilerTask extends Task.Backgroundable {
if (myErrorCount > 0) {
appIcon.setErrorBadge(myProject, String.valueOf(myErrorCount));
appIcon.requestAttention(myProject, true);
} else if (!myCompilationStartedAutomatically) {
}
else if (!myCompilationStartedAutomatically) {
appIcon.setOkBadge(myProject, true);
appIcon.requestAttention(myProject, false);
}
@@ -450,18 +488,22 @@ public class CompilerTask extends Task.Backgroundable {
public void showCompilerContent() {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
Content[] contents = messageView.getContentManager().getContents();
for (Content content : contents) {
if (CONTENT_ID_KEY.get(content) == myContentId) {
messageView.getContentManager().setSelectedContent(content);
return;
}
}
showCompilerContent(myProject, myContentId);
}
}
}
public static boolean showCompilerContent(final Project project, final Object contentId) {
final MessageView messageView = MessageView.SERVICE.getInstance(project);
for (Content content : messageView.getContentManager().getContents()) {
if (CONTENT_ID_KEY.get(content) == contentId) {
messageView.getContentManager().setSelectedContent(content);
return true;
}
}
return false;
}
private void removeAllContents(Project project, Content notRemove) {
if (project.isDisposed()) {
return;
@@ -488,7 +530,7 @@ public class CompilerTask extends Task.Backgroundable {
private void activateMessageView() {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
if (myErrorTreeView != null && myProject != null) {
final ToolWindow tw = ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
if (tw != null) {
tw.activate(null, false);
@@ -497,34 +539,6 @@ public class CompilerTask extends Task.Backgroundable {
}
}
private void closeUI() {
if (isHeadlessMode()) {
return;
}
Window window = getWindow();
ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL;
final Application application = ApplicationManager.getApplication();
application.invokeLater(new Runnable() {
@Override
public void run() {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
final boolean shouldRetainView = myErrorCount > 0 || myWarningCount > 0 && !myErrorTreeView.isHideWarnings();
if (shouldRetainView) {
addMessage(new CompilerMessageImpl(myProject, CompilerMessageCategory.STATISTICS, CompilerBundle.message("statistics.error.count", myErrorCount)));
addMessage(new CompilerMessageImpl(myProject, CompilerMessageCategory.STATISTICS, CompilerBundle.message("statistics.warnings.count", myWarningCount)));
//activateMessageView();
myErrorTreeView.selectFirstMessage();
}
else {
removeAllContents(myProject, null);
}
}
}
}
}, modalityState);
}
public Window getWindow(){
return null;
}
@@ -607,7 +621,7 @@ public class CompilerTask extends Task.Backgroundable {
if (event.getContent() == myContent) {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
myErrorTreeView.dispose();
Disposer.dispose(myErrorTreeView);
myErrorTreeView = null;
if (myIndicator.isRunning()) {
cancel();
@@ -23,12 +23,10 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
import com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl;
import com.intellij.debugger.ui.tree.render.*;
import com.intellij.ide.actions.ShowSettingsUtilImpl;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import org.jetbrains.annotations.Nullable;
public class AdjustArrayRangeAction extends DebuggerAction {
@@ -67,30 +65,25 @@ public class AdjustArrayRangeAction extends DebuggerAction {
title = title + " " + label.substring(index);
}
final ArrayRenderer clonedRenderer = renderer.clone();
final NamedArrayConfigurable configurable = new NamedArrayConfigurable(title, clonedRenderer);
SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable,
ShowSettingsUtilImpl.createDimensionKey(configurable), false);
editor.show();
if(editor.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
if (ShowSettingsUtil.getInstance().editConfigurable(project, new NamedArrayConfigurable(title, clonedRenderer))) {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor();
final Renderer lastRenderer = nodeDescriptor.getLastRenderer();
if (lastRenderer instanceof ArrayRenderer) {
selectedNode.setRenderer(clonedRenderer);
}
else if (lastRenderer instanceof CompoundNodeRenderer) {
final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer;
final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
if (childrenRenderer instanceof ExpressionChildrenRenderer) {
ExpressionChildrenRenderer.setPreferableChildrenRenderer(nodeDescriptor, clonedRenderer);
selectedNode.calcRepresentation();
}
@Override
public void contextAction() throws Exception {
final ValueDescriptorImpl nodeDescriptor = (ValueDescriptorImpl)selectedNode.getDescriptor();
final Renderer lastRenderer = nodeDescriptor.getLastRenderer();
if (lastRenderer instanceof ArrayRenderer) {
selectedNode.setRenderer(clonedRenderer);
}
else if (lastRenderer instanceof CompoundNodeRenderer) {
final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer)lastRenderer;
final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
if (childrenRenderer instanceof ExpressionChildrenRenderer) {
ExpressionChildrenRenderer.setPreferableChildrenRenderer(nodeDescriptor, clonedRenderer);
selectedNode.calcRepresentation();
}
}
});
}
});
}
}
@@ -19,23 +19,15 @@ import com.intellij.debugger.settings.ThreadsViewConfigurable;
import com.intellij.debugger.settings.ThreadsViewSettings;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.options.ShowSettingsUtil;
/**
* User: lex
* Date: Sep 26, 2003
* Time: 4:40:12 PM
*/
public class CustomizeThreadsViewAction extends DebuggerAction {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, new ThreadsViewConfigurable(ThreadsViewSettings.getInstance()));
editor.show();
ShowSettingsUtil.getInstance().editConfigurable(e.getProject(), new ThreadsViewConfigurable(ThreadsViewSettings.getInstance()));
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setVisible(true);
e.getPresentation().setText(ActionsBundle.actionText(DebuggerActions.CUSTOMIZE_THREADS_VIEW));
@@ -37,6 +37,7 @@ import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
public class ShowStructureSettingsAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) {
@@ -61,7 +62,8 @@ public class ShowStructureSettingsAction extends AnAction implements DumbAware {
return panel;
}
}.show();
} else {
}
else {
ShowSettingsUtil
.getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(project));
}
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
public class TemplateProjectStructureAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(final AnActionEvent e) {
Project defaultProject = ProjectManagerEx.getInstanceEx().getDefaultProject();
ShowSettingsUtil.getInstance().editConfigurable(defaultProject, OptionsEditorDialog.DIMENSION_KEY, ProjectStructureConfigurable.getInstance(defaultProject));
@@ -2,6 +2,6 @@ public class StructuredConfigKey {
{
try {
} catch (<caret>)
} catch (<caret>
}
}
@@ -0,0 +1,43 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.impl.file.impl;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import java.io.IOException;
public class TempFileSystemTest extends LightPlatformCodeInsightFixtureTestCase {
public void testMove() {
ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
VirtualFile sourceRoot = rootManager.getContentSourceRoots()[0];
PsiManager psiManager = PsiManager.getInstance(getProject());
PsiDirectory psiSourceRoot = psiManager.findDirectory(sourceRoot);
PsiFile psiFile = psiSourceRoot.createFile("TestDocument.xml");
try {
psiFile.getVirtualFile().move(this, psiSourceRoot.createSubdirectory("com").getVirtualFile());
} catch (IOException e) {
e.printStackTrace();
}
assertTrue(psiFile.isValid());
psiFile.delete();
assertFalse(psiFile.isValid());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,16 @@ package com.intellij.lexer;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
/**
* Naive implementation of lexer that able to combine element types of two other lexers.
*
* The implementation doesn't give any guarantees about valid points of 'incremental relexing',
* because it returns start/end-offsets not for token that was used but for the shortest one.
*
* Also it reduces state size to 16 bits for nested lexer.
*
* @deprecated use {@link com.intellij.psi.templateLanguages.TemplateBlackAndWhiteLexer} or {@link com.intellij.lexer.LayeredLexer} instead
*/
public abstract class CompositeLexer extends LexerBase {
private final Lexer myLexer1;
private final Lexer myLexer2;
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.generation;
import com.intellij.codeInsight.template.Template;
@@ -13,6 +28,7 @@ import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.treeStructure.SimpleTree;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -55,8 +71,9 @@ public class GenerateByPatternDialog extends DialogWrapper {
};
myTree.setRootVisible(false);
myTree.setCellRenderer(new DefaultTreeCellRenderer() {
@NotNull
@Override
public Component getTreeCellRendererComponent(JTree tree,
public Component getTreeCellRendererComponent(@NotNull JTree tree,
Object value,
boolean sel,
boolean expanded,
@@ -78,7 +95,7 @@ public class GenerateByPatternDialog extends DialogWrapper {
myTree.setModel(new DefaultTreeModel(root));
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
public void valueChanged(@NotNull TreeSelectionEvent e) {
update();
}
});
@@ -141,6 +158,7 @@ public class GenerateByPatternDialog extends DialogWrapper {
private DefaultMutableTreeNode createNode(@Nullable PatternDescriptor descriptor) {
DefaultMutableTreeNode root = new DefaultMutableTreeNode(descriptor) {
@NotNull
@Override
public String toString() {
Object object = getUserObject();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.popup.JBPopup;
@@ -52,7 +51,6 @@ import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -182,7 +180,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
myEditVariablesButton.addActionListener(
new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
editVariables();
}
}
@@ -201,7 +199,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
myTemplate.parseSegments();
}
@Nullable
@NotNull
private JComponent createNorthPanel() {
JPanel panel = new JPanel(new GridBagLayout());
@@ -240,7 +238,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
myExpandByCombo = new ComboBox(new String[]{myDefaultShortcutItem, SPACE, TAB, ENTER});
myExpandByCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
public void itemStateChanged(@NotNull ItemEvent e) {
Object selectedItem = myExpandByCombo.getSelectedItem();
if(myDefaultShortcutItem.equals(selectedItem)) {
myTemplate.setShortcutChar(TemplateSettings.DEFAULT_CHAR);
@@ -278,7 +276,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
cb.setSelected(myOptions.get(processor).booleanValue());
cb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
myOptions.put(processor, cb.isSelected());
}
});
@@ -469,14 +467,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
}
private void updateHighlighter() {
List<TemplateContextType> applicableContexts = getApplicableContexts();
if (!applicableContexts.isEmpty()) {
TemplateContext contextByType = new TemplateContext();
contextByType.setEnabled(applicableContexts.get(0), true);
TemplateEditorUtil.setHighlighter(myTemplateEditor, contextByType);
return;
}
((EditorEx) myTemplateEditor).repaint(0, myTemplateEditor.getDocument().getTextLength());
TemplateEditorUtil.setHighlighter(myTemplateEditor, ContainerUtil.getFirstItem(getApplicableContexts()));
}
private void validateEditVariablesButton() {
@@ -520,7 +511,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
myCbReformat.setSelected(myTemplate.isToReformat());
myCbReformat.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
myTemplate.setToReformat(myCbReformat.isSelected());
}
});
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package com.intellij.codeInsight.template.impl;
import com.intellij.codeInsight.template.TemplateContextType;
import com.intellij.ide.DataManager;
import com.intellij.lexer.CompositeLexer;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.MergingLexerAdapter;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -31,7 +30,8 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
import com.intellij.openapi.editor.ex.util.LayerDescriptor;
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
import com.intellij.openapi.fileEditor.FileDocumentManager;
@@ -42,6 +42,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -87,54 +88,41 @@ public class TemplateEditorUtil {
if (file != null) {
EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project);
((EditorEx) editor).setHighlighter(highlighter);
}
return editor;
}
public static void setHighlighter(Editor editor, TemplateContext templateContext) {
SyntaxHighlighter baseHighlighter = null;
for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) {
if (templateContext.isEnabled(type)) {
baseHighlighter = type.createHighlighter();
if (baseHighlighter != null) break;
public static void setHighlighter(Editor editor, @Nullable TemplateContext templateContext) {
SyntaxHighlighter highlighter = null;
if (templateContext != null) {
for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) {
if (templateContext.isEnabled(type)) {
highlighter = type.createHighlighter();
if (highlighter != null) break;
}
}
}
if (baseHighlighter == null) {
baseHighlighter = new PlainSyntaxHighlighter();
}
SyntaxHighlighter highlighter = createTemplateTextHighlighter(baseHighlighter);
((EditorEx)editor).setHighlighter(new LexerEditorHighlighter(highlighter, EditorColorsManager.getInstance().getGlobalScheme()));
setHighlighter((EditorEx)editor, highlighter);
}
private final static TokenSet TOKENS_TO_MERGE = TokenSet.create(TemplateTokenType.TEXT);
public static void setHighlighter(@NotNull Editor editor, @Nullable TemplateContextType templateContextType) {
setHighlighter((EditorEx)editor, templateContextType != null ? templateContextType.createHighlighter() : null);
}
private static SyntaxHighlighter createTemplateTextHighlighter(final SyntaxHighlighter original) {
return new TemplateHighlighter(original);
private static void setHighlighter(EditorEx editor, @Nullable SyntaxHighlighter highlighter) {
EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
LayeredLexerEditorHighlighter layeredHighlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), editorColorsScheme);
layeredHighlighter.registerLayer(TemplateTokenType.TEXT, new LayerDescriptor(ObjectUtils.notNull(highlighter, new PlainSyntaxHighlighter()), ""));
editor.setHighlighter(layeredHighlighter);
}
private static class TemplateHighlighter extends SyntaxHighlighterBase {
private final Lexer myLexer;
private final SyntaxHighlighter myOriginalHighlighter;
public TemplateHighlighter(SyntaxHighlighter original) {
myOriginalHighlighter = original;
Lexer originalLexer = original.getHighlightingLexer();
Lexer templateLexer = new TemplateTextLexer();
templateLexer = new MergingLexerAdapter(templateLexer, TOKENS_TO_MERGE);
myLexer = new CompositeLexer(originalLexer, templateLexer) {
@Override
protected IElementType getCompositeTokenType(IElementType type1, IElementType type2) {
if (type2 == TemplateTokenType.VARIABLE) {
return type2;
}
else {
return type1;
}
}
};
public TemplateHighlighter() {
myLexer = new MergingLexerAdapter(new TemplateTextLexer(), TokenSet.create(TemplateTokenType.TEXT));
}
@Override
@@ -146,11 +134,7 @@ public class TemplateEditorUtil {
@Override
@NotNull
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
if (tokenType == TemplateTokenType.VARIABLE) {
return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES);
}
return myOriginalHighlighter.getTokenHighlights(tokenType);
return tokenType == TemplateTokenType.VARIABLE ? pack(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES) : EMPTY;
}
}
}
@@ -30,6 +30,7 @@ import com.intellij.ide.util.PropertiesComponent;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.ListPopupStep;
@@ -919,35 +920,77 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
public static ItemWrapper[] createSettingsList(@NotNull final Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
public static ItemWrapper[] createSettingsList(@NotNull Project project, @NotNull ExecutorProvider executorProvider, boolean createEditAction) {
List<ItemWrapper> result = new ArrayList<ItemWrapper>();
final List<ItemWrapper> result = new ArrayList<ItemWrapper>();
if (createEditAction) {
ItemWrapper<Void> edit = new ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return AllIcons.Actions.EditSource;
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
if (new EditConfigurationsDialog(project) {
@Override
protected void init() {
setOKButtonText(executor.getStartActionText());
setOKButtonIcon(executor.getIcon());
myExecutor = executor;
super.init();
}
}.showAndGet()) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
ExecutionUtil.runConfiguration(configuration, executor);
}
}
}, project.getDisposed());
}
}
@Override
public boolean available(Executor executor) {
return true;
}
};
edit.setMnemonic(0);
result.add(edit);
}
RunManagerEx manager = RunManagerEx.getInstanceEx(project);
final RunnerAndConfigurationSettings selectedConfiguration = manager.getSelectedConfiguration();
if (selectedConfiguration != null) {
boolean isFirst = true;
final ExecutionTarget activeTarget = ExecutionTargetManager.getActiveTarget(project);
for (final ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) {
for (ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selectedConfiguration)) {
result.add(new ItemWrapper<ExecutionTarget>(eachTarget, isFirst) {
{
setChecked(eachTarget.equals(activeTarget));
setChecked(getValue().equals(activeTarget));
}
@Override
public Icon getIcon() {
return eachTarget.getIcon();
return getValue().getIcon();
}
@Override
public String getText() {
return eachTarget.getDisplayName();
return getValue().getDisplayName();
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
ExecutionTargetManager.setActiveTarget(project, eachTarget);
ExecutionTargetManager.setActiveTarget(project, getValue());
ExecutionUtil.runConfiguration(selectedConfiguration, executor);
}
@@ -960,18 +1003,24 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
final Map<RunnerAndConfigurationSettings, ItemWrapper> wrappedExisting = new LinkedHashMap<RunnerAndConfigurationSettings, ItemWrapper>();
final ConfigurationType[] types = manager.getConfigurationFactories();
for (final ConfigurationType type : types) {
Map<RunnerAndConfigurationSettings, ItemWrapper> wrappedExisting = new LinkedHashMap<RunnerAndConfigurationSettings, ItemWrapper>();
for (ConfigurationType type : manager.getConfigurationFactories()) {
if (!(type instanceof UnknownConfigurationType)) {
Map<String, List<RunnerAndConfigurationSettings>> structure = manager.getStructure(type);
for (final Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) {
if (entry.getValue().isEmpty())
for (Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) {
if (entry.getValue().isEmpty()) {
continue;
}
final String key = entry.getKey();
if (key != null){
if (key != null) {
boolean isSelected = entry.getValue().contains(selectedConfiguration);
FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider, key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName()+"\")" : ""), entry.getValue());
if (isSelected) {
assert selectedConfiguration != null;
}
FolderWrapper folderWrapper = new FolderWrapper(project, executorProvider,
key + (isSelected ? " (mnemonic is to \"" + selectedConfiguration.getName() + "\")" : ""),
entry.getValue());
if (isSelected) {
folderWrapper.setMnemonic(1);
}
@@ -992,53 +1041,6 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
populateWithDynamicRunners(result, wrappedExisting, project, manager, selectedConfiguration);
result.addAll(wrappedExisting.values());
//noinspection unchecked
final ItemWrapper edit = new ItemWrapper(null) {
@Override
public Icon getIcon() {
return AllIcons.Actions.EditSource;
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ActionsBundle.message("action.editRunConfigurations.text"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project) {
@Override
protected void init() {
setOKButtonText(executor.getStartActionText());
setOKButtonIcon(executor.getIcon());
myExecutor = executor;
super.init();
}
};
dialog.show();
if (dialog.isOK()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ExecutionUtil.runConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor);
}
});
}
}
@Override
public boolean available(Executor executor) {
return true;
}
};
edit.setMnemonic(0);
if (createEditAction) {
result.add(0, edit);
}
return result.toArray(new ItemWrapper[result.size()]);
}
@@ -26,7 +26,7 @@ public class EditConfigurationsDialog extends SingleConfigurableEditor implement
protected Executor myExecutor;
public EditConfigurationsDialog(final Project project) {
super(project, new RunConfigurable(project), IdeModalityType.PROJECT);
super(project, new RunConfigurable(project), "#com.intellij.execution.impl.EditConfigurationsDialog", IdeModalityType.PROJECT);
((RunConfigurable)getConfigurable()).setRunDialog(this);
setTitle(ExecutionBundle.message("run.debug.dialog.title"));
setHorizontalStretch(1.3F);
@@ -42,11 +42,6 @@ public class EditConfigurationsDialog extends SingleConfigurableEditor implement
}
}
@Override
protected String getDimensionServiceKey() {
return "#com.intellij.execution.impl.EditConfigurationsDialog";
}
@Nullable
@Override
public Executor getExecutor() {
@@ -290,7 +290,8 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
final ContentManager manager = ContentFactory.SERVICE.getInstance().createContentManager(this, false, myProject);
Disposer.register((Disposable)myRunnerUi, manager);
manager.getComponent();
} else {
}
else {
final DockManager dockManager = DockManager.getInstance(myProject);
if (dockManager != null) { //default project
dockManager.register(this);
@@ -1375,7 +1376,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
private class MyComponent extends Wrapper.FocusHolder implements DataProvider, QuickActionProvider {
private boolean myWasEverAdded;
public MyComponent() {
@@ -1390,9 +1390,13 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
if (KEY.is(dataId)) {
return RunnerContentUi.this;
}
else {
return null;
ContentManager originalContentManager = myOriginal == null ? null : myOriginal.getContentManager();
JComponent originalContentComponent = originalContentManager == null ? null : originalContentManager.getComponent();
if (originalContentComponent instanceof DataProvider) {
return ((DataProvider)originalContentComponent).getData(dataId);
}
return null;
}
@SuppressWarnings("NullableProblems")
@@ -1841,9 +1845,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
public void dragOutFinished(MouseEvent event, TabInfo source) {
final Component component = event.getComponent();
final IdeFrame window = UIUtil.getParentOfType(IdeFrame.class, component);
if (window != null) {
}
mySession.process(event);
mySession = null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import com.intellij.ide.DataManager;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.fileTemplates.FileTemplate;
import com.intellij.ide.fileTemplates.FileTemplateManager;
import com.intellij.lexer.CompositeLexer;
import com.intellij.lexer.FlexAdapter;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.MergingLexerAdapter;
@@ -38,7 +37,8 @@ import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.editor.event.DocumentAdapter;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
import com.intellij.openapi.editor.ex.util.LayerDescriptor;
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
import com.intellij.openapi.fileTypes.*;
@@ -99,7 +99,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
private URL myDefaultDescriptionUrl;
private final Project myProject;
private final List<ChangeListener> myChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList();;
private final List<ChangeListener> myChangeListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private Splitter mySplitter;
private final FileType myVelocityFileType = FileTypeManager.getInstance().getFileTypeByExtension("ft");
private JPanel myDescriptionPanel;
@@ -205,13 +205,13 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
myNameField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
public void focusLost(@NotNull FocusEvent e) {
onNameChanged();
}
});
myExtensionField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
public void focusLost(@NotNull FocusEvent e) {
onNameChanged();
}
});
@@ -221,8 +221,11 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
private Editor createEditor() {
EditorFactory editorFactory = EditorFactory.getInstance();
Document doc = myFile == null ? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText()) : PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
Editor editor = myProject == null ? editorFactory.createEditor(doc) : editorFactory.createEditor(doc, myProject);
Document doc = myFile == null
? editorFactory.createDocument(myTemplate == null ? "" : myTemplate.getText())
: PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
assert doc != null;
Editor editor = editorFactory.createEditor(doc, myProject);
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
@@ -367,7 +370,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
@Nullable
private PsiFile createFile(final String text, final String name) {
if (myTemplate == null || myProject == null) return null;
if (myTemplate == null) return null;
final FileType fileType = myVelocityFileType;
if (fileType == FileTypes.UNKNOWN) return null;
@@ -388,7 +391,7 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
}
private EditorHighlighter createHighlighter() {
if (myTemplate != null && myProject != null && myVelocityFileType != FileTypes.UNKNOWN) {
if (myTemplate != null && myVelocityFileType != FileTypes.UNKNOWN) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, new LightVirtualFile("aaa." + myTemplate.getExtension() + ".ft"));
}
@@ -399,38 +402,27 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
if (fileType == null) {
fileType = FileTypes.PLAIN_TEXT;
}
SyntaxHighlighter originalHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
if (originalHighlighter == null) originalHighlighter = new PlainSyntaxHighlighter();
return new LexerEditorHighlighter(new TemplateHighlighter(originalHighlighter), EditorColorsManager.getInstance().getGlobalScheme());
if (originalHighlighter == null) {
originalHighlighter = new PlainSyntaxHighlighter();
}
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
LayeredLexerEditorHighlighter highlighter = new LayeredLexerEditorHighlighter(new TemplateHighlighter(), scheme);
highlighter.registerLayer(FileTemplateTokenType.TEXT, new LayerDescriptor(originalHighlighter, ""));
return highlighter;
}
private final static TokenSet TOKENS_TO_MERGE = TokenSet.create(FileTemplateTokenType.TEXT);
private static class TemplateHighlighter extends SyntaxHighlighterBase {
private final Lexer myLexer;
private final SyntaxHighlighter myOriginalHighlighter;
public TemplateHighlighter(SyntaxHighlighter original) {
myOriginalHighlighter = original;
Lexer originalLexer = original.getHighlightingLexer();
Lexer templateLexer = new FlexAdapter(new FileTemplateTextLexer());
templateLexer = new MergingLexerAdapter(templateLexer, TOKENS_TO_MERGE);
myLexer = new CompositeLexer(originalLexer, templateLexer) {
@Override
protected IElementType getCompositeTokenType(IElementType type1, IElementType type2) {
if (type2 == FileTemplateTokenType.MACRO || type2 == FileTemplateTokenType.DIRECTIVE) {
return type2;
}
else {
return type1;
}
}
};
public TemplateHighlighter() {
myLexer = new MergingLexerAdapter(new FlexAdapter(new FileTemplateTextLexer()), TokenSet.create(FileTemplateTokenType.TEXT));
}
@Override
@NotNull
@Override
public Lexer getHighlightingLexer() {
return myLexer;
}
@@ -438,14 +430,11 @@ public class FileTemplateConfigurable implements Configurable, Configurable.NoSc
@Override
@NotNull
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
if (tokenType == FileTemplateTokenType.MACRO) {
return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES);
}
else if (tokenType == FileTemplateTokenType.DIRECTIVE) {
return pack(myOriginalHighlighter.getTokenHighlights(tokenType), TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES);
if (tokenType == FileTemplateTokenType.MACRO || tokenType == FileTemplateTokenType.DIRECTIVE) {
return pack(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES);
}
return myOriginalHighlighter.getTokenHighlights(tokenType);
return EMPTY;
}
}
@@ -419,7 +419,7 @@ public class ManagePackagesDialog extends DialogWrapper {
else {
myFilteredOut.add(repoPackage);
}
if (StringUtil.equals(packageName, filter)) toSelect = repoPackage;
if (StringUtil.equalsIgnoreCase(packageName, filter)) toSelect = repoPackage;
}
filter(filtered, toSelect);
}
@@ -43,19 +43,23 @@ public abstract class ShowSettingsUtil {
public abstract boolean editConfigurable(@Nullable Component parent, @NotNull Configurable configurable);
public abstract boolean editConfigurable(Component parent, Configurable configurable, Runnable advancedInitialization);
public abstract boolean editConfigurable(Component parent, Configurable configurable, @NotNull Runnable advancedInitialization);
public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable);
public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable, boolean showApplyButton);
public abstract boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable);
/**
* @deprecated create a new instance of configurable instead
* to remove in IDEA 15
*/
public abstract <T extends Configurable> T findProjectConfigurable(Project project, Class<T> confClass);
/**
* @deprecated create a new instance of configurable instead
* to remove in IDEA 15
*/
public abstract <T extends Configurable> T findApplicationConfigurable(Class<T> confClass);
@@ -1233,6 +1233,7 @@ public abstract class DialogWrapper {
if (SystemInfo.isWindows) {
installEnterHook(root);
}
myErrorTextAlarm.setActivationComponent(root);
}
@NotNull
@@ -1838,15 +1839,14 @@ public abstract class DialogWrapper {
return;
}
myLastErrorText = text;
if (myActualSize == null && !StringUtil.isEmpty(text)) {
myActualSize = getSize();
}
myErrorTextAlarm.cancelAllRequests();
myErrorTextAlarm.addRequest(new Runnable() {
@Override
public void run() {
final String text = myLastErrorText;
if (myActualSize == null && !StringUtil.isEmpty(text)) {
myActualSize = getSize();
}
myErrorText.setError(text);
if (text != null && text.length() > myMaxErrorTextLength) {
// during the first update, resize only for growing. during a subsequent update,
@@ -235,7 +235,7 @@ public class JBScrollPane extends JScrollPane {
}
if (colHead != null) {
Rectangle headerBounds = colHead.getBounds();
headerBounds.width = viewportBounds.width - headerBounds.x;
headerBounds.width = viewportBounds.width;
colHead.setBounds(headerBounds);
}
hideFromView(layout.getCorner(UPPER_RIGHT_CORNER));
@@ -249,7 +249,7 @@ public class JBScrollPane extends JScrollPane {
}
if (rowHead != null) {
Rectangle headerBounds = rowHead.getBounds();
headerBounds.height = viewportBounds.height - headerBounds.y;
headerBounds.height = viewportBounds.height;
rowHead.setBounds(headerBounds);
}
@@ -1,37 +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 com.intellij.ide.actionMacro;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nullable;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jul 22, 2003
* Time: 3:30:56 PM
* To change this template use Options | File Templates.
*/
public class EditMacrosDialog extends SingleConfigurableEditor {
public EditMacrosDialog(@Nullable Project project) {
super(project, new ActionMacroConfigurable());
}
protected String getDimensionServiceKey(){
return "#com.intellij.ide.actionMacro.EditMacrosDialog";
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,29 +16,22 @@
package com.intellij.ide.actionMacro.actions;
import com.intellij.ide.actionMacro.ActionMacro;
import com.intellij.ide.actionMacro.ActionMacroConfigurable;
import com.intellij.ide.actionMacro.ActionMacroManager;
import com.intellij.ide.actionMacro.EditMacrosDialog;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.DumbAware;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jul 22, 2003
* Time: 3:33:04 PM
* To change this template use Options | File Templates.
*/
public class EditMacrosAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(AnActionEvent e) {
EditMacrosDialog dialog = new EditMacrosDialog(CommonDataKeys.PROJECT.getData(e.getDataContext()));
dialog.show();
ShowSettingsUtil.getInstance().editConfigurable(e.getProject(), "#com.intellij.ide.actionMacro.EditMacrosDialog", new ActionMacroConfigurable());
}
@Override
public void update(AnActionEvent e) {
final ActionMacroManager manager = ActionMacroManager.getInstance();
ActionMacro[] macros = manager.getAllMacros();
ActionMacro[] macros = ActionMacroManager.getInstance().getAllMacros();
e.getPresentation().setEnabled(macros != null && macros.length > 0);
}
}
@@ -18,10 +18,7 @@ package com.intellij.ide.actions;
import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.options.*;
import com.intellij.openapi.options.ex.*;
import com.intellij.openapi.options.newEditor.IdeSettingsDialog;
import com.intellij.openapi.options.newEditor.OptionsEditor;
@@ -31,6 +28,7 @@ import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.navigation.Place;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jetbrains.annotations.NotNull;
@@ -60,6 +58,7 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
if (Registry.is("ide.new.settings.dialog")) {
return new IdeSettingsDialog(project, filteredGroups, toSelect);
}
//noinspection deprecation
return Registry.is("ide.perProjectModality")
? new OptionsEditorDialog(project, filteredGroups, toSelect, true)
: new OptionsEditorDialog(project, filteredGroups, toSelect);
@@ -160,8 +159,6 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) {
ConfigurableGroup[] group = getConfigurableGroups(project, true);
Project actualProject = getProject(project);
group = filterEmptyGroups(group);
final Configurable configurable2Select = findConfigurable2Select(id2Select, group);
@@ -231,17 +228,29 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
@Override
public <T extends Configurable> T findProjectConfigurable(final Project project, final Class<T> confClass) {
//noinspection deprecation
return ConfigurableExtensionPointUtil.findProjectConfigurable(project, confClass);
}
@Override
public boolean editConfigurable(Project project, String dimensionServiceKey, @NotNull Configurable configurable) {
return editConfigurable(null, project, configurable, dimensionServiceKey, null);
return editConfigurable(project, dimensionServiceKey, configurable, isWorthToShowApplyButton(configurable));
}
private static boolean isWorthToShowApplyButton(@NotNull Configurable configurable) {
return configurable instanceof Place.Navigator ||
configurable instanceof Composite ||
configurable instanceof TabbedConfigurable;
}
@Override
public boolean editConfigurable(Project project, String dimensionServiceKey, @NotNull Configurable configurable, boolean showApplyButton) {
return editConfigurable(null, project, configurable, dimensionServiceKey, null, showApplyButton);
}
@Override
public boolean editConfigurable(Project project, Configurable configurable, Runnable advancedInitialization) {
return editConfigurable(null, project, configurable, createDimensionKey(configurable), advancedInitialization);
return editConfigurable(null, project, configurable, createDimensionKey(configurable), advancedInitialization, isWorthToShowApplyButton(configurable));
}
@Override
@@ -251,20 +260,21 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
@Override
public boolean editConfigurable(@Nullable Component parent, @NotNull Configurable configurable, @Nullable Runnable advancedInitialization) {
return editConfigurable(parent, null, configurable, createDimensionKey(configurable), advancedInitialization);
return editConfigurable(parent, null, configurable, createDimensionKey(configurable), advancedInitialization, isWorthToShowApplyButton(configurable));
}
private static boolean editConfigurable(@Nullable Component parent,
@Nullable Project project,
@NotNull Configurable configurable,
String dimensionKey,
@Nullable final Runnable advancedInitialization) {
SingleConfigurableEditor editor;
@Nullable final Runnable advancedInitialization,
boolean showApplyButton) {
final SingleConfigurableEditor editor;
if (parent == null) {
editor = new SingleConfigurableEditor(project, configurable, dimensionKey);
editor = new SingleConfigurableEditor(project, configurable, dimensionKey, showApplyButton);
}
else {
editor = new SingleConfigurableEditor(parent, configurable, dimensionKey);
editor = new SingleConfigurableEditor(parent, configurable, dimensionKey, showApplyButton);
}
if (advancedInitialization != null) {
new UiNotifyConnector.Once(editor.getContentPane(), new Activatable.Adapter() {
@@ -284,8 +294,8 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
}
@Override
public boolean editConfigurable(Component parent, String dimensionServiceKey,Configurable configurable) {
return editConfigurable(parent, null, configurable, dimensionServiceKey, null);
public boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable) {
return editConfigurable(parent, null, configurable, dimensionServiceKey, null, isWorthToShowApplyButton(configurable));
}
public boolean isAlreadyShown() {
@@ -20,18 +20,21 @@ import java.util.List;
public abstract class CompositeConfigurable<T extends UnnamedConfigurable> extends BaseConfigurable {
private List<T> myConfigurables;
@Override
public void reset() {
for (T configurable : getConfigurables()) {
configurable.reset();
}
}
@Override
public void apply() throws ConfigurationException {
for (T configurable : getConfigurables()) {
configurable.apply();
}
}
@Override
public boolean isModified() {
for (T configurable : getConfigurables()) {
if (configurable.isModified()) {
@@ -41,6 +44,7 @@ public abstract class CompositeConfigurable<T extends UnnamedConfigurable> exten
return false;
}
@Override
public void disposeUIResources() {
if (myConfigurables != null) {
for (final T myConfigurable : myConfigurables) {
@@ -25,17 +25,13 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.PathMacros;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.WaitForProgressToShow;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
public class ProjectMacrosUtil {
@@ -50,11 +46,7 @@ public class ProjectMacrosUtil {
if (application.isHeadlessEnvironment() || application.isUnitTestMode()) {
throw new RuntimeException(text + ": " + StringUtil.join(undefinedMacros, ", "));
}
final UndefinedMacrosConfigurable configurable =
new UndefinedMacrosConfigurable(text, undefinedMacros);
final SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
editor.show();
return editor.isOK();
return ShowSettingsUtil.getInstance().editConfigurable(project, new UndefinedMacrosConfigurable(text, undefinedMacros));
}
public static boolean checkNonIgnoredMacros(final Project project, final Set<String> usedMacros){
@@ -136,7 +136,8 @@ public class TempFileSystem extends LocalFileSystemBase {
}
fsItem.getParent().removeChild(fsItem);
((FSDir)newParentItem).addChild(fsItem);
newDir.addChild(fsItem);
fsItem.myParent = newDir;
}
@Override
@@ -263,7 +264,7 @@ public class TempFileSystem extends LocalFileSystemBase {
}
private abstract static class FSItem {
private final FSDir myParent;
private FSDir myParent;
private String myName;
private long myTimestamp;
private boolean myWritable;
@@ -298,6 +298,7 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
protected void processKeyEvent(KeyEvent e) {
if (e.isAltDown()) return;
if (e.isShiftDown() && isNavigationKey(e.getKeyCode())) return;
if (mySearchPopup != null) {
mySearchPopup.processKeyEvent(e);
return;
@@ -499,6 +500,15 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
return keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN;
}
private static boolean isPgUpPgDown(int keyCode) {
return keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_PAGE_DOWN;
}
private static boolean isNavigationKey(int keyCode) {
return isPgUpPgDown(keyCode) || isUpDownHomeEnd(keyCode);
}
private void manageSearchPopup(@Nullable SearchPopup searchPopup) {
Project project = null;
if (ApplicationManager.getApplication() != null && !ApplicationManager.getApplication().isDisposed()) {
@@ -676,6 +676,11 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
dataProviders.add(provider);
}
@Nullable
public DataProvider getDataProvider() {
return myComponent;
}
@Override
public void propertyChange(@NotNull PropertyChangeEvent event) {
if (Content.PROP_COMPONENT.equals(event.getPropertyName())) {
@@ -127,21 +127,16 @@ public class CloudAccountSelectionEditor {
}
};
final SingleConfigurableEditor configurableEditor
= new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) {
if (!new SingleConfigurableEditor(myMainPanel, configurable, ShowSettingsUtilImpl.createDimensionKey(configurable), false) {
{
errorConsumerRef.set(new Consumer<String>() {
@Override
public void consume(String s) {
setErrorText(s);
}
});
}
};
if (!configurableEditor.showAndGet()) {
}.showAndGet()) {
return;
}
@@ -1,152 +0,0 @@
package com.intellij.structuralsearch.plugin.ui;
import com.intellij.openapi.MnemonicHelper;
import com.intellij.CommonBundle;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.*;
import org.jetbrains.annotations.NonNls;
/**
* Base dialog class
*/
public abstract class DialogBase extends JDialog {
private JButton ok;
private JButton cancel;
private Action okAction;
private Action cancelAction;
private static Rectangle virtualBounds;
class OkAction extends AbstractAction {
OkAction() {
putValue(NAME, CommonBundle.getOkButtonText());
}
public void actionPerformed(ActionEvent e) {
doOKAction();
}
}
class CancelAction extends AbstractAction {
CancelAction() {
putValue(NAME,CommonBundle.getCancelButtonText());
}
public void actionPerformed(ActionEvent e) {
doCancelAction();
}
}
protected DialogBase() {
this(null);
}
protected DialogBase(Frame frame) {
this(frame,true);
}
protected DialogBase(Frame frame,boolean modal) {
super(frame,modal);
new MnemonicHelper().register(getContentPane());
okAction = new OkAction();
cancelAction = new CancelAction();
ok = createJButtonForAction(okAction);
cancel = createJButtonForAction(cancelAction);
if (virtualBounds == null) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
virtualBounds = new Rectangle();
for (int j = 0; j < gs.length; j++) {
GraphicsDevice gd = gs[j];
GraphicsConfiguration[] gc = gd.getConfigurations();
for (int i=0; i < gc.length; i++) {
virtualBounds = virtualBounds.union(gc[i].getBounds());
}
}
}
@NonNls String cancelCommandName = "close";
KeyStroke escKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0);
ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escKeyStroke, cancelCommandName);
ok.getActionMap().put(cancelCommandName, cancelAction);
@NonNls String startCommandName = "start";
KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,InputEvent.CTRL_MASK);
ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterKeyStroke, startCommandName);
ok.getActionMap().put(startCommandName, okAction);
}
protected JButton getCancelButton() {
return cancel;
}
protected JButton getOkButton() {
return ok;
}
protected abstract JComponent createCenterPanel();
protected JComponent createSouthPanel() {
JPanel p = new JPanel( null );
p.setLayout( new BoxLayout(p,BoxLayout.X_AXIS) );
p.add(Box.createHorizontalGlue());
p.add(getOkButton());
p.add(getCancelButton());
return p;
}
public void init() {
getContentPane().setLayout(new BorderLayout());
getContentPane().add(BorderLayout.CENTER,createCenterPanel());
getContentPane().add(BorderLayout.SOUTH,createSouthPanel());
pack();
Dimension dim = getPreferredSize();
setLocation(
(int)(virtualBounds.getWidth()/2 - dim.getWidth()/2),
(int)(virtualBounds.getHeight()/2 - dim.getHeight()/2)
);
}
public void show() {
pack();
super.show();
}
protected void doCancelAction() {
setVisible(false);
}
protected void doOKAction() {
setVisible(false);
}
protected void setOKActionEnabled(boolean b) {
okAction.setEnabled(b);
}
protected void setOKButtonText(String text) {
okAction.putValue(Action.NAME,text);
}
protected void setCancelButtonText(String text) {
cancelAction.putValue(Action.NAME,text);
}
protected JButton createJButtonForAction(Action _action) {
JButton jb = new JButton( (String)_action.getValue(Action.NAME) );
jb.setAction(_action);
return jb;
}
}
@@ -3,7 +3,6 @@ package com.intellij.structuralsearch.plugin.ui;
import com.intellij.codeInsight.hint.TooltipController;
import com.intellij.codeInsight.hint.TooltipGroup;
import com.intellij.codeInsight.template.TemplateContextType;
import com.intellij.codeInsight.template.impl.TemplateContext;
import com.intellij.codeInsight.template.impl.TemplateEditorUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
@@ -77,12 +76,8 @@ public class UIUtil {
else {
((EditorEx)editor).setEmbeddedIntoDialogWrapper(true);
}
if (contextType != null) {
TemplateContext context = new TemplateContext();
context.setEnabled(contextType, true);
TemplateEditorUtil.setHighlighter(editor, context);
}
TemplateEditorUtil.setHighlighter(editor, contextType);
if (addToolTipForVariableHandler) {
SubstitutionShortInfoHandler handler = new SubstitutionShortInfoHandler(editor);
@@ -222,11 +217,6 @@ public class UIUtil {
}
public static void updateHighlighter(Editor editor, StructuralSearchProfile profile) {
final TemplateContextType contextType = profile.getTemplateContextType();
if (contextType != null) {
TemplateContext context = new TemplateContext();
context.setEnabled(contextType, true);
TemplateEditorUtil.setHighlighter(editor, context);
}
TemplateEditorUtil.setHighlighter(editor, profile.getTemplateContextType());
}
}
@@ -58,7 +58,7 @@ ide.checkDuplicateMnemonics.description=Check for duplicate mnemonics.
ide.dnd.textHints=false
ide.max.recent.projects=25
ide.hide.excluded.files=true
ide.hide.excluded.files=false
ide.hide.excluded.files.restartRequired=true
ide.hide.excluded.files.description=Do not show excluded files in Project View and exclude them from VCS
@@ -20,11 +20,8 @@
package com.intellij.lang.properties.editor;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.PropertiesHighlighter;
import com.intellij.lang.properties.PropertiesUtil;
import com.intellij.lang.properties.*;
import com.intellij.lang.properties.ResourceBundle;
import com.intellij.lang.properties.psi.Property;
import com.intellij.navigation.ColoredItemPresentation;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.editor.colors.EditorColorsManager;
@@ -62,7 +59,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
@Override
public PsiElement[] getPsiElements() {
return new PsiElement[] {getProperty().getPsiElement()};
return new PsiElement[] {getValue()};
}
public void setPresentableName(final String presentableName) {
@@ -70,8 +67,8 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView
}
@Override
public Property getValue() {
return (Property)myProperty.getPsiElement();
public PsiElement getValue() {
return myProperty.getPsiElement();
}
@Override
@@ -170,7 +170,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
TreeElement[] children = myStructureViewComponent.getTreeModel().getRoot().getChildren();
if (children.length != 0) {
TreeElement child = children[0];
String propName = ((ResourceBundlePropertyStructureViewElement)child).getValue().getUnescapedKey();
String propName = ((ResourceBundlePropertyStructureViewElement)child).getProperty().getUnescapedKey();
setState(new ResourceBundleEditorState(propName));
}
myDataProviderPanel = new DataProviderPanel(splitPanel);
@@ -248,7 +248,7 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit
DefaultMutableTreeNode node = toCheck.pop();
final ResourceBundleEditorViewElement element = getSelectedElement(node);
String value = element instanceof ResourceBundlePropertyStructureViewElement
? ((ResourceBundlePropertyStructureViewElement)element).getValue().getUnescapedKey()
? ((ResourceBundlePropertyStructureViewElement)element).getProperty().getUnescapedKey()
: null;
if (propertyName.equals(value)) {
nodeToSelect = node;
@@ -191,11 +191,22 @@ public class SearchingForTestsTask extends Task.Backgroundable {
private void composeTestSuiteFromClasses() {
Map<String, Collection<String>> map = new HashMap<String, Collection<String>>();
final boolean findTestMethodsForClass = shouldSearchForTestMethods();
for (final Map.Entry<PsiClass, Collection<PsiMethod>> entry : myClasses.entrySet()) {
Collection<String> methods = new HashSet<String>(entry.getValue().size());
for (PsiMethod method : entry.getValue()) {
final Collection<PsiMethod> depMethods = entry.getValue();
Collection<String> methods = new HashSet<String>(depMethods.size());
for (PsiMethod method : depMethods) {
methods.add(method.getName());
}
if (findTestMethodsForClass && depMethods.isEmpty()) {
for (PsiMethod method : entry.getKey().getMethods()) {
if (TestNGUtil.hasTest(method)) {
methods.add(method.getName());
}
}
}
map.put(ApplicationManager.getApplication().runReadAction(
new Computable<String>() {
@Nullable
@@ -243,6 +254,17 @@ public class SearchingForTestsTask extends Task.Backgroundable {
}
}
private boolean shouldSearchForTestMethods() {
boolean dependantMethods = false;
for (Collection<PsiMethod> methods : myClasses.values()) {
if (!methods.isEmpty()) {
dependantMethods = true;
break;
}
}
return dependantMethods;
}
private void composeTestSuiteFromXml() throws CantRunException {
final Map<String, String> buildTestParams = buildTestParameters();
try {
@@ -144,19 +144,6 @@ public class TestNGRunnableState extends JavaCommandLineState {
if (mySearchForTestIndicator != null && !mySearchForTestIndicator.isCanceled()) {
task.finish();
}
final Runnable notificationRunnable = new Runnable() {
public void run() {
final Project project = config.getProject();
if (project.isDisposed()) return;
final TestConsoleProperties consoleProperties = console.getProperties();
if (consoleProperties == null) return;
final TestNGResults resultsView = console.getResultsView();
TestsUIUtil.notifyByBalloon(project, myStarted, console.getResultsView().getRoot(), consoleProperties, "in " + resultsView.getTime());
}
};
SwingUtilities.invokeLater(notificationRunnable);
}
@Override
@@ -175,7 +162,7 @@ public class TestNGRunnableState extends JavaCommandLineState {
public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
final TestNGResults resultsView = console.getResultsView();
if (resultsView != null) {
resultsView.finish();
resultsView.finish(myStarted);
}
}
@@ -23,12 +23,14 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.theoryinpractice.testng.util.TestNGUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -83,10 +85,25 @@ public class DependsOnMethodInspection extends BaseJavaLocalInspectionTool
}
}
}
Matcher matcher = PATTERN.matcher(text);
final Set<String> names = new HashSet<String>();
final Matcher matcher = PATTERN.matcher(text);
int idx = 0;
while (matcher.find()) {
String methodName = matcher.group(1);
String methodName = matcher.group(1);
if (!names.add(methodName)) {
PsiAnnotationMemberValue element2Highlight = value;
if (value instanceof PsiArrayInitializerMemberValue) {
final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)value).getInitializers();
if (idx < initializers.length) {
element2Highlight = initializers[idx];
}
}
problemDescriptors.add(manager.createProblemDescriptor(element2Highlight, "Duplicated method name: " + methodName,
(LocalQuickFix)null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly));
}
checkMethodNameDependency(manager, psiClass, methodName, value, problemDescriptors, isOnTheFly);
idx++;
}
}
}
@@ -48,10 +48,6 @@ public class TestNGRemoteListener implements IRemoteSuiteListener, IRemoteTestLi
public void onFinish(SuiteMessage suiteMessage) {
unboundOutputRoot.flush();
console.finish();
final TestNGResults view = console.getResultsView();
if (view != null) {
view.finish();
}
}
public void onStart(TestMessage tm) {
@@ -378,7 +378,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
rootNode.setStarted(true);
}
public void finish() {
public void finish(final boolean started) {
if (start > 0) {
end = System.currentTimeMillis();
}
@@ -409,6 +409,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
}
}
tree.repaint();
TestsUIUtil.notifyByBalloon(project, started, rootNode, getProperties(), "in " + getTime());
}
});
}
@@ -126,7 +126,7 @@ public class PythonPathEditor extends SdkPathEditor {
@Override
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
AnActionButton reloadButton = new AnActionButton("Reload List of Paths", AllIcons.Actions.Refresh) {
AnActionButton reloadButton = new AnActionButton("Reload list of paths", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent e) {
onReloadButtonClicked();
@@ -435,7 +435,7 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
private class ShowPathButton extends AnActionButton implements DumbAware {
public ShowPathButton() {
super("Show path for the selected interpreter", AllIcons.Actions.ShowAsTree);
super("Show paths for the selected interpreter", AllIcons.Actions.ShowAsTree);
}
@Override
@@ -272,6 +272,7 @@ abstract public class AbstractProjectSettingsStep extends AbstractActionWithPane
}
public boolean checkValid() {
if (myLocationField == null) return true;
final String projectName = myLocationField.getText();
setErrorText(null);
myInstallFramework = false;
@@ -43,7 +43,7 @@ public class PyDocstringVisitorFilter implements PythonVisitorFilter {
visitorClass == PyByteLiteralInspection.class || visitorClass == PyNonAsciiCharInspection.class ||
visitorClass == PyPackageRequirementsInspection.class || visitorClass == PyMandatoryEncodingInspection.class ||
visitorClass == PyInterpreterInspection.class || visitorClass == PyDocstringTypesInspection.class ||
visitorClass == PySingleQuotedDocstringInspection.class) {
visitorClass == PySingleQuotedDocstringInspection.class || visitorClass == PyClassHasNoInitInspection.class) {
return false;
}
//annotators
@@ -200,9 +200,7 @@ public class PyCompatibilityInspection extends PyInspection {
}
for (int i = 0; i != myVersionsToProcess.size(); ++i) {
LanguageLevel languageLevel = myVersionsToProcess.get(i);
PsiFile file = resolved.getContainingFile();
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null && ind.isInLibraryClasses(virtualFile)) {
if (PyBuiltinCache.getInstance(resolved).isBuiltin(resolved)) {
if (!"print".equals(name) && !myUsedImports.contains(name) && UnsupportedFeaturesUtil.BUILTINS.get(languageLevel).contains(name)) {
len = appendLanguageLevel(message, len, languageLevel);
}
@@ -74,7 +74,7 @@ public class PyDefaultArgumentQuickFix implements LocalQuickFix {
}
str.append("):\n\tpass");
PyIfStatement ifStatement = elementGenerator.createFromText(LanguageLevel.forElement(function), PyIfStatement.class,
"if not " + defName + ": " + defName + " = " + defaultValue.getText());
"if not " + defName + ":\n\t" + defName + " = " + defaultValue.getText());
PyStatement firstStatement = list.getStatements()[0];
PyStringLiteralExpression docString = function.getDocStringExpression();
@@ -21,8 +21,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.impl.source.tree.LeafPsiElement;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
@@ -46,15 +48,80 @@ public class StatementEffectFunctionCallQuickFix implements LocalQuickFix {
PsiElement expression = descriptor.getPsiElement();
if (expression != null && expression.isWritable() && expression instanceof PyReferenceExpression) {
final String expressionText = expression.getText();
if (PyNames.PRINT.equals(expressionText) || PyNames.EXEC.equals(expressionText))
replacePrintExec(expression);
if (PyNames.PRINT.equals(expressionText))
replacePrint(expression);
else if (PyNames.EXEC.equals(expressionText))
replaceExec(expression);
else
expression.replace(PyElementGenerator.getInstance(project).createCallExpression(LanguageLevel.forElement(expression),
expressionText));
}
}
private static void replacePrintExec(@NotNull final PsiElement expression) {
private static void replaceExec(@NotNull final PsiElement expression) {
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(expression.getProject());
final String expressionText = expression.getText();
final StringBuilder stringBuilder = new StringBuilder(expressionText + " (");
final PsiElement whiteSpace = expression.getContainingFile().findElementAt(expression.getTextOffset() + expression.getTextLength());
PsiElement next = null;
if (whiteSpace instanceof PsiWhiteSpace) {
final String whiteSpaceText = whiteSpace.getText();
if (!whiteSpaceText.contains("\n")) {
next = whiteSpace.getNextSibling();
while (next instanceof PsiWhiteSpace && whiteSpaceText.contains("\\")) {
next = next.getNextSibling();
}
}
}
else
next = whiteSpace;
RemoveUnnecessaryBackslashQuickFix.removeBackSlash(next);
if (whiteSpace != null) whiteSpace.delete();
if (next == null) {
stringBuilder.append(")");
expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyExpression.class,
stringBuilder.toString()));
return;
}
if (next instanceof PyExpressionStatement) {
final PyExpression expr = ((PyExpressionStatement)next).getExpression();
if (expr instanceof PyBinaryExpression) {
addInArguments(stringBuilder, (PyBinaryExpression)expr);
}
else if (expr instanceof PyTupleExpression) {
final PyExpression[] elements = ((PyTupleExpression)expr).getElements();
if (elements.length > 1) {
if (elements[0] instanceof PyBinaryExpression) {
addInArguments(stringBuilder, (PyBinaryExpression)elements[0]);
}
stringBuilder.append(", ");
stringBuilder.append(elements[1].getText());
}
}
}
else {
stringBuilder.append(next.getText());
}
next.delete();
stringBuilder.append(")");
expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyExpression.class,
stringBuilder.toString()));
}
private static void addInArguments(@NotNull final StringBuilder stringBuilder, @NotNull final PyBinaryExpression binaryExpression) {
final PsiElement operator = binaryExpression.getPsiOperator();
if (operator instanceof LeafPsiElement && ((LeafPsiElement)operator).getElementType() == PyTokenTypes.IN_KEYWORD) {
stringBuilder.append(binaryExpression.getLeftExpression().getText());
stringBuilder.append(", ");
final PyExpression rightExpression = binaryExpression.getRightExpression();
if (rightExpression != null)
stringBuilder.append(rightExpression.getText());
}
}
private static void replacePrint(@NotNull final PsiElement expression) {
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(expression.getProject());
final String expressionText = expression.getText();
final StringBuilder stringBuilder = new StringBuilder(expressionText + " (");
@@ -84,8 +151,7 @@ public class StatementEffectFunctionCallQuickFix implements LocalQuickFix {
final String text = next instanceof PyExpressionStatement ? ((PyExpressionStatement)next).getExpression().getText() : next.getText();
stringBuilder.append(text);
if (text.endsWith(",") && PyNames.PRINT.equals(expressionText))
stringBuilder.append(" end=' '");
if (text.endsWith(",")) stringBuilder.append(" end=' '");
next.delete();
}
stringBuilder.append(")");
@@ -44,7 +44,6 @@ public class PyWithIfElseSurrounder extends PyStatementSurrounder {
PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyIfStatement.class, "if True:\n pass\nelse: pass\n");
final PsiElement parent = elements[0].getParent();
final PyStatementList statementList = ifStatement.getIfPart().getStatementList();
assert statementList != null;
statementList.addRange(elements[0], elements[elements.length - 1]);
statementList.deleteChildRange(statementList.getFirstChild(), statementList.getFirstChild());
@@ -22,10 +22,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.PyElementGenerator;
import com.jetbrains.python.psi.PyIfStatement;
import com.jetbrains.python.psi.PyStatementList;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -40,7 +37,6 @@ public class PyWithIfSurrounder extends PyStatementSurrounder {
PyIfStatement ifStatement = PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyIfStatement.class, "if True:\n ");
final PsiElement parent = elements[0].getParent();
final PyStatementList statementList = ifStatement.getIfPart().getStatementList();
assert statementList != null;
statementList.addRange(elements[0], elements[elements.length - 1]);
ifStatement = (PyIfStatement) parent.addBefore(ifStatement, elements[0]);
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
@@ -49,7 +45,8 @@ public class PyWithIfSurrounder extends PyStatementSurrounder {
if (ifStatement == null) {
return null;
}
return ifStatement.getIfPart().getCondition().getTextRange();
final PyExpression condition = ifStatement.getIfPart().getCondition();
return condition != null ? condition.getTextRange() : null;
}
public String getTemplateDescription() {
@@ -44,7 +44,6 @@ public class PyWithTryExceptSurrounder extends PyStatementSurrounder {
createFromText(LanguageLevel.getDefault(), PyTryExceptStatement.class, getTemplate());
final PsiElement parent = elements[0].getParent();
final PyStatementList statementList = tryStatement.getTryPart().getStatementList();
assert statementList != null;
statementList.addRange(elements[0], elements[elements.length - 1]);
statementList.getFirstChild().delete();
tryStatement = (PyTryExceptStatement)parent.addBefore(tryStatement, elements[0]);
@@ -71,7 +70,6 @@ public class PyWithTryExceptSurrounder extends PyStatementSurrounder {
protected TextRange getResultRange(PyTryExceptStatement tryStatement) {
final PyExceptPart part = tryStatement.getExceptParts()[0];
final PyStatementList list = part.getStatementList();
assert list != null;
return list.getTextRange();
}
@@ -42,7 +42,6 @@ public class PyWithTryFinallySurrounder extends PyWithTryExceptSurrounder {
final PyFinallyPart finallyPart = tryStatement.getFinallyPart();
assert finallyPart != null;
final PyStatementList statementList = finallyPart.getStatementList();
assert statementList != null;
return statementList.getTextRange();
}
}
@@ -41,7 +41,6 @@ public class PyWithWhileSurrounder extends PyStatementSurrounder{
PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyWhileStatement.class, "while True:\n ");
final PsiElement parent = elements[0].getParent();
final PyStatementList statementList = whileStatement.getWhilePart().getStatementList();
assert statementList != null;
statementList.addRange(elements[0], elements[elements.length - 1]);
whileStatement = (PyWhileStatement) parent.addBefore(whileStatement, elements[0]);
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
@@ -1,3 +1,4 @@
def foo(args=None):
if not args: args = []
if not args:
args = []
pass