From d8c4a386d906e5a218838ee96f41718c2d1eac9f Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 22 Aug 2014 22:33:58 +0400 Subject: [PATCH 01/16] QuickDoc: support in-memory images --- .../AbstractDocumentationProvider.java | 9 ---- .../DocumentationProviderEx.java | 6 +++ .../documentation/DocumentationComponent.java | 52 +++++++++++++++++-- .../documentation/DocumentationManager.java | 14 +++++ 4 files changed, 69 insertions(+), 12 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java b/platform/lang-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java index f57190e5725e..9a80bf72ed6d 100644 --- a/platform/lang-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java +++ b/platform/lang-api/src/com/intellij/lang/documentation/AbstractDocumentationProvider.java @@ -15,15 +15,6 @@ */ package com.intellij.lang.documentation; -import com.intellij.openapi.editor.Editor; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - /** * @author Dmitry Avdeev */ diff --git a/platform/lang-api/src/com/intellij/lang/documentation/DocumentationProviderEx.java b/platform/lang-api/src/com/intellij/lang/documentation/DocumentationProviderEx.java index 5ae5af91bac0..8b9143a0d995 100644 --- a/platform/lang-api/src/com/intellij/lang/documentation/DocumentationProviderEx.java +++ b/platform/lang-api/src/com/intellij/lang/documentation/DocumentationProviderEx.java @@ -22,6 +22,7 @@ import com.intellij.psi.PsiManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.awt.*; import java.util.List; /** @@ -57,4 +58,9 @@ public class DocumentationProviderEx implements DocumentationProvider { public PsiElement getCustomDocumentationElement(@NotNull final Editor editor, @NotNull final PsiFile file, @Nullable PsiElement contextElement) { return null; } + + @Nullable + public Image getLocalImageForElement(@NotNull PsiElement element, @NotNull String imageSpec) { + return null; + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index f8958709fc20..0ebff2eaf9d5 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -68,10 +68,9 @@ import javax.swing.event.HyperlinkListener; import javax.swing.text.*; import java.awt.*; import java.awt.event.*; -import java.util.Collections; +import java.net.URL; +import java.util.*; import java.util.List; -import java.util.Map; -import java.util.Stack; public class DocumentationComponent extends JPanel implements Disposable, DataProvider { @@ -103,6 +102,13 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr private final MyShowSettingsButton myShowSettingsButton; private boolean myIgnoreFontSizeSliderChange; private String myEffectiveExternalUrl; + private final MyDictionary myImageProvider = new MyDictionary() { + @Override + public Image get(Object key) { + PsiElement element = getElement(); + return element == null ? null : myManager.getElementImage(element, ((URL)key).toExternalForm()); + } + }; private static class Context { final SmartPsiElementPointer element; @@ -180,6 +186,14 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr GraphicsUtil.setupAntialiasing(g); super.paintComponent(g); } + + @Override + public void setDocument(Document doc) { + super.setDocument(doc); + if (doc instanceof StyledDocument) { + doc.putProperty("imageCache", myImageProvider); + } + } }; DataProvider helpDataProvider = new DataProvider() { @Override @@ -880,4 +894,36 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr mySettingsPanel.setVisible(true); } } + + private static abstract class MyDictionary extends Dictionary { + @Override + public int size() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isEmpty() { + throw new UnsupportedOperationException(); + } + + @Override + public Enumeration keys() { + throw new UnsupportedOperationException(); + } + + @Override + public Enumeration elements() { + throw new UnsupportedOperationException(); + } + + @Override + public V put(K key, V value) { + throw new UnsupportedOperationException(); + } + + @Override + public V remove(Object key) { + throw new UnsupportedOperationException(); + } + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 0ca85ae6e676..c6d0618a1f2b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -994,6 +994,20 @@ public class DocumentationManager extends DockablePopupManager Date: Thu, 21 Aug 2014 10:07:12 +0200 Subject: [PATCH 02/16] remove unnecessary logging --- .../lib/cvsclient/ConnectionStreams.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java index d5e89f20dbb3..5484909b35f0 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java @@ -17,7 +17,6 @@ import org.netbeans.lib.cvsclient.file.IReaderFactory; import org.netbeans.lib.cvsclient.file.IWriterFactory; import org.netbeans.lib.cvsclient.io.IStreamLogger; import org.netbeans.lib.cvsclient.util.BugLog; -import org.jetbrains.annotations.NonNls; import java.io.*; import java.util.zip.Deflater; @@ -43,8 +42,6 @@ public final class ConnectionStreams private OutputStream outputStream; private DeflaterOutputStream deflaterOutputStream; private final String myCharset; - @NonNls private static final String UNTIL_HERE_THE_CONTENT_IS_GZIPPED_MESSAGE = "@until here the content is gzipped@"; - @NonNls private static final String FROM_NOW_ON_THE_CONTENT_IS_GZIPPED_MESSAGE = "@from now on the content is gzipped@"; // Setup ================================================================== @@ -111,8 +108,6 @@ public final class ConnectionStreams loggedWriter.flush(); if (deflaterOutputStream != null) { deflaterOutputStream.finish(); - - println(UNTIL_HERE_THE_CONTENT_IS_GZIPPED_MESSAGE, streamLogger.getOutputLogStream()); } loggedOutputStream.flush(); } @@ -155,9 +150,6 @@ public final class ConnectionStreams loggedWriter.flush(); loggedOutputStream.flush(); - println(FROM_NOW_ON_THE_CONTENT_IS_GZIPPED_MESSAGE, streamLogger.getInputLogStream()); - println(FROM_NOW_ON_THE_CONTENT_IS_GZIPPED_MESSAGE, streamLogger.getOutputLogStream()); - deflaterOutputStream = new DeflaterOutputStream(connection.getOutputStream(), new Deflater(6)); setOutputStream(deflaterOutputStream); @@ -179,15 +171,4 @@ public final class ConnectionStreams this.loggedOutputStream = streamLogger.createLoggingOutputStream(outputStream); this.loggedWriter = createWriter(this.loggedOutputStream); } - - private void println(String text, OutputStream outputStream) throws IOException { - final OutputStreamWriter writerNoSpecialEncoding = new OutputStreamWriter(outputStream); - println(text, writerNoSpecialEncoding); - writerNoSpecialEncoding.flush(); - } - - private void println(String text, Writer writer) throws IOException { - writer.write(text); - writer.write('\n'); - } } From 20fe055b5fdefd3bf61449302eb5650e018b0eb1 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 22 Aug 2014 15:55:37 +0200 Subject: [PATCH 03/16] SSR bundle typo --- platform/structuralsearch/source/messages/SSRBundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index bfd12890ffb9..c3aa3eef0d15 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -33,7 +33,7 @@ looking.in.progress.message=Looking in {0} found.progress.message=Found {0} occurrences occurrences.of=occurrences of {0} occurrence=occurrence -found.occurrences=Found occurrence +found.occurrences=Found occurrences # search dialog messages this.pattern.is.malformed.message=This pattern is malformed\n {0} From 5b18584597a7d606160785889cf4954dc80c9df5 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 22 Aug 2014 21:02:56 +0200 Subject: [PATCH 04/16] improve SSR search result presentation of tab and target --- .../replace/ui/ReplaceUsageViewContext.java | 7 ---- .../plugin/ui/UsageViewContext.java | 34 ++++++++----------- .../source/messages/SSRBundle.properties | 4 +-- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java index 6a0d352d3284..f5279e15026e 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java @@ -44,13 +44,6 @@ class ReplaceUsageViewContext extends UsageViewContext { return command; } - protected String _getPresentableText() { - return SSRBundle.message("replaceusageview.text", - getConfiguration().getMatchOptions().getSearchPattern(), - ((ReplaceConfiguration)getConfiguration()).getOptions().getReplacement() - ); - } - public Replacer getReplacer() { return replacer; } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java index a55a16d4c379..e492906f0d4f 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java @@ -8,9 +8,13 @@ import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; +import com.intellij.structuralsearch.MatchOptions; import com.intellij.structuralsearch.SSRBundle; import com.intellij.structuralsearch.plugin.replace.ui.ReplaceCommand; -import com.intellij.usages.*; +import com.intellij.usages.ConfigurableUsageTarget; +import com.intellij.usages.Usage; +import com.intellij.usages.UsageView; +import com.intellij.usages.UsageViewPresentation; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -61,20 +65,15 @@ public class UsageViewContext { return new SearchCommand(mySearchContext.getProject(), this); } - protected String _getPresentableText() { - return myConfiguration.getMatchOptions().getSearchPattern(); - } - - public UsageTarget getTarget() { - return new MyUsageTarget(_getPresentableText()); + public ConfigurableUsageTarget getTarget() { + return new MyUsageTarget(); } public void configure(@NotNull UsageViewPresentation presentation) { - String s = _getPresentableText(); - if (s.length() > 15) s = s.substring(0,15) + "..."; - final String usagesString = SSRBundle.message("occurrences.of", s); - presentation.setUsagesString(usagesString); - presentation.setTabText(StringUtil.capitalize(usagesString)); + final String pattern = myConfiguration.getMatchOptions().getSearchPattern(); + final String usagesString = SSRBundle.message("occurrences.of", StringUtil.shortenTextWithEllipsis(pattern, 50, 0, true)); + presentation.setUsagesString(SSRBundle.message("occurrences.of", pattern)); + presentation.setTabText(usagesString); presentation.setUsagesWord(SSRBundle.message("occurrence")); presentation.setCodeUsagesString(SSRBundle.message("found.occurrences")); } @@ -82,15 +81,12 @@ public class UsageViewContext { protected void configureActions() {} private class MyUsageTarget implements ConfigurableUsageTarget,ItemPresentation { - private final String myPresentableText; - - MyUsageTarget(String str) { - myPresentableText = str; - } + @NotNull @Override public String getPresentableText() { - return myPresentableText; + final MatchOptions matchOptions = myConfiguration.getMatchOptions(); + return SSRBundle.message("occurrences.of.0.in.1", matchOptions.getSearchPattern(), matchOptions.getScope().getDisplayName()); } @Override @@ -177,7 +173,7 @@ public class UsageViewContext { @NotNull @Override public String getLongDescriptiveName() { - return _getPresentableText(); + return getPresentableText(); } } } diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index c3aa3eef0d15..97baac9bf247 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -31,7 +31,8 @@ search.dialog.file.dialect.label=D&ialect: #search usage view specific looking.in.progress.message=Looking in {0} found.progress.message=Found {0} occurrences -occurrences.of=occurrences of {0} +occurrences.of=Occurrences of ''{0}'' +occurrences.of.0.in.1=Occurrences of ''{0}'' in {1} occurrence=occurrence found.occurrences=Found occurrences @@ -48,7 +49,6 @@ selecttemplate.template.label.please.select.template=
Please # Replace Dialog specific titles/options structural.replace.title=Structural Replace shorten.fully.qualified.names.checkbox=Sh&orten fully qualified names -format.according.to.style.checkbox=Fo&rmat according to style replacement.template.label=Replacement template: # Replace validation messages From 4cc4123789ea8d6f46899a0f5c5349b9aadf7905 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 22 Aug 2014 21:07:06 +0200 Subject: [PATCH 05/16] FindInProjectManager cleanup --- .../find/findInProject/FindInProjectManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java b/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java index b78ce2c7ead7..87d0b78acf39 100644 --- a/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java @@ -52,14 +52,14 @@ public class FindInProjectManager { public void findInProject(@NotNull DataContext dataContext) { final boolean isOpenInNewTabEnabled; - final boolean[] toOpenInNewTab = new boolean[1]; + final boolean toOpenInNewTab; Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true); if (selectedContent != null && selectedContent.isPinned()) { - toOpenInNewTab[0] = true; + toOpenInNewTab = true; isOpenInNewTabEnabled = false; } else { - toOpenInNewTab[0] = FindSettings.getInstance().isShowResultsInSeparateView(); + toOpenInNewTab = FindSettings.getInstance().isShowResultsInSeparateView(); isOpenInNewTabEnabled = UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0; } @@ -68,7 +68,7 @@ public class FindInProjectManager { findModel.setReplaceState(false); findModel.setOpenInNewTabVisible(true); findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled); - findModel.setOpenInNewTab(toOpenInNewTab[0]); + findModel.setOpenInNewTab(toOpenInNewTab); FindInProjectUtil.setDirectoryName(findModel, dataContext); String text = PlatformDataKeys.PREDEFINED_TEXT.getData(dataContext); @@ -85,7 +85,7 @@ public class FindInProjectManager { public void run() { findModel.setOpenInNewTabVisible(false); if (isOpenInNewTabEnabled) { - FindSettings.getInstance().setShowResultsInSeparateView(toOpenInNewTab[0] = findModel.isOpenInNewTab()); + FindSettings.getInstance().setShowResultsInSeparateView(findModel.isOpenInNewTab()); } startFindInProject(findModel); From 5404882d3ea01d57eaf4d8669ea6fb85f249d86f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 23 Aug 2014 11:45:15 +0200 Subject: [PATCH 06/16] IDEA-127785 (Add "Replace in Path" searches to "Recent Find Usages") --- .../replaceInProject/ReplaceInProjectManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java index 7e220c149369..15418ed84a73 100644 --- a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java @@ -20,6 +20,7 @@ import com.intellij.find.*; import com.intellij.find.actions.FindInPathAction; import com.intellij.find.findInProject.FindInProjectManager; import com.intellij.find.impl.FindInProjectUtil; +import com.intellij.find.impl.FindManagerImpl; import com.intellij.ide.DataManager; import com.intellij.notification.NotificationGroup; import com.intellij.openapi.actionSystem.ActionManager; @@ -38,6 +39,7 @@ import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.Segment; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -48,9 +50,8 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.ui.content.Content; -import com.intellij.usageView.*; +import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; -import com.intellij.usages.UsageViewManager; import com.intellij.usages.impl.UsageViewImpl; import com.intellij.usages.rules.UsageInFile; import com.intellij.util.AdapterProcessor; @@ -168,7 +169,7 @@ public class ReplaceInProjectManager { @Override public String getLongDescriptiveName() { UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(false, myFindModel); - return "Replace "+presentation.getToolwindowTitle()+" with '"+ myFindModel.getStringToReplace()+"'"; + return "Replace "+ StringUtil.decapitalize(presentation.getToolwindowTitle())+" with '"+ myFindModel.getStringToReplace()+"'"; } @Override @@ -193,7 +194,9 @@ public class ReplaceInProjectManager { final FindManager findManager) { presentation.setMergeDupLinesAvailable(false); final ReplaceContext[] context = new ReplaceContext[1]; - manager.searchAndShowUsages(new UsageTarget[]{new ReplaceInProjectTarget(myProject, findModelCopy)}, + final ReplaceInProjectTarget target = new ReplaceInProjectTarget(myProject, findModelCopy); + ((FindManagerImpl)FindManager.getInstance(myProject)).getFindUsagesManager().addToHistory(target); + manager.searchAndShowUsages(new UsageTarget[]{target}, usageSearcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() { @Override public void usageViewCreated(@NotNull UsageView usageView) { From aeb3ef0499513ca2c0ceb4f1b968d16016a46389 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 23 Aug 2014 11:49:12 +0200 Subject: [PATCH 07/16] IDEA-119760 (Replace in Path missing "Open in new tab" checkbox) --- .../ReplaceInProjectManager.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java index 15418ed84a73..0c6a3766342d 100644 --- a/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java +++ b/platform/lang-impl/src/com/intellij/find/replaceInProject/ReplaceInProjectManager.java @@ -116,9 +116,23 @@ public class ReplaceInProjectManager { } public void replaceInProject(@NotNull DataContext dataContext) { + final boolean isOpenInNewTabEnabled; + final boolean toOpenInNewTab; + final Content selectedContent = com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent(true); + if (selectedContent != null && selectedContent.isPinned()) { + toOpenInNewTab = true; + isOpenInNewTabEnabled = false; + } + else { + toOpenInNewTab = FindSettings.getInstance().isShowResultsInSeparateView(); + isOpenInNewTabEnabled = com.intellij.usageView.UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0; + } final FindManager findManager = FindManager.getInstance(myProject); - final FindModel findModel = (FindModel)findManager.getFindInProjectModel().clone(); + final FindModel findModel = findManager.getFindInProjectModel().clone(); findModel.setReplaceState(true); + findModel.setOpenInNewTabVisible(true); + findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled); + findModel.setOpenInNewTab(toOpenInNewTab); FindInProjectUtil.setDirectoryName(findModel, dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); @@ -139,9 +153,9 @@ public class ReplaceInProjectManager { if (manager == null) return; findManager.getFindInProjectModel().copyFrom(findModel); - final FindModel findModelCopy = (FindModel)findModel.clone(); + final FindModel findModelCopy = findModel.clone(); - final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(true, findModelCopy); + final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModel.isOpenInNewTab(), findModelCopy); final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, true, presentation); UsageSearcherFactory factory = new UsageSearcherFactory(findModelCopy, psiDirectory, processPresentation); From 6b7b9c38f6c4520f13ea802b94b1836e83d76893 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Sun, 24 Aug 2014 01:45:43 +0400 Subject: [PATCH 08/16] WEB-12707 Mocha - console output mangles ANSI escape codes --- .../states/TestComparisionFailedState.java | 21 +++++++------------ .../sm/runner/states/TestFailedState.java | 4 +++- .../sm/runner/ui/TestsPresentationUtil.java | 19 +++++++++++++++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java index 84b28a79c5e8..2d500115c038 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestComparisionFailedState.java @@ -15,9 +15,11 @@ */ package com.intellij.execution.testframework.sm.runner.states; +import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.CompositePrintable; import com.intellij.execution.testframework.Printer; +import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil; import com.intellij.execution.testframework.stacktrace.DiffHyperlink; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.project.Project; @@ -41,10 +43,8 @@ public class TestComparisionFailedState extends TestFailedState implements Abstr super(localizedMessage, stackTrace); myHyperlink = new DiffHyperlink(expectedText, actualText, null); - myErrorMsgPresentation = StringUtil.isEmptyOrSpaces(localizedMessage) ? "" - : localizedMessage; - myStacktracePresentation = StringUtil.isEmptyOrSpaces(stackTrace) ? "" - : stackTrace; + myErrorMsgPresentation = StringUtil.isEmptyOrSpaces(localizedMessage) ? "" : localizedMessage; + myStacktracePresentation = StringUtil.isEmptyOrSpaces(stackTrace) ? "" : stackTrace; } @Override @@ -53,20 +53,15 @@ public class TestComparisionFailedState extends TestFailedState implements Abstr printer.mark(); // Error msg - if (myErrorMsgPresentation != null) { - printer.print(myErrorMsgPresentation, ConsoleViewContentType.ERROR_OUTPUT); - } + TestsPresentationUtil.printWithAnsiColoring(printer, myErrorMsgPresentation, ProcessOutputTypes.STDERR); // Diff link myHyperlink.printOn(printer); // Stacktrace - if (myStacktracePresentation != null) { - printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); - - printer.print(myStacktracePresentation, ConsoleViewContentType.ERROR_OUTPUT); - printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); - } + printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); + TestsPresentationUtil.printWithAnsiColoring(printer, myStacktracePresentation, ProcessOutputTypes.STDERR); + printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT); } public void openDiff(final Project project) { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java index 8906bd1867a9..712f6fc35dbf 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/states/TestFailedState.java @@ -15,8 +15,10 @@ */ package com.intellij.execution.testframework.sm.runner.states; +import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.execution.testframework.CompositePrintable; import com.intellij.execution.testframework.Printer; +import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.containers.ContainerUtilRt; @@ -75,7 +77,7 @@ public class TestFailedState extends AbstractState { printer.mark(); addMark = false; } - printer.print(errorText, ConsoleViewContentType.ERROR_OUTPUT); + TestsPresentationUtil.printWithAnsiColoring(printer, errorText, ProcessOutputTypes.STDERR); } } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java index 7cb42773f735..d36250191b09 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java @@ -15,14 +15,19 @@ */ package com.intellij.execution.testframework.sm.runner.ui; +import com.intellij.execution.process.AnsiEscapeDecoder; +import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.execution.testframework.PoolOfTestIcons; +import com.intellij.execution.testframework.Printer; import com.intellij.execution.testframework.TestConsoleProperties; import com.intellij.execution.testframework.TestsUIUtil; import com.intellij.execution.testframework.sm.SMTestsRunnerBundle; import com.intellij.execution.testframework.sm.runner.SMTestProxy; import com.intellij.execution.testframework.sm.runner.states.TestStateInfo; import com.intellij.execution.testframework.ui.TestsProgressAnimator; +import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.icons.AllIcons; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.ColoredTableCellRenderer; import com.intellij.ui.SimpleTextAttributes; @@ -448,4 +453,18 @@ public class TestsPresentationUtil { break; } } + + public static void printWithAnsiColoring(@NotNull final Printer printer, @NotNull String text, @NotNull final Key processOutputType) { + AnsiEscapeDecoder decoder = new AnsiEscapeDecoder(); + decoder.escapeText(text, ProcessOutputTypes.STDOUT, new AnsiEscapeDecoder.ColoredTextAcceptor() { + @Override + public void coloredTextAvailable(String text, Key attributes) { + ConsoleViewContentType contentType = ConsoleViewContentType.getConsoleViewType(attributes); + if (contentType == null || contentType == ConsoleViewContentType.NORMAL_OUTPUT) { + contentType = ConsoleViewContentType.getConsoleViewType(processOutputType); + } + printer.print(text, contentType); + } + }); + } } From 9083c972ce9a3cfbaafc7a15f7f1617b877e605c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 24 Aug 2014 08:15:16 +0200 Subject: [PATCH 09/16] =?UTF-8?q?convert=20to=20Kotlin=20=E2=80=94=20Kotli?= =?UTF-8?q?n=20doesn't=20support=20module=20package=20prefix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/util/src/com/intellij/openapi/util/Ref.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/util/src/com/intellij/openapi/util/Ref.java b/platform/util/src/com/intellij/openapi/util/Ref.java index d35b39de264b..0119c5626bf7 100644 --- a/platform/util/src/com/intellij/openapi/util/Ref.java +++ b/platform/util/src/com/intellij/openapi/util/Ref.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.util; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -49,6 +50,7 @@ public class Ref { return false; } + @NotNull public static Ref create() { return new Ref(); } From 965ab26ce8ed4043f59052af71901540e58f757f Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 22 Aug 2014 15:39:55 +0200 Subject: [PATCH 10/16] AdvancedEnhancer: remove unused code, cleanup --- .../net/sf/cglib/proxy/AdvancedEnhancer.java | 172 ++---------------- 1 file changed, 11 insertions(+), 161 deletions(-) diff --git a/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java b/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java index 92d98a708036..a2f21c3d0018 100644 --- a/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java +++ b/platform/platform-impl/src/net/sf/cglib/proxy/AdvancedEnhancer.java @@ -15,7 +15,7 @@ */ package net.sf.cglib.proxy; -import com.intellij.ide.plugins.PluginManager; +import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.ide.plugins.cl.PluginClassLoader; import com.intellij.util.ReflectionUtil; import net.sf.cglib.core.*; @@ -127,7 +127,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator /** Internal interface, only public due to ClassLoader issues. */ public interface EnhancerKey { - public Object newInstance(String type, + Object newInstance(String type, String[] interfaces, CallbackFilter filter, Type[] callbackTypes, @@ -251,18 +251,6 @@ public class AdvancedEnhancer extends AbstractClassGenerator this.interceptDuringConstruction = interceptDuringConstruction; } - /** - * Set the single type of {@link Callback} to use. - * This may be used instead of {@link #setCallback} when calling - * {@link #createClass}, since it may not be possible to have - * an array of actual callback instances. - * @param callbackType the type of callback to use for all methods - * @see #setCallbackTypes - */ - public void setCallbackType(Class callbackType) { - setCallbackTypes(new Class[]{ callbackType }); - } - /** * Set the array of callback types to use. * This may be used instead of {@link #setCallbacks} when calling @@ -317,27 +305,6 @@ public class AdvancedEnhancer extends AbstractClassGenerator } } - /** - * Generate a new class if necessary and return it without creating a new instance. - * This ignores any callbacks that have been set. - * To create a new instance you will have to use reflection, and methods - * called during the constructor will not be intercepted. To avoid this problem, - * use the multi-arg create method. - * @see #create(Class[], Object[]) - */ - public Class createClass() { - classOnly = true; - return (Class)createHelper(); - } - - /** - * Insert a static serialVersionUID field into the generated class. - * @param sUID the field value, or null to avoid generating field. - */ - public void setSerialVersionUID(Long sUID) { - serialVersionUID = sUID; - } - private void validate() { if (classOnly ^ (callbacks == null)) { if (classOnly) { @@ -403,7 +370,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator for (final Class anInterface : interfaces) { final ClassLoader loader = anInterface.getClassLoader(); if (loader instanceof PluginClassLoader) { - final int order = PluginManager.getPluginLoadingOrder(((PluginClassLoader)loader).getPluginId()); + final int order = PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)loader).getPluginId()); if (maxIndex < order) { maxIndex = order; bestLoader = loader; @@ -415,7 +382,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator if (superclass != null) { superLoader = superclass.getClassLoader(); if (superLoader instanceof PluginClassLoader && - maxIndex < PluginManager.getPluginLoadingOrder(((PluginClassLoader)superLoader).getPluginId())) { + maxIndex < PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)superLoader).getPluginId())) { return superLoader; } } @@ -428,24 +395,6 @@ public class AdvancedEnhancer extends AbstractClassGenerator sig.getDescriptor()); } - /** - * Finds all of the methods that will be extended by an - * Enhancer-generated class using the specified superclass and - * interfaces. This can be useful in building a list of Callback - * objects. The methods are added to the end of the given list. Due - * to the subclassing nature of the classes generated by Enhancer, - * the methods are guaranteed to be non-static, non-final, and - * non-private. Each method signature will only occur once, even if - * it occurs in multiple classes. - * @param superclass the class that will be extended, or null - * @param interfaces the list of interfaces that will be implemented, or null - * @param methods the list into which to copy the applicable methods - */ - public static void getMethods(Class superclass, Class[] interfaces, List methods) - { - getMethods(superclass, interfaces, methods, null, null); - } - private static void getMethods(Class superclass, Class[] interfaces, List methods, List interfaceMethods, Set forcePublic) { ReflectUtils.addAllMethods(superclass, methods); @@ -628,57 +577,6 @@ public class AdvancedEnhancer extends AbstractClassGenerator } } - /** - * Call this method to register the {@link Callback} array to use before - * creating a new instance of the generated class via reflection. If you are using - * an instance of Enhancer or the {@link Factory} interface to create - * new instances, this method is unnecessary. Its primary use is for when you want to - * cache and reuse a generated class yourself, and the generated class does - * not implement the {@link Factory} interface. - *

- * Note that this method only registers the callbacks on the current thread. - * If you want to register callbacks for instances created by multiple threads, - * use {@link #registerStaticCallbacks}. - *

- * The registered callbacks are overwritten and subsequently cleared - * when calling any of the create methods (such as - * {@link #create}). - * @param generatedClass a class previously created by {@link Enhancer} - * @param callbacks the array of callbacks to use when instances of the generated - * class are created - * @see #setUseFactory - */ - public static void registerCallbacks(Class generatedClass, Callback[] callbacks) { - setThreadCallbacks(generatedClass, callbacks); - } - - /** - * Similar to {@link #registerCallbacks}, but suitable for use - * when multiple threads will be creating instances of the generated class. - * The thread-level callbacks will always override the static callbacks. - * Static callbacks are never cleared. - * @param generatedClass a class previously created by {@link Enhancer} - * @param callbacks the array of callbacks to use when instances of the generated - * class are created - */ - public static void registerStaticCallbacks(Class generatedClass, Callback[] callbacks) { - setCallbacksHelper(generatedClass, callbacks, SET_STATIC_CALLBACKS_NAME); - } - - /** - * Determine if a class was generated using Enhancer. - * @param type any class - * @return whether the class was generated using Enhancer - */ - public static boolean isEnhanced(Class type) { - try { - getCallbacksSetter(type, SET_THREAD_CALLBACKS_NAME); - return true; - } catch (NoSuchMethodException e) { - return false; - } - } - private static void setThreadCallbacks(Class type, Callback[] callbacks) { setCallbacksHelper(type, callbacks, SET_THREAD_CALLBACKS_NAME); } @@ -720,54 +618,6 @@ public class AdvancedEnhancer extends AbstractClassGenerator } } - /** - * Helper method to create an intercepted object. - * For finer control over the generated instance, use a new instance of Enhancer - * instead of this static method. - * @param type class to extend or interface to implement - * @param callback the callback to use for all methods - */ - public static Object create(Class type, Callback callback) { - Enhancer e = new Enhancer(); - e.setSuperclass(type); - e.setCallback(callback); - return e.create(); - } - - /** - * Helper method to create an intercepted object. - * For finer control over the generated instance, use a new instance of Enhancer - * instead of this static method. - * @param type class to extend or interface to implement - * @param interfaces array of interfaces to implement, or null - * @param callback the callback to use for all methods - */ - public static Object create(Class superclass, Class interfaces[], Callback callback) { - Enhancer e = new Enhancer(); - e.setSuperclass(superclass); - e.setInterfaces(interfaces); - e.setCallback(callback); - return e.create(); - } - - /** - * Helper method to create an intercepted object. - * For finer control over the generated instance, use a new instance of Enhancer - * instead of this static method. - * @param type class to extend or interface to implement - * @param interfaces array of interfaces to implement, or null - * @param filter the callback filter to use when generating a new class - * @param callbacks callback implementations to use for the enhanced object - */ - public static Object create(Class superclass, Class[] interfaces, CallbackFilter filter, Callback[] callbacks) { - Enhancer e = new Enhancer(); - e.setSuperclass(superclass); - e.setInterfaces(interfaces); - e.setCallbackFilter(filter); - e.setCallbacks(callbacks); - return e.create(); - } - private void emitConstructors(ClassEmitter ce, List constructors) { boolean seenNull = false; for (final Object constructor1 : constructors) { @@ -801,7 +651,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator return keys; } - private void emitGetCallback(ClassEmitter ce, int[] keys) { + private static void emitGetCallback(ClassEmitter ce, int[] keys) { final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACK, null); e.load_this(); e.invoke_static_this(BIND_CALLBACKS); @@ -876,14 +726,14 @@ public class AdvancedEnhancer extends AbstractClassGenerator e.end_method(); } - private void emitNewInstanceCallbacks(ClassEmitter ce) { + private static void emitNewInstanceCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, NEW_INSTANCE, null); e.load_arg(0); e.invoke_static_this(SET_THREAD_CALLBACKS); emitCommonNewInstance(e); } - private void emitCommonNewInstance(CodeEmitter e) { + private static void emitCommonNewInstance(CodeEmitter e) { e.new_instance_this(); e.dup(); e.invoke_constructor_this(); @@ -915,7 +765,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator emitCommonNewInstance(e); } - private void emitNewInstanceMultiarg(ClassEmitter ce, List constructors) { + private static void emitNewInstanceMultiarg(ClassEmitter ce, List constructors) { final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, MULTIARG_NEW_INSTANCE, null); e.load_arg(2); e.invoke_static_this(SET_THREAD_CALLBACKS); @@ -1044,7 +894,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator se.end_method(); } - private void emitSetThreadCallbacks(ClassEmitter ce) { + private static void emitSetThreadCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC | Constants.ACC_STATIC, SET_THREAD_CALLBACKS, null); @@ -1055,7 +905,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator e.end_method(); } - private void emitSetStaticCallbacks(ClassEmitter ce) { + private static void emitSetStaticCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC | Constants.ACC_STATIC, SET_STATIC_CALLBACKS, null); @@ -1065,7 +915,7 @@ public class AdvancedEnhancer extends AbstractClassGenerator e.end_method(); } - private void emitCurrentCallback(CodeEmitter e, int index) { + private static void emitCurrentCallback(CodeEmitter e, int index) { e.load_this(); e.getfield(getCallbackField(index)); e.dup(); From 3f96c1338832a02c49c02409f2096e77b045aca4 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Sun, 24 Aug 2014 18:20:26 +0400 Subject: [PATCH 11/16] IDEA-128336 / 1.1 / makes less significant settings appear on top of important ones --- .../openapi/options/ConfigurableEP.java | 3 ++ .../options/ex/ConfigurableWrapper.java | 4 -- .../options/ex/MixedConfigurableGroup.java | 4 +- .../openapi/options/ex/NodeConfigurable.java | 8 ++- .../options/newEditor/SettingsTreeView.java | 50 ++++++++++++++++++- 5 files changed, 60 insertions(+), 9 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java index 11c8bdd90052..78a4c1ece130 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java +++ b/platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java @@ -93,6 +93,9 @@ public class ConfigurableEP extends AbstractExten @Attribute("groupId") public String groupId; + @Attribute("groupWeight") + public int groupWeight; + /** Marks project level configurables that do not apply to the default project. */ @Attribute("nonDefaultProject") public boolean nonDefaultProject; diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java index 5f8dc0e890df..3b67a3478368 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java @@ -165,10 +165,6 @@ public class ConfigurableWrapper implements SearchableConfigurable { return myEp; } - public String getGroupId() { - return myEp.groupId; - } - public String getParentId() { return myEp.parentId; } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java index 799f4c06249c..b57dd12a3105 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java @@ -100,7 +100,7 @@ public final class MixedConfigurableGroup implements SearchableConfigurable, Con for (Configurable configurable : configurables) { String groupId = null; if (configurable instanceof ConfigurableWrapper) { - groupId = ((ConfigurableWrapper)configurable).getGroupId(); + groupId = ((ConfigurableWrapper)configurable).getExtensionPoint().groupId; } ArrayList list = map.get(groupId); if (list == null) { @@ -110,7 +110,7 @@ public final class MixedConfigurableGroup implements SearchableConfigurable, Con } ArrayList buildList = map.get("build"); if (buildList != null) { - NodeConfigurable buildTools = new NodeConfigurable("build.tools"); + NodeConfigurable buildTools = new NodeConfigurable("build.tools", 1000); buildTools.add(find("MavenSettings", buildList.iterator())); buildTools.add(find("reference.settingsdialog.project.gradle", buildList.iterator())); buildTools.add(find("reference.settingsdialog.project.gant", buildList.iterator())); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java index 02adfdb8e4b7..609943d02943 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java @@ -27,9 +27,15 @@ import java.util.ArrayList; public final class NodeConfigurable extends SearchableConfigurable.Parent.Abstract { private final ArrayList myConfigurables = new ArrayList(); private final String myId; + private final int myWeight; - public NodeConfigurable(@NotNull String id) { + public NodeConfigurable(@NotNull String id, int weight) { myId = id; + myWeight = weight; + } + + public int getGroupWeight() { + return myWeight; } public void add(Configurable configurable) { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java index 0f4b4f4ea465..44976041dc1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java @@ -24,6 +24,7 @@ import com.intellij.openapi.options.ex.NodeConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.*; import com.intellij.ui.treeStructure.*; import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder; @@ -441,7 +442,17 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd @Override public int getWeight() { - return WeightBasedComparator.UNDEFINED_WEIGHT; + SimpleNode parent = getParent(); + if (parent != null && myRoot == parent.getParent()) { + if (myConfigurable instanceof NodeConfigurable) { + return ((NodeConfigurable)myConfigurable).getGroupWeight(); + } + if (myConfigurable instanceof ConfigurableWrapper) { + return ((ConfigurableWrapper)myConfigurable).getExtensionPoint().groupWeight; + } + return 0; // sort by name + } + return Integer.MIN_VALUE; // do not sort } } @@ -524,6 +535,17 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd else if (myFilter.myContext.getModified().contains(configurable)) { myTextLabel.setForeground(JBColor.BLUE); } + else { + SimpleNode simpleNode = node; + while (simpleNode != null) { + SimpleNode parent = simpleNode.getParent(); + if (parent != null && myRoot == parent.getParent() && simpleNode.getWeight() == 0) { + myTextLabel.setForeground(JBColor.GRAY); + parent = null; + } + simpleNode = parent; + } + } } } // configure project icon @@ -744,7 +766,7 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd boolean myWasHoldingFilter; public MyBuilder(SimpleTreeStructure structure) { - super(myTree, myFilter, structure, new WeightBasedComparator(false)); + super(myTree, myFilter, structure, COMPARATOR); myTree.addTreeExpansionListener(new TreeExpansionListener() { public void treeExpanded(TreeExpansionEvent event) { invalidateExpansions(); @@ -832,4 +854,28 @@ final class SettingsTreeView extends JComponent implements Disposable, OptionsEd } } } + + private static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(NodeDescriptor descriptor1, NodeDescriptor descriptor2) { + MyNode node1 = extractNode(descriptor1); + MyNode node2 = extractNode(descriptor2); + if (node1 == null || node2 == null) { + return node2 != null ? -1 : node1 != null ? 1 : 0; + } + int weight1 = node1.getWeight(); + int weight2 = node2.getWeight(); + + if (weight1 > weight2) { + return -1; + } + if (weight1 < weight2) { + return 1; + } + if (weight1 == Integer.MIN_VALUE) { + return 0; // do not sort if undefined weight + } + return StringUtil.naturalCompare(node1.myDisplayName, node2.myDisplayName); + } + }; } From ff6d4bb2390961d2bda280b16f6cdd1d9f4c5277 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Sun, 24 Aug 2014 18:42:48 +0400 Subject: [PATCH 12/16] IDEA-128336 / 1.2 / set order for the important settings --- .../src/META-INF/LangExtensions.xml | 16 ++++++++-------- .../src/META-INF/PlatformExtensions.xml | 12 ++++++------ .../src/META-INF/PlatformLangPlugin.xml | 2 +- .../src/META-INF/VcsExtensions.xml | 2 +- .../src/META-INF/XmlPlugin.xml | 2 +- plugins/copyright/src/META-INF/plugin.xml | 2 +- plugins/terminal/resources/META-INF/terminal.xml | 2 +- resources/src/idea/RichPlatformPlugin.xml | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index c338dac9848b..4aa4ef8dea94 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -360,25 +360,25 @@ serviceImplementation="com.intellij.codeInspection.ex.ProjectInspectionProfilesVisibleTreeState"/> - - + - - @@ -386,7 +386,7 @@ serviceImplementation="com.intellij.codeInsight.template.impl.TemplateManagerImpl"/> - @@ -394,7 +394,7 @@ bundle="messages.IdeBundle"/> - @@ -613,7 +613,7 @@ - @@ -753,7 +753,7 @@ - + diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 467ef8233919..3af4cd6cc6ee 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -197,14 +197,14 @@ serviceImplementation="com.intellij.openapi.editor.impl.LazyRangeMarkerFactoryImpl"/> - + - - @@ -214,10 +214,10 @@ key="title.customizations" bundle="messages.IdeBundle"/> - + - @@ -250,7 +250,7 @@ - diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml index ea14882e5ae6..b675e6491e09 100644 --- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml +++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml @@ -81,7 +81,7 @@ - + diff --git a/platform/platform-resources/src/META-INF/VcsExtensions.xml b/platform/platform-resources/src/META-INF/VcsExtensions.xml index a05f28107034..2322381c3b89 100644 --- a/platform/platform-resources/src/META-INF/VcsExtensions.xml +++ b/platform/platform-resources/src/META-INF/VcsExtensions.xml @@ -25,7 +25,7 @@ - + diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 525ea3c94540..ab66dc6fb35f 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -531,7 +531,7 @@ - diff --git a/plugins/copyright/src/META-INF/plugin.xml b/plugins/copyright/src/META-INF/plugin.xml index 8d0c4b038d85..594c28e20966 100644 --- a/plugins/copyright/src/META-INF/plugin.xml +++ b/plugins/copyright/src/META-INF/plugin.xml @@ -11,7 +11,7 @@ com.intellij.modules.java - + - + diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 4697d2551e38..444336338b1a 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -239,10 +239,10 @@ - + - From 07aa8e31152373dbd8691f229f8e1457d1137356 Mon Sep 17 00:00:00 2001 From: nik Date: Mon, 25 Aug 2014 10:58:32 +0400 Subject: [PATCH 13/16] don't check spelling of injected code using strategy from the injection host (IDEA-83526) --- .../intellij/spellchecker/tokenizer/SpellcheckingStrategy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java index 6d28563e062c..17044a102559 100644 --- a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java +++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java @@ -49,6 +49,9 @@ public class SpellcheckingStrategy { @NotNull public Tokenizer getTokenizer(PsiElement element) { + if (element instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)element)) { + return EMPTY_TOKENIZER; + } if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer(); if (element instanceof PsiComment) { if (SuppressionUtil.isSuppressionComment(element)) { From 998c7ba5afc436e1cbff9cc17129c3adc4ddc67e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 24 Aug 2014 19:04:02 +0200 Subject: [PATCH 14/16] support Runnable tag --- .../issueLinks/LinkMouseListenerBase.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/changes/issueLinks/LinkMouseListenerBase.java b/platform/platform-impl/src/com/intellij/openapi/vcs/changes/issueLinks/LinkMouseListenerBase.java index 402d88cef38a..92eed9582fd2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/changes/issueLinks/LinkMouseListenerBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/changes/issueLinks/LinkMouseListenerBase.java @@ -27,18 +27,24 @@ import java.awt.event.MouseMotionListener; public abstract class LinkMouseListenerBase extends ClickListener implements MouseMotionListener { public static void installSingleTagOn(@NotNull SimpleColoredComponent component) { - new LinkMouseListenerBase>() { + new LinkMouseListenerBase() { @Nullable @Override - protected Consumer getTagAt(@NotNull MouseEvent e) { + protected Object getTagAt(@NotNull MouseEvent e) { //noinspection unchecked - return (Consumer)((SimpleColoredComponent)e.getSource()).getFragmentTagAt(e.getX()); + return ((SimpleColoredComponent)e.getSource()).getFragmentTagAt(e.getX()); } @Override - protected void handleTagClick(@Nullable Consumer tag, @NotNull MouseEvent event) { + protected void handleTagClick(@Nullable Object tag, @NotNull MouseEvent event) { if (tag != null) { - tag.consume(event); + if (tag instanceof Consumer) { + //noinspection unchecked + ((Consumer)tag).consume(event); + } + else { + ((Runnable)tag).run(); + } } } }.installOn(component); From f0ea331b24166c7fda81d79777a9d65b35aeaff7 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sun, 24 Aug 2014 19:06:41 +0200 Subject: [PATCH 15/16] add convenient constructor --- .../intellij/openapi/ui/DialogBuilder.java | 19 +++++++++++++++---- .../impl/FileDocumentManagerImpl.java | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java index ed374a905462..64d77c566134 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java @@ -59,16 +59,20 @@ public class DialogBuilder implements Disposable { showImpl(false); } - public DialogBuilder(Project project) { + public DialogBuilder(@Nullable Project project) { myDialogWrapper = new MyDialogWrapper(project, true); Disposer.register(myDialogWrapper.getDisposable(), this); } - public DialogBuilder(Component parent) { + public DialogBuilder(@Nullable Component parent) { myDialogWrapper = new MyDialogWrapper(parent, true); Disposer.register(myDialogWrapper.getDisposable(), this); } + public DialogBuilder() { + this(((Project)null)); + } + @Override public void dispose() { } @@ -90,6 +94,12 @@ public class DialogBuilder implements Disposable { myCenterPanel = centerPanel; } + @NotNull + public DialogBuilder centerPanel(@NotNull JComponent centerPanel) { + myCenterPanel = centerPanel; + return this; + } + @NotNull public DialogBuilder setNorthPanel(@NotNull JComponent northPanel) { myNorthPanel = northPanel; @@ -100,6 +110,7 @@ public class DialogBuilder implements Disposable { myTitle = title; } + @NotNull public DialogBuilder title(@NotNull String title) { myTitle = title; return this; @@ -267,7 +278,7 @@ public class DialogBuilder implements Disposable { protected Action createAction(final DialogWrapper dialogWrapper) { return new AbstractAction(){ @Override - public void actionPerformed(ActionEvent e) { + public void actionPerformed(@NotNull ActionEvent e) { dialogWrapper.close(myExitCode); } }; @@ -325,7 +336,7 @@ public class DialogBuilder implements Disposable { private class MyDialogWrapper extends DialogWrapper { private String myHelpId = null; - private MyDialogWrapper(Project project, boolean canBeParent) { + private MyDialogWrapper(@Nullable Project project, boolean canBeParent) { super(project, canBeParent); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java index ad7ae4e0beb9..ec2559fc06ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java @@ -651,7 +651,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt public boolean process(final VirtualFile file, final Document document) { String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl()); - final DialogBuilder builder = new DialogBuilder((Project)null); + final DialogBuilder builder = new DialogBuilder(); builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER)); builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button")); builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button")); From ade300c6d40cc9f6689ebfdd834b90fa7b585c5a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 25 Aug 2014 08:33:49 +0200 Subject: [PATCH 16/16] NotNull --- .../com/intellij/openapi/util/PasswordUtil.java | 14 ++++++++++---- .../com/intellij/openapi/diagnostic/Logger.java | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java b/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java index 4ba3fa7c1516..c4995a34ac27 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/util/PasswordUtil.java @@ -15,13 +15,17 @@ */ package com.intellij.openapi.util; +import org.jetbrains.annotations.Nullable; + public class PasswordUtil { private PasswordUtil() { } // weak encryption just to avoid plain text passwords in text files - public static String encodePassword(String password) { + public static String encodePassword(@Nullable String password) { String result = ""; - if (password == null) return result; + if (password == null) { + return result; + } for (int i = 0; i < password.length(); i++) { int c = password.charAt(i); c ^= 0xdfaa; @@ -30,9 +34,11 @@ public class PasswordUtil { return result; } - public static String decodePassword(String password) throws NumberFormatException { + public static String decodePassword(@Nullable String password) throws NumberFormatException { String result = ""; - if (password == null) return result; + if (password == null) { + return result; + } for (int i = 0; i < password.length(); i += 4) { String s = password.substring(i, i + 4); int c = Integer.parseInt(s, 16); diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java index f3da0c22fde5..d90876fe6be9 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java @@ -69,6 +69,7 @@ public abstract class Logger { return ourFactory.getLoggerInstance(category); } + @NotNull public static Logger getInstance(Class cl) { return getInstance("#" + cl.getName()); }