From 06a367a4ab70562aa2252a13f08c503a0dcc44bb Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 19 Aug 2010 16:37:11 +0400 Subject: [PATCH 01/14] fixed vanishing predefined log files --- .../application/ApplicationConfiguration.java | 2 +- .../execution/remote/RemoteConfiguration.java | 2 +- .../configurations/RunConfigurationBase.java | 3 +- .../logging/LogConfigurationPanel.java | 81 ++++++------------- .../execution/junit/JUnitConfiguration.java | 2 +- .../configuration/TestNGConfiguration.java | 2 +- 6 files changed, 32 insertions(+), 60 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java index 2f7ed31c9834..e6023fd5f7b8 100644 --- a/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/application/ApplicationConfiguration.java @@ -85,7 +85,7 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration group = new SettingsEditorGroup(); group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new ApplicationConfigurable(getProject())); RunConfigurationExtension.appendEditors(this, group); - group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); + group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); return group; } diff --git a/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java b/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java index d44f1d415373..99b482e07b08 100644 --- a/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/remote/RemoteConfiguration.java @@ -77,7 +77,7 @@ public class RemoteConfiguration extends ModuleBasedConfiguration getConfigurationEditor() { SettingsEditorGroup group = new SettingsEditorGroup(); group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new RemoteConfigurable()); - group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); + group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); return group; } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java index 882752c9db3a..6628bd2934ad 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java @@ -101,7 +101,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements return runConfiguration; } - public @Nullable LogFileOptions getOptionsForPredefinedLogFile(PredefinedLogFile predefinedLogFile) { + @Nullable + public LogFileOptions getOptionsForPredefinedLogFile(PredefinedLogFile predefinedLogFile) { return null; } diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java index e62ebf5f3c3a..3bdb254876dc 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConfigurationPanel.java @@ -51,9 +51,9 @@ import java.util.Map; * User: anna * Date: Apr 22, 2005 */ -public class LogConfigurationPanel extends SettingsEditor { - private final TableView myFilesTable; - private final ListTableModel myModel; +public class LogConfigurationPanel extends SettingsEditor { + private final TableView myFilesTable; + private final ListTableModel myModel; private JPanel myWholePanel; private JButton myAddButton; private JButton myRemoveButton; @@ -63,11 +63,11 @@ public class LogConfigurationPanel extends Setti private final ColumnInfo IS_SHOW = new MyIsActiveColumnInfo(); private final ColumnInfo FILE = new MyLogFileColumnInfo(); - private final ColumnInfo IS_SKIP_CONTENT = new MyIsSkippColumnInfo(); + private final ColumnInfo IS_SKIP_CONTENT = new MyIsSkipColumnInfo(); public LogConfigurationPanel() { - myModel = new ListTableModel(new ColumnInfo[]{IS_SHOW, FILE, IS_SKIP_CONTENT}); - myFilesTable = new TableView(myModel); + myModel = new ListTableModel(IS_SHOW, FILE, IS_SKIP_CONTENT); + myFilesTable = new TableView(myModel); final JTableHeader tableHeader = myFilesTable.getTableHeader(); final FontMetrics fontMetrics = tableHeader.getFontMetrics(tableHeader.getFont()); @@ -149,7 +149,7 @@ public class LogConfigurationPanel extends Setti final LogFileOptions options = configurationBase.getOptionsForPredefinedLogFile(predefined); if (LogFileOptions.areEqual(item, options)) { newItems.add(item); - } + } else { changed = true; myLog2Predefined.remove(item); @@ -184,7 +184,6 @@ public class LogConfigurationPanel extends Setti } protected void resetEditorFrom(final RunConfigurationBase configuration) { - clearModel(); ArrayList list = new ArrayList(); final ArrayList logFiles = configuration.getLogFiles(); for (LogFileOptions setting : logFiles) { @@ -213,30 +212,23 @@ public class LogConfigurationPanel extends Setti configuration.removeAllPredefinedLogFiles(); for (int i = 0; i < myModel.getRowCount(); i++) { - LogFileOptions pair = (LogFileOptions)myModel.getValueAt(i, 1); - if (Comparing.equal(pair.getPathPattern(),"")){ - continue; - } + LogFileOptions options = (LogFileOptions)myModel.getValueAt(i, 1); + if (Comparing.equal(options.getPathPattern(),"")){ + continue; + } final Boolean checked = (Boolean)myModel.getValueAt(i, 0); final Boolean skipped = (Boolean)myModel.getValueAt(i, 2); - final PredefinedLogFile predefined = myLog2Predefined.get(pair); - if (predefined != null && !isPredefinedChanged(configuration, predefined, pair)) { - configuration.addPredefinedLogFile(new PredefinedLogFile(predefined.getId(), pair.isEnabled())); + final PredefinedLogFile predefined = myLog2Predefined.get(options); + if (predefined != null) { + configuration.addPredefinedLogFile(new PredefinedLogFile(predefined.getId(), options.isEnabled())); } else { - configuration.addLogFile(pair.getPathPattern(), pair.getName(), checked.booleanValue(), skipped.booleanValue(), pair.isShowAll()); + configuration.addLogFile(options.getPathPattern(), options.getName(), checked.booleanValue(), skipped.booleanValue(), options.isShowAll()); } } for (PredefinedLogFile logFile : myUnresolvedPredefined) { configuration.addPredefinedLogFile(logFile); - } } - - private static boolean isPredefinedChanged(final RunConfigurationBase configuration, final PredefinedLogFile predefined, final LogFileOptions options) { - final LogFileOptions oldOptions = configuration.getOptionsForPredefinedLogFile(predefined); - return oldOptions == null || !oldOptions.getPathPattern().equals(options.getPathPattern()) || - oldOptions.isSkipContent() != options.isSkipContent() || oldOptions.isShowAll() != options.isShowAll() || - !oldOptions.getName().equals(options.getName()); } @NotNull @@ -245,26 +237,9 @@ public class LogConfigurationPanel extends Setti } protected void disposeEditor() { - } - public JComponent getLoggerComponent() { - return getComponent(); - } - - public void addLogFile(String file, String alias, boolean isShowAll, boolean checked, boolean skipContent) { - final List itemsUnmodifiable = myModel.getItems(); - List items = new ArrayList(); - items.addAll(itemsUnmodifiable); - items.add(new LogFileOptions(alias, file, checked, skipContent, isShowAll)); - myModel.setItems(items); - } - - private void clearModel() { - myModel.setItems(new ArrayList()); - } - - @Nullable + @Nullable private static LogFileOptions showEditorDialog(String name, String location, boolean showAll){ EditLogPatternDialog dialog = new EditLogPatternDialog(); dialog.init(name, location, showAll); @@ -306,22 +281,22 @@ public class LogConfigurationPanel extends Setti public TableCellEditor getEditor(final LogFileOptions item) { return new LogFileCellEditor(item); - } + } public void setValue(final LogFileOptions o, final LogFileOptions aValue) { if (aValue != null) { if (!o.getName().equals(aValue.getName()) || !o.getPathPattern().equals(aValue.getPathPattern()) || o.isShowAll() != aValue.isShowAll()) { myLog2Predefined.remove(o); - } + } o.setName(aValue.getName()); o.setLast(!aValue.isShowAll()); o.setPathPattern(aValue.getPathPattern()); - } + } } public boolean isCellEditable(final LogFileOptions o) { - return true; + return !myLog2Predefined.containsKey(o); } } @@ -346,13 +321,13 @@ public class LogConfigurationPanel extends Setti final PredefinedLogFile predefinedLogFile = myLog2Predefined.get(element); if (predefinedLogFile != null) { predefinedLogFile.setEnabled(checked.booleanValue()); - } - element.setEnable(checked.booleanValue()); } + element.setEnable(checked.booleanValue()); + } } - private class MyIsSkippColumnInfo extends ColumnInfo { - protected MyIsSkippColumnInfo() { + private class MyIsSkipColumnInfo extends ColumnInfo { + protected MyIsSkipColumnInfo() { super(DiagnosticBundle.message("log.monitor.is.skipped.column")); } @@ -365,18 +340,15 @@ public class LogConfigurationPanel extends Setti } public boolean isCellEditable(LogFileOptions element) { - return true; + return !myLog2Predefined.containsKey(element); } public void setValue(LogFileOptions element, Boolean skipped) { - if (element.isSkipContent() != skipped.booleanValue()) { - myLog2Predefined.remove(element); - } element.setSkipContent(skipped.booleanValue()); } } - private class LogFileCellEditor extends AbstractTableCellEditor { + private static class LogFileCellEditor extends AbstractTableCellEditor { private final CellEditorComponentWithBrowseButton myComponent; private LogFileOptions myLogFileOptions; @@ -389,7 +361,6 @@ public class LogConfigurationPanel extends Setti public void actionPerformed(ActionEvent e) { final LogFileOptions newValue = showEditorDialog(myLogFileOptions.getName(), myLogFileOptions.getPathPattern(), myLogFileOptions.isShowAll()); if (newValue != null) { - myLog2Predefined.remove(myLogFileOptions); myLogFileOptions = newValue; } JTextField textField = getChildComponent(); diff --git a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java index 5a2f2f50eed0..4bdb9cb9ea04 100644 --- a/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java +++ b/plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java @@ -84,7 +84,7 @@ public class JUnitConfiguration extends ModuleBasedConfiguration group = new SettingsEditorGroup(); group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new JUnitConfigurable(getProject())); RunConfigurationExtension.appendEditors(this, group); - group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); + group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); return group; } diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java index eb1a1eb8b4ab..1d6577d7e866 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfiguration.java @@ -262,7 +262,7 @@ public class TestNGConfiguration extends ModuleBasedConfiguration group = new SettingsEditorGroup(); group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new TestNGConfigurationEditor(getProject())); RunConfigurationExtension.appendEditors(this, group); - group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); + group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); return group; } From 7390d9ad02ccdf42d5563d0f3dffdd777f3718f6 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 19 Aug 2010 12:12:45 +0400 Subject: [PATCH 02/14] add more name suggestions for type casts and () expressions --- .../psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 9262b86f16c1..58932d94d7db 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -640,6 +640,10 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { return new NamesByExprInfo(null, constantValueToConstantName(names)); } } + } else if (expr instanceof PsiParenthesizedExpression) { + return suggestVariableNameByExpressionOnly(((PsiParenthesizedExpression)expr).getExpression(), variableKind); + } else if (expr instanceof PsiTypeCastExpression) { + return suggestVariableNameByExpressionOnly(((PsiTypeCastExpression)expr).getOperand(), variableKind); } return new NamesByExprInfo(null, ArrayUtil.EMPTY_STRING_ARRAY); From d33aaccb19ecf8cfcad66037762bd4534263163b Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 19 Aug 2010 12:25:03 +0400 Subject: [PATCH 03/14] set default charset if configured (IDEA-57699 ) --- .../com/intellij/execution/configurations/JavaParameters.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java b/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java index 58cae05339ba..08f41d249a6b 100644 --- a/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java +++ b/java/execution/openapi/src/com/intellij/execution/configurations/JavaParameters.java @@ -117,6 +117,7 @@ public class JavaParameters extends SimpleJavaParameters { if ((classPathType & CLASSES_ONLY) == 0) { return; } + setDefaultCharset(project); configureEnumerator(OrderEnumerator.orderEntries(project).runtimeOnly(), classPathType, jdk).collectPaths(getClassPath()); } From c3984b4df9fd0ade3323c5bf6f77b7dc3f4fc825 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 19 Aug 2010 15:33:59 +0400 Subject: [PATCH 04/14] IDEA-57777 --- .../changeSignature/JavaChangeSignatureHandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java index 720e8d766da1..3f941ba7e746 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureHandler.java @@ -107,8 +107,12 @@ public class JavaChangeSignatureHandler implements ChangeSignatureHandler { return PsiTreeUtil.getParentOfType(element, PsiMethod.class); } - if (element.getParent() instanceof PsiMethod && ((PsiMethod)element.getParent()).getNameIdentifier()==element) { - return element.getParent(); + final PsiElement elementParent = element.getParent(); + if (elementParent instanceof PsiMethod && ((PsiMethod)elementParent).getNameIdentifier()==element) { + return elementParent; + } + if (elementParent instanceof PsiClass && ((PsiClass)elementParent).getNameIdentifier()==element) { + return elementParent; } final PsiCallExpression expression = PsiTreeUtil.getParentOfType(element, PsiCallExpression.class); From fe8da55302acdb9cfcd75209fbdd2fa1ad816685 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 19 Aug 2010 17:19:46 +0400 Subject: [PATCH 05/14] fix running tests using new ipr runner --- .../src/com/intellij/openapi/application/ex/PathManagerEx.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/application/ex/PathManagerEx.java b/platform/platform-api/src/com/intellij/openapi/application/ex/PathManagerEx.java index 50865410af49..7b6521a60a72 100644 --- a/platform/platform-api/src/com/intellij/openapi/application/ex/PathManagerEx.java +++ b/platform/platform-api/src/com/intellij/openapi/application/ex/PathManagerEx.java @@ -272,6 +272,9 @@ public class PathManagerEx { try { return Class.forName(className, true, classLoader); } + catch (NoClassDefFoundError e) { + return null; + } catch (ClassNotFoundException e) { return null; } From 08f0825db2b81df6c4d73b001ea26913923f095f Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Thu, 19 Aug 2010 17:24:28 +0400 Subject: [PATCH 06/14] FormBuilder + OCIntroduceVariableDialog --- .../src/com/intellij/util/ui/FormBuilder.java | 66 +++++++++++++++++++ .../util/src/com/intellij/util/ui/UIUtil.java | 7 ++ 2 files changed, 73 insertions(+) create mode 100644 platform/util/src/com/intellij/util/ui/FormBuilder.java diff --git a/platform/util/src/com/intellij/util/ui/FormBuilder.java b/platform/util/src/com/intellij/util/ui/FormBuilder.java new file mode 100644 index 000000000000..f23113f5c9c1 --- /dev/null +++ b/platform/util/src/com/intellij/util/ui/FormBuilder.java @@ -0,0 +1,66 @@ +/* + * Copyright 2000-2010 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. + */ + +/* + * @author max + */ +package com.intellij.util.ui; + +import javax.swing.*; +import java.awt.*; + +public class FormBuilder { + + private int line = 0; + private final JPanel panel; + + public FormBuilder() { + panel = new JPanel(new GridBagLayout()); + } + + public FormBuilder addLabeledComponent(String labelText, JComponent component) { + JLabel label = new JLabel(UIUtil.removeMnemonic(labelText)); + label.setDisplayedMnemonicIndex(UIUtil.getDisplayMnemonicIndex(labelText)); + label.setLabelFor(component); + + GridBagConstraints c = new GridBagConstraints(); + int verticalInset = line > 0 ? 10 : 0; + + c.gridx = 0; + c.gridy = line; + c.weightx = 0; + c.anchor = GridBagConstraints.EAST; + c.insets = new Insets(verticalInset, 0, 0, 5); + + panel.add(label, c); + + c.gridx = 1; + c.gridy = line; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.WEST; + c.weightx = 1; + c.insets = new Insets(verticalInset, 0, 0, 0); + panel.add(component, c); + + line++; + + return this; + } + + public JPanel getPanel() { + return panel; + } +} diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 1ce45180dc94..4cce773ac07c 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -207,6 +207,13 @@ public class UIUtil { return s; } + public static int getDisplayMnemonicIndex(@NotNull String s) { + int idx = s.indexOf('&'); + if (idx >= 0) return idx; + + return s.indexOf(MNEMONIC); + } + public static String replaceMnemonicAmpersand(final String value) { if (value.indexOf('&') >= 0) { boolean useMacMnemonic = value.contains("&&"); From 836e4782160a6bf15f4378c4b0d5eef14e009f8d Mon Sep 17 00:00:00 2001 From: Alexey Gopachenko Date: Thu, 19 Aug 2010 17:27:55 +0400 Subject: [PATCH 07/14] Spellchecker performance - faster lowlevel splitting --- .../inspections/BaseSplitter.java | 2 +- .../inspections/IdentifierSplitter.java | 59 +++++++++++++---- .../intellij/spellchecker/util/Strings.java | 65 ------------------- .../spellchecker/inspector/SplitterTest.java | 15 ++--- 4 files changed, 51 insertions(+), 90 deletions(-) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/BaseSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/BaseSplitter.java index 8d99251253ff..795fe9f62648 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/BaseSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/BaseSplitter.java @@ -95,7 +95,7 @@ public abstract class BaseSplitter implements Splitter { } @Nullable - protected List excludeByPattern(String text, TextRange range, @NotNull Pattern toExclude, int groupToInclude) { + static protected List excludeByPattern(String text, TextRange range, @NotNull Pattern toExclude, int groupToInclude) { List toCheck = new ArrayList(); int from = range.getStartOffset(); int till; diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java index e04491b28905..bfa974cee62b 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java @@ -32,8 +32,6 @@ public class IdentifierSplitter extends BaseSplitter { @NonNls private static final Pattern WORD = Pattern.compile("\\b\\p{L}*'?\\p{L}*"); - @NonNls - private static final Pattern WORD_EXT = Pattern.compile("(\\p{L}*?)[-_$\\[\\]0-9]"); @NonNls private static final Pattern WORD_IN_QUOTES = Pattern.compile("'([^']*)'"); @@ -96,22 +94,57 @@ public class IdentifierSplitter extends BaseSplitter { } public static List splitByCase(@NotNull String text, @NotNull TextRange range) { + //System.out.println("text = " + text + " range = " + range); List result = new ArrayList(); - Matcher matcher = WORD_EXT.matcher(text.substring(range.getStartOffset(), range.getEndOffset())); - int from = range.getStartOffset(); - while (matcher.find()) { - TextRange found = matcherRange(range, matcher); - TextRange foundWord = matcherRange(range, matcher, 1); - - if (!tooSmall(from, foundWord.getEndOffset())) { - Strings.addAll(text, foundWord, result); + int i = range.getStartOffset(); + int s = -1; + int prevType = Character.MATH_SYMBOL; + while (i < range.getEndOffset()) { + final char ch = text.charAt(i); + final int type = Character.getType(ch); + if (type == Character.LOWERCASE_LETTER || + type == Character.UPPERCASE_LETTER || + type == Character.TITLECASE_LETTER || + type == Character.OTHER_LETTER || + type == Character.MODIFIER_LETTER || + type == Character.OTHER_PUNCTUATION + ) { + //letter + if (s < 0) { + //start + s = i; + } + else if (s >= 0 && type == Character.UPPERCASE_LETTER && prevType == Character.LOWERCASE_LETTER) { + //a|Camel + add(text, result, i, s); + s = i; + } + else if (i - s >= 1 && type == Character.LOWERCASE_LETTER && prevType == Character.UPPERCASE_LETTER) { + //CAPITALN|ext + add(text, result, i - 1, s); + s = i - 1; + } } - from = found.getEndOffset(); + else if (s >= 0) { + //non-letter + add(text, result, i, s); + s = -1; + } + prevType = type; + i++; } - if (!tooSmall(from, range.getEndOffset())) { - Strings.addAll(text, new TextRange(from, range.getEndOffset()), result); + //remainder + if (s >= 0) { + add(text, result, i, s); } return result; } + private static void add(String text, List result, int i, int s) { + if (i - s > 3) { + final TextRange textRange = new TextRange(s, i); + //System.out.println("textRange = " + textRange + " = "+ textRange.substring(text)); + result.add(textRange); + } + } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/util/Strings.java b/plugins/spellchecker/src/com/intellij/spellchecker/util/Strings.java index 4b4223eff742..20767f708a51 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/util/Strings.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/util/Strings.java @@ -20,9 +20,7 @@ import org.jetbrains.annotations.NotNull; import java.text.CharacterIterator; import java.text.StringCharacterIterator; -import java.util.ArrayList; import java.util.List; -import java.util.regex.Matcher; public final class Strings { private Strings() { @@ -100,67 +98,4 @@ public final class Strings { } } - - private enum WordState { - NO_WORD, PREV_UC, WORD - } - - public static void addAll(@NotNull String text, @NotNull TextRange range, @NotNull List result) { - CharacterIterator it = new StringCharacterIterator(text, range.getStartOffset(), range.getEndOffset(), range.getStartOffset()); - StringBuffer b = new StringBuffer(); - WordState state = WordState.NO_WORD; - char curPrevUC = '\0'; - int pos = range.getStartOffset(); - for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) { - switch (state) { - case NO_WORD: - if (!Character.isUpperCase(c)) { - b.append(c); - state = WordState.WORD; - } - else { - state = WordState.PREV_UC; - curPrevUC = c; - } - break; - case PREV_UC: - if (!Character.isUpperCase(c)) { - if (b.length() > 0) { - result.add(new TextRange(pos, pos + b.length())); - pos += b.length(); - } - b = new StringBuffer(); - b.append(curPrevUC); - b.append(c); - state = WordState.WORD; - } - else { - b.append(curPrevUC); - state = WordState.PREV_UC; - curPrevUC = c; - } - break; - case WORD: - if (Character.isUpperCase(c)) { - if (b.length() > 0) { - result.add(new TextRange(pos, pos + b.length())); - pos += b.length(); - } - b.setLength(0); - state = WordState.PREV_UC; - curPrevUC = c; - } - else { - b.append(c); - } - break; - } - } - if (state == WordState.PREV_UC) { - b.append(curPrevUC); - } - result.add(new TextRange(pos, pos + b.length())); - } - - } diff --git a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index 1d1417ffac2e..f07d83f0f81a 100644 --- a/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/plugins/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -74,7 +74,7 @@ public class SplitterTest extends TestCase { public void testCapitalizedWithShortWords() { String text = "IntelliJ"; List checkAreas = SplitterFactory.getInstance().getIdentifierSplitter().split(text); - correctListToCheck(checkAreas, text, new String[]{}); + correctListToCheck(checkAreas, text, new String[]{"Intelli"}); } public void testWords() { @@ -86,7 +86,7 @@ public class SplitterTest extends TestCase { public void testCapitalizedWithShortAndLongWords() { String text = "IntelliJTestTest"; List checkAreas = SplitterFactory.getInstance().getIdentifierSplitter().split(text); - correctListToCheck(checkAreas, text, new String[]{}); + correctListToCheck(checkAreas, text, new String[]{"Intelli", "Test", "Test"}); } public void testWordWithApostrophe1() { @@ -443,15 +443,8 @@ public class SplitterTest extends TestCase { private static void correctListToCheck(List toCheck, String text, @NotNull String[] expected) { List words = wordsToCheck(toCheck, text); - if (expected.length == 0) { - Assert.assertNull(words); - } - else { - Assert.assertNotNull(words); - Assert.assertEquals(expected.length, words.size()); - List expectedWords = Arrays.asList(expected); - Assert.assertEquals(expectedWords, words); - } + List expectedWords = Arrays.asList(expected); + Assert.assertEquals("Splitting:'" + text + "'", expectedWords.toString(), words!=null ? words.toString() : "[]"); } From 2cef8c113e3ae5469e7650d24981bd5f0ea0f08d Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 19 Aug 2010 17:29:14 +0400 Subject: [PATCH 08/14] IDEA-57762 Soft wrap: Provide ability to quickly switch soft wraps appliance at console IDEA-57764 Soft wrap: Provide ability to quickly switch soft wraps appliance for active editor Dedicated 'toggle soft wraps usage' action is created and configured for editor and console --- platform/icons/src/actions/toggleSoftWrap.png | Bin 0 -> 416 bytes .../execution/impl/ConsoleViewImpl.java | 8 +- .../openapi/actionSystem/IdeActions.java | 1 + .../actions/ToggleUseSoftWrapsAction.java | 89 ++++++++++++++++++ .../ToggleUseSoftWrapsToolbarAction.java | 33 +++++++ .../src/messages/ActionsBundle.properties | 2 + 6 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 platform/icons/src/actions/toggleSoftWrap.png create mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsAction.java create mode 100644 platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsToolbarAction.java diff --git a/platform/icons/src/actions/toggleSoftWrap.png b/platform/icons/src/actions/toggleSoftWrap.png new file mode 100644 index 0000000000000000000000000000000000000000..75646cd9fd4b2504e6ed2c2de736ac491b937dd7 GIT binary patch literal 416 zcmV;R0bl-!P)souA4X$hR1JfU%`M>`$f(-!ytJUv5V{rja z%=8na`42E0{y|*uo0FMGz3b(BG#B8+Of0|tpZx<2#9#jym`$d=-t`OUl3$|CfIPaw%(nn=s;!1*UnSLR(}xnG2cO znP&cc{pZrJ55Q0bqW=%~{dqJem=&Mxz*qoAK3Y;%XnFPj&yC%Go-B!Gg@rWUbbv0v z`uY0b2T;v~(g9WjZg<+V5R(o-&IgA95%~qH|6zHAk<#o85MTg|sHT8ru(+@Q0000< KMNUMnLSTZvv%dHM literal 0 HcmV?d00001 diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 8f70ed2d1157..059e5ba7064f 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -36,6 +36,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.actions.DiffActions; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.actionSystem.*; +import com.intellij.openapi.editor.actions.ToggleUseSoftWrapsToolbarAction; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.colors.EditorColorsManager; @@ -1414,12 +1415,15 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo prevAction.getTemplatePresentation().setText(getPreviousOccurenceActionName()); AnAction nextAction = actionsManager.createNextOccurenceAction(this); nextAction.getTemplatePresentation().setText(getNextOccurenceActionName()); + AnAction switchSoftWrapsAction = new ToggleUseSoftWrapsToolbarAction(); + //Initializing custom actions - AnAction[] consoleActions = new AnAction[2 + customActions.size()]; + AnAction[] consoleActions = new AnAction[3 + customActions.size()]; consoleActions[0] = prevAction; consoleActions[1] = nextAction; + consoleActions[2] = switchSoftWrapsAction; for (int i = 0; i < customActions.size(); ++i) { - consoleActions[i + 2] = customActions.get(i); + consoleActions[i + 3] = customActions.get(i); } return consoleActions; } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java index 92a07bda75a5..62cbfd90ffdf 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/IdeActions.java @@ -45,6 +45,7 @@ public interface IdeActions { @NonNls String ACTION_EDITOR_ESCAPE = "EditorEscape"; @NonNls String ACTION_EDITOR_JOIN_LINES = "EditorJoinLines"; @NonNls String ACTION_EDITOR_COMPLETE_STATEMENT = "EditorCompleteStatement"; + @NonNls String ACTION_EDITOR_USE_SOFT_WRAPS = "EditorToggleUseSoftWraps"; @NonNls String ACTION_EDITOR_NEXT_TEMPLATE_VARIABLE = "NextTemplateVariable"; @NonNls String ACTION_EDITOR_PREVIOUS_TEMPLATE_VARIABLE = "PreviousTemplateVariable"; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsAction.java new file mode 100644 index 000000000000..556c513782a2 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsAction.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.editor.Editor; +import org.jetbrains.annotations.Nullable; + +/** + * Action that toggles 'show soft wraps at editor' option. + * + * @author Denis Zhdanov + * @since Aug 19, 2010 3:15:26 PM + */ +public class ToggleUseSoftWrapsAction extends ToggleAction { + + private final boolean myShowIcon; + + @SuppressWarnings({"UnusedDeclaration"}) // Used implicitly by IoC container + public ToggleUseSoftWrapsAction() { + this(false); + } + + /** + * This class is assumed to be configured at IDEA components container, i.e. it is expected to have all data configured + * (name, description, icon). However, there are different use-cases for its appliance. We can point out at least two of them: + *
+   * 
    + *
  • show icon (e.g. for toolbar-based action);
  • + *
  • don't show icon (e.g. for main menu action);
  • + *
+ *
+ * Hence, it's possible to customize its behavior via given parameter(s). + * + * @param showIcon flag that indicates if current action object should process configured icon if any + */ + public ToggleUseSoftWrapsAction(boolean showIcon) { + myShowIcon = showIcon; + } + + @Override + public boolean isSelected(AnActionEvent e) { + Editor editor = getEditor(e); + return editor != null && editor.getSettings().isUseSoftWraps(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + final Editor editor = getEditor(e); + assert editor != null; + editor.getSettings().setUseSoftWraps(state); + } + + @Override + public void update(AnActionEvent e){ + super.update(e); + if (!myShowIcon) { + e.getPresentation().setIcon(null); + } + + if (getEditor(e) == null) { + e.getPresentation().setEnabled(false); + e.getPresentation().setVisible(false); + } else { + e.getPresentation().setEnabled(true); + e.getPresentation().setVisible(true); + } + } + + @Nullable + private static Editor getEditor(AnActionEvent e) { + return e.getData(PlatformDataKeys.EDITOR); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsToolbarAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsToolbarAction.java new file mode 100644 index 000000000000..5fbbaf55ff35 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsToolbarAction.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.IdeActions; + +/** + * {@link ToggleUseSoftWrapsAction} extension that doesn't suppress configured icon (if any). + * + * @author Denis Zhdanov + * @since Aug 19, 2010 5:07:08 PM + */ +public class ToggleUseSoftWrapsToolbarAction extends ToggleUseSoftWrapsAction { + + public ToggleUseSoftWrapsToolbarAction() { + super(true); + copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_USE_SOFT_WRAPS)); + } +} diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 61a74a964483..a4eabe57d100 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -123,6 +123,8 @@ action.EditorToggleShowIndentLines.text=Sh_ow Indent Guides action.EditorToggleShowIndentLines.description=Toggle display indent guides in current editor action.EditorToggleShowLineNumbers.text=Show L_ine Numbers action.EditorToggleShowLineNumbers.description=Toggle display line numbers in current editor +action.EditorToggleUseSoftWraps.text=Use Soft Wraps +action.EditorToggleUseSoftWraps.description=Toggle using soft wraps in current editor action.ViewImportPopups.text=Show Import Popups action.ViewImportPopups.description=Toggle display import popups in current file action.EditorScrollToCenter.text=Scroll to Center From bfd076efa1fa952968e2b1b0bb044d88e1a91815 Mon Sep 17 00:00:00 2001 From: Denis Zhdanov Date: Thu, 19 Aug 2010 17:29:27 +0400 Subject: [PATCH 09/14] IDEA-57733 Remove 'vcs-impl -> lang-impl' dependency introduced by the change to use editor for commit message processing 1. Defined dedicated interface for spell checking-aware editor retrieval; 2. Moved actual spell checking-aware editor text field construction to 'lang-impl'; 3. Commit message component retrieves spell checking-aware editor via target interface now; --- platform/platform-resources/src/idea/PlatformActions.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 3c5b8ce9c23b..7845e2df7979 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -77,6 +77,7 @@ + @@ -180,6 +181,7 @@ + @@ -366,6 +368,7 @@ + From b6f0b07b8ecca92fdd15917a1433e7af7cb732d5 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Thu, 19 Aug 2010 17:41:45 +0400 Subject: [PATCH 10/14] fix completion popup crop to dialog size for single line editors (see copy class dialog as example) --- .../CompletionProgressIndicator.java | 6 +++++ .../src/com/intellij/ui/LightweightHint.java | 23 +++++++++++++++---- .../com/intellij/ui/popup/AbstractPopup.java | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index d53b026b7417..82fcb38bf007 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -90,6 +90,12 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement myFreezeSemaphore = freezeSemaphore; myLookup = (LookupImpl)LookupManager.getInstance(editor.getProject()).createLookup(editor, LookupElement.EMPTY_ARRAY, "", new CompletionLookupArranger(parameters)); + if (editor.isOneLineMode()) { + myLookup.setForceShowAsPopup(true); + myLookup.setCancelOnClickOutside(true); + myLookup.setCancelOnOtherWindowOpen(true); + myLookup.setResizable(false); + } myLookup.addLookupListener(new LookupAdapter() { public void itemSelected(LookupEvent event) { diff --git a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java index 48251f87e99c..d068c8c3fd2a 100644 --- a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java @@ -48,6 +48,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint { private boolean myForceShowAsPopup = false; private String myTitle = null; + private boolean myCancelOnClickOutside; + private boolean myCancelOnOtherWindowOpen; + private boolean myResizable; public LightweightHint(@NotNull final JComponent component) { myComponent = component; @@ -74,6 +77,18 @@ public class LightweightHint extends UserDataHolderBase implements Hint { mySelectingHint = selectingHint; } + public void setCancelOnClickOutside(final boolean b) { + myCancelOnClickOutside = b; + } + + public void setCancelOnOtherWindowOpen(final boolean b) { + myCancelOnOtherWindowOpen = b; + } + + public void setResizable(final boolean b) { + myResizable = b; + } + /** * Shows the hint in the layered pane. Coordinates x and y * are in parentComponent coordinate system. Note that the component @@ -105,13 +120,13 @@ public class LightweightHint extends UserDataHolderBase implements Hint { myIsRealPopup = true; myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myComponent, null) .setRequestFocus(false) - .setResizable(myForceShowAsPopup) - .setMovable(myForceShowAsPopup) + .setResizable(myResizable) + .setMovable(myTitle != null) .setTitle(myTitle) .setShowShadow(false) .setCancelKeyEnabled(false) - .setCancelOnClickOutside(false) - .setCancelOnOtherWindowOpen(false) + .setCancelOnClickOutside(myCancelOnClickOutside) + .setCancelOnOtherWindowOpen(myCancelOnOtherWindowOpen) .createPopup(); beforeShow(); diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index db179130e98b..7fd4950bad6a 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -197,7 +197,7 @@ public class AbstractPopup implements JBPopup { myPopupBorder = PopupBorder.Factory.create(true); myShadowed = showShadow; myPaintShadow = showShadow && !SystemInfo.isMac && !movable && !resizable && Registry.is("ide.popup.dropShadow"); - myContent = createContentPanel(resizable, myPopupBorder, isToDrawMacCorner()); + myContent = createContentPanel(resizable, myPopupBorder, isToDrawMacCorner() && resizable); myMayBeParent = mayBeParent; myContent.add(component, BorderLayout.CENTER); From 331ab43d9b21dcec13ec0fb455e87bd351007539 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Thu, 19 Aug 2010 18:08:47 +0400 Subject: [PATCH 11/14] Fix: IDEA-57638 (Support namedQueries in Grails) --- .../groovy/lang/psi/impl/synthetic/GrImplicitVariable.java | 5 ++--- .../lang/psi/impl/synthetic/GrImplicitVariableImpl.java | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariable.java index 9ee09fecbe11..c97830fb3254 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariable.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariable.java @@ -15,13 +15,12 @@ */ package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic; -import com.intellij.navigation.ItemPresentation; -import com.intellij.navigation.NavigationItem; import com.intellij.psi.ImplicitVariable; +import com.intellij.psi.NavigatablePsiElement; /** * User: Dmitry.Krasilschikov * Date: 04.02.2008 */ -public interface GrImplicitVariable extends ImplicitVariable { +public interface GrImplicitVariable extends ImplicitVariable, NavigatablePsiElement { } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariableImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariableImpl.java index 0d711532a21e..bc2391b5c05a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariableImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrImplicitVariableImpl.java @@ -29,7 +29,7 @@ public class GrImplicitVariableImpl extends LightVariableBase implements GrImpli myNameIdentifier = new GrLightIdentifier(myManager, name); } - public void accept(@NotNull PsiElementVisitor visitor) { + public void accept(@NotNull PsiElementVisitor visitor) { if (visitor instanceof JavaElementVisitor) { ((JavaElementVisitor) visitor).visitImplicitVariable(this); } @@ -53,6 +53,11 @@ public class GrImplicitVariableImpl extends LightVariableBase implements GrImpli return myInnerModifierList.hasModifierProperty(modifier); } + @Override + public boolean isEquivalentTo(PsiElement another) { + return another == getNavigationElement() || super.isEquivalentTo(another); + } + protected static class GrLightIdentifier extends LightIdentifier { private String myTextInternal; From aa90bbaadf53983550c5a81dea1567cc466f2489 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 19 Aug 2010 18:29:28 +0400 Subject: [PATCH 12/14] to reduce number of anonymous classes --- .../com/intellij/util/ConstantFunction.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 platform/util/src/com/intellij/util/ConstantFunction.java diff --git a/platform/util/src/com/intellij/util/ConstantFunction.java b/platform/util/src/com/intellij/util/ConstantFunction.java new file mode 100644 index 000000000000..8affabfb6914 --- /dev/null +++ b/platform/util/src/com/intellij/util/ConstantFunction.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Bulenkov + */ +public class ConstantFunction implements NotNullFunction { + private final Result value; + + public ConstantFunction(@NotNull Result value) { + this.value = value; + } + + @NotNull + @Override + public Result fun(Param param) { + return value; + } +} From 33c2b304a0e8c2c252a94666b4aeec8dbe366873 Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Thu, 19 Aug 2010 18:46:56 +0400 Subject: [PATCH 13/14] more performance checks --- .../intelliLang/inject/java/ConcatenationInjector.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java index c1228510bb9b..80dcf34c353d 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/java/ConcatenationInjector.java @@ -149,7 +149,9 @@ public class ConcatenationInjector implements ConcatenationAwareInjector { } } } - process(variable, null, -1); + if (areThereInjectionsWithName(variable.getName(), false)) { + process(variable, null, -1); + } return false; } @@ -176,7 +178,8 @@ public class ConcatenationInjector implements ConcatenationAwareInjector { final PsiMethod method = declarationScope instanceof PsiMethod ? (PsiMethod)declarationScope : null; final PsiParameterList parameterList = method == null ? null : method.getParameterList(); // don't check catchblock parameters & etc. - if (!(parameterList == null || parameterList != e.getParent())) { + if (!(parameterList == null || parameterList != e.getParent()) && + areThereInjectionsWithName(method.getName(), false)) { final int parameterIndex = parameterList.getParameterIndex((PsiParameter)e); process((PsiModifierListOwner)e, method, parameterIndex); } From 518c0a6a98b7bac2470fa9802321354e2aaa2daa Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 19 Aug 2010 16:30:23 +0400 Subject: [PATCH 14/14] don't create UsageTargets from elements which don't implement NavigationItem (PY-1608) --- .../codeInsight/highlighting/HighlightUsagesHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java index 32b66903242e..fd86a51808ab 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/HighlightUsagesHandler.java @@ -22,6 +22,7 @@ import com.intellij.find.EditorSearchComponent; import com.intellij.find.findUsages.PsiElement2UsageTargetAdapter; import com.intellij.injected.editor.EditorWindow; import com.intellij.lang.injection.InjectedLanguageManager; +import com.intellij.navigation.NavigationItem; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.actionSystem.Shortcut; @@ -79,7 +80,12 @@ public class HighlightUsagesHandler extends HighlightHandlerBase { if (usageTargets == null) { PsiElement targetElement = getTargetElement(editor, file); if (targetElement != null) { - usageTargets = new UsageTarget[]{new PsiElement2UsageTargetAdapter(targetElement)}; + if (!(targetElement instanceof NavigationItem)) { + targetElement = targetElement.getNavigationElement(); + } + if (targetElement instanceof NavigationItem) { + usageTargets = new UsageTarget[]{new PsiElement2UsageTargetAdapter(targetElement)}; + } } }