Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-06-04 16:48:55 +04:00
22 changed files with 156 additions and 299 deletions
@@ -260,4 +260,6 @@ public abstract class QuickFixFactory {
public abstract IntentionAction createAddMissingRequiredAnnotationParametersFix(@NotNull PsiAnnotation annotation,
@NotNull PsiMethod[] annotationMethods,
@NotNull Collection<String> missedElements);
@NotNull
public abstract IntentionAction createSurroundWithQuotesAnnotationParameterValueFix(@NotNull PsiAnnotationMemberValue value, @NotNull PsiType expectedType);
}
@@ -153,7 +153,10 @@ public class AnnotationsHighlightUtil {
String description = JavaErrorMessages.message("annotation.incompatible.types",
JavaHighlightUtil.formatType(type), JavaHighlightUtil.formatType(expectedType));
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
final HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create();
QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createSurroundWithQuotesAnnotationParameterValueFix(value, expectedType));
return info;
}
LOG.error("Unknown annotation member value: " + value);
@@ -595,4 +595,11 @@ public class EmptyQuickFixFactory extends QuickFixFactory {
public IntentionAction createAddMissingRequiredAnnotationParametersFix(@NotNull PsiAnnotation psiAnnotation, @NotNull PsiMethod[] psiMethods, @NotNull Collection<String> strings) {
return QuickFixes.EMPTY_FIX;
}
@NotNull
@Override
public IntentionAction createSurroundWithQuotesAnnotationParameterValueFix(@NotNull PsiAnnotationMemberValue value,
@NotNull PsiType expectedType) {
return QuickFixes.EMPTY_FIX;
}
}
@@ -0,0 +1,76 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Batkovich
*/
public class SurroundWithQuotesAnnotationParameterValueFix implements IntentionAction {
private final PsiAnnotationMemberValue myValue;
private final PsiType myExpectedType;
public SurroundWithQuotesAnnotationParameterValueFix(final PsiAnnotationMemberValue value, final PsiType expectedType) {
myValue = value;
myExpectedType = expectedType;
}
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (!myValue.isValid() || !(myExpectedType instanceof PsiClassType)) {
return false;
}
final PsiClass resolvedType = ((PsiClassType)myExpectedType).resolve();
return resolvedType != null && CommonClassNames.JAVA_LANG_STRING.equals(resolvedType.getQualifiedName()) && myValue instanceof PsiLiteralExpression;
}
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
String newText = myValue.getText();
newText = StringUtil.stripQuotesAroundValue(newText);
newText = "\"" + newText + "\"";
PsiElement newToken = JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(newText, null);
final PsiElement newElement = myValue.replace(newToken);
editor.getCaretModel().moveToOffset(newElement.getTextOffset() + newElement.getTextLength());
}
@NotNull
@Override
public String getFamilyName() {
return "Surround annotation parameter value with quotes";
}
@NotNull
@Override
public String getText() {
return getFamilyName();
}
@Override
public boolean startInWriteAction() {
return true;
}
}
@@ -15,13 +15,15 @@
*/
package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction;
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,11 +36,15 @@ public class CreateSwitchIntention extends BaseElementAtCaretIntentionAction {
@Override
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) {
return;
}
final PsiExpressionStatement expressionStatement = resolveExpressionStatement(element);
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiSwitchStatement switchStatement = (PsiSwitchStatement)elementFactory
.createStatementFromText(String.format("switch (%s) {\n$MARKER$\n}", expressionStatement.getExpression().getText()), null);
switchStatement = (PsiSwitchStatement)expressionStatement.replace(switchStatement);
CodeStyleManager.getInstance(project).reformat(switchStatement);
for (final PsiStatement psiStatement : switchStatement.getBody().getStatements()) {
if (psiStatement.getText().equals("$MARKER$")) {
@@ -55,7 +61,7 @@ public class CreateSwitchIntention extends BaseElementAtCaretIntentionAction {
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
final PsiExpressionStatement expressionStatement = resolveExpressionStatement(element);
return expressionStatement != null && isValidTypeForSwitch(expressionStatement.getExpression().getType());
return expressionStatement != null && isValidTypeForSwitch(expressionStatement.getExpression().getType(), expressionStatement);
}
private static PsiExpressionStatement resolveExpressionStatement(final PsiElement element) {
@@ -67,7 +73,7 @@ public class CreateSwitchIntention extends BaseElementAtCaretIntentionAction {
}
}
private static boolean isValidTypeForSwitch(@Nullable final PsiType type) {
private static boolean isValidTypeForSwitch(@Nullable final PsiType type, final PsiElement context) {
if (type == null) {
return false;
}
@@ -77,7 +83,8 @@ public class CreateSwitchIntention extends BaseElementAtCaretIntentionAction {
if (resolvedClass == null) {
return false;
}
return resolvedClass.isEnum() || (CommonClassNames.JAVA_LANG_STRING.equals(resolvedClass.getQualifiedName()));
return (PsiUtil.isLanguageLevel5OrHigher(context) && resolvedClass.isEnum())
|| (PsiUtil.isLanguageLevel7OrHigher(context) && CommonClassNames.JAVA_LANG_STRING.equals(resolvedClass.getQualifiedName()));
}
return type.equals(PsiType.INT) || type.equals(PsiType.BYTE) || type.equals(PsiType.SHORT) || type.equals(PsiType.CHAR);
}
@@ -1,105 +0,0 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.intention.impl;
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author Dmitry Batkovich
*/
public class SurroundWithQuotesStringAnnotationParameterValueIntention extends PsiElementBaseIntentionAction {
private static final Set<IElementType> SUITABLE_TYPES = ContainerUtil.newHashSet(JavaTokenType.LONG_LITERAL,
JavaTokenType.FLOAT_LITERAL,
JavaTokenType.INTEGER_LITERAL,
JavaTokenType.DOUBLE_LITERAL,
JavaTokenType.CHARACTER_LITERAL,
JavaTokenType.TRUE_KEYWORD,
JavaTokenType.FALSE_KEYWORD);
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
String newText = element.getText();
if (((PsiJavaToken)element).getTokenType().equals(JavaTokenType.CHARACTER_LITERAL)) {
newText = newText.substring(1, newText.length() - 1);
}
newText = "\"" + newText + "\"";
PsiElement newToken = JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(newText, null).getFirstChild();
final PsiElement newElement = element.replace(newToken);
editor.getCaretModel().moveToOffset(newElement.getTextOffset() + newElement.getTextLength());
}
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (!(element instanceof PsiJavaToken && SUITABLE_TYPES.contains(((PsiJavaToken)element).getTokenType()))) {
return false;
}
final PsiElement literalExpression = element.getParent();
if (literalExpression == null) {
return false;
}
final PsiElement nameValuePair = literalExpression.getParent();
if (!(nameValuePair instanceof PsiNameValuePair)) {
return false;
}
final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(nameValuePair, PsiAnnotation.class);
if (annotation == null) {
return false;
}
final PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
if (nameRef == null) {
return false;
}
final PsiElement resolved = nameRef.resolve();
if (!(resolved instanceof PsiClass)) {
return false;
}
final String parameterName = ((PsiNameValuePair)nameValuePair).getName();
final PsiMethod[] methods =
((PsiClass)resolved).findMethodsByName(parameterName == null ? PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME : parameterName, false);
if (methods.length != 1) {
return false;
}
final PsiType methodReturnType = methods[0].getReturnType();
if (!(methodReturnType instanceof PsiClassType)) {
return false;
}
final PsiClass returnTypeClass = ((PsiClassType)methodReturnType).resolve();
return returnTypeClass != null && CommonClassNames.JAVA_LANG_STRING.equals(returnTypeClass.getQualifiedName());
}
@NotNull
@Override
public String getFamilyName() {
return "Surround annotation parameter value with quotes";
}
@NotNull
@Override
public String getText() {
return getFamilyName();
}
}
@@ -755,6 +755,13 @@ public class QuickFixFactoryImpl extends QuickFixFactory {
return new AddMissingRequiredAnnotationParametersFix(annotation, annotationMethods, missedElements);
}
@NotNull
@Override
public IntentionAction createSurroundWithQuotesAnnotationParameterValueFix(@NotNull PsiAnnotationMemberValue value,
@NotNull PsiType expectedType) {
return new SurroundWithQuotesAnnotationParameterValueFix(value, expectedType);
}
private static boolean timeToOptimizeImports(@NotNull PsiFile file) {
if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.intention;
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
@@ -226,7 +226,6 @@ public class CodeStyleMainPanel extends JPanel implements LanguageSelectorListen
panel.setModel(myModel);
mySettingsPanels.put(name, panel);
mySettingsPanel.add(scheme.getName(), panel);
mySchemesPanel.setCodeStyleSettingsPanel(panel);
panel.setLanguage(myLangSelector.getLanguage());
}
@@ -20,6 +20,7 @@ package com.intellij.application.options.codeStyle;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.codeStyle.CodeStyleScheme;
import com.intellij.ui.ListCellRendererWrapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -29,7 +30,7 @@ import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
public class CodeStyleSchemesPanel{
public class CodeStyleSchemesPanel {
private JComboBox myCombo;
private final CodeStyleSchemesModel myModel;
@@ -37,7 +38,6 @@ public class CodeStyleSchemesPanel{
private JButton myManageButton;
private boolean myIsReset = false;
private NewCodeStyleSettingsPanel mySettingsPanel;
private final Font myDefaultComboFont;
private final Font myBoldComboFont;
@@ -48,7 +48,7 @@ public class CodeStyleSchemesPanel{
myBoldComboFont = myDefaultComboFont.deriveFont(Font.BOLD);
myCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
if (!myIsReset) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
@@ -75,7 +75,7 @@ public class CodeStyleSchemesPanel{
myManageButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
showManageSchemesDialog();
}
});
@@ -148,10 +148,6 @@ public class CodeStyleSchemesPanel{
return myPanel;
}
public void setCodeStyleSettingsPanel(NewCodeStyleSettingsPanel settingsPanel) {
mySettingsPanel = settingsPanel;
}
private void showManageSchemesDialog() {
ManageCodeStyleSchemesDialog manageSchemesDialog = new ManageCodeStyleSchemesDialog(myPanel, myModel);
manageSchemesDialog.show();
@@ -82,7 +82,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
mySchemesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
mySchemesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
public void valueChanged(@NotNull ListSelectionEvent e) {
updateActions();
}
});
@@ -91,25 +91,25 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
myDeleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
deleteSelected();
}
});
mySaveAsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
onSaveAs();
}
});
myCopyToProjectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
onCopyToProject();
}
});
myCloseButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
doCancelAction();
}
});
@@ -120,7 +120,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
myExportButton.setVisible(true);
myExportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
CodeStyleScheme selected = getSelectedScheme();
ExportSchemeAction.doExport((CodeStyleSchemeImpl)selected, mySchemesManager);
}
@@ -135,7 +135,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
myImportButton.setVisible(true);
myImportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
chooseAndImport();
}
});
@@ -326,8 +326,9 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
private MySchemesTable() {
myFixedItemsRenderer = new DefaultTableCellRenderer() {
@NotNull
@Override
public Component getTableCellRendererComponent(JTable table,
public Component getTableCellRendererComponent(@NotNull JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
@@ -361,6 +362,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
updateSchemes();
}
@NotNull
@Override
public String getColumnName(int column) {
assert column == 0;
@@ -479,7 +481,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
for (CodeStyleScheme scheme : schemes) {
names.add(scheme.getName());
}
SaveSchemeDialog saveDialog = new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names);
SaveSchemeDialog saveDialog = new SaveSchemeDialog(myParent, ApplicationBundle.message("title.save.code.style.scheme.as"), names, "");
saveDialog.show();
if (saveDialog.isOK()) {
int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), saveDialog.getSchemeName());
@@ -29,7 +29,9 @@ import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.options.SchemesManager;
import com.intellij.util.Consumer;
import com.intellij.util.EventDispatcher;
import org.jetbrains.annotations.Nullable;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.UniqueNameGenerator;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -61,7 +63,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
mySchemeComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
if (mySchemeComboBox.getSelectedIndex() != -1) {
EditorColorsScheme selected = myOptions.selectScheme((String)mySchemeComboBox.getSelectedItem());
if (ColorAndFontOptions.isReadOnly(selected)) {
@@ -97,16 +99,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
return myListLoaded;
}
public void clearSearch() {
}
@Nullable
@SuppressWarnings({"unchecked"})
public static <T> T safeCast(final Object obj, final Class<T> expectedClass) {
if (expectedClass.isInstance(obj)) return (T)obj;
return null;
}
private JPanel createSchemePanel() {
JPanel panel = new JPanel(new GridBagLayout());
@@ -124,7 +116,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
JButton saveAsButton = new JButton(ApplicationBundle.message("button.save.as"));
saveAsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
showSaveAsDialog();
}
});
@@ -135,7 +127,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
myDeleteButton = new JButton(ApplicationBundle.message("button.delete"));
myDeleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
if (mySchemeComboBox.getSelectedIndex() != -1) {
myOptions.removeScheme((String)mySchemeComboBox.getSelectedItem());
}
@@ -151,7 +143,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
myExportButton = new JButton("Share...");
myExportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
EditorColorsScheme selected = myOptions.getOriginalSelectedScheme();
ExportSchemeAction
.doExport((EditorColorsSchemeImpl)selected, ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager());
@@ -170,7 +162,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
myImportButton.setMnemonic('I');
myImportButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
public void actionPerformed(@NotNull final ActionEvent e) {
SchemesToImportPopup<EditorColorsScheme, EditorColorsSchemeImpl> popup =
new SchemesToImportPopup<EditorColorsScheme, EditorColorsSchemeImpl>(SchemesPanel.this) {
@Override
@@ -196,7 +188,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
final JButton button = new JButton(importHandler.getTitle());
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
importHandler.performImport(button, new Consumer<EditorColorsScheme>() {
@Override
public void consume(EditorColorsScheme scheme) {
@@ -214,14 +206,18 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
}
private void showSaveAsDialog() {
ArrayList<String> names = new ArrayList<String>();
EditorColorsScheme[] allSchemes = EditorColorsManager.getInstance().getAllSchemes();
ComboBoxModel model = mySchemeComboBox.getModel();
for (EditorColorsScheme scheme : allSchemes) {
names.add(scheme.getName());
int size = model.getSize();
ArrayList<String> names = ContainerUtil.newArrayListWithCapacity(size);
for (int i = 0; i < size; i++) {
Object at = model.getElementAt(i);
if (at instanceof String) names.add((String)at);
}
SaveSchemeDialog dialog = new SaveSchemeDialog(this, ApplicationBundle.message("title.save.color.scheme.as"), names);
String selectedName = myOptions.getSelectedScheme().getName();
String defaultName = UniqueNameGenerator.generateUniqueName(selectedName + " copy", names);
SaveSchemeDialog dialog = new SaveSchemeDialog(this, ApplicationBundle.message("title.save.color.scheme.as"), names, defaultName);
dialog.show();
if (dialog.isOK()) {
myOptions.saveSchemeAs(dialog.getSchemeName());
@@ -32,10 +32,11 @@ public class SaveSchemeDialog extends DialogWrapper {
private final JTextField mySchemeName = new JTextField();
private final ArrayList myInvalidNames;
public SaveSchemeDialog(Component parent, String title, ArrayList invalidNames){
public SaveSchemeDialog(Component parent, String title, ArrayList invalidNames, String selectedName){
super(parent, false);
myInvalidNames = invalidNames;
setTitle(title);
mySchemeName.setText(selectedName);
init();
}
@@ -16,7 +16,6 @@
package com.intellij.ide.customize;
import com.intellij.openapi.util.Condition;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nullable;
@@ -36,11 +35,6 @@ class IdSet {
description = description.substring(i + 1, description.length());
}
myIds = description.split(",");
for (String id : myIds) {
if (PluginGroups.getInstance().findPlugin(id) == null) {
myIds = ArrayUtil.remove(myIds, id);
}
}
myIds = ContainerUtil.filter(myIds, new Condition<String>() {
@Override
public boolean value(String id) {
@@ -65,7 +59,7 @@ class IdSet {
@Override
public String toString() {
return String.valueOf(myTitle) + ": " + myIds.length;
return String.valueOf(myTitle) + ": " + (myIds != null ? myIds.length : 0);
}
@Nullable
@@ -89,7 +89,7 @@
</constraints>
<properties>
<selected value="true"/>
<text value="&amp;Encrypt with user credentials"/>
<text value="&amp;Encrypt with OS user credentials"/>
<toolTipText value="The master password will be stored in password database &#10;encrypted with user credentials using OS-specific mechanisms.&#10;If this checkbox is selected, the master password will not be asked&#10;from user, on new session."/>
</properties>
</component>
@@ -96,10 +96,11 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
}
protected void showSearchPopup() {
final Object value = getComponent().getClientProperty("JTextField.Search.FindPopup");
final JTextComponent component = getComponent();
final Object value = component == null ? null : component.getClientProperty("JTextField.Search.FindPopup");
if (value instanceof JPopupMenu) {
final JPopupMenu popup = (JPopupMenu)value;
popup.show(getComponent(), getSearchIconCoord().x, getComponent().getHeight());
popup.show(component, getSearchIconCoord().x, component.getHeight());
}
}
@@ -1,90 +0,0 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.ui.search;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* User: anna
* Date: 17-Mar-2006
*/
public class DefaultSearchableConfigurable implements Configurable {
private final SearchableConfigurable myDelegate;
private JComponent myComponent;
public DefaultSearchableConfigurable(final SearchableConfigurable delegate) {
myDelegate = delegate;
}
@NonNls
public String getId() {
return myDelegate.getId();
}
public void clearSearch() {
}
public void enableSearch(String option) {
Runnable runnable = myDelegate.enableSearch(option);
if (runnable != null){
runnable.run();
}
}
public String getDisplayName() {
return myDelegate.getDisplayName();
}
@Nullable
@NonNls
public String getHelpTopic() {
return myDelegate.getHelpTopic();
}
public JComponent createComponent() {
myComponent = myDelegate.createComponent();
return myComponent;
}
public boolean isModified() {
return myDelegate.isModified();
}
public void apply() throws ConfigurationException {
myDelegate.apply();
}
public void reset() {
myDelegate.reset();
}
public void disposeUIResources() {
myComponent = null;
myDelegate.disposeUIResources();
}
public Configurable getDelegate() {
return myDelegate;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,8 @@ import static com.intellij.util.BitUtil.notSet;
* @version 11.1
*/
public class FileSystemUtil {
private static final String FORCE_USE_NIO2_KEY = "idea.io.use.nio2";
private static final String COARSE_TIMESTAMP = "idea.io.coarse.ts";
static final String FORCE_USE_NIO2_KEY = "idea.io.use.nio2";
static final String COARSE_TIMESTAMP = "idea.io.coarse.ts";
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.io.FileSystemUtil");
@@ -424,8 +424,8 @@ public class FileSystemUtil {
return new File(path).getCanonicalPath();
}
catch (IOException e) {
final String message = e.getMessage();
if (message != null && message.toLowerCase().contains("too many levels of symbolic links")) {
String message = e.getMessage();
if (message != null && message.toLowerCase(Locale.US).contains("too many levels of symbolic links")) {
LOG.debug(e);
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,36 +19,22 @@ import com.intellij.openapi.util.SystemInfo;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.lang.reflect.Field;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
public class FileAttributesNio2ReadingTest extends FileAttributesReadingTest {
private static final String FORCE_USE_NIO_2_KEY;
static {
try {
Field field = FileSystemUtil.class.getDeclaredField("FORCE_USE_NIO2_KEY");
field.setAccessible(true);
FORCE_USE_NIO_2_KEY = (String)field.get(null);
}
catch (Exception e) {
throw new AssertionError("Please keep constants in sync: " + e.getMessage());
}
}
@BeforeClass
public static void setUpClass() throws Exception {
assumeTrue(SystemInfo.isJavaVersionAtLeast("1.7"));
System.setProperty(FORCE_USE_NIO_2_KEY, "true");
System.setProperty(FileSystemUtil.FORCE_USE_NIO2_KEY, "true");
FileSystemUtil.resetMediator();
assertEquals("Nio2", FileSystemUtil.getMediatorName());
}
@AfterClass
public static void tearDownClass() throws Exception {
System.setProperty(FORCE_USE_NIO_2_KEY, "");
System.clearProperty(FileSystemUtil.FORCE_USE_NIO2_KEY);
FileSystemUtil.resetMediator();
}
}
@@ -1,10 +0,0 @@
class X {
@interface Foo {
String value();
}
@Foo("123")
void m() {
}
}
@@ -1,10 +0,0 @@
class X {
@interface Foo {
String value();
}
@Foo(<spot>123</spot>)
void m() {
}
}
@@ -1,5 +0,0 @@
<html>
<body>
Intention surrounds annotation parameter value with quotes
</body>
</html>