Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vladimir.Orlov
2015-02-06 18:14:06 +03:00
24 changed files with 103 additions and 48 deletions
@@ -105,7 +105,7 @@ public class PrimitiveRenderer extends NodeRendererImpl {
static void appendCharValue(CharValue value, StringBuilder buf) {
buf.append('\'');
String s = value.toString();
StringUtil.escapeStringCharacters(s.length(), s, buf);
StringUtil.escapeStringCharacters(s.length(), s, "\'", buf);
buf.append('\'');
}
@@ -57,7 +57,11 @@ public class DfaVariableValue extends DfaValue {
}
public DfaVariableValue createVariableValue(PsiVariable myVariable, boolean isNegated) {
return createVariableValue(myVariable, myVariable.getType(), isNegated, null);
PsiType varType = myVariable.getType();
if (varType instanceof PsiEllipsisType) {
varType = new PsiArrayType(((PsiEllipsisType)varType).getComponentType());
}
return createVariableValue(myVariable, varType, isNegated, null);
}
@NotNull
public DfaVariableValue createVariableValue(@NotNull PsiModifierListOwner myVariable,
@@ -53,6 +53,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
@Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL = true;
@SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_GETTER = true;
@SuppressWarnings({"WeakerAccess"}) public boolean IGNORE_EXTERNAL_SUPER_NOTNULL = false;
@SuppressWarnings({"WeakerAccess"}) public boolean REQUIRE_NOTNULL_FIELDS_INITIALIZED = true;
@SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED = false;
@Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_SETTER_PARAMETER = true;
@Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true; // remains for test
@@ -67,7 +68,8 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
String name = child.getAttributeValue("name");
String value = child.getAttributeValue("value");
if ("IGNORE_EXTERNAL_SUPER_NOTNULL".equals(name) && "false".equals(value) ||
"REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED".equals(name) && "false".equals(value)) {
"REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED".equals(name) && "false".equals(value) ||
"REQUIRE_NOTNULL_FIELDS_INITIALIZED".equals(name) && "true".equals(value)) {
node.removeContent(child);
}
}
@@ -178,12 +180,14 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
}
List<PsiExpression> initializers = DfaPsiUtil.findAllConstructorInitializers(field);
if (annotated.isDeclaredNotNull && initializers.isEmpty()) {
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
if (annotation != null) {
holder.registerProblem(annotation.isPhysical() ? annotation : field.getNameIdentifier(),
"Not-null fields must be initialized",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
if (REQUIRE_NOTNULL_FIELDS_INITIALIZED) {
if (annotated.isDeclaredNotNull && initializers.isEmpty()) {
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
if (annotation != null) {
holder.registerProblem(annotation.isPhysical() ? annotation : field.getNameIdentifier(),
"Not-null fields must be initialized",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
}
@@ -40,6 +40,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase {
private JButton myConfigureAnnotationsButton;
private JCheckBox myIgnoreExternalSuperNotNull;
private JCheckBox myNNParameterOverridesNA;
private JCheckBox myRequireNNFieldsInitialized;
private OptionsPanel() {
super(new BorderLayout());
@@ -56,6 +57,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase {
myNNParameterOverridesNA.addActionListener(actionListener);
myReportNotAnnotatedGetter.addActionListener(actionListener);
myIgnoreExternalSuperNotNull.addActionListener(actionListener);
myRequireNNFieldsInitialized.addActionListener(actionListener);
myConfigureAnnotationsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -74,6 +76,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase {
myReportNotAnnotatedGetter.setSelected(REPORT_NOT_ANNOTATED_GETTER);
myIgnoreExternalSuperNotNull.setSelected(IGNORE_EXTERNAL_SUPER_NOTNULL);
myNNParameterOverridesNA.setSelected(REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED);
myRequireNNFieldsInitialized.setSelected(REQUIRE_NOTNULL_FIELDS_INITIALIZED);
myIgnoreExternalSuperNotNull.setEnabled(myNAMethodOverridesNN.isSelected());
}
@@ -84,6 +87,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase {
REPORT_NOT_ANNOTATED_GETTER = myReportNotAnnotatedGetter.isSelected();
IGNORE_EXTERNAL_SUPER_NOTNULL = myIgnoreExternalSuperNotNull.isSelected();
REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED = myNNParameterOverridesNA.isSelected();
REQUIRE_NOTNULL_FIELDS_INITIALIZED = myRequireNNFieldsInitialized.isSelected();
REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL;
myIgnoreExternalSuperNotNull.setEnabled(myNAMethodOverridesNN.isSelected());
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.nullable.NullableStuffInspection.OptionsPanel">
<grid id="cc1c9" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="cc1c9" binding="myPanel" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="69" y="57" width="634" height="235"/>
<xy x="69" y="57" width="634" height="239"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="c3eef">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2f304" class="javax.swing.JCheckBox" binding="myReportNotAnnotatedGetter">
@@ -39,7 +39,7 @@
</component>
<component id="ef852" class="javax.swing.JButton" binding="myConfigureAnnotationsButton" default-binding="true">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/InspectionsBundle" key="configure.annotations.option"/>
@@ -61,6 +61,14 @@
<text value="Report @NotNull &amp;parameters overriding non-annotated"/>
</properties>
</component>
<component id="f6e46" class="javax.swing.JCheckBox" binding="myRequireNNFieldsInitialized">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Require @NotNull fields to be initialized explicitly"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -1713,14 +1713,17 @@ public class ExtractMethodProcessor implements MatchProvider {
if (duplicates != null && !duplicates.isEmpty()) {
return true;
}
final ExtractMethodSignatureSuggester suggester = new ExtractMethodSignatureSuggester(myProject, myExtractedMethod, myMethodCall, myVariableDatum);
duplicates = suggester.getDuplicates(myExtractedMethod, myMethodCall);
if (duplicates != null && !duplicates.isEmpty()) {
myDuplicates = duplicates;
myExtractedMethod = suggester.getExtractedMethod();
myMethodCall = suggester.getMethodCall();
myVariableDatum = suggester.getVariableData();
return null;
if (myExtractedMethod != null) {
final ExtractMethodSignatureSuggester suggester = new ExtractMethodSignatureSuggester(myProject, myExtractedMethod, myMethodCall, myVariableDatum);
duplicates = suggester.getDuplicates(myExtractedMethod, myMethodCall);
if (duplicates != null && !duplicates.isEmpty()) {
myDuplicates = duplicates;
myExtractedMethod = suggester.getExtractedMethod();
myMethodCall = suggester.getMethodCall();
myVariableDatum = suggester.getVariableData();
return null;
}
}
return false;
}
@@ -0,0 +1,6 @@
class X {
public static String compute(String... s) {
if (s == null) return null;
return "";
}
}
@@ -0,0 +1,9 @@
import org.jetbrains.annotations.*;
class Test {
@NotNull Object member;
private void accessMember() {
member = new Object();
}
}
@@ -40,4 +40,5 @@ public class ContractCheckTest extends LightCodeInsightFixtureTestCase {
public void testNestedCallsMayThrow() { doTest(); }
public void testSignatureIssues() { doTest(); }
public void testVarargInferred() { doTest(); }
}
@@ -47,7 +47,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
//noinspection AssignmentToStaticFieldFromInstanceMethod
InspectionProfileImpl.INIT_INSPECTIONS = true;
super.setUp();
InspectionToolRegistrar.getInstance().ensureInitialized();
InspectionToolRegistrar.getInstance().createTools();
}
@Override
@@ -48,7 +48,13 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
public void testNullableFieldNotnullParam() throws Exception{ doTest(); }
public void testNotNullFieldNullableParam() throws Exception{ doTest(); }
public void testNotNullCustomException() throws Exception{ doTest(); }
public void testNotNullFieldNotInitialized() throws Exception{ doTest(); }
public void testNotNullFieldNotInitializedSetting() {
myInspection.REQUIRE_NOTNULL_FIELDS_INITIALIZED = false;
doTest();
}
public void testNotNullAnnotationChecksInChildClassMethods() { doTest(); }
public void testGetterSetterProblems() throws Exception{ doTest(); }
@@ -15,7 +15,6 @@ public class RedundantSuppressTest extends InspectionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
InspectionToolRegistrar.getInstance().ensureInitialized();
myInspectionToolWrappers = new InspectionToolWrapper[]{
new LocalInspectionToolWrapper(new I18nInspection()),
new LocalInspectionToolWrapper(new RawUseOfParameterizedTypeInspection()),
@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author max
@@ -41,10 +42,11 @@ public class InspectionToolRegistrar {
private final List<Factory<InspectionToolWrapper>> myInspectionToolFactories = new ArrayList<Factory<InspectionToolWrapper>>();
private final AtomicBoolean myInspectionComponentsLoaded = new AtomicBoolean(false);
private boolean myInspectionComponentsLoaded = false;
public void ensureInitialized() {
if (!myInspectionComponentsLoaded.getAndSet(true)) {
private synchronized void ensureInitialized() {
if (!myInspectionComponentsLoaded) {
myInspectionComponentsLoaded = true;
Set<InspectionToolProvider> providers = new THashSet<InspectionToolProvider>();
ContainerUtil.addAll(providers, ApplicationManager.getApplication().getComponents(InspectionToolProvider.class));
ContainerUtil.addAll(providers, Extensions.getExtensions(InspectionToolProvider.EXTENSION_POINT_NAME));
@@ -89,7 +91,7 @@ public class InspectionToolRegistrar {
throw new RuntimeException("unknown inspection class: " + profileEntry + "; "+profileEntry.getClass());
}
public void registerTools(@NotNull InspectionToolProvider[] providers) {
private void registerTools(@NotNull InspectionToolProvider[] providers) {
for (InspectionToolProvider provider : providers) {
Class[] classes = provider.getInspectionClasses();
for (Class aClass : classes) {
@@ -117,7 +119,7 @@ public class InspectionToolRegistrar {
* make sure that it is not too late
*/
@NotNull
public Factory<InspectionToolWrapper> registerInspectionToolFactory(@NotNull Factory<InspectionToolWrapper> factory, boolean store) {
private Factory<InspectionToolWrapper> registerInspectionToolFactory(@NotNull Factory<InspectionToolWrapper> factory, boolean store) {
if (store) {
myInspectionToolFactories.add(factory);
}
@@ -62,7 +62,7 @@ public class ApplicationUtil {
* Note that the process may continue to run in background indefinitely - so <b>avoid using this method unless absolutely needed</b>.
*/
public static <T> T runWithCheckCanceled(@NotNull final Callable<T> callable,
@NotNull final ProgressIndicator indicator, ExecutorService executorService) throws Exception {
@NotNull final ProgressIndicator indicator, @NotNull ExecutorService executorService) throws Exception {
final Ref<T> result = Ref.create();
final Ref<Throwable> error = Ref.create();
@@ -207,6 +207,7 @@ public class LookupTypedHandler extends TypedActionHandlerBase {
@Nullable
private static CharFilter.Result getFiltersDecision(char charTyped, LookupImpl lookup) {
lookup.checkValid();
LookupElement item = lookup.getCurrentItem();
int prefixLength = item == null ? lookup.getAdditionalPrefix().length(): lookup.itemPattern(item).length();
@@ -215,6 +216,9 @@ public class LookupTypedHandler extends TypedActionHandlerBase {
if (result != null) {
return result;
}
if (lookup.isLookupDisposed()) {
throw new AssertionError("Lookup disposed after " + extension);
}
}
return null;
}
@@ -22,13 +22,19 @@ import com.intellij.openapi.editor.EditorCopyPasteHelper;
import com.intellij.openapi.editor.EditorModificationUtil;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.util.Producer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.datatransfer.Transferable;
public abstract class BasePasteHandler extends EditorWriteActionHandler {
public class BasePasteHandler extends EditorWriteActionHandler {
protected Transferable myTransferable;
@Override
public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
return !editor.isViewer();
}
@Override
public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
// We capture the contents to paste here, so it that it won't be affected by possible clipboard operations later (e.g. during unlocking
@@ -17,12 +17,8 @@ package com.intellij.openapi.editor.actions;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -30,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class SimplePasteAction extends EditorAction {
public SimplePasteAction() {
super(new Handler());
super(new BasePasteHandler());
}
@Override
@@ -41,11 +37,4 @@ public class SimplePasteAction extends EditorAction {
presentation.setVisible(presentation.isEnabled());
}
}
private static class Handler extends BasePasteHandler {
@Override
public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
return !editor.isViewer();
}
}
}
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.WeighedFileEditorProvider;
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
@@ -86,6 +87,9 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
if (ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) {
return false;
}
return provider.accept(project, file);
}
})) {
@@ -52,6 +52,7 @@ public class GCUtil {
if (q.poll() != null) {
break;
}
TimeoutUtil.sleep(10);
long bytes = Math.min(Runtime.getRuntime().freeMemory() / 2, Integer.MAX_VALUE);
list.add(new SoftReference<byte[]>(new byte[(int)bytes]));
}
@@ -1558,7 +1558,7 @@ public class StringUtil extends StringUtilRt {
sb.insert(0, units[i]).insert(0, count);
}
else if (remainder > 0) {
sb.append(String.format("%.2f", count + (double)remainder / multipliers[i - 1])).append(units[i]);
sb.append(String.format(Locale.US, "%.2f", count + (double)remainder / multipliers[i - 1])).append(units[i]);
}
return sb.toString();
}
+3
View File
@@ -37,6 +37,9 @@
<add-to-group group-id="RepositoryChangesBrowserToolbar" anchor="last"/>
</action>
<action id="Subversion.TogglePropertiesDiff" class="com.intellij.openapi.actionSystem.EmptyAction" popup="true"
icon="AllIcons.Actions.Preview"/>
<action id="PropertiesDiff" class="org.jetbrains.idea.svn.actions.ShowPropertiesDiffAction" popup="true" icon="SvnIcons.PropertiesDiff">
<add-to-group group-id="RepositoryChangesBrowserToolbar" anchor="last"/>
</action>
@@ -642,6 +642,8 @@ merge.source.details.title=Merge source details for {0} [{1}]
repository.browser.edit.location.dialog.title= Edit Location Url
loading.default.branches.configuration.text=Loading default branches configuration...
loading.data.for.root.text=Loading data for {0}
action.Subversion.TogglePropertiesDiff.text=Show properties
action.Subversion.TogglePropertiesDiff.description=Show differences in SVN properties
action.PropertiesDiff.text=Compare Subversion Properties
action.AlienPropertiesLocalDiff.text=Compare Subversion Properties with Branch
action.IntegrateChangeSetAction.text=Integrate to Branch
@@ -10,9 +10,9 @@ import com.intellij.diff.requests.DiffRequest;
import com.intellij.diff.requests.ErrorDiffRequest;
import com.intellij.diff.tools.ErrorDiffTool;
import com.intellij.diff.util.DiffUtil;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.EmptyAction;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbAware;
@@ -192,6 +192,7 @@ public class SvnDiffViewer implements DiffViewer {
//
private void updatePropertiesPanel() {
boolean wasFocused = myContext.isFocused();
if (!mySettings.isHideProperties()) {
mySplitter.setSecondComponent(myPropertiesViewer.getComponent());
myNotificationPanel.setContent(null);
@@ -200,6 +201,7 @@ public class SvnDiffViewer implements DiffViewer {
mySplitter.setSecondComponent(null);
myNotificationPanel.setContent(createNotification());
}
if (wasFocused) myContext.requestFocus();
}
@NotNull
@@ -278,9 +280,9 @@ public class SvnDiffViewer implements DiffViewer {
// Actions
//
private class ToggleHidePropertiesAction extends ToggleAction implements DumbAware { // TODO: shortcut
private class ToggleHidePropertiesAction extends ToggleAction implements DumbAware {
public ToggleHidePropertiesAction() {
super("Show SVN properties", null, AllIcons.Actions.Preview);
EmptyAction.setupAction(this, "Subversion.TogglePropertiesDiff", null);
}
@Override
@@ -50,8 +50,6 @@ public class DomHighlightingLiteTest extends DomTestCase {
protected void setUp() throws Exception {
super.setUp();
final InspectionToolRegistrar registrar = new InspectionToolRegistrar();
registrar.registerTools(new InspectionToolProvider[0]);
myInspectionProfile = new MockInspectionProfile();
myAnnotationsManager = new DomElementAnnotationsManagerImpl(getProject()) {