Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2015-11-16 19:40:27 +01:00
411 changed files with 46503 additions and 683 deletions
@@ -4,7 +4,7 @@
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
<install-over minbuild="129.1" maxbuild="139.9999" version="14"/>
<logo url="/idea_community_logo.png" textcolor="aaaaaa" progressColor="FDA916" progressY="230" progressTailIcon="/community_progress_tail.png"/>
<about url="/idea_community_about.png" foreground="7A858F" copyrightForeground="7A858F" linkColor="9b5121" logoX="300" logoY="265" logoW="75" logoH="30"/>
<about url="/idea_community_about.png" foreground="333333" copyrightForeground="7A858F" linkColor="9b5121" logoX="300" logoY="265" logoW="75" logoH="30"/>
<icon size32="/icon_CE.png" size16="/icon_CEsmall.png" size12="/toolwindows/toolWindowProject.png" size128="/icon_CE_128.png" ico="idea_CE.ico"/>
<names product="IDEA" fullname="IntelliJ IDEA" script="idea"/>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 175 KiB

@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -206,7 +207,7 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> exten
for (int i = 0; i < referenceData.length; i++) {
PsiElement ref = refs[i];
if (ref != null) {
LOG.assertTrue(ref.isValid());
PsiUtilCore.ensureValid(ref);
Object refObject = refObjects[i];
boolean found = false;
for (Object selected : selectedObjects) {
@@ -49,7 +49,7 @@ public class JavaTreeGenerator implements TreeGenerator {
@Override
@Nullable
public TreeElement generateTreeFor(PsiElement original, final CharTable table, final PsiManager manager) {
public TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull final CharTable table, @NotNull final PsiManager manager) {
if (original instanceof PsiKeyword || original instanceof PsiIdentifier) {
final String text = original.getText();
return createLeafFromText(text, table, manager, original, ((PsiJavaToken)original).getTokenType());
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<description>rtetre tretre</description>
<display-name>rrr aksjdb sadkj fgrrretyr re tre tre tre t</display-name>
<jsp-config>
<jsp-property-group>
<description>
<caret><!--<ddd/>-->
</description>
<dddddddddd/>
</jsp-property-group>
</jsp-config>
</web-app>
@@ -604,21 +604,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
assertEquals(3, markers.size());
}
public void testClearingHighlightersOnType() throws Exception {
configureByFile(BASE_PATH + getTestName(false) + ".xml");
Collection<HighlightInfo> errors = highlightErrors();
assertEquals(1, errors.size());
assertEquals("Element dddddddddd is not allowed here", errors.iterator().next().getDescription());
commentLine();
List<HighlightInfo> afterTyping = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.ERROR, getProject());
HighlightInfo error = assertOneElement(afterTyping);
assertEquals("Element dddddddddd is not allowed here", error.getDescription());
}
private static void commentLine() {
WriteCommandAction.runWriteCommandAction(null, () -> {
CommentByLineCommentAction action = new CommentByLineCommentAction();
@@ -628,7 +613,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void testChangeXmlIncludeLeadsToRehighlight() throws Exception {
LanguageFilter[] extensions = ((CompositeLanguage)StdLanguages.XML).getLanguageExtensions();
for (LanguageFilter extension : extensions) {
((CompositeLanguage)StdLanguages.XML).unregisterLanguageExtension(extension);
@@ -19,17 +19,24 @@ import com.intellij.openapi.util.Couple;
import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ConcurrentFactoryMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
/**
* @author yole
*/
public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
private final Map<String, CoreJarHandler> myHandlers = new HashMap<String, CoreJarHandler>();
private final Map<String, CoreJarHandler> myHandlers = new ConcurrentFactoryMap<String, CoreJarHandler>() {
@Nullable
@Override
protected CoreJarHandler create(String key) {
return new CoreJarHandler(CoreJarFileSystem.this, key);
}
};
@NotNull
@Override
@@ -40,7 +47,7 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
@Override
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
Couple<String> pair = splitPath(path);
return getHandler(pair.first).findFileByPath(pair.second);
return myHandlers.get(pair.first).findFileByPath(pair.second);
}
@NotNull
@@ -54,16 +61,6 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
return Couple.of(localPath, pathInJar);
}
@NotNull
private CoreJarHandler getHandler(String localPath) {
CoreJarHandler handler = myHandlers.get(localPath);
if (handler == null) {
handler = new CoreJarHandler(this, localPath);
myHandlers.put(localPath, handler);
}
return handler;
}
@Override
public void refresh(boolean asynchronous) { }
@@ -71,4 +68,9 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
return findFileByPath(path);
}
@SuppressWarnings("unused") // used in Kotlin
public void clearHandlersCache() {
myHandlers.clear();
}
}
@@ -144,7 +144,8 @@ public class ChangeUtil {
}
@Nullable
public static TreeElement generateTreeElement(PsiElement original, CharTable table, final PsiManager manager) {
public static TreeElement generateTreeElement(@Nullable PsiElement original, @NotNull CharTable table, @NotNull final PsiManager manager) {
if (original == null) return null;
PsiUtilCore.ensureValid(original);
if (SourceTreeToPsiMap.hasTreeElement(original)) {
return copyElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(original), table);
@@ -23,11 +23,12 @@ import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.util.CharTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface TreeGenerator {
ExtensionPointName<TreeGenerator> EP_NAME = ExtensionPointName.create("com.intellij.treeGenerator");
@Nullable
TreeElement generateTreeFor(PsiElement original, CharTable table, final PsiManager manager);
TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull CharTable table, @NotNull final PsiManager manager);
}
@@ -127,7 +127,7 @@ public class DebugReflectionUtil {
return true;
}
private static boolean isLoadedAlready(Class root) {
private static boolean isLoadedAlready(@NotNull Class root) {
if (Unsafe_shouldBeInitialized == null) return false;
boolean isLoadedAlready = false;
try {
@@ -140,7 +140,7 @@ public class DebugReflectionUtil {
}
public static class BackLink {
public final Object value;
@NotNull public final Object value;
private final Field field;
private final BackLink backLink;
@@ -158,15 +158,17 @@ public class DebugReflectionUtil {
String valueStr;
try {
valueStr = backLink.value instanceof FList
? "FList" : backLink.value instanceof Collection ? "Collection" : String.valueOf(backLink.value);
? "FList (size="+((FList)backLink.value).size()+")" :
backLink.value instanceof Collection ? "Collection (size="+((Collection)backLink.value).size()+")" :
String.valueOf(backLink.value);
valueStr = StringUtil.trimLog(StringUtil.convertLineSeparators(valueStr, "//"), 100);
}
catch (Throwable e) {
valueStr = "(" + e.getMessage() + " while computing .toString())";
}
Field field = backLink.field;
String fieldStr = field == null ? "?" : field.getName() + " of " + field.getDeclaringClass();
result += "via " + fieldStr + "; Value: " + valueStr + " of " + backLink.value.getClass() + "\n";
String fieldName = field == null ? "?" : field.getDeclaringClass().getName()+"."+field.getName();
result += "via '" + fieldName + "'; Value: '" + valueStr + "' of " + backLink.value.getClass() + "\n";
backLink = backLink.backLink;
}
return result;
@@ -42,7 +42,11 @@ public abstract class ListenerDiffViewerBase extends DiffViewerBase {
super(context, request);
myDocumentListener = createDocumentListener();
myFileListener = createFileListener(request);
}
@Override
protected void onInit() {
super.onInit();
if (myFileListener != null) VirtualFileManager.getInstance().addVirtualFileListener(myFileListener);
for (Document document : getDocuments()) {
@@ -16,9 +16,9 @@
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.ide.diff.DirDiffSettings;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.EmptyIcon;
@@ -27,7 +27,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
class ChangeCompareModeAction extends AnAction {
class ChangeCompareModeAction extends DumbAwareAction {
private final static Icon ON = PlatformIcons.CHECK_ICON;
private final static Icon ON_SELECTED = PlatformIcons.CHECK_ICON_SELECTED;
private final static Icon OFF = EmptyIcon.create(ON.getIconHeight());
@@ -19,6 +19,7 @@ import com.intellij.ide.diff.DirDiffSettings;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.NotNull;
@@ -29,7 +30,7 @@ import java.util.ArrayList;
/**
* @author Konstantin Bulenkov
*/
public class ChangeCompareModeGroup extends ComboBoxAction implements ShortcutProvider{
public class ChangeCompareModeGroup extends ComboBoxAction implements ShortcutProvider, DumbAware {
private final DefaultActionGroup myGroup;
private DirDiffSettings mySettings;
private JButton myButton;
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.ShortcutProvider;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -27,7 +28,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
public abstract class DirDiffAction extends ToggleAction implements ShortcutProvider {
public abstract class DirDiffAction extends ToggleAction implements ShortcutProvider, DumbAware {
private final DirDiffTableModel myModel;
protected DirDiffAction(DirDiffTableModel model) {
@@ -16,10 +16,10 @@
package com.intellij.openapi.diff.impl.dir.actions.popup;
import com.intellij.ide.diff.DirDiffOperation;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffElementImpl;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import com.intellij.openapi.project.DumbAwareAction;
import javax.swing.*;
@@ -27,7 +27,7 @@ import javax.swing.*;
* @author lene
* Date: 23.04.12
*/
public class SetNoOperation extends AnAction {
public class SetNoOperation extends DumbAwareAction {
@Override
public void actionPerformed(AnActionEvent e) {
final DirDiffTableModel model = SetOperationToBase.getModel(e);
@@ -17,11 +17,11 @@ package com.intellij.openapi.diff.impl.dir.actions.popup;
import com.intellij.ide.diff.DirDiffElement;
import com.intellij.ide.diff.DirDiffOperation;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffElementImpl;
import com.intellij.openapi.diff.impl.dir.DirDiffPanel;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,7 +30,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
public abstract class SetOperationToBase extends AnAction {
public abstract class SetOperationToBase extends DumbAwareAction {
@Override
public void actionPerformed(AnActionEvent e) {
DirDiffOperation operation = getOperation();
@@ -0,0 +1,101 @@
/*
* 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.diff
import com.intellij.diff.tools.simple.SimpleThreesideDiffViewer
import com.intellij.diff.util.TextDiffType
import com.intellij.openapi.diff.impl.settings.DiffPreviewPanel
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.editor.markup.RangeHighlighter
import com.intellij.openapi.util.Disposer
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
class DiffColorSettingsTest : DiffTestCase() {
private var projectFixture: IdeaProjectTestFixture? = null
override fun setUp() {
super.setUp()
projectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture()
projectFixture!!.setUp()
}
override fun tearDown() {
projectFixture?.tearDown()
super.tearDown()
}
fun testChanges() {
val disposable = Disposer.newDisposable()
try {
val panel = DiffPreviewPanel(disposable)
val viewer = panel.testGetViewer()
assertEquals(viewer.changes.size, 6)
assertContainsRange(viewer, TextDiffType.MODIFIED)
assertContainsRange(viewer, TextDiffType.INSERTED)
assertContainsRange(viewer, TextDiffType.DELETED)
assertContainsRange(viewer, TextDiffType.CONFLICT)
assertContainsBackgroundColor(viewer, TextDiffType.MODIFIED, true)
assertContainsBackgroundColor(viewer, TextDiffType.INSERTED, true)
assertContainsBackgroundColor(viewer, TextDiffType.DELETED, true)
assertContainsBackgroundColor(viewer, TextDiffType.CONFLICT, true)
assertContainsBackgroundColor(viewer, TextDiffType.MODIFIED, false)
assertContainsBackgroundColor(viewer, TextDiffType.INSERTED, false)
assertContainsBackgroundColor(viewer, TextDiffType.DELETED, false)
assertContainsBackgroundColor(viewer, TextDiffType.CONFLICT, false)
assertContainsMarkerColor(viewer, TextDiffType.MODIFIED)
assertContainsMarkerColor(viewer, TextDiffType.INSERTED)
assertContainsMarkerColor(viewer, TextDiffType.DELETED)
assertContainsMarkerColor(viewer, TextDiffType.CONFLICT)
}
finally {
Disposer.dispose(disposable)
}
}
private fun assertContainsRange(viewer: SimpleThreesideDiffViewer, type: TextDiffType) {
assertNotNull(viewer.changes.find { change ->
change.diffType == type
})
}
private fun assertContainsBackgroundColor(viewer: SimpleThreesideDiffViewer, type: TextDiffType, isIgnored: Boolean) {
assertContainsBackgroundColor(viewer) { editor, highlighter ->
val actual = highlighter.textAttributes?.backgroundColor
val expected = if (isIgnored) type.getIgnoredColor(editor) else type.getColor(editor)
actual == expected
}
}
private fun assertContainsMarkerColor(viewer: SimpleThreesideDiffViewer, type: TextDiffType) {
assertContainsBackgroundColor(viewer) { editor, highlighter ->
highlighter.textAttributes?.errorStripeColor == type.getMarkerColor(editor)
}
}
private fun assertContainsBackgroundColor(viewer: SimpleThreesideDiffViewer, condition: (EditorEx, RangeHighlighter) -> Boolean) {
val ranges = viewer.editors.flatMap { editor ->
listOfNotNull(editor.markupModel.allHighlighters.map { highlighter ->
return@map if (condition(editor, highlighter)) highlighter else null
})
}
assertTrue(ranges.isNotEmpty())
}
}
@@ -51,8 +51,9 @@ public class CompletionLookupArranger extends LookupArranger {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionLookupArranger");
@Nullable private static StatisticsUpdate ourPendingUpdate;
private static final Alarm ourStatsAlarm = new Alarm(ApplicationManager.getApplication());
private static final Key<String> PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
private static final Comparator<LookupElement> BY_PRESENTATION_COMPARATOR = new Comparator<LookupElement>() {
private static final Key<String> GLOBAL_PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
private final Key<String> PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
private final Comparator<LookupElement> BY_PRESENTATION_COMPARATOR = new Comparator<LookupElement>() {
@Override
public int compare(LookupElement o1, LookupElement o2) {
String invariant = PRESENTATION_INVARIANT.get(o1);
@@ -152,6 +153,7 @@ public class CompletionLookupArranger extends LookupArranger {
final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
element.putUserData(PRESENTATION_INVARIANT, invariant);
element.putUserData(GLOBAL_PRESENTATION_INVARIANT, invariant);
CompletionSorterImpl sorter = obtainSorter(element);
Classifier<LookupElement> classifier = myClassifiers.get(sorter);
@@ -208,7 +210,7 @@ public class CompletionLookupArranger extends LookupArranger {
return tailText == null || tailText.isEmpty() ? " " : tailText;
}
private static List<LookupElement> sortByPresentation(Iterable<LookupElement> source, LookupImpl lookup) {
private List<LookupElement> sortByPresentation(Iterable<LookupElement> source, LookupImpl lookup) {
ArrayList<LookupElement> startMatches = ContainerUtil.newArrayList();
ArrayList<LookupElement> middleMatches = ContainerUtil.newArrayList();
for (LookupElement element : source) {
@@ -369,7 +371,7 @@ public class CompletionLookupArranger extends LookupArranger {
return new CompletionLookupArranger(myParameters, myProcess);
}
private static int getItemToSelect(LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
private int getItemToSelect(LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) {
return 0;
}
@@ -391,7 +393,7 @@ public class CompletionLookupArranger extends LookupArranger {
for (int i = 0; i < items.size(); i++) {
String invariant = PRESENTATION_INVARIANT.get(items.get(i));
if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) {
if (invariant != null && invariant.equals(GLOBAL_PRESENTATION_INVARIANT.get(lastSelection))) {
return i;
}
}
@@ -577,7 +579,7 @@ public class CompletionLookupArranger extends LookupArranger {
}
}
private static class AlphaClassifier extends Classifier<LookupElement> {
private class AlphaClassifier extends Classifier<LookupElement> {
private final LookupImpl myLookup;
private AlphaClassifier(LookupImpl lookup) {
@@ -45,6 +45,7 @@ import com.intellij.util.EventDispatcher;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.awt.*;
import java.util.List;
@@ -229,4 +230,10 @@ public class DiffPreviewPanel implements PreviewPanel {
@Override
public void disposeUIResources() {
}
@NotNull
@TestOnly
public SimpleThreesideDiffViewer testGetViewer() {
return myViewer;
}
}
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
@@ -38,6 +39,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class InstalledPackagesPanel extends JPanel {
private static final Logger LOG = Logger.getInstance(InstalledPackagesPanel.class);
private final AnActionButton myUpgradeButton;
protected final AnActionButton myInstallButton;
private final AnActionButton myUninstallButton;
@@ -418,7 +420,7 @@ public class InstalledPackagesPanel extends JPanel {
packages = packageManagementService.getInstalledPackages();
}
catch (IOException e) {
// do nothing, we already have an empty list
LOG.warn(e.getMessage()); // do nothing, we already have an empty list
}
finally {
final Collection<InstalledPackage> finalPackages = packages;
@@ -25,6 +25,8 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.editor.ex.util.EditorUIUtil;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.HintHint;
@@ -57,8 +59,12 @@ public class EditorFragmentComponent extends JPanel {
private void doInit(EditorEx editor, int startLine, int endLine, boolean showFolding, boolean showGutter) {
Document doc = editor.getDocument();
final int endOffset = endLine < doc.getLineCount() ? doc.getLineEndOffset(endLine) : doc.getTextLength();
final int textImageWidth = Math.min(editor.getMaxWidthInRange(doc.getLineStartOffset(startLine), endOffset), ScreenUtil
.getScreenRectangle(1, 1).width);
boolean newRendering = editor instanceof EditorImpl && ((EditorImpl)editor).myUseNewRendering;
int widthAdjustment = newRendering ? EditorUtil.getSpaceWidth(Font.PLAIN, editor) : 0;
final int textImageWidth = Math.min(
editor.getMaxWidthInRange(doc.getLineStartOffset(startLine), endOffset) + widthAdjustment,
ScreenUtil.getScreenRectangle(1, 1).width
);
LOG.assertTrue(textImageWidth > 0, "TextWidth: "+textImageWidth+"; startLine:" + startLine + "; endLine:" + endLine + ";");
FoldingModelEx foldingModel = editor.getFoldingModel();
@@ -74,7 +80,7 @@ public class EditorFragmentComponent extends JPanel {
final int textImageHeight = y2 - y1 == 0 ? editor.getLineHeight() : y2 - y1;
LOG.assertTrue(textImageHeight > 0, "Height: " + textImageHeight + "; startLine:" + startLine + "; endLine:" + endLine + "; p1:" + p1 + "; p2:" + p2);
int savedScrollOffset = editor.getScrollingModel().getHorizontalScrollOffset();
int savedScrollOffset = newRendering ? 0 : editor.getScrollingModel().getHorizontalScrollOffset();
if (savedScrollOffset > 0) {
editor.getScrollingModel().scrollHorizontally(0);
}
@@ -3152,7 +3152,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
+ ", soft wraps data: " + getSoftWrapModel().dumpState()
+ "\n\nfolding data: " + getFoldingModel().dumpState()
+ (myDocument instanceof DocumentImpl ? "\n\ndocument info: " + ((DocumentImpl)myDocument).dumpState() : "")
+ "\nfont preferences: " + myScheme.getFontPreferences();
+ "\nfont preferences: " + myScheme.getFontPreferences()
+ "\npure painting mode: " + myPurePaintingMode
+ (myView == null ? "" : "\nview: " + myView.dumpState());
}
private class CachedFontContent {
@@ -15,7 +15,10 @@
*/
package com.intellij.openapi.editor.impl.view;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.EditorLinePainter;
import com.intellij.openapi.editor.FoldRegion;
@@ -45,7 +48,9 @@ import java.util.List;
/**
* Calculates width (in pixels) of editor contents.
*/
class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener {
class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener, Dumpable {
private static final Logger LOG = Logger.getInstance(EditorSizeManager.class);
private static final int UNKNOWN_WIDTH = Integer.MAX_VALUE;
private final EditorView myView;
@@ -197,6 +202,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
}
private int calculatePreferredWidth() {
if (myLineWidths.size() != myEditor.getVisibleLineCount()) {
LOG.error("Inconsistent state", new Attachment("editor.txt", myEditor.dumpState()));
reset();
}
assert myLineWidths.size() == myEditor.getVisibleLineCount();
VisualLinesIterator iterator = new VisualLinesIterator(myView, 0);
int maxWidth = 0;
@@ -324,4 +333,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
myEditor.getFoldingModel().setFoldingEnabled(foldingEnabled);
}
}
@NotNull
@Override
public String dumpState() {
return "[line widths: " + myLineWidths + "]";
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl.view;
import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.FoldRegion;
@@ -44,7 +45,7 @@ import java.awt.image.BufferedImage;
*
* Also contains a cache of several font-related quantities (line height, space width, etc).
*/
public class EditorView implements TextDrawingCallback, Disposable {
public class EditorView implements TextDrawingCallback, Disposable, Dumpable {
private static Key<LineLayout> FOLD_REGION_TEXT_LAYOUT = Key.create("text.layout");
private final EditorImpl myEditor;
@@ -244,6 +245,7 @@ public class EditorView implements TextDrawingCallback, Disposable {
public Dimension getPreferredSize() {
assertIsDispatchThread();
assert !myEditor.isPurePaintingMode();
myEditor.getSoftWrapModel().prepareToMapping();
return mySizeManager.getPreferredSize();
}
@@ -467,4 +469,10 @@ public class EditorView implements TextDrawingCallback, Disposable {
public void drawChars(@NotNull Graphics g, @NotNull char[] data, int start, int end, int x, int y, Color color, FontInfo fontInfo) {
myPainter.drawChars(g, data, start, end, x, y, color, fontInfo);
}
@NotNull
@Override
public String dumpState() {
return "[Size manager: " + mySizeManager.dumpState() + "]";
}
}
@@ -173,7 +173,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
return false;
}
if (focusOwner instanceof JTextComponent && ((JTextComponent)focusOwner).isEditable()) {
if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyChar() != KeyEvent.VK_ESCAPE) {
if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyCode() != KeyEvent.VK_ESCAPE) {
MacUIUtil.hideCursor();
}
}
@@ -30,7 +30,7 @@
<projectService serviceInterface="com.intellij.xdebugger.impl.XDebuggerHistoryManager"
serviceImplementation="com.intellij.xdebugger.impl.XDebuggerHistoryManager"/>
<applicationConfigurable groupId="build" dynamic="true" key="debugger.configurable.display.name" bundle="messages.XDebuggerBundle"
<applicationConfigurable groupId="build" dynamic="true" groupWeight="120" key="debugger.configurable.display.name" bundle="messages.XDebuggerBundle"
id="project.propDebugger" provider="com.intellij.xdebugger.impl.settings.DebuggerConfigurableProvider"/>
<customizableActionGroupProvider implementation="com.intellij.xdebugger.impl.ui.XDebugTabCustomizableActionGroupProvider"/>
@@ -10,6 +10,7 @@ import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentIterator;
import com.intellij.openapi.util.Computable;
@@ -47,7 +48,7 @@ public class MatcherImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.structuralsearch.impl.matcher.MatcherImpl");
// project being worked on
private final Project project;
private final PsiDocumentManager documentManager;
private final DumbService myDumbService;
// context of matching
private final MatchContext matchContext;
@@ -70,7 +71,7 @@ public class MatcherImpl {
matchContext.setOptions(matchOptions);
cacheCompiledPattern(matchOptions, PatternCompiler.compilePattern(project,matchOptions));
}
documentManager = PsiDocumentManager.getInstance(this.project);
myDumbService = DumbService.getInstance(project);
}
static class LastMatchData {
@@ -523,7 +524,7 @@ public class MatcherImpl {
matchContext.getSink().processFile((PsiFile)file);
}
documentManager.commitAndRunReadAction(new Runnable() {
myDumbService.runReadActionInSmartMode(new Runnable() {
@Override
public void run() {
if (!file.isValid()) return;
@@ -20,9 +20,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
/**
* Implement this to add additional custom actions to the popup invoked by right-clicking on the annotation gutter.
*
* @author Kirill Likhodedov
* Implement this to add an additional custom action to the annotation gutter popup (invoked by right-click to an annotation).
*/
public interface AnnotationGutterActionProvider {
@@ -30,10 +28,11 @@ public interface AnnotationGutterActionProvider {
/**
* Create an action that will be added to the annotation gutter popup.
*
* @param annotation annotation which is currently shown on the gutter.
* @return new action that can be invoked from the annotation gutter popup.
*/
@NotNull
AnAction createAction(FileAnnotation annotation);
AnAction createAction(@NotNull FileAnnotation annotation);
}
@@ -26,7 +26,6 @@ import java.util.Collection;
/**
* Provides custom titles and messages used in MultipleFileMergeDialog and DiffTool invoked from it.
* @author Kirill Likhodedov
*/
public class MergeDialogCustomizer {
@@ -34,7 +33,7 @@ public class MergeDialogCustomizer {
* @param files files that have conflicted changes and are shown in the dialog.
* @return description that is shows above the list of conflicted files. Null (which is equivalent to empty) by default.
*/
public @Nullable String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
@Nullable public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return null;
}
@@ -42,7 +41,7 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title of the merge dialog invoked for a 3-way merge of a file.
*/
public @Nullable String getMergeWindowTitle(VirtualFile file) {
@Nullable public String getMergeWindowTitle(@NotNull VirtualFile file) {
return VcsBundle.message("multiple.file.merge.request.title", FileUtil.toSystemDependentName(file.getPresentableUrl()));
}
@@ -50,7 +49,7 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title that is shown above the left panel in the 3-way merge dialog. "Local changes" by default.
*/
public @Nullable String getLeftPanelTitle(VirtualFile file) {
@Nullable public String getLeftPanelTitle(@NotNull VirtualFile file) {
return VcsBundle.message("merge.version.title.local.changes");
}
@@ -58,18 +57,18 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title that is shown above the center panel in the 3-way merge dialog. "Merge result" by default.
*/
public @Nullable String getCenterPanelTitle(VirtualFile file) {
@Nullable public String getCenterPanelTitle(@NotNull VirtualFile file) {
return VcsBundle.message("merge.version.title.merge.result");
}
/**
* @param file file that is merged.
* @param lastRevisionNumber
* @param file file that is being merged.
* @param revisionNumber revision number of the file at the right, can be null if unknown.
* @return title that is shown above the right panel in the 3-way merge dialog. "Changes from server" with the revision number by default.
*/
public @Nullable String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
if (lastRevisionNumber != null) {
return VcsBundle.message("merge.version.title.last.version.number", lastRevisionNumber.asString());
@Nullable public String getRightPanelTitle(@NotNull VirtualFile file, @Nullable VcsRevisionNumber revisionNumber) {
if (revisionNumber != null) {
return VcsBundle.message("merge.version.title.last.version.number", revisionNumber.asString());
} else {
return VcsBundle.message("merge.version.title.last.version");
}
@@ -77,11 +76,9 @@ public class MergeDialogCustomizer {
/**
* @return The title of multiple files merge dialog.
* Don't mix with {@link #getMergeWindowTitle(com.intellij.openapi.vfs.VirtualFile)} which is the title of a 3-way merge dialog
* displayed for a single file.
* Don't mix with {@link #getMergeWindowTitle(VirtualFile)} which is the title of a 3-way merge dialog displayed for a single file.
*/
public @NotNull String getMultipleFileDialogTitle() {
@NotNull public String getMultipleFileDialogTitle() {
return VcsBundle.message("multiple.file.merge.title");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.psiutils.CloneUtils;
import com.siyeh.ig.psiutils.MethodUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -33,7 +34,7 @@ public class CastToConcreteClassInspection extends BaseInspection {
public boolean ignoreAbstractClasses = false;
@SuppressWarnings("PublicField")
public boolean ignoreInEquals = true;
public boolean ignoreInEquals = true; // keep for compatibility
@Override
@NotNull
@@ -73,11 +74,9 @@ public class CastToConcreteClassInspection extends BaseInspection {
if (!ConcreteClassUtil.typeIsConcreteClass(typeElement, ignoreAbstractClasses)) {
return;
}
if (ignoreInEquals) {
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
if (MethodUtils.isEquals(method)) {
return;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
if (MethodUtils.isEquals(method) || CloneUtils.isClone(method)) {
return;
}
registerError(typeElement, typeElement.getType());
}
@@ -116,11 +115,9 @@ public class CastToConcreteClassInspection extends BaseInspection {
if (!ConcreteClassUtil.typeIsConcreteClass(parameter, ignoreAbstractClasses)) {
return;
}
if (ignoreInEquals) {
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
if (MethodUtils.isEquals(method)) {
return;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
if (MethodUtils.isEquals(method) || CloneUtils.isClone(method)) {
return;
}
registerMethodCallError(expression, parameter);
}
@@ -15,8 +15,11 @@
*/
package com.siyeh.ig.errorhandling;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.controlFlow.DefUseUtil;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -60,13 +63,7 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (!ExpressionUtils.hasExpressionCount(argumentList, 1)) {
return;
}
final PsiExpression argument = ExpressionUtils.getFirstExpressionInList(argumentList);
if (argument == null) {
return;
}
final PsiExpression argument = ExpressionUtils.getOnlyExpressionInList(argumentList);
if (!TypeUtils.expressionHasTypeOrSubtype(argument, CommonClassNames.JAVA_LANG_THROWABLE)) {
return;
}
@@ -80,12 +77,42 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
}
final PsiExpression qualifier = ParenthesesUtils.stripParentheses(methodExpression.getQualifierExpression());
final PsiNewExpression newExpression = findNewExpression(qualifier);
if (!isCauseConstructorAvailable(newExpression)) {
if (!isCauseConstructorAvailable(newExpression) || !canExpressionBeMovedBackwards(argument, newExpression)) {
return;
}
registerMethodCallError(expression);
}
private static boolean canExpressionBeMovedBackwards(final PsiExpression cause, final PsiExpression newLocation) {
if (cause == null || newLocation == null) return false;
assert cause.getTextOffset() > newLocation.getTextOffset();
final PsiCodeBlock block = PsiTreeUtil.getParentOfType(cause, PsiCodeBlock.class);
final PsiCodeBlock newBlock = PsiTreeUtil.getParentOfType(newLocation, PsiCodeBlock.class);
if (block == null || newBlock == null || !PsiTreeUtil.isAncestor(block, newBlock, false)) return false;
final int offset = newLocation.getTextOffset();
final Ref<Boolean> result = new Ref<Boolean>(Boolean.TRUE);
cause.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
if (!result.get().booleanValue()) {
return;
}
super.visitReferenceExpression(expression);
final PsiElement target = expression.resolve();
if (!(target instanceof PsiVariable)) {
return;
}
final PsiElement[] defs = DefUseUtil.getDefs(block, (PsiVariable)target, cause);
for (PsiElement def : defs) {
if (def.getTextOffset() > offset) {
result.set(Boolean.FALSE);
}
}
}
});
return result.get().booleanValue();
}
public static boolean isCauseConstructorAvailable(PsiNewExpression newExpression) {
if (newExpression == null) {
return false;
@@ -140,10 +167,25 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
}
final PsiVariable variable = (PsiVariable)target;
final PsiExpression initializer = variable.getInitializer();
if (!(initializer instanceof PsiNewExpression)) {
if ((initializer instanceof PsiNewExpression)) {
return (PsiNewExpression)initializer;
}
final PsiCodeBlock block = PsiTreeUtil.getParentOfType(target, PsiCodeBlock.class);
final PsiElement[] defs = DefUseUtil.getDefs(block, variable, expression);
if (defs.length != 1) {
return null;
}
return (PsiNewExpression)initializer;
final PsiElement def = defs[0];
if (!(def instanceof PsiReferenceExpression) || !(def.getParent() instanceof PsiAssignmentExpression)) {
return null;
}
final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)def.getParent();
if (assignmentExpression.getOperationTokenType() != JavaTokenType.EQ) return null;
final PsiExpression rhs = ParenthesesUtils.stripParentheses(assignmentExpression.getRExpression());
if (!(rhs instanceof PsiNewExpression)) {
return null;
}
return (PsiNewExpression)rhs;
}
return null;
}
@@ -478,7 +478,7 @@ public class ControlFlowUtils {
return getOnlyChildOfType(codeBlock, PsiStatement.class);
}
private static <T extends PsiElement> T getOnlyChildOfType(@Nullable PsiElement element, @NotNull Class<T> aClass) {
static <T extends PsiElement> T getOnlyChildOfType(@Nullable PsiElement element, @NotNull Class<T> aClass) {
if (element == null) return null;
T result = null;
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
@@ -72,6 +72,11 @@ public class ExpressionUtils {
return PsiTreeUtil.getChildOfType(expressionList, PsiExpression.class);
}
@Nullable
public static PsiExpression getOnlyExpressionInList(@Nullable PsiExpressionList expressionList) {
return ControlFlowUtils.getOnlyChildOfType(expressionList, PsiExpression.class);
}
public static boolean isDeclaredConstant(PsiExpression expression) {
PsiField field =
PsiTreeUtil.getParentOfType(expression, PsiField.class);
@@ -2,12 +2,10 @@
<body>
Reports casting a value to a concrete class, rather than an interface.
Such declarations may represent a failure of abstraction, and may make testing more difficult.
Declarations whose classes come from system or third-party libraries will not be reported by this inspection.
Casts to system or library classes and casts inside <b>equals()</b> and <b>clone()</b> methods will not be reported by this inspection.
<!-- tooltip end -->
<p>
Use the first checkbox below to have this inspection ignore casts to abstract classes.
<p>
Use the second checkbox below to have this inspection ignore casts inside <code>equals()</code> methods.
Use the checkbox below to have this inspection ignore casts to abstract classes.
<p>
</body>
@@ -7,7 +7,7 @@ class Indirect {
new FileInputStream("asdf");
} catch (FileNotFoundException e) {
final RuntimeException exception = new RuntimeException(e);
throw e;
throw exception;
}
}
}
@@ -8,7 +8,7 @@ class Indirect {
} catch (FileNotFoundException e) {
final RuntimeException exception = new RuntimeException();
exception.<caret>initCause(e);
throw e;
throw exception;
}
}
}
@@ -14,10 +14,15 @@ class CastToConcreteClass {
}
}
@Override
public CastToConcreteClass clone() throws CloneNotSupportedException {
return (CastToConcreteClass) super.clone();
}
void foo(Object o) {
CastToConcreteClass c = (CastToConcreteClass)o;
CastToConcreteClass c2 = CastToConcreteClass.class.cast(o);
CastToConcreteClass c = (<warning descr="Cast to concrete class 'CastToConcreteClass'">CastToConcreteClass</warning>)o;
CastToConcreteClass c2 = CastToConcreteClass.class.<warning descr="Cast to concrete class 'CastToConcreteClass'">cast</warning>(o);
final Class<CastToConcreteClass> aClass = CastToConcreteClass.class;
final CastToConcreteClass c3 = aClass.cast(o);
final CastToConcreteClass c3 = aClass.<warning descr="Cast to concrete class 'CastToConcreteClass'">cast</warning>(o);
}
}
@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>CastToConcreteClass.java</file>
<line>18</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Cast to a concrete class</problem_class>
<description>Cast to concrete class &lt;code&gt;CastToConcreteClass&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>CastToConcreteClass.java</file>
<line>19</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Cast to a concrete class</problem_class>
<description>Cast to concrete class &lt;code&gt;CastToConcreteClass&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>CastToConcreteClass.java</file>
<line>21</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Cast to a concrete class</problem_class>
<description>Cast to concrete class &lt;code&gt;CastToConcreteClass&lt;/code&gt; #loc</description>
</problem>
</problems>
@@ -17,10 +17,10 @@ class ObjectToString<E>
class N {}
void foo(N n) {
n.toString();
<warning descr="Call to default 'toString()' on 'n'">n</warning>.toString();
}
String bar(N n) {
return "n: " + n + "a";
return "n: " + <warning descr="Call to default 'toString()' on 'n'">n</warning> + "a";
}
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>ObjectToString.java</file>
<line>20</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Call to default 'toString()'</problem_class>
<description>Call to default 'toString()' on &lt;code&gt;n&lt;/code&gt; #loc</description>
</problem>
<problem>
<file>ObjectToString.java</file>
<line>24</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Call to default 'toString()'</problem_class>
<description>Call to default 'toString()' on &lt;code&gt;n&lt;/code&gt; #loc</description>
</problem>
</problems>
@@ -1,12 +1,20 @@
package com.siyeh.ig.abstraction;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class CastToConcreteClassInspectionTest extends IGInspectionTestCase {
public class CastToConcreteClassInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
final CastToConcreteClassInspection tool = new CastToConcreteClassInspection();
tool.ignoreInEquals = true;
doTest("com/siyeh/igtest/abstraction/cast_to_concrete_class", tool);
public void testCastToConcreteClass() {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
final CastToConcreteClassInspection inspection = new CastToConcreteClassInspection();
inspection.ignoreInEquals = true;
return inspection;
}
}
@@ -1,11 +1,18 @@
package com.siyeh.ig.bugs;
import com.siyeh.ig.IGInspectionTestCase;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
public class ObjectToStringInspectionTest extends IGInspectionTestCase {
public class ObjectToStringInspectionTest extends LightInspectionTestCase {
public void test() throws Exception {
doTest("com/siyeh/igtest/bugs/object_to_string",
new ObjectToStringInspection());
public void testObjectToString() throws Exception {
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new ObjectToStringInspection();
}
}
@@ -0,0 +1,60 @@
/*
* 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.siyeh.ig.errorhandling;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
/**
* @author Bas Leijdekkers
*/
public class UnnecessaryInitCauseInspectionTest extends LightInspectionTestCase {
public void testSplitDeclarationAssignment() {
doMemberTest("void foo() {\n" +
" RuntimeException exception = null;\n" +
" try {\n" +
" new java.io.FileInputStream(\"asdf\");\n" +
" } catch (java.io.FileNotFoundException e) {\n" +
" exception = new RuntimeException();\n" +
" exception./*Unnecessary 'Throwable.initCause()' call*/initCause/**/(e);\n" +
" } catch (RuntimeException e) {\n" +
" exception = e;\n" +
" }\n" +
" throw exception;\n" +
"}");
}
public void testReassigned() {
doMemberTest("void foo() {\n" +
" try {\n" +
" new java.io.FileInputStream(\"asdf\");\n" +
" } catch (java.io.FileNotFoundException e) {\n" +
" RuntimeException exception = new RuntimeException();\n" +
" e = null;\n" +
" exception.initCause(e);\n" +
" throw exception;\n" +
" }\n" +
"}");
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new UnnecessaryInitCauseInspection();
}
}
+1
View File
@@ -137,6 +137,7 @@
<vcsChangesViewRefresher implementation="git4idea.changes.GitChangesViewRefresher" />
<pushSupport implementation="git4idea.push.GitPushSupport"/>
<cherryPicker implementation="git4idea.cherrypick.GitCherryPicker"/>
<vcsAnnotationGutterActionProvider implementation="git4idea.actions.GitShowCommitInLogAnnotationGutterActionProvider" />
<projectService serviceImplementation="git4idea.repo.GitRepositoryManager"/>
<projectService
@@ -0,0 +1,55 @@
/*
* 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 git4idea.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.annotate.UpToDateLineNumberListener;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import git4idea.log.GitShowCommitInLogAction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class GitShowCommitInLogAnnotationGutterActionProvider implements AnnotationGutterActionProvider {
@NotNull
@Override
public AnAction createAction(@NotNull final FileAnnotation annotation) {
return new MyShowCommitInLogAction(annotation);
}
private static class MyShowCommitInLogAction extends GitShowCommitInLogAction implements UpToDateLineNumberListener {
private final FileAnnotation myAnnotation;
private int myLineNumber;
public MyShowCommitInLogAction(@NotNull FileAnnotation annotation) {
myAnnotation = annotation;
}
@Nullable
@Override
protected VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
return myAnnotation.getLineRevisionNumber(myLineNumber);
}
@Override
public void consume(Integer lineNumber) {
myLineNumber = lineNumber;
}
}
}
@@ -623,18 +623,18 @@ public class GitCherryPicker extends VcsCherryPicker {
}
@Override
public String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return "<html>Conflicts during cherry-picking commit <code>" + myCommitHash + "</code> made by " + myCommitAuthor + "<br/>" +
"<code>\"" + myCommitMessage + "\"</code></html>";
}
@Override
public String getLeftPanelTitle(VirtualFile file) {
public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Local changes";
}
@Override
public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return "<html>Changes from cherry-pick <code>" + myCommitHash + "</code>";
}
}
@@ -38,7 +38,7 @@ import git4idea.GitVcs;
import git4idea.changes.GitChangeUtils;
import git4idea.config.GitExecutableValidator;
import git4idea.history.browser.SHAHash;
import git4idea.history.wholeTree.SelectRevisionInGitLogAction;
import git4idea.log.GitShowCommitInLogAction;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import org.jetbrains.annotations.NotNull;
@@ -69,7 +69,7 @@ public class GitHistoryProvider implements VcsHistoryProviderEx, VcsCacheableHis
return new AnAction[] {
ShowAllAffectedGenericAction.getInstance(),
ActionManager.getInstance().getAction(VcsActions.ACTION_COPY_REVISION_NUMBER),
new SelectRevisionInGitLogAction() };
new GitShowCommitInLogAction() };
}
public boolean isDateOmittable() {
@@ -1,4 +1,19 @@
package git4idea.history.wholeTree;
/*
* 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 git4idea.log;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -31,11 +46,11 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
public class SelectRevisionInGitLogAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance(SelectRevisionInGitLogAction.class);
public class GitShowCommitInLogAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance(GitShowCommitInLogAction.class);
public SelectRevisionInGitLogAction() {
super(GitBundle.getString("vcs.history.action.gitlog"), GitBundle.getString("vcs.history.action.gitlog"), null);
public GitShowCommitInLogAction() {
super(GitBundle.getString("vcs.history.action.gitlog"));
}
@Override
@@ -106,7 +121,7 @@ public class SelectRevisionInGitLogAction extends DumbAwareAction {
}
@Nullable
private static VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
protected VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
VcsRevisionNumber revision = event.getData(VcsDataKeys.VCS_REVISION_NUMBER);
if (revision == null) {
VcsFileRevision fileRevision = event.getData(VcsDataKeys.VCS_FILE_REVISION);
@@ -122,8 +137,7 @@ public class SelectRevisionInGitLogAction extends DumbAwareAction {
super.update(e);
e.getPresentation().setEnabled(e.getProject() != null &&
VcsLogContentProvider.findLogManager(e.getProject()) != null &&
(e.getData(VcsDataKeys.VCS_FILE_REVISION) != null ||
e.getData(VcsDataKeys.VCS_REVISION_NUMBER) != null));
getRevisionNumber(e) != null);
}
@Nullable
@@ -74,7 +74,7 @@ public class GitConflictResolver {
private String myErrorNotificationAdditionalDescription = "";
private String myMergeDescription = "";
private MergeDialogCustomizer myMergeDialogCustomizer = new MergeDialogCustomizer() {
@Override public String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
@Override public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return myMergeDescription;
}
};
@@ -216,17 +216,17 @@ public class GitStashChangesSaver extends GitChangesSaver {
private static class UnstashMergeDialogCustomizer extends MergeDialogCustomizer {
@Override
public String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return "Uncommitted changes that were stashed before update have conflicts with updated files.";
}
@Override
public String getLeftPanelTitle(VirtualFile file) {
public String getLeftPanelTitle(@NotNull VirtualFile file) {
return getConflictLeftPanelTitle();
}
@Override
public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return getConflictRightPanelTitle();
}
}
@@ -444,17 +444,17 @@ public class GitUnstashDialog extends DialogWrapper {
}
@Override
public String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return "<html>Conflicts during unstashing <code>" + myStashInfo.getStash() + "\"" + myStashInfo.getMessage() + "\"</code></html>";
}
@Override
public String getLeftPanelTitle(VirtualFile file) {
public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Local changes";
}
@Override
public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return "Changes from stash";
}
}
@@ -125,19 +125,19 @@ public class GitPreservingProcess {
GitChangesSaver saver = GitChangesSaver.getSaver(myProject, myFacade, myGit, myProgressIndicator, myStashMessage, saveMethod);
MergeDialogCustomizer mergeDialogCustomizer = new MergeDialogCustomizer() {
@Override
public String getMultipleFileMergeDescription(Collection<VirtualFile> files) {
public String getMultipleFileMergeDescription(@NotNull Collection<VirtualFile> files) {
return String.format(
"<html>Uncommitted changes that were saved before %s have conflicts with files from <code>%s</code></html>",
myOperationTitle, myDestinationName);
}
@Override
public String getLeftPanelTitle(VirtualFile file) {
public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Uncommitted changes from stash";
}
@Override
public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return String.format("<html>Changes from <b><code>%s</code></b></html>", myDestinationName);
}
};
@@ -51,8 +51,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
e.getPresentation().setVisible(false);
return;
}
int corrected = eventData.getCorrectedLineNumber();
e.getPresentation().setEnabled(corrected >= 0 && myAnnotation.getLineRevisionNumber(corrected) != null);
e.getPresentation().setEnabled(myLineNumber >= 0 && myAnnotation.getLineRevisionNumber(myLineNumber) != null);
e.getPresentation().setVisible(GithubUtil.isRepositoryOnGitHub(eventData.getRepository()));
}
@@ -63,7 +62,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
return;
}
final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(eventData.getCorrectedLineNumber());
final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber);
if (revisionNumber != null) {
openInBrowser(eventData.getProject(), eventData.getRepository(), revisionNumber.asString());
}
@@ -86,7 +85,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
return null;
}
return new EventData(project, repository, lineNumber);
return new EventData(project, repository);
}
@Override
@@ -97,12 +96,10 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
private static class EventData {
@NotNull private final Project myProject;
@NotNull private final GitRepository myRepository;
private final int myCorrectedLineNumber;
private EventData(@NotNull Project project, @NotNull GitRepository repository, int correctedLineNumber) {
private EventData(@NotNull Project project, @NotNull GitRepository repository) {
myProject = project;
myRepository = repository;
myCorrectedLineNumber = correctedLineNumber;
}
@NotNull
@@ -114,10 +111,5 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
public GitRepository getRepository() {
return myRepository;
}
private int getCorrectedLineNumber() {
return myCorrectedLineNumber;
}
}
}
@@ -20,12 +20,13 @@ import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.impl.source.tree.TreeGenerator;
import com.intellij.util.CharTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
public class GroovyTreeGenerator implements TreeGenerator {
@Override
public TreeElement generateTreeFor(PsiElement original, CharTable table, PsiManager manager) {
public TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull CharTable table, @NotNull PsiManager manager) {
if (original instanceof GrModifierList) {
final String text = original.getText();
@@ -19,7 +19,6 @@ import sys
if sys.version_info < (3,0):
b = bytes = str
u_prefix = 'u'
from StringIO import StringIO as BytesIO
else:
import builtins
bytes = builtins.bytes
@@ -14,13 +14,13 @@ custom component objects first, and pass *them* to
__docformat__ = 'reStructuredText'
import sys
import pprint
from docutils import __version__, __version_details__, SettingsSpec
from docutils import frontend, io, utils, readers, writers
from docutils.frontend import OptionParser
from docutils.transforms import Transformer
import sys
import docutils.readers.doctree
from docutils import __version__, __version_details__, SettingsSpec
from docutils import io, utils, readers, writers
from docutils.frontend import OptionParser
class Publisher:
@@ -27,18 +27,19 @@ Also exports the following functions:
__docformat__ = 'reStructuredText'
import ConfigParser as CP
import codecs
import optparse
import os
import os.path
import sys
import warnings
import ConfigParser as CP
import codecs
import docutils
import docutils.utils
import docutils.nodes
import optparse
from optparse import SUPPRESS_HELP
import docutils
import docutils.nodes
import docutils.utils
def store_multiple(option, opt, value, parser, *args, **kwargs):
"""
@@ -21,12 +21,12 @@ hierarchy.
__docformat__ = 'reStructuredText'
import sys
import os
import re
import warnings
import sys
import types
import unicodedata
import warnings
# ==============================
# Functional Node Base Classes
@@ -69,11 +69,10 @@ appropriate).
__docformat__ = 'reStructuredText'
import docutils.parsers
import docutils.statemachine
from docutils import frontend
from docutils.parsers.rst import states
from docutils import frontend, nodes
class Parser(docutils.parsers.Parser):
@@ -8,12 +8,12 @@ This package contains directive implementation modules.
__docformat__ = 'reStructuredText'
import re
import codecs
import re
from docutils import nodes
from docutils.parsers.rst.languages import en as _fallback_language_module
_directive_registry = {
'attention': ('admonitions', 'Attention'),
'caution': ('admonitions', 'Caution'),
@@ -8,10 +8,9 @@ Admonition directives.
__docformat__ = 'reStructuredText'
from docutils.parsers.rst import Directive
from docutils.parsers.rst import states, directives
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
class BaseAdmonition(Directive):
@@ -10,8 +10,6 @@ See `docutils.parsers.rst.directives` for API details.
__docformat__ = 'reStructuredText'
import sys
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
@@ -8,7 +8,6 @@ Directives for typically HTML-specific constructs.
__docformat__ = 'reStructuredText'
import sys
from docutils import nodes, utils
from docutils.parsers.rst import Directive
from docutils.parsers.rst import states
@@ -8,12 +8,10 @@ Directives for figures and simple images.
__docformat__ = 'reStructuredText'
import sys
from docutils import nodes, utils
from docutils import nodes
from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives, states
from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst.roles import set_classes
try:
@@ -6,15 +6,16 @@
__docformat__ = 'reStructuredText'
import sys
import os.path
import re
import time
from docutils import io, nodes, statemachine, utils
from docutils.parsers.rst import Directive, convert_directive_function
from docutils.parsers.rst import directives, roles, states
from docutils.transforms import misc
class Include(Directive):
"""
@@ -9,9 +9,9 @@ Directives for document parts.
__docformat__ = 'reStructuredText'
from docutils import nodes, languages
from docutils.transforms import parts
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
from docutils.transforms import parts
class Contents(Directive):
@@ -9,9 +9,9 @@ Directives for references and targets.
__docformat__ = 'reStructuredText'
from docutils import nodes
from docutils.transforms import references
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
from docutils.transforms import references
class TargetNotes(Directive):
@@ -8,15 +8,14 @@ Directives for table elements.
__docformat__ = 'reStructuredText'
import sys
import os.path
import csv
import os.path
import sys
from docutils import io, nodes, statemachine, utils
from docutils.utils import SystemMessagePropagation
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
from docutils.utils import SystemMessagePropagation
class Table(Directive):

Some files were not shown because too many files have changed in this diff Show More