diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-30 14:54:39 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-05-30 17:25:18 -0700 |
commit | 7e4b8e9d595e45baa9d87cdb8282f02759e73abc (patch) | |
tree | 2da5fccd6c1e00c972c69323e3cf10df2e5ab264 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java | |
parent | 5ee7da2ae31dcbe781ed81c07f31b31d0a0a7d7f (diff) | |
download | sdk-7e4b8e9d595e45baa9d87cdb8282f02759e73abc.zip sdk-7e4b8e9d595e45baa9d87cdb8282f02759e73abc.tar.gz sdk-7e4b8e9d595e45baa9d87cdb8282f02759e73abc.tar.bz2 |
Fix nullness annotations
Eclipse 4.2 includes analysis support for @Nullable and @NonNull
annotations. However, it requires these annotations to be *repeated*
on every single method implementing or overriding a superclass or
interface method (!).
This changeset basically applies the quickfixes to inline these
annotations. It also changes the retention of our nullness
annotations from source to class, since without this Eclipse believes
that a @NonNull annotation downstream is a redefinition of a @Nullable
annotation.
Finally, the null analysis revealed a dozen or so places where the
nullness annotation was either wrong, or some null checking on
parameters or return values needed to be done.
Change-Id: I43b4e56e2d025a8a4c92a8873f55c13cdbc4c1cb
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java index c51d229..a737251 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridLayoutRule.java @@ -16,7 +16,6 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_COLUMN; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_GRAVITY; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ROW; @@ -30,7 +29,10 @@ import static com.android.ide.common.layout.LayoutConstants.GRAVITY_VALUE_FILL_V import static com.android.ide.common.layout.LayoutConstants.GRAVITY_VALUE_LEFT; import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; import static com.android.ide.common.layout.LayoutConstants.VALUE_TRUE; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; @@ -148,8 +150,10 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public void addLayoutActions(List<RuleAction> actions, final INode parentNode, - final List<? extends INode> children) { + public void addLayoutActions( + @NonNull List<RuleAction> actions, + final @NonNull INode parentNode, + final @NonNull List<? extends INode> children) { super.addLayoutActions(actions, parentNode, children); String namespace = getNamespace(parentNode); @@ -174,11 +178,14 @@ public class GridLayoutRule extends BaseLayoutRule { IMenuCallback actionCallback = new IMenuCallback() { @Override - public void action(final RuleAction action, List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + public void action( + final @NonNull RuleAction action, + @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, + final @Nullable Boolean newValue) { parentNode.editXml("Add/Remove Row/Column", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { String id = action.getId(); if (id.equals(ACTION_SHOW_STRUCTURE)) { sShowStructure = !sShowStructure; @@ -268,15 +275,16 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + @Nullable IDragElement[] elements) { GridDropHandler userData = new GridDropHandler(this, targetNode, targetView); IFeedbackPainter painter = GridLayoutPainter.createDropFeedbackPainter(this, elements); return new DropFeedback(userData, painter); } @Override - public DropFeedback onDropMove(INode targetNode, IDragElement[] elements, - DropFeedback feedback, Point p) { + public DropFeedback onDropMove(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback, @NonNull Point p) { feedback.requestPaint = true; GridDropHandler handler = (GridDropHandler) feedback.userData; @@ -286,8 +294,8 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public void onDropped(final INode targetNode, final IDragElement[] elements, - DropFeedback feedback, Point p) { + public void onDropped(final @NonNull INode targetNode, final @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback, @NonNull Point p) { Rect b = targetNode.getBounds(); if (!b.isValid()) { return; @@ -319,7 +327,8 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public void onChildInserted(INode node, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { if (insertType == InsertType.MOVE_WITHIN) { // Don't adjust widths/heights/weights when just moving within a single layout return; @@ -386,7 +395,7 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public void onRemovingChildren(List<INode> deleted, INode parent) { + public void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent) { super.onRemovingChildren(deleted, parent); // Attempt to clean up spacer objects for any newly-empty rows or columns @@ -521,8 +530,8 @@ public class GridLayoutRule extends BaseLayoutRule { } @Override - public void paintSelectionFeedback(IGraphics graphics, INode parentNode, - List<? extends INode> childNodes, Object view) { + public void paintSelectionFeedback(@NonNull IGraphics graphics, @NonNull INode parentNode, + @NonNull List<? extends INode> childNodes, @Nullable Object view) { super.paintSelectionFeedback(graphics, parentNode, childNodes, view); if (sShowStructure) { @@ -569,7 +578,10 @@ public class GridLayoutRule extends BaseLayoutRule { * approach #3 above. */ @Override - public void onPaste(INode targetNode, Object targetView, IDragElement[] elements) { + public void onPaste( + @NonNull INode targetNode, + @Nullable Object targetView, + @NonNull IDragElement[] elements) { DropFeedback feedback = onDropEnter(targetNode, targetView, elements); if (feedback != null) { Rect b = targetNode.getBounds(); |