Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2015-05-19 23:00:40 +02:00
28 changed files with 561 additions and 116 deletions
+31 -24
View File
@@ -35,9 +35,9 @@ target(compile: "Compile project") {
}
}
private pass(String prop) {
private pass(List<String> args, String prop) {
if (isDefined(prop)) {
ant.jvmarg(value: "-D$prop=${p(prop)}")
args << "-D$prop=${p(prop)}"
}
}
@@ -49,29 +49,36 @@ target('run_tests': 'Run java tests') {
new File(classpathFile).text = testRuntimeClasspath.findAll({ new File((String)it).exists() }).join('\n')
testcases.each { testCase ->
List<String> jvmArgs = [
"-Dclasspath.file=${classpathFile}",
"-Didea.platform.prefix=Idea",
"-Dbootstrap.testcases=$testCase"
]
[
"idea.test.group",
"idea.test.patterns",
"idea.fast.only",
"idea.coverage.enabled.build",
"teamcity.build.tempDir",
"teamcity.tests.recentlyFailedTests.file"
].each { pass(jvmArgs, it) }
System.getProperties().entrySet().each {
if (it.key.startsWith("pass.")) {
def trimmed = it.key.substring("pass.".length());
jvmArgs << "-D${trimmed}=${it.value}"
};
}
jvmArgs.addAll(commonJvmArgsForTests())
if (isDefined("jvm_args")) {
jvmArgs.addAll(jvm_args)
}
projectBuilder.info("Starting JUnit $testCase, JVM options: $jvmArgs")
ant.junit(fork: "yes", showoutput: "true", logfailedtests: false) {
jvmarg(value: "-Dclasspath.file=${classpathFile}")
pass("idea.test.group")
pass("idea.test.patterns")
pass("idea.fast.only")
pass("idea.coverage.enabled.build")
pass("teamcity.build.tempDir")
pass("teamcity.tests.recentlyFailedTests.file")
jvmarg(value: "-Didea.platform.prefix=Idea")
System.getProperties().entrySet().each {
if (it.key.startsWith("pass.")) {
def trimmed = it.key.substring("pass.".length());
jvmarg(value: "-D${trimmed}=${it.value}");
};
}
commonJvmArgsForTests().each { jvmarg(value: it) }
jvmarg(value: "-Dbootstrap.testcases=$testCase")
if (isDefined("jvm_args")) {
jvm_args.each { jvmarg(value: it) }
jvmArgs.each {
jvmarg(value: it)
}
classpath {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 121 KiB

@@ -0,0 +1,35 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.images.options.impl;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class ImagesOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new OptionsConfigurabe();
}
}
@@ -179,8 +179,11 @@ public class JavaNoVariantsDelegator extends CompletionContributor {
}
final Set<LookupElement> allClasses = new LinkedHashSet<LookupElement>();
JavaClassNameCompletionContributor.addAllClasses(parameters.withPosition(qualifier.getReferenceNameElement(), qualifier.getTextRange().getEndOffset()),
true, qMatcher, new CollectConsumer<LookupElement>(allClasses));
PsiElement qualifierName = qualifier.getReferenceNameElement();
if (qualifierName != null) {
JavaClassNameCompletionContributor.addAllClasses(parameters.withPosition(qualifierName, qualifierName.getTextRange().getEndOffset()),
true, qMatcher, new CollectConsumer<LookupElement>(allClasses));
}
return allClasses;
}
@@ -18,7 +18,6 @@ package com.intellij.psi.impl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootModificationTracker;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.*;
@@ -395,12 +394,10 @@ public class PsiSuperMethodImplUtil {
result = new HierarchicalMethodSignatureImpl((MethodSignatureBackedByPsiMethod)method.getSignature(PsiSubstitutor.EMPTY));
}
Project project = aClass == null ? method.getProject() : aClass.getProject();
// cache Cls method hierarchy until root changed
Object dependency = method instanceof PsiCompiledElement ? ProjectRootModificationTracker.getInstance(project) :
!method.isPhysical() ? method :
PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT;
return CachedValueProvider.Result.create(result, dependency);
if (!method.isPhysical()) {
return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT, method);
}
return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
};
@@ -14,7 +14,9 @@
* limitations under the License.
*/
package com.intellij.psi.resolve
import com.intellij.openapi.application.ex.PathManagerEx
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.vfs.JarFileSystem
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
@@ -217,4 +219,22 @@ class Testcase {
myFixture.checkHighlighting()
}
public void "test update method hierarchy on class file change"() {
myFixture.testDataPath = PathManagerEx.getTestDataPath() + "/libResolve/methodHierarchy"
myFixture.copyDirectoryToProject("", "lib")
PsiTestUtil.addLibrary(myModule, "lib", myFixture.tempDirFixture.getFile("").path, "lib");
def message = JavaPsiFacade.getInstance(project).findClass('com.google.protobuf.AbstractMessageLite',
GlobalSearchScope.allScope(project))
assert message
def method = message.findMethodsByName("toByteArray", false)[0]
assert method
assert method.hierarchicalMethodSignature.superSignatures.size() == 1
WriteCommandAction.runWriteCommandAction(project) {
message.interfaces[0].containingFile.virtualFile.delete(this)
}
assert method.hierarchicalMethodSignature.superSignatures.size() == 0
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.stubs.PsiFileStubImpl;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.ExceptionUtil;
@@ -143,8 +144,13 @@ public class PsiInvalidElementAccessException extends RuntimeException implement
String m = "parent is null";
if (root instanceof StubBasedPsiElement) {
StubElement stub = ((StubBasedPsiElement)root).getStub();
m += "; stub=" + stub;
if (stub != null) m += "; p.s.=" + stub.getParentStub();
while (stub != null) {
m += "\n each stub=" + stub;
if (stub instanceof PsiFileStubImpl) {
m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStubImpl)stub).getInvalidationReason();
}
stub = stub.getParentStub();
}
}
return m;
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2015 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.application.options.editor;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class AutoImportOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new AutoImportOptionsConfigurable();
}
}
@@ -0,0 +1,54 @@
/*
* Copyright 2000-2015 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.application.options.editor;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import javax.swing.*;
/**
* @author Sergey.Malenkov
*/
public class CodeFoldingOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
private int myCount;
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
myCount = 0;
return new CodeFoldingConfigurable();
}
@Override
protected String getName(Configurable configurable) {
return null;
}
@Override
protected String getOptionName(JCheckBox checkbox) {
String name = super.getOptionName(checkbox);
if (name != null && 0 < myCount++) {
name = "Collapse by default: " + name;
}
return name;
}
}
@@ -2,7 +2,7 @@
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.editor.EditorOptionsPanel">
<tabbedpane id="97a1e">
<constraints>
<xy x="22" y="49" width="812" height="1364"/>
<xy x="22" y="49" width="812" height="1491"/>
</constraints>
<properties/>
<border type="none"/>
@@ -438,7 +438,7 @@
</component>
</children>
</grid>
<grid id="7bb4" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="7bb4" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -451,12 +451,12 @@
<children>
<vspacer id="32f7b">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2a6d" class="javax.swing.JCheckBox" binding="myCbUseSoftWrapsAtEditor">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="true"/>
@@ -465,7 +465,7 @@
</component>
<component id="42235" class="javax.swing.JCheckBox" binding="myCbUseSoftWrapsAtConsole">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ApplicationBundle" key="checkbox.use.soft.wraps.at.console"/>
@@ -473,7 +473,7 @@
</component>
<component id="42c6f" class="javax.swing.JCheckBox" binding="myCbShowSoftWrapsOnlyOnCaretLine">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ApplicationBundle" key="checkbox.show.softwraps.only.for.caret.line"/>
@@ -492,12 +492,21 @@
</component>
<component id="e5f5a" class="javax.swing.JTextField" binding="myCustomSoftWrapIndent">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="35" height="-1"/>
</grid>
</constraints>
<properties>
<enabled value="false"/>
<text value=""/>
</properties>
</component>
<component id="41357" class="javax.swing.JLabel" binding="myCustomSoftWrapIndentLabel">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/ApplicationBundle" key="label.use.custom.soft.wraps.indent"/>
</properties>
</component>
</children>
@@ -96,6 +96,7 @@ public class EditorOptionsPanel {
private JCheckBox myCbUseSoftWrapsAtConsole;
private JCheckBox myCbUseCustomSoftWrapIndent;
private JTextField myCustomSoftWrapIndent;
private JLabel myCustomSoftWrapIndentLabel;
private JCheckBox myCbShowSoftWrapsOnlyOnCaretLine;
private JCheckBox myPreselectCheckBox;
private JBCheckBox myCbShowQuickDocOnMouseMove;
@@ -580,6 +581,7 @@ public class EditorOptionsPanel {
boolean softWrapsEnabled = myCbUseSoftWrapsAtEditor.isSelected() || myCbUseSoftWrapsAtConsole.isSelected();
myCbUseCustomSoftWrapIndent.setEnabled(softWrapsEnabled);
myCustomSoftWrapIndent.setEnabled(myCbUseCustomSoftWrapIndent.isEnabled() && myCbUseCustomSoftWrapIndent.isSelected());
myCustomSoftWrapIndentLabel.setEnabled(myCustomSoftWrapIndent.isEnabled());
myCbShowSoftWrapsOnlyOnCaretLine.setEnabled(softWrapsEnabled);
}
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2015 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.application.options.editor;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class EditorOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new EditorOptions();
}
@Override
protected String getName(Configurable configurable) {
return null;
}
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2015 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.application.options.editor;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class EditorSmartKeysOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new EditorSmartKeysConfigurable();
}
}
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2015 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.application.options.editor;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class EditorTabsOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new EditorTabsConfigurable();
}
@Override
protected String getName(Configurable configurable) {
return null;
}
}
@@ -179,7 +179,7 @@ public class CompletionLookupArranger extends LookupArranger {
LookupImpl lookupImpl = (LookupImpl)lookup;
List<LookupElement> listModel = isAlphaSorted() ?
sortByPresentation(items, lookupImpl) :
fillModelByRelevance(lookupImpl, items, itemsBySorter, relevantSelection);
fillModelByRelevance(lookupImpl, ContainerUtil.newIdentityTroveSet(items), itemsBySorter, relevantSelection);
int toSelect = getItemToSelect(lookupImpl, listModel, onExplicitAction, relevantSelection);
LOG.assertTrue(toSelect >= 0);
@@ -197,7 +197,7 @@ public class CompletionLookupArranger extends LookupArranger {
}
private List<LookupElement> fillModelByRelevance(LookupImpl lookup,
List<LookupElement> items,
Set<LookupElement> items,
MultiMap<CompletionSorterImpl, LookupElement> inputBySorter,
@Nullable LookupElement relevantSelection) {
Iterator<LookupElement> byRelevance = sortByRelevance(inputBySorter).iterator();
@@ -235,10 +235,10 @@ public class CompletionLookupArranger extends LookupArranger {
});
}
private static void ensureItemAdded(List<LookupElement> items,
private static void ensureItemAdded(Set<LookupElement> items,
LinkedHashSet<LookupElement> model,
Iterator<LookupElement> byRelevance, @Nullable final LookupElement item) {
if (item != null && ContainerUtil.indexOfIdentity(items, item) >= 0 && !model.contains(item)) {
if (item != null && items.contains(item) && !model.contains(item)) {
addSomeItems(model, byRelevance, new Condition<LookupElement>() {
@Override
public boolean value(LookupElement lastAdded) {
@@ -255,7 +255,7 @@ public class CompletionLookupArranger extends LookupArranger {
}
}
private void addFrozenItems(List<LookupElement> items, LinkedHashSet<LookupElement> model) {
private void addFrozenItems(Set<LookupElement> items, LinkedHashSet<LookupElement> model) {
myFrozenItems.retainAll(items);
model.addAll(myFrozenItems);
}
@@ -265,10 +265,10 @@ public class CompletionLookupArranger extends LookupArranger {
ContainerUtil.addAll(model, sortByRelevance(groupItemsBySorter(getPrefixItems(false))));
}
private static void addCurrentlySelectedItemToTop(Lookup lookup, List<LookupElement> items, LinkedHashSet<LookupElement> model) {
private static void addCurrentlySelectedItemToTop(Lookup lookup, Set<LookupElement> items, LinkedHashSet<LookupElement> model) {
if (!lookup.isSelectionTouched()) {
LookupElement lastSelection = lookup.getCurrentItem();
if (ContainerUtil.indexOfIdentity(items, lastSelection) >= 0) {
if (items.contains(lastSelection)) {
model.add(lastSelection);
}
}
@@ -20,7 +20,9 @@ import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -102,7 +104,12 @@ public abstract class LookupArranger {
}
protected List<LookupElement> getMatchingItems() {
return Collections.unmodifiableList(myMatchingItems);
return ContainerUtil.filter(myMatchingItems, new Condition<LookupElement>() {
@Override
public boolean value(LookupElement element) {
return element.isValid();
}
});
}
public Map<LookupElement,StringBuilder> getRelevanceStrings() {
@@ -0,0 +1,171 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.ui;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.ex.ConfigurableVisitor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.util.*;
/**
* @author Sergey.Malenkov
*/
public abstract class ConfigurableOptionsTopHitProvider extends OptionsTopHitProvider {
private static final Logger LOG = Logger.getInstance(ConfigurableOptionsTopHitProvider.class);
private final Deque<String> myPrefix = new ArrayDeque<String>();
protected abstract Configurable getConfigurable(Project project);
/**
* Returns a name that will be added to all option names.
* This implementation returns the display name of the configurable.
*
* @param configurable the configurable to process
* @return a main prefix or {@code null} to ignore
*/
protected String getName(Configurable configurable) {
return configurable.getDisplayName();
}
/**
* Returns a section name that will be added to some option names,
* which are located within the specified container.
* This implementation returns the border title of the component.
*
* @param component the component to process
* @return a section prefix or {@code null} to ignore
*/
protected String getSection(Component component) {
if (component instanceof JComponent) {
Border border = ((JComponent)component).getBorder();
if (border instanceof TitledBorder) {
return ((TitledBorder)border).getTitle();
}
}
return null;
}
/**
* Returns an option name that will be used to create an option.
*
* @param checkbox the candidate to create an option
* @return an option prefix or {@code null} to ignore this option
*/
protected String getOptionName(JCheckBox checkbox) {
String name = StringUtil.stripHtml(checkbox.getText(), false);
if (StringUtil.isEmpty(name)) {
return null;
}
if (myPrefix.isEmpty()) {
return name;
}
StringBuilder sb = new StringBuilder();
Iterator<String> iterator = myPrefix.descendingIterator();
while (iterator.hasNext()) {
sb.append(iterator.next()).append(": ");
}
return sb.append(name).toString();
}
protected void init(Collection<BooleanOptionDescription> options, Configurable configurable, Component component) {
initRecursively(options, configurable, component);
}
private void initRecursively(Collection<BooleanOptionDescription> options, Configurable configurable, Component component) {
String section = getSection(component);
if (section != null) {
myPrefix.push(section);
}
if (component instanceof JCheckBox) {
JCheckBox checkbox = (JCheckBox)component;
String option = getOptionName(checkbox);
if (option != null) {
options.add(new Option(configurable, checkbox, option));
}
}
else if (component instanceof Container) {
Container container = (Container)component;
for (int i = 0; i < container.getComponentCount(); i++) {
initRecursively(options, configurable, container.getComponent(i));
}
}
if (section != null) {
myPrefix.pop();
}
}
@NotNull
@Override
public Collection<BooleanOptionDescription> getOptions(@Nullable Project project) {
try {
Configurable configurable = getConfigurable(project);
Component component = configurable.createComponent();
configurable.reset();
myPrefix.clear();
String name = getName(configurable);
if (name != null) {
myPrefix.push(name);
}
Collection<BooleanOptionDescription> options = new ArrayList<BooleanOptionDescription>();
init(options, configurable, component);
return Collections.unmodifiableCollection(options);
}
catch (Exception exception) {
LOG.debug(exception);
}
return Collections.emptyList();
}
private static final class Option extends BooleanOptionDescription {
private final Configurable myConfigurable;
private final JCheckBox myCheckBox;
private Option(Configurable configurable, JCheckBox checkbox, String option) {
super(option, ConfigurableVisitor.ByID.getID(configurable));
myConfigurable = configurable;
myCheckBox = checkbox;
}
@Override
public boolean isOptionEnabled() {
return myCheckBox.isSelected();
}
@Override
public void setOptionState(boolean selected) {
if (selected != myCheckBox.isSelected()) {
myCheckBox.setSelected(selected);
try {
myConfigurable.apply();
}
catch (ConfigurationException exception) {
LOG.debug(exception);
}
}
}
}
}
@@ -16,10 +16,7 @@
package com.intellij.ide.ui;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -31,54 +28,8 @@ import java.util.Collection;
*/
public class EditorOptionsTopHitProvider extends OptionsTopHitProvider {
private static final String ID = "editor";
private static final Collection<BooleanOptionDescription> ourOptions = ContainerUtil.immutableList(
editor("Mouse: " + messageApp("checkbox.honor.camelhumps.words.settings.on.double.click"),
"IS_MOUSE_CLICK_SELECTION_HONORS_CAMEL_WORDS"),
editor("Mouse: " + messageApp(SystemInfo.isMac
? "checkbox.enable.ctrl.mousewheel.changes.font.size.macos"
: "checkbox.enable.ctrl.mousewheel.changes.font.size"), "IS_WHEEL_FONTCHANGE_ENABLED"),
editor("Mouse: " + messageApp("checkbox.enable.drag.n.drop.functionality.in.editor"), "IS_DND_ENABLED"),
new EditorOptionDescription(null, messageApp("checkbox.use.soft.wraps.at.editor.action.text"), "preferences.editor") {
@Override
public boolean isOptionEnabled() {
return EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR);
}
@Override
public void setOptionState(boolean enabled) {
EditorSettingsExternalizable.getInstance().setUseSoftWraps(enabled, SoftWrapAppliancePlaces.MAIN_EDITOR);
fireUpdated();
}
},
new EditorOptionDescription(null, messageApp("checkbox.use.soft.wraps.at.console.action.text"), "preferences.editor") {
@Override
public boolean isOptionEnabled() {
return EditorSettingsExternalizable.getInstance().isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE);
}
@Override
public void setOptionState(boolean enabled) {
EditorSettingsExternalizable.getInstance().setUseSoftWraps(enabled, SoftWrapAppliancePlaces.CONSOLE);
fireUpdated();
}
},
editor(messageApp("checkbox.use.custom.soft.wraps.indent.action.text"), "USE_CUSTOM_SOFT_WRAP_INDENT"),
new EditorOptionDescription(null, messageApp("checkbox.show.softwraps.only.for.caret.line.action.text"), "preferences.editor") {
@Override
public boolean isOptionEnabled() {
return !EditorSettingsExternalizable.getInstance().isAllSoftWrapsShown();
}
@Override
public void setOptionState(boolean enabled) {
EditorSettingsExternalizable.getInstance().setAllSoftwrapsShown(!enabled);
fireUpdated();
}
},
editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.after.end.of.line"), "IS_VIRTUAL_SPACE"),
editor("Virtual Space: " + messageApp("checkbox.allow.placement.of.caret.inside.tabs"), "IS_CARET_INSIDE_TABS"),
editor("Virtual Space: " + messageApp("checkbox.show.virtual.space.at.file.bottom"), "ADDITIONAL_PAGE_AT_BOTTOM"),
editorUI("Appearance: " + messageIde("checkbox.use.antialiased.font.in.editor"), "ANTIALIASING_IN_EDITOR"),
editorUI("Appearance: " + messageIde("checkbox.use.lcd.rendered.font.in.editor"), "USE_LCD_RENDERING_IN_EDITOR"),
editorApp("Appearance: Caret blinking", "IS_CARET_BLINKING"),
@@ -91,16 +42,8 @@ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider {
editorApp("Appearance: Show trailing whitespaces", "IS_TRAILING_WHITESPACES_SHOWN"),
editorApp("Appearance: Show vertical indent guides", "IS_INDENT_GUIDES_SHOWN"),
editorCode("Appearance: " + messageApp("checkbox.show.small.icons.in.gutter"), "SHOW_SMALL_ICONS_IN_GUTTER"),
option("Appearance: " + messageApp("checkbox.show.code.folding.outline"), "IS_FOLDING_OUTLINE_SHOWN", "editor.preferences.folding"),
editorTabs("Tabs: " + messageApp("checkbox.editor.tabs.in.single.row"), "SCROLL_TAB_LAYOUT_IN_EDITOR"),
editorTabs("Tabs: " + messageApp("checkbox.editor.scroll.if.need"), "HIDE_TABS_IF_NEED"),
editorTabs("Tabs: " + messageApp("checkbox.hide.file.extension.in.editor.tabs"), "HIDE_KNOWN_EXTENSION_IN_TABS"),
editorTabs("Tabs: Show directory in editor tabs for non-unique filenames", "SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES"),
editorTabs("Tabs: " + messageApp("checkbox.editor.tabs.show.close.button"), "SHOW_CLOSE_BUTTON"),
editorTabs("Tabs: " + messageApp("checkbox.mark.modified.tabs.with.asterisk"), "MARK_MODIFIED_TABS_WITH_ASTERISK"),
editorTabs("Tabs: " + messageApp("checkbox.show.tabs.tooltips"), "SHOW_TABS_TOOLTIPS"),
editorTabs("Tabs: " + messageApp("checkbox.smart.tab.reuse"), "REUSE_NOT_MODIFIED_TABS"),
editorTabs("Tabs: " + messageApp("radio.close.non.modified.files.first"), "CLOSE_NON_MODIFIED_FILES_FIRST")
editorTabs(messageApp("group.tab.closing.policy") + ": " +
messageApp("radio.close.non.modified.files.first"), "CLOSE_NON_MODIFIED_FILES_FIRST")
);
@NotNull
@@ -137,7 +80,7 @@ public class EditorOptionsTopHitProvider extends OptionsTopHitProvider {
static BooleanOptionDescription editorCode(String option, String field) {
return new DaemonCodeAnalyzerOptionDescription(field, option, "editor.preferences.appearance");
}
public static class Ex extends OptionsTopHitProvider implements CoveredByToggleActions {
private static final Collection<BooleanOptionDescription> ourOptions = ContainerUtil.immutableList(
editorApp("Appearance: " + messageApp("checkbox.show.line.numbers"), "ARE_LINE_NUMBERS_SHOWN")
@@ -158,6 +158,7 @@ public class StorageUtil {
@NotNull final VirtualFile file,
@NotNull final BufferExposingByteArrayOutputStream content,
@Nullable final LineSeparator lineSeparatorIfPrependXmlProlog) throws IOException {
LOG.debug("Save " + file.getPresentableUrl());
AccessToken token = WriteAction.start();
try {
OutputStream out = file.getOutputStream(requestor);
@@ -394,13 +394,10 @@ radio.close.non.modified.files.first=Close non-modified files first
label.when.number.of.opened.editors.exceeds.tab.limit=<html>When number of opened editors exceeds tab limit:</html>
group.soft.wraps=Soft Wraps
checkbox.use.soft.wraps.at.editor=Use soft wraps in editor
checkbox.use.soft.wraps.at.editor.action.text=Soft Wraps: Use in editor
checkbox.use.soft.wraps.at.console=Use soft wraps in console
checkbox.use.soft.wraps.at.console.action.text=Soft Wraps: Use in console
checkbox.use.custom.soft.wraps.indent=Use original line's indent for wrapped parts. Additional shift:
checkbox.use.custom.soft.wraps.indent.action.text=Soft Wraps: Use original line's indent for wrapped parts
checkbox.use.custom.soft.wraps.indent=Use original line's indent for wrapped parts
label.use.custom.soft.wraps.indent=Additional shift:
checkbox.show.softwraps.only.for.caret.line=Show soft wraps for current line only
checkbox.show.softwraps.only.for.caret.line.action.text=Soft Wraps: Show for current line only
group.virtual.space=Virtual Space
checkbox.allow.placement.of.caret.after.end.of.line=Allow placement of caret after end of line
checkbox.allow.placement.of.caret.inside.tabs=Allow placement of caret inside tabs
@@ -377,6 +377,13 @@
<search.topHitProvider implementation="com.intellij.ide.ui.InspectionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.ide.ui.RegistryOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.ide.ui.PluginOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.application.options.editor.EditorOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.application.options.editor.EditorSmartKeysOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.application.options.editor.EditorTabsOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.application.options.editor.CodeFoldingOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.application.options.editor.AutoImportOptionsTopHitProvider"/>
<search.topHitProvider implementation="com.intellij.uiDesigner.GuiDesignerOptionsTopHitProvider"/>
<search.topHitProvider implementation="org.intellij.images.options.impl.ImagesOptionsTopHitProvider"/>
<projectService serviceImplementation="com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.UnknownFeaturesCollector"/>
<postStartupActivity implementation="com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser" order="before OpenFilesActivity"/>
<actionPromoter implementation="com.intellij.ui.ToolbarDecoratorActionPromoter"/>
@@ -229,6 +229,7 @@ public class GroupTreeNode extends AbstractTreeNode implements Disposable {
apply = true;
}
else if (showOnlyFilteredItems) {
Disposer.dispose(child);
continue;
}
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2015 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.uiDesigner;
import com.intellij.ide.ui.ConfigurableOptionsTopHitProvider;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public class GuiDesignerOptionsTopHitProvider extends ConfigurableOptionsTopHitProvider {
@Override
public String getId() {
return "editor";
}
@Override
protected Configurable getConfigurable(Project project) {
return new GuiDesignerConfigurable(project);
}
}