mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.codeInsight.highlighting;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -31,7 +30,6 @@ import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -79,7 +77,7 @@ public class BraceHighlighter extends AbstractProjectComponent {
|
||||
}
|
||||
}
|
||||
};
|
||||
eventMulticaster.addSelectionListener(mySelectionListener);
|
||||
eventMulticaster.addSelectionListener(mySelectionListener, myProject);
|
||||
|
||||
DocumentListener documentListener = new DocumentAdapter() {
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
@@ -101,7 +99,7 @@ public class BraceHighlighter extends AbstractProjectComponent {
|
||||
updateBraces(editor, myAlarm);
|
||||
}
|
||||
};
|
||||
((EditorEventMulticasterEx)eventMulticaster).addFocusChangeListner(myFocusChangeListener);
|
||||
((EditorEventMulticasterEx)eventMulticaster).addFocusChangeListner(myFocusChangeListener, myProject);
|
||||
|
||||
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
|
||||
|
||||
@@ -110,14 +108,6 @@ public class BraceHighlighter extends AbstractProjectComponent {
|
||||
myAlarm.cancelAllRequests();
|
||||
}
|
||||
}, myProject);
|
||||
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
public void dispose() {
|
||||
EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
((EditorEventMulticasterEx)eventMulticaster).removeFocusChangeListner(myFocusChangeListener);
|
||||
eventMulticaster.removeSelectionListener(mySelectionListener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void updateBraces(@NotNull final Editor editor, @NotNull final Alarm alarm) {
|
||||
|
||||
-6
@@ -46,12 +46,6 @@ public abstract class LangScriptingContextConfigurable implements Configurable,
|
||||
return project.getPicoContainer().getComponentInstance("com.intellij.openapi.roots.ui.configuration.projectRoot.GlobalLibrariesConfigurable") == null;
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Libraries";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myPanel.getPanel();
|
||||
|
||||
@@ -603,11 +603,13 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
|
||||
final IElementType contentElementType = getContentElementType();
|
||||
if (!(contentElementType instanceof IStubFileElementType)) {
|
||||
final FileViewProvider viewProvider = getViewProvider();
|
||||
throw new AssertionError("A stub in a non-stub file '" + vFile +"'; isValid()=" + vFile.isValid() +
|
||||
" type: "+contentElementType+";" +
|
||||
"; Type: " + contentElementType + "; " +
|
||||
"Psi roots: " + viewProvider.getAllFiles() + "; " +
|
||||
" StubUpdatingIndex.canHaveStub(vFile)=" + StubUpdatingIndex.canHaveStub(vFile) +
|
||||
" content:<<<\n"+
|
||||
StringUtil.first(getViewProvider().getContents(),200,true)+
|
||||
StringUtil.first(viewProvider.getContents(),200,true)+
|
||||
"\n>>>; stubs=" + stubHolder.getPlainList());
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class EditorTextFieldProviderImpl implements EditorTextFieldProvider {
|
||||
for (EditorCustomization.Feature feature : features) {
|
||||
for (EditorCustomization customization : customizations) {
|
||||
if (customization.getSupportedFeatures().contains(feature)) {
|
||||
customization.customize(ex, feature);
|
||||
customization.addCustomization(ex, feature);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -42,6 +42,7 @@ public interface EditorEventMulticaster {
|
||||
void removeCaretListener(@NotNull CaretListener listener);
|
||||
|
||||
void addSelectionListener(@NotNull SelectionListener listener);
|
||||
void addSelectionListener(@NotNull SelectionListener listener, @NotNull Disposable parentDisposable);
|
||||
void removeSelectionListener(@NotNull SelectionListener listener);
|
||||
|
||||
void addVisibleAreaListener(@NotNull VisibleAreaListener listener);
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class JBPopupFactory {
|
||||
public abstract ListPopup createConfirmation(String title, String yesText, String noText, Runnable onYes, Runnable onNo, int defaultOptionIndex);
|
||||
|
||||
public abstract ListPopupStep createActionsStep(ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
String title,
|
||||
@@ -96,7 +96,7 @@ public abstract class JBPopupFactory {
|
||||
boolean honorActionMnemonics);
|
||||
|
||||
public abstract ListPopupStep createActionsStep(ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
String title,
|
||||
@@ -157,7 +157,7 @@ public abstract class JBPopupFactory {
|
||||
*/
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions);
|
||||
|
||||
@@ -174,9 +174,9 @@ public abstract class JBPopupFactory {
|
||||
*/
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions, final @Nullable String actionPlace);
|
||||
boolean showDisabledActions, @Nullable final String actionPlace);
|
||||
|
||||
/**
|
||||
* Creates a popup allowing to choose one of the actions from the specified action group.
|
||||
@@ -193,7 +193,7 @@ public abstract class JBPopupFactory {
|
||||
*/
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
@Nullable Runnable disposeCallback,
|
||||
@@ -201,7 +201,7 @@ public abstract class JBPopupFactory {
|
||||
|
||||
public abstract ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
boolean honorActionMnemonics,
|
||||
@@ -237,7 +237,7 @@ public abstract class JBPopupFactory {
|
||||
* - current selected node for tree<br>
|
||||
* - current selected row for list<br>
|
||||
*/
|
||||
public abstract RelativePoint guessBestPopupLocation(DataContext dataContext);
|
||||
public abstract RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext);
|
||||
|
||||
/**
|
||||
* Returns the location where a popup invoked from the specified editor should be displayed.
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* use {@link com.intellij.openapi.vfs.VirtualFileAdapter} instead
|
||||
*/
|
||||
public class VirtualFileListenerBase implements VirtualFileListener{
|
||||
public void propertyChanged(VirtualFilePropertyEvent event) {}
|
||||
public void contentsChanged(VirtualFileEvent event) {}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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;
|
||||
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.ui.EditorCustomization;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Basic super class for {@link EditorCustomization editor customizations} that don't consider un-applying feature.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 1/14/11 12:52 PM
|
||||
*/
|
||||
public abstract class AbstractUnappliableEditorCustomization implements EditorCustomization {
|
||||
|
||||
@Override
|
||||
public void removeCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
+1
@@ -33,5 +33,6 @@ public interface EditorEventMulticasterEx extends EditorEventMulticaster{
|
||||
void removePropertyChangeListener(@NotNull PropertyChangeListener listener);
|
||||
|
||||
void addFocusChangeListner(@NotNull FocusChangeListener listener);
|
||||
void addFocusChangeListner(@NotNull FocusChangeListener listener, @NotNull Disposable parentDisposable);
|
||||
void removeFocusChangeListner(@NotNull FocusChangeListener listener);
|
||||
}
|
||||
|
||||
+10
@@ -130,6 +130,11 @@ public class EditorEventMulticasterImpl implements EditorEventMulticasterEx {
|
||||
mySelectionMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionListener(@NotNull SelectionListener listener, @NotNull Disposable parentDisposable) {
|
||||
mySelectionMulticaster.addListener(listener, parentDisposable);
|
||||
}
|
||||
|
||||
public void removeSelectionListener(@NotNull SelectionListener listener) {
|
||||
mySelectionMulticaster.removeListener(listener);
|
||||
}
|
||||
@@ -175,6 +180,11 @@ public class EditorEventMulticasterImpl implements EditorEventMulticasterEx {
|
||||
myFocusChangeListenerMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFocusChangeListner(@NotNull FocusChangeListener listener, @NotNull Disposable parentDisposable) {
|
||||
myFocusChangeListenerMulticaster.addListener(listener,parentDisposable);
|
||||
}
|
||||
|
||||
public void removeFocusChangeListner(@NotNull FocusChangeListener listener) {
|
||||
myFocusChangeListenerMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,6 @@ public abstract class EditorBasedWidget extends FileEditorManagerAdapter impleme
|
||||
@Nullable
|
||||
protected final Editor getEditor() {
|
||||
final Project project = getProject();
|
||||
Editor result = null;
|
||||
|
||||
if (project == null) return null;
|
||||
|
||||
@@ -59,6 +58,7 @@ public abstract class EditorBasedWidget extends FileEditorManagerAdapter impleme
|
||||
splitters = ((DockableEditorTabbedContainer)c).getSplitters();
|
||||
}
|
||||
|
||||
Editor result = null;
|
||||
if (splitters != null && splitters.getCurrentWindow() != null) {
|
||||
EditorWithProviderComposite editor = splitters.getCurrentWindow().getSelectedEditor();
|
||||
if (editor != null) {
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.impl.status;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.util.GotoLineNumberDialog;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
@@ -25,20 +23,15 @@ import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
@@ -80,7 +73,7 @@ public class PositionPanel extends EditorBasedWidget implements StatusBarWidget.
|
||||
|
||||
@Override
|
||||
public float getAlignment() {
|
||||
return JComponent.CENTER_ALIGNMENT;
|
||||
return Component.CENTER_ALIGNMENT;
|
||||
}
|
||||
|
||||
public String getTooltipText() {
|
||||
@@ -110,18 +103,11 @@ public class PositionPanel extends EditorBasedWidget implements StatusBarWidget.
|
||||
};
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
final EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
multicaster.removeCaretListener(this);
|
||||
multicaster.removeSelectionListener(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void install(@NotNull StatusBar statusBar) {
|
||||
super.install(statusBar);
|
||||
final EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
multicaster.addCaretListener(this);
|
||||
multicaster.addSelectionListener(this);
|
||||
multicaster.addCaretListener(this, this);
|
||||
multicaster.addSelectionListener(this, this);
|
||||
}
|
||||
|
||||
private static void appendLogicalPosition(LogicalPosition caret, StringBuilder message) {
|
||||
@@ -150,12 +136,12 @@ public class PositionPanel extends EditorBasedWidget implements StatusBarWidget.
|
||||
private void updatePosition(final Editor editor) {
|
||||
if (editor == null) {
|
||||
myText = "";
|
||||
myStatusBar.updateWidget(ID());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!isOurEditor(editor)) return;
|
||||
myText = getPositionText(editor);
|
||||
myStatusBar.updateWidget(ID());
|
||||
}
|
||||
myStatusBar.updateWidget(ID());
|
||||
}
|
||||
|
||||
private String getPositionText(Editor editor) {
|
||||
|
||||
@@ -59,46 +59,45 @@ public class TextPanel extends JComponent {
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
String s = getText();
|
||||
if (s != null) {
|
||||
final Rectangle bounds = getBounds();
|
||||
final Insets insets = getInsets();
|
||||
if (s == null) return;
|
||||
final Rectangle bounds = getBounds();
|
||||
final Insets insets = getInsets();
|
||||
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setFont(getFont());
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setFont(getFont());
|
||||
|
||||
UIUtil.applyRenderingHints(g2);
|
||||
UIUtil.applyRenderingHints(g2);
|
||||
|
||||
final FontMetrics fm = g2.getFontMetrics();
|
||||
final int sWidth = fm.stringWidth(s);
|
||||
final FontMetrics fm = g2.getFontMetrics();
|
||||
final int sWidth = fm.stringWidth(s);
|
||||
|
||||
int x = insets.left;
|
||||
if (myAlignment == JComponent.CENTER_ALIGNMENT || myAlignment == JComponent.RIGHT_ALIGNMENT) {
|
||||
x = myAlignment == JComponent.CENTER_ALIGNMENT ? (bounds.width - sWidth) / 2 : bounds.width - insets.right - sWidth;
|
||||
}
|
||||
|
||||
final Rectangle textR = new Rectangle();
|
||||
final Rectangle iconR = new Rectangle();
|
||||
final Rectangle viewR = new Rectangle(bounds);
|
||||
textR.x = textR.y = textR.width = textR.height = 0;
|
||||
|
||||
viewR.width -= insets.left;
|
||||
viewR.width -= insets.right;
|
||||
|
||||
if (sWidth > (bounds.width - insets.left - insets.right)) {
|
||||
s = SwingUtilities
|
||||
.layoutCompoundLabel(fm, s, null, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.CENTER, SwingUtilities.TRAILING,
|
||||
bounds, iconR, textR, 0);
|
||||
}
|
||||
|
||||
final int y = UIUtil.getStringY(s, bounds, g2);
|
||||
if (SystemInfo.isMac && myDecorate) {
|
||||
g2.setColor(new Color(215, 215, 215));
|
||||
g2.drawString(s, x, y + 1);
|
||||
}
|
||||
|
||||
g2.setColor(getForeground());
|
||||
g2.drawString(s, x, y);
|
||||
int x = insets.left;
|
||||
if (myAlignment == Component.CENTER_ALIGNMENT || myAlignment == Component.RIGHT_ALIGNMENT) {
|
||||
x = myAlignment == Component.CENTER_ALIGNMENT ? (bounds.width - sWidth) / 2 : bounds.width - insets.right - sWidth;
|
||||
}
|
||||
|
||||
final Rectangle textR = new Rectangle();
|
||||
final Rectangle iconR = new Rectangle();
|
||||
final Rectangle viewR = new Rectangle(bounds);
|
||||
textR.x = textR.y = textR.width = textR.height = 0;
|
||||
|
||||
viewR.width -= insets.left;
|
||||
viewR.width -= insets.right;
|
||||
|
||||
if (sWidth > bounds.width - insets.left - insets.right) {
|
||||
s = SwingUtilities
|
||||
.layoutCompoundLabel(fm, s, null, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.TRAILING,
|
||||
bounds, iconR, textR, 0);
|
||||
}
|
||||
|
||||
final int y = UIUtil.getStringY(s, bounds, g2);
|
||||
if (SystemInfo.isMac && myDecorate) {
|
||||
g2.setColor(new Color(215, 215, 215));
|
||||
g2.drawString(s, x, y + 1);
|
||||
}
|
||||
|
||||
g2.setColor(getForeground());
|
||||
g2.drawString(s, x, y);
|
||||
}
|
||||
|
||||
public void setTextAlignment(final float alignment) {
|
||||
|
||||
@@ -49,5 +49,13 @@ public interface EditorCustomization {
|
||||
* @param editor editor to customize
|
||||
* @param feature feature to apply to the given editor
|
||||
*/
|
||||
void customize(@NotNull EditorEx editor, @NotNull Feature feature);
|
||||
void addCustomization(@NotNull EditorEx editor, @NotNull Feature feature);
|
||||
|
||||
/**
|
||||
* Asks to un-apply customization performed earlier during {@link #addCustomization(EditorEx, Feature)} processing (if any).
|
||||
*
|
||||
* @param editor editor to customize
|
||||
* @param feature feature to un-apply to the given editor
|
||||
*/
|
||||
void removeCustomization(@NotNull EditorEx editor, @NotNull Feature feature);
|
||||
}
|
||||
|
||||
+3
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.AbstractUnappliableEditorCustomization;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -26,12 +27,12 @@ import java.util.Set;
|
||||
* Date: 12/6/10
|
||||
* Time: 10:18 AM
|
||||
*/
|
||||
public class HorizontalScrollBarEditorCustomization implements EditorCustomization {
|
||||
public class HorizontalScrollBarEditorCustomization extends AbstractUnappliableEditorCustomization {
|
||||
public Set<Feature> getSupportedFeatures() {
|
||||
return EnumSet.of(Feature.NO_HORIZONTAL_SCROLLBAR);
|
||||
}
|
||||
|
||||
public void customize(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
public void addCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
if (Feature.NO_HORIZONTAL_SCROLLBAR.equals(feature)) {
|
||||
editor.setHorizontalScrollbarVisible(false);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.AbstractUnappliableEditorCustomization;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -24,12 +25,12 @@ import java.util.Set;
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class OneLineEditorCustomization implements EditorCustomization {
|
||||
public class OneLineEditorCustomization extends AbstractUnappliableEditorCustomization {
|
||||
public Set<Feature> getSupportedFeatures() {
|
||||
return EnumSet.of(Feature.ONE_LINE);
|
||||
}
|
||||
|
||||
public void customize(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
public void addCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
if (Feature.ONE_LINE.equals(feature)) {
|
||||
editor.setOneLineMode(true);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.AbstractUnappliableEditorCustomization;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,7 +30,7 @@ import java.util.Set;
|
||||
* @author Denis Zhdanov
|
||||
* @since Aug 20, 2010 4:54:48 PM
|
||||
*/
|
||||
public class SoftWrapsEditorCustomization implements EditorCustomization {
|
||||
public class SoftWrapsEditorCustomization extends AbstractUnappliableEditorCustomization {
|
||||
|
||||
@Override
|
||||
public Set<Feature> getSupportedFeatures() {
|
||||
@@ -37,7 +38,7 @@ public class SoftWrapsEditorCustomization implements EditorCustomization {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
public void addCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
editor.getSettings().setUseSoftWraps(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.openapi.actionSystem.impl.ActionMenu;
|
||||
import com.intellij.openapi.actionSystem.impl.Utils;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -61,7 +60,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class PopupFactoryImpl extends JBPopupFactory {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.popup.PopupFactoryImpl");
|
||||
private static final Icon QUICK_LIST_ICON = IconLoader.getIcon("/actions/quickList.png");
|
||||
|
||||
public ListPopup createConfirmation(String title, final Runnable onYes, int defaultOptionIndex) {
|
||||
@@ -106,7 +104,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
private static ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean useAlphaAsNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -119,7 +117,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
public ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
boolean honorActionMnemonics,
|
||||
@@ -131,7 +129,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
private static ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean useAlphaAsNumbers,
|
||||
boolean showDisabledActions,
|
||||
@@ -180,7 +178,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
AnAction action = actionItem.getAction();
|
||||
Presentation presentation = new Presentation();
|
||||
presentation.setDescription(action.getTemplatePresentation().getDescription());
|
||||
final String actualActionPlace = (actionPlace == null) ? ActionPlaces.UNKNOWN : actionPlace;
|
||||
final String actualActionPlace = actionPlace == null ? ActionPlaces.UNKNOWN : actionPlace;
|
||||
action.update(new AnActionEvent(null, DataManager.getInstance().getDataContext(component), actualActionPlace, presentation,
|
||||
ActionManager.getInstance(), 0));
|
||||
ActionMenu.showDescriptionInStatusBar(true, component, presentation.getDescription());
|
||||
@@ -190,7 +188,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
public ListPopup createActionGroupPopup(final String title,
|
||||
final ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
boolean showNumbers,
|
||||
boolean showDisabledActions,
|
||||
boolean honorActionMnemonics,
|
||||
@@ -203,7 +201,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions) {
|
||||
return createActionGroupPopup(title, actionGroup, dataContext,
|
||||
@@ -216,7 +214,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
@Nullable String actionPlace) {
|
||||
@@ -230,7 +228,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
|
||||
public ListPopup createActionGroupPopup(String title,
|
||||
ActionGroup actionGroup,
|
||||
DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
ActionSelectionAid selectionAidMethod,
|
||||
boolean showDisabledActions,
|
||||
Runnable disposeCallback,
|
||||
@@ -245,7 +243,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
public ListPopupStep createActionsStep(final ActionGroup actionGroup,
|
||||
final DataContext dataContext,
|
||||
@NotNull DataContext dataContext,
|
||||
final boolean showNumbers,
|
||||
final boolean showDisabledActions,
|
||||
final String title,
|
||||
@@ -254,7 +252,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
return createActionsStep(actionGroup, dataContext, showNumbers, showDisabledActions, title, component, honorActionMnemonics, 0, false);
|
||||
}
|
||||
|
||||
private static ListPopupStep createActionsStep(ActionGroup actionGroup, DataContext dataContext, boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions,
|
||||
private static ListPopupStep createActionsStep(ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean useAlphaAsNumbers, boolean showDisabledActions,
|
||||
String title, Component component, boolean honorActionMnemonics, int defaultOptionIndex,
|
||||
final boolean autoSelectionEnabled) {
|
||||
final ActionStepBuilder builder = new ActionStepBuilder(dataContext, showNumbers, useAlphaAsNumbers, showDisabledActions, honorActionMnemonics);
|
||||
@@ -265,7 +263,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
autoSelectionEnabled);
|
||||
}
|
||||
|
||||
public ListPopupStep createActionsStep(ActionGroup actionGroup, DataContext dataContext, boolean showNumbers, boolean showDisabledActions,
|
||||
public ListPopupStep createActionsStep(ActionGroup actionGroup, @NotNull DataContext dataContext, boolean showNumbers, boolean showDisabledActions,
|
||||
String title, Component component, boolean honorActionMnemonics, int defaultOptionIndex,
|
||||
final boolean autoSelectionEnabled) {
|
||||
return createActionsStep(actionGroup, dataContext, showNumbers, true, showDisabledActions, title, component, honorActionMnemonics,
|
||||
@@ -301,7 +299,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
|
||||
public RelativePoint guessBestPopupLocation(DataContext dataContext) {
|
||||
public RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext) {
|
||||
KeyboardFocusManager focusManager=KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Component component = focusManager.getFocusOwner();
|
||||
JComponent focusOwner=component instanceof JComponent ? (JComponent)component : null;
|
||||
@@ -573,7 +571,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
@NotNull
|
||||
private String myActionPlace;
|
||||
|
||||
private ActionStepBuilder(final DataContext dataContext,
|
||||
private ActionStepBuilder(@NotNull DataContext dataContext,
|
||||
final boolean showNumbers,
|
||||
final boolean useAlphaAsNumbers,
|
||||
final boolean showDisabled,
|
||||
|
||||
@@ -34,6 +34,7 @@ border.standard.after.checkin.options.group=After {0}
|
||||
checkbox.checkin.options.check.files.up.to.date=Check remote status
|
||||
checkbox.checkin.options.optimize.imports=&Optimize imports
|
||||
checkbox.checkin.options.reformat.code=&Reformat code
|
||||
checkbox.check.commit.message.spelling=Check commit message spelling
|
||||
progress.text.searching.for.modified.files=Searching for modified files
|
||||
button.text.overwrite.modified.file=&Overwrite Modified File
|
||||
button.text.overwrite.modified.files=&Overwrite Modified Files
|
||||
|
||||
@@ -75,6 +75,10 @@ public class MockEditorEventMulticaster implements EditorEventMulticaster {
|
||||
public void addSelectionListener(@NotNull SelectionListener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelectionListener(@NotNull SelectionListener listener, @NotNull Disposable parentDisposable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSelectionListener(@NotNull SelectionListener listener) {
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public final class VcsConfiguration implements PersistentStateComponent<Element>
|
||||
public boolean ENABLE_BACKGROUND_PROCESSES = false;
|
||||
public int CHANGED_ON_SERVER_INTERVAL = 60;
|
||||
public boolean SHOW_ONLY_CHANGED_IN_SELECTION_DIFF = true;
|
||||
public boolean CHECK_COMMIT_MESSAGE_SPELLING = true;
|
||||
|
||||
public enum StandardOption {
|
||||
ADD(VcsBundle.message("vcs.command.name.add")),
|
||||
|
||||
+25
-2
@@ -38,7 +38,6 @@ import com.intellij.openapi.vcs.checkin.*;
|
||||
import com.intellij.openapi.vcs.ui.CommitMessage;
|
||||
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.SeparatorFactory;
|
||||
import com.intellij.util.Alarm;
|
||||
@@ -49,6 +48,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
@@ -94,6 +95,8 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
|
||||
private final PseudoMap<Object, Object> myAdditionalData;
|
||||
private String myHelpId;
|
||||
|
||||
private final JCheckBox myCheckSpellingBox;
|
||||
|
||||
private static class MyUpdateButtonsRunnable implements Runnable {
|
||||
private CommitChangeListDialog myDialog;
|
||||
@@ -261,6 +264,23 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
}
|
||||
}
|
||||
|
||||
myCheckSpellingBox = new JCheckBox(VcsBundle.message("checkbox.check.commit.message.spelling"));
|
||||
myCheckSpellingBox.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
|
||||
boolean checkSpelling = e.getStateChange() == ItemEvent.SELECTED;
|
||||
if (configuration != null) {
|
||||
configuration.CHECK_COMMIT_MESSAGE_SPELLING = checkSpelling;
|
||||
}
|
||||
myCommitMessageArea.setCheckSpelling(checkSpelling);
|
||||
}
|
||||
});
|
||||
VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
|
||||
if (configuration != null) {
|
||||
myCheckSpellingBox.setSelected(configuration.CHECK_COMMIT_MESSAGE_SPELLING);
|
||||
}
|
||||
|
||||
myActionName = VcsBundle.message("commit.dialog.title");
|
||||
|
||||
myAdditionalOptionsPanel = new JPanel();
|
||||
@@ -767,7 +787,10 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
|
||||
JPanel infoPanel = new JPanel(new BorderLayout());
|
||||
myChangesInfoCalculator = new CommitLegendPanel.ChangeInfoCalculator();
|
||||
myLegend = new CommitLegendPanel(myChangesInfoCalculator);
|
||||
infoPanel.add(myLegend.getComponent(), BorderLayout.NORTH);
|
||||
JPanel commonPanel = new JPanel(new BorderLayout());
|
||||
commonPanel.add(myLegend.getComponent());
|
||||
commonPanel.add(myCheckSpellingBox, BorderLayout.SOUTH);
|
||||
infoPanel.add(commonPanel, BorderLayout.NORTH);
|
||||
infoPanel.add(myAdditionalOptionsPanel, BorderLayout.CENTER);
|
||||
rootPane.add(infoPanel, BorderLayout.EAST);
|
||||
infoPanel.setBorder(IdeBorderFactory.createEmptyBorder(0, 10, 0, 0));
|
||||
|
||||
@@ -21,9 +21,13 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.ui.EditorCustomization;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.EditorTextFieldProvider;
|
||||
@@ -32,14 +36,23 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommitMessage extends JPanel implements Disposable {
|
||||
|
||||
private final EditorTextField myEditorField;
|
||||
private final Project myProject;
|
||||
|
||||
public CommitMessage(Project project) {
|
||||
super(new BorderLayout());
|
||||
myEditorField = createEditorField(project);
|
||||
boolean checkSpelling = true;
|
||||
VcsConfiguration configuration = VcsConfiguration.getInstance(project);
|
||||
if (configuration != null) {
|
||||
checkSpelling = configuration.CHECK_COMMIT_MESSAGE_SPELLING;
|
||||
}
|
||||
myEditorField = createEditorField(project, checkSpelling);
|
||||
myProject = project;
|
||||
|
||||
// Note that we assume here that editor used for commit message processing uses font family implied by LAF (in contrast,
|
||||
// IJ code editor uses monospaced font). Hence, we don't need any special actions here
|
||||
@@ -64,10 +77,14 @@ public class CommitMessage extends JPanel implements Disposable {
|
||||
setBorder(BorderFactory.createEmptyBorder());
|
||||
}
|
||||
|
||||
private static EditorTextField createEditorField(final Project project) {
|
||||
private static EditorTextField createEditorField(final Project project, final boolean checkSpelling) {
|
||||
EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
|
||||
Set<EditorCustomization.Feature> features = EnumSet.of(EditorCustomization.Feature.SOFT_WRAP);
|
||||
if (checkSpelling) {
|
||||
features.add(EditorCustomization.Feature.SPELL_CHECK);
|
||||
}
|
||||
return service.getEditorField(
|
||||
FileTypes.PLAIN_TEXT.getLanguage(), project, EditorCustomization.Feature.SOFT_WRAP, EditorCustomization.Feature.SPELL_CHECK
|
||||
FileTypes.PLAIN_TEXT.getLanguage(), project, features.toArray(new EditorCustomization.Feature[features.size()])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,6 +115,26 @@ public class CommitMessage extends JPanel implements Disposable {
|
||||
myEditorField.selectAll();
|
||||
}
|
||||
|
||||
public void setCheckSpelling(boolean check) {
|
||||
Editor editor = myEditorField.getEditor();
|
||||
if (!(editor instanceof EditorEx)) {
|
||||
return;
|
||||
}
|
||||
EditorEx editorEx = (EditorEx)editor;
|
||||
EditorCustomization[] customizations = Extensions.getExtensions(EditorCustomization.EP_NAME, myProject);
|
||||
EditorCustomization.Feature feature = EditorCustomization.Feature.SPELL_CHECK;
|
||||
for (EditorCustomization customization : customizations) {
|
||||
if (customization.getSupportedFeatures().contains(feature)) {
|
||||
if (check) {
|
||||
customization.addCustomization(editorEx, feature);
|
||||
}
|
||||
else {
|
||||
customization.removeCustomization(editorEx, feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,39 +160,33 @@ public class ExpectedTypeUtils{
|
||||
final PsiJavaToken sign = binaryExpression.getOperationSign();
|
||||
final IElementType tokenType = sign.getTokenType();
|
||||
final PsiType type = binaryExpression.getType();
|
||||
if (TypeUtils.isJavaLangString(type)) {
|
||||
final PsiExpression rhs = binaryExpression.getROperand();
|
||||
if (rhs == null) {
|
||||
expectedType = null;
|
||||
} else if (isArithmeticOperation(tokenType)) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = binaryExpression.getLOperand();
|
||||
PsiType lhsType = lhs.getType();
|
||||
if (lhsType == null) {
|
||||
expectedType = null;
|
||||
return;
|
||||
}
|
||||
PsiType rhsType = rhs.getType();
|
||||
if (rhsType == null) {
|
||||
expectedType = null;
|
||||
return;
|
||||
}
|
||||
if (TypeUtils.isJavaLangString(type) ||
|
||||
isArithmeticOperation(tokenType) ||
|
||||
isBooleanOperation(tokenType)) {
|
||||
expectedType = type;
|
||||
} else if (isShiftOperation(tokenType)) {
|
||||
final PsiExpression lhs = binaryExpression.getLOperand();
|
||||
if (wrappedExpression.equals(lhs)) {
|
||||
expectedType = unaryNumericPromotion(lhs.getType());
|
||||
expectedType = unaryNumericPromotion(lhsType);
|
||||
} else {
|
||||
final PsiExpression rhs = binaryExpression.getROperand();
|
||||
if (rhs == null) {
|
||||
expectedType = null;
|
||||
} else {
|
||||
expectedType = unaryNumericPromotion(rhs.getType());
|
||||
}
|
||||
expectedType = unaryNumericPromotion(rhsType);
|
||||
}
|
||||
} else if (ComparisonUtils.isComparisonOperation(tokenType)) {
|
||||
final PsiExpression rhs = binaryExpression.getROperand();
|
||||
if (rhs == null) {
|
||||
expectedType = null;
|
||||
return;
|
||||
}
|
||||
final PsiExpression lhs = binaryExpression.getLOperand();
|
||||
PsiType lhsType = lhs.getType();
|
||||
if (lhsType == null) {
|
||||
expectedType = null;
|
||||
return;
|
||||
}
|
||||
PsiType rhsType = rhs.getType();
|
||||
if (rhsType == null) {
|
||||
expectedType = null;
|
||||
return;
|
||||
}
|
||||
if (!ClassUtils.isPrimitive(lhsType)) {
|
||||
lhsType = PsiPrimitiveType.getUnboxedType(lhsType);
|
||||
if (lhsType == null) {
|
||||
@@ -220,8 +214,6 @@ public class ExpectedTypeUtils{
|
||||
} else {
|
||||
expectedType = PsiType.INT;
|
||||
}
|
||||
} else if (isBooleanOperation(tokenType)) {
|
||||
expectedType = type;
|
||||
} else {
|
||||
expectedType = null;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,36 @@ public class AutoBoxing {
|
||||
static {
|
||||
Long someNumber = 0L;
|
||||
Long aLong = someNumber << 2;
|
||||
someNumber++;
|
||||
Long other = someNumber++;
|
||||
someNumber = ~someNumber;
|
||||
someNumber = -someNumber;
|
||||
someNumber = +someNumber;
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
Integer bar = 3;
|
||||
int baz = new Integer(3);
|
||||
if (new Integer(3) == 3) {
|
||||
return;
|
||||
}
|
||||
if (new Integer(3) + 3 == 3) {
|
||||
return;
|
||||
}
|
||||
Integer x = 3;
|
||||
}
|
||||
|
||||
|
||||
public void bar(Double value) {
|
||||
if (value > 0.0) { // this is not found!
|
||||
return;
|
||||
}
|
||||
|
||||
bazz(value);
|
||||
}
|
||||
|
||||
private void bazz(double value) {
|
||||
System.out.println("value = " + value);
|
||||
Boolean c = Boolean.TRUE & false;
|
||||
Long d = Integer.valueOf(2) & 1L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,60 @@
|
||||
<description>Auto-boxing <code>someNumber << 2</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>11</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>someNumber++</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>12</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>~someNumber</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>13</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>-someNumber</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>14</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>+someNumber</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>18</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>3</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>26</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>3</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>40</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>Boolean.TRUE & false</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
|
||||
<problem>
|
||||
<file>AutoBoxing.java</file>
|
||||
<line>41</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-boxing</problem_class>
|
||||
<description>Auto-boxing <code>Integer.valueOf(2) & 1L</code> #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+28
-1
@@ -5,8 +5,35 @@ package com.siyeh.igtest.jdk.auto_unboxing;
|
||||
public class AutoUnboxing {
|
||||
{
|
||||
Long someNumber = Long.valueOf(0);
|
||||
|
||||
someNumber++;
|
||||
long l = someNumber + 0;
|
||||
Long aLong = Long.valueOf(someNumber << 2);
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
Integer bar = 3;
|
||||
int baz = new Integer(3);
|
||||
if (new Integer(3) == 3) {
|
||||
return;
|
||||
}
|
||||
if (new Integer(3) + 3 == 3) {
|
||||
return;
|
||||
}
|
||||
Integer x = 3;
|
||||
}
|
||||
|
||||
|
||||
public void bar(Double value) {
|
||||
if (value > 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bazz(value);
|
||||
}
|
||||
|
||||
private void bazz(double value) {
|
||||
System.out.println("value = " + value);
|
||||
Boolean c = Boolean.TRUE & false;
|
||||
Long d = Integer.valueOf(2) & 1L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>8</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>someNumber</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>9</line>
|
||||
@@ -15,4 +22,54 @@
|
||||
<description>Auto-unboxing <code>someNumber</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>15</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>new Integer(3)</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>16</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>new Integer(3)</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>19</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>new Integer(3)</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>27</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>value</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>31</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>value</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>36</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>Boolean.TRUE</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
|
||||
<problem>
|
||||
<file>AutoUnboxing.java</file>
|
||||
<line>37</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Auto-unboxing</problem_class>
|
||||
<description>Auto-unboxing <code>Integer.valueOf(2)</code> #loc</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.siyeh.igtest.portability;
|
||||
|
||||
public class AutoUnboxingInspection {
|
||||
public void foo() {
|
||||
Integer bar = 3;
|
||||
int baz = new Integer(3);
|
||||
if (new Integer(3) == 3) {
|
||||
return;
|
||||
}
|
||||
if (new Integer(3) + 3 == 3) {
|
||||
return;
|
||||
}
|
||||
Integer x = 3;
|
||||
}
|
||||
|
||||
|
||||
public void bar(Double value) {
|
||||
if (value > 0.0) { // this is not found!
|
||||
return;
|
||||
}
|
||||
|
||||
bazz(value);
|
||||
}
|
||||
|
||||
private void bazz(double value) {
|
||||
System.out.println("value = " + value);
|
||||
}
|
||||
}
|
||||
+25
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.spellchecker.ui;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.intention.IntentionManager;
|
||||
import com.intellij.codeInspection.InspectionProfile;
|
||||
@@ -120,7 +121,7 @@ public class SpellCheckingEditorCustomization implements EditorCustomization {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
public void addCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
if (INSPECTION_PROFILE_WRAPPER == null) {
|
||||
return;
|
||||
}
|
||||
@@ -136,5 +137,28 @@ public class SpellCheckingEditorCustomization implements EditorCustomization {
|
||||
}
|
||||
file.putUserData(InspectionProfileWrapper.KEY, INSPECTION_PROFILE_WRAPPER);
|
||||
editor.putUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY, false);
|
||||
updateRepresentation(project, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCustomization(@NotNull EditorEx editor, @NotNull Feature feature) {
|
||||
Project project = editor.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
file.putUserData(InspectionProfileWrapper.KEY, null);
|
||||
updateRepresentation(project, file);
|
||||
}
|
||||
|
||||
private static void updateRepresentation(@NotNull Project project, @NotNull PsiFile file) {
|
||||
DaemonCodeAnalyzer analyzer = DaemonCodeAnalyzer.getInstance(project);
|
||||
if (analyzer != null) {
|
||||
analyzer.restart(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user