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 | |
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')
69 files changed, 567 insertions, 352 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java index 57406d5..d7adbae 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AbsoluteLayoutRule.java @@ -16,11 +16,13 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_X; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_Y; import static com.android.ide.common.layout.LayoutConstants.VALUE_N_DP; +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; @@ -45,7 +47,7 @@ import java.util.Map; public class AbsoluteLayoutRule extends BaseLayoutRule { @Override - public List<String> getSelectionHint(INode parentNode, INode childNode) { + public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode) { List<String> infos = new ArrayList<String>(2); infos.add("AbsoluteLayout is deprecated."); infos.add("Use other layouts instead."); @@ -56,8 +58,8 @@ public class AbsoluteLayoutRule extends BaseLayoutRule { // The AbsoluteLayout accepts any drag'n'drop anywhere on its surface. @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, - final IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + final @Nullable IDragElement[] elements) { if (elements.length == 0) { return null; @@ -65,7 +67,8 @@ public class AbsoluteLayoutRule extends BaseLayoutRule { DropFeedback df = new DropFeedback(null, new IFeedbackPainter() { @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { // Paint callback for the AbsoluteLayout. // This is called by the canvas when a draw is needed. drawFeedback(gc, node, elements, feedback); @@ -128,8 +131,8 @@ public class AbsoluteLayoutRule extends BaseLayoutRule { } @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) { // Update the data used by the DropFeedback.paintCallback above. feedback.userData = p; feedback.requestPaint = true; @@ -138,13 +141,14 @@ public class AbsoluteLayoutRule extends BaseLayoutRule { } @Override - public void onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback) { + public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback) { // Nothing to do. } @Override - public void onDropped(final INode targetNode, final IDragElement[] elements, - final DropFeedback feedback, final Point p) { + public void onDropped(final @NonNull INode targetNode, final @NonNull IDragElement[] elements, + final @Nullable DropFeedback feedback, final @NonNull Point p) { final Rect b = targetNode.getBounds(); if (!b.isValid()) { @@ -158,7 +162,7 @@ public class AbsoluteLayoutRule extends BaseLayoutRule { targetNode.editXml("Add elements to AbsoluteLayout", new INodeHandler() { @Override - public void handle(INode node) { + public void handle(@NonNull INode node) { boolean first = true; Point offset = null; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AdapterViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AdapterViewRule.java index 5b23e34..28f5fc9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AdapterViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/AdapterViewRule.java @@ -15,6 +15,8 @@ */ package com.android.ide.common.layout; +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; @@ -27,12 +29,14 @@ import com.android.ide.common.api.Rect; /** Rule for AdapterView subclasses that don't have more specific rules */ public class AdapterViewRule extends BaseLayoutRule { @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + @Nullable IDragElement[] elements) { // You are not allowed to insert children into AdapterViews; you must // use the dedicated addView methods etc dynamically DropFeedback dropFeedback = new DropFeedback(null, new IFeedbackPainter() { @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { Rect b = node.getBounds(); if (b.isValid()) { gc.useStyle(DrawingStyle.DROP_RECIPIENT); @@ -50,8 +54,8 @@ public class AdapterViewRule extends BaseLayoutRule { } @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.invalidTarget = true; return feedback; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java index 581788b..6f76b51 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.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_ID; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ABOVE; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE; @@ -52,7 +51,10 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_Y; import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT; import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT; import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; +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.IAttributeInfo; @@ -114,11 +116,13 @@ public class BaseLayoutRule extends BaseViewRule { IMenuCallback actionCallback = new IMenuCallback() { @Override - public void action(RuleAction action, List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + public void action(@NonNull RuleAction action, + @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, + final @Nullable Boolean newValue) { parentNode.editXml("Change Margins", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { String uri = ANDROID_URI; String all = first.getStringAttr(uri, ATTR_LAYOUT_MARGIN); String left = first.getStringAttr(uri, ATTR_LAYOUT_MARGIN_LEFT); @@ -154,8 +158,8 @@ public class BaseLayoutRule extends BaseViewRule { final INode first = targets.get(0); ChoiceProvider provider = new ChoiceProvider() { @Override - public void addChoices(List<String> titles, List<URL> iconUrls, - List<String> ids) { + public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls, + @NonNull List<String> ids) { IAttributeInfo info = first.getAttributeInfo(ANDROID_URI, attributeName); if (info != null) { // Generate list of possible gravity value constants @@ -180,8 +184,10 @@ public class BaseLayoutRule extends BaseViewRule { } @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); final List<? extends INode> targets = children == null || children.size() == 0 ? @@ -192,8 +198,11 @@ public class BaseLayoutRule extends BaseViewRule { // Shared action callback IMenuCallback actionCallback = new IMenuCallback() { @Override - public void action(RuleAction action, List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + public void action( + @NonNull RuleAction action, + @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, + final @Nullable Boolean newValue) { final String actionId = action.getId(); final String undoLabel; if (actionId.equals(ACTION_FILL_WIDTH)) { @@ -205,7 +214,7 @@ public class BaseLayoutRule extends BaseViewRule { } parentNode.editXml(undoLabel, new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { String attribute = actionId.equals(ACTION_FILL_WIDTH) ? ATTR_LAYOUT_WIDTH : ATTR_LAYOUT_HEIGHT; String value; @@ -244,7 +253,8 @@ public class BaseLayoutRule extends BaseViewRule { * Derived layouts should override this behavior if not appropriate. */ @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) { Point p = targetNode.getBounds().getTopLeft(); @@ -576,7 +586,7 @@ public class BaseLayoutRule extends BaseViewRule { targetNode.editXml("Insert Elements", new INodeHandler() { @Override - public void handle(INode node) { + public void handle(@NonNull INode node) { // Now write the new elements. int insertPos = initialInsertPos; for (IDragElement element : elements) { @@ -606,9 +616,9 @@ public class BaseLayoutRule extends BaseViewRule { } @Override - public DropFeedback onResizeBegin(INode child, INode parent, - SegmentType horizontalEdge, SegmentType verticalEdge, - Object childView, Object parentView) { + public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, + @Nullable SegmentType horizontalEdge, @Nullable SegmentType verticalEdge, + @Nullable Object childView, @Nullable Object parentView) { ResizeState state = createResizeState(parent, parentView, child); state.horizontalEdgeType = horizontalEdge; state.verticalEdgeType = verticalEdge; @@ -618,7 +628,8 @@ public class BaseLayoutRule extends BaseViewRule { Map<INode, Rect> sizes = mRulesEngine.measureChildren(parent, new IClientRulesEngine.AttributeFilter() { @Override - public String getAttribute(INode node, String namespace, String localName) { + public String getAttribute(@NonNull INode node, @Nullable String namespace, + @NonNull String localName) { // Change attributes to wrap_content if (ATTR_LAYOUT_WIDTH.equals(localName) && SdkConstants.NS_RESOURCES.equals(namespace)) { @@ -638,7 +649,8 @@ public class BaseLayoutRule extends BaseViewRule { return new DropFeedback(state, new IFeedbackPainter() { @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { ResizeState resizeState = (ResizeState) feedback.userData; if (resizeState != null && resizeState.bounds != null) { paintResizeFeedback(gc, node, resizeState); @@ -737,8 +749,8 @@ public class BaseLayoutRule extends BaseViewRule { } @Override - public void onResizeUpdate(DropFeedback feedback, INode child, INode parent, - Rect newBounds, int modifierMask) { + public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child, + @NonNull INode parent, @NonNull Rect newBounds, int modifierMask) { ResizeState state = (ResizeState) feedback.userData; state.bounds = newBounds; state.modifierMask = modifierMask; @@ -799,14 +811,14 @@ public class BaseLayoutRule extends BaseViewRule { } @Override - public void onResizeEnd(DropFeedback feedback, INode child, final INode parent, - final Rect newBounds) { + public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child, + final @NonNull INode parent, final @NonNull Rect newBounds) { final Rect oldBounds = child.getBounds(); if (oldBounds.w != newBounds.w || oldBounds.h != newBounds.h) { final ResizeState state = (ResizeState) feedback.userData; child.editXml("Resize", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { setNewSizeBounds(state, n, parent, oldBounds, newBounds, state.horizontalEdgeType, state.verticalEdgeType); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java index 507bed5..4cc5f5e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseViewRule.java @@ -94,7 +94,7 @@ public class BaseViewRule extends AbstractViewRule { new HashMap<String, Map<String, Prop>>(); @Override - public boolean onInitialize(String fqcn, IClientRulesEngine engine) { + public boolean onInitialize(@NonNull String fqcn, @NonNull IClientRulesEngine engine) { this.mRulesEngine = engine; // This base rule can handle any class so we don't need to filter on @@ -124,7 +124,8 @@ public class BaseViewRule extends AbstractViewRule { * - List of all other simple toggle attributes. */ @Override - public void addContextMenuActions(List<RuleAction> actions, final INode selectedNode) { + public void addContextMenuActions(@NonNull List<RuleAction> actions, + final @NonNull INode selectedNode) { String width = null; String currentWidth = selectedNode.getStringAttr(ANDROID_URI, ATTR_LAYOUT_WIDTH); @@ -155,9 +156,9 @@ public class BaseViewRule extends AbstractViewRule { final IMenuCallback onChange = new IMenuCallback() { @Override public void action( - final RuleAction action, - final List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + final @NonNull RuleAction action, + final @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, final @Nullable Boolean newValue) { String fullActionId = action.getId(); boolean isProp = fullActionId.startsWith(PROP_PREFIX); final String actionId = isProp ? @@ -425,14 +426,14 @@ public class BaseViewRule extends AbstractViewRule { onChange /*callback*/, null /*icon*/, 50, true /*supportsMultipleNodes*/, new ActionProvider() { @Override - public List<RuleAction> getNestedActions(INode node) { + public @NonNull List<RuleAction> getNestedActions(@NonNull INode node) { List<RuleAction> propertyActionTypes = new ArrayList<RuleAction>(); propertyActionTypes.add(RuleAction.createChoices( "recent", "Recent", //$NON-NLS-1$ onChange /*callback*/, null /*icon*/, 10, true /*supportsMultipleNodes*/, new ActionProvider() { @Override - public List<RuleAction> getNestedActions(INode n) { + public @NonNull List<RuleAction> getNestedActions(@NonNull INode n) { List<RuleAction> propertyActions = new ArrayList<RuleAction>(); addRecentPropertyActions(propertyActions, n, onChange); return propertyActions; @@ -449,7 +450,7 @@ public class BaseViewRule extends AbstractViewRule { onChange /*callback*/, null /*icon*/, 60, true /*supportsMultipleNodes*/, new ActionProvider() { @Override - public List<RuleAction> getNestedActions(INode n) { + public @NonNull List<RuleAction> getNestedActions(@NonNull INode n) { List<RuleAction> propertyActions = new ArrayList<RuleAction>(); addPropertyActions(propertyActions, n, onChange, null, true); return propertyActions; @@ -463,7 +464,7 @@ public class BaseViewRule extends AbstractViewRule { onChange /*callback*/, null /*icon*/, 80, true /*supportsMultipleNodes*/, new ActionProvider() { @Override - public List<RuleAction> getNestedActions(INode n) { + public @NonNull List<RuleAction> getNestedActions(@NonNull INode n) { List<RuleAction> propertyActions = new ArrayList<RuleAction>(); addPropertyActions(propertyActions, n, onChange, null, false); return propertyActions; @@ -527,7 +528,7 @@ public class BaseViewRule extends AbstractViewRule { onChange /*callback*/, null /*icon*/, sortPriority++, true /*supportsMultipleNodes*/, new ActionProvider() { @Override - public List<RuleAction> getNestedActions(INode n) { + public @NonNull List<RuleAction> getNestedActions(@NonNull INode n) { List<RuleAction> propertyActions = new ArrayList<RuleAction>(); addPropertyActions(propertyActions, n, onChange, definedBy, false); return propertyActions; @@ -744,7 +745,8 @@ public class BaseViewRule extends AbstractViewRule { */ private static ChoiceProvider BOOLEAN_CHOICE_PROVIDER = new ChoiceProvider() { @Override - public void addChoices(List<String> titles, List<URL> iconUrls, List<String> ids) { + public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls, + @NonNull List<String> ids) { titles.add("True"); ids.add(TRUE_ID); @@ -772,7 +774,8 @@ public class BaseViewRule extends AbstractViewRule { } @Override - public void addChoices(List<String> titles, List<URL> iconUrls, List<String> ids) { + public void addChoices(@NonNull List<String> titles, @NonNull List<URL> iconUrls, + @NonNull List<String> ids) { for (Entry<String, String> entry : mProperty.getChoices().entrySet()) { ids.add(entry.getKey()); titles.add(entry.getValue()); @@ -888,7 +891,8 @@ public class BaseViewRule extends AbstractViewRule { * an indication of where to paste. */ @Override - public void onPaste(INode targetNode, Object targetView, IDragElement[] elements) { + public void onPaste(@NonNull INode targetNode, @Nullable Object targetView, + @NonNull IDragElement[] elements) { // INode parent = targetNode.getParent(); if (parent != null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/CalendarViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/CalendarViewRule.java index c580d8a..c509b95 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/CalendarViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/CalendarViewRule.java @@ -16,10 +16,11 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -30,7 +31,8 @@ import com.android.ide.common.api.InsertType; public class CalendarViewRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); // CalendarViews need a lot of space, and the wrapping doesn't seem to work diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java index e7a129b..86855ae 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/DialerFilterRule.java @@ -16,13 +16,14 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_BELOW; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; import static com.android.ide.common.layout.LayoutConstants.FQCN_EDIT_TEXT; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -33,7 +34,8 @@ import com.android.ide.common.api.InsertType; public class DialerFilterRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); // A DialerFilter requires a couple of nested EditTexts with fixed ids: diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java index 875756b..dc60086 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/EditTextRule.java @@ -16,10 +16,12 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_EMS; import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.REQUEST_FOCUS; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; @@ -35,7 +37,8 @@ import java.util.List; public class EditTextRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (parent != null) { @@ -57,7 +60,8 @@ public class EditTextRule extends BaseViewRule { * Adds a "Request Focus" menu item. */ @Override - public void addContextMenuActions(List<RuleAction> actions, final INode selectedNode) { + public void addContextMenuActions(@NonNull List<RuleAction> actions, + final @NonNull INode selectedNode) { super.addContextMenuActions(actions, selectedNode); final boolean hasFocus = hasFocus(selectedNode); @@ -65,11 +69,14 @@ public class EditTextRule extends BaseViewRule { IMenuCallback onChange = new IMenuCallback() { @Override - public void action(RuleAction menuAction, List<? extends INode> selectedNodes, - String valueId, Boolean newValue) { + public void action( + @NonNull RuleAction menuAction, + @NonNull List<? extends INode> selectedNodes, + @Nullable String valueId, + @Nullable Boolean newValue) { selectedNode.editXml(label, new INodeHandler() { @Override - public void handle(INode node) { + public void handle(@NonNull INode node) { INode focus = findFocus(findRoot(node)); if (focus != null && focus.getParent() != null) { focus.getParent().removeChild(focus); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FragmentRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FragmentRule.java index fdef082..533795d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FragmentRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FragmentRule.java @@ -15,9 +15,10 @@ */ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_NAME; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -27,7 +28,8 @@ import com.android.ide.common.api.InsertType; */ public class FragmentRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { // When dropping a fragment tag, ask the user which layout to include. if (insertType == InsertType.CREATE) { // NOT InsertType.CREATE_PREVIEW String fqcn = mRulesEngine.displayFragmentSourceInput(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java index 8a93fef..bbe4f1d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/FrameLayoutRule.java @@ -16,11 +16,13 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_GRAVITY; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +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; @@ -50,15 +52,16 @@ public class FrameLayoutRule extends BaseLayoutRule { // The FrameLayout accepts any drag'n'drop anywhere on its surface. @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, - final IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + final @Nullable IDragElement[] elements) { if (elements.length == 0) { return null; } return new DropFeedback(null, new IFeedbackPainter() { @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { drawFeedback(gc, node, elements, feedback); } }); @@ -113,21 +116,22 @@ public class FrameLayoutRule extends BaseLayoutRule { } @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.userData = p; feedback.requestPaint = true; return feedback; } @Override - public void onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback) { + public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback) { // ignore } @Override - public void onDropped(final INode targetNode, final IDragElement[] elements, - final DropFeedback feedback, final Point p) { + public void onDropped(final @NonNull INode targetNode, final @NonNull IDragElement[] elements, + final @Nullable DropFeedback feedback, final @NonNull Point p) { Rect b = targetNode.getBounds(); if (!b.isValid()) { return; @@ -141,7 +145,7 @@ public class FrameLayoutRule extends BaseLayoutRule { targetNode.editXml("Add elements to FrameLayout", new INodeHandler() { @Override - public void handle(INode node) { + public void handle(@NonNull INode node) { // Now write the new elements. for (IDragElement element : elements) { @@ -159,8 +163,10 @@ public class FrameLayoutRule 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); actions.add(RuleAction.createSeparator(25)); actions.add(createMarginAction(parentNode, children)); @@ -170,7 +176,8 @@ public class FrameLayoutRule extends BaseLayoutRule { } @Override - public void onChildInserted(INode node, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { // Look at the fill preferences and fill embedded layouts etc String fqcn = node.getFqcn(); IViewMetadata metadata = mRulesEngine.getMetadata(fqcn); 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(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridViewRule.java index bc3de5e..7eb3474 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/GridViewRule.java @@ -16,10 +16,11 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.ATTR_NUM_COLUMNS; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -30,7 +31,8 @@ import com.android.ide.common.api.InsertType; public class GridViewRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); node.setAttribute(ANDROID_URI, ATTR_LAYOUT_WIDTH, getFillParentValueName()); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java index b2ea435..e7be263 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/HorizontalScrollViewRule.java @@ -16,13 +16,15 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.ATTR_ORIENTATION; import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; +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; @@ -39,7 +41,8 @@ import com.android.ide.common.api.Rect; public class HorizontalScrollViewRule extends FrameLayoutRule { @Override - public void onChildInserted(INode child, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, + @NonNull InsertType insertType) { super.onChildInserted(child, parent, insertType); // The child of the ScrollView should fill in both directions @@ -49,7 +52,8 @@ public class HorizontalScrollViewRule extends FrameLayoutRule { } @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { @@ -62,8 +66,8 @@ public class HorizontalScrollViewRule extends FrameLayoutRule { } @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) { DropFeedback f = super.onDropMove(targetNode, elements, feedback, p); // HorizontalScrollViews only allow a single child diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IgnoredLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IgnoredLayoutRule.java index 999c6a0..3a65a86 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IgnoredLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IgnoredLayoutRule.java @@ -16,6 +16,8 @@ package com.android.ide.common.layout; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.INode; @@ -32,7 +34,8 @@ import com.android.ide.common.api.INode; */ public abstract class IgnoredLayoutRule extends BaseLayoutRule { @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + @Nullable IDragElement[] elements) { // Do nothing; this layout rule corresponds to a layout that // should not be handled as a layout by the visual editor - usually // because some widget is extending a layout for implementation purposes diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java index e1afb56..364a3b6 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageButtonRule.java @@ -16,9 +16,10 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -29,7 +30,8 @@ import com.android.ide.common.api.InsertType; public class ImageButtonRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); // When dropping an include tag, ask the user which layout to include. diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java index b255c14..08ef17c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ImageViewRule.java @@ -16,9 +16,10 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -29,7 +30,8 @@ import com.android.ide.common.api.InsertType; public class ImageViewRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); // When dropping an include tag, ask the user which layout to include. diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IncludeRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IncludeRule.java index a451257..978455a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IncludeRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/IncludeRule.java @@ -17,6 +17,7 @@ package com.android.ide.common.layout; import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.ATTR_LAYOUT; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -26,7 +27,8 @@ import com.android.ide.common.api.InsertType; */ public class IncludeRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { // When dropping an include tag, ask the user which layout to include. if (insertType == InsertType.CREATE) { // NOT InsertType.CREATE_PREVIEW String include = mRulesEngine.displayIncludeSourceInput(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java index 8f8ea02..04373e1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/LinearLayoutRule.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_BASELINE_ALIGNED; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_GRAVITY; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; @@ -29,7 +28,10 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_HORIZONTAL; import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL; import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; import static com.android.ide.common.layout.LayoutConstants.VALUE_ZERO_DP; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.annotations.VisibleForTesting; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; @@ -123,8 +125,10 @@ public class LinearLayoutRule 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); if (supportsOrientation()) { Choices action = RuleAction.createChoices( @@ -146,7 +150,7 @@ public class LinearLayoutRule extends BaseLayoutRule { if (!isVertical(parentNode)) { String current = parentNode.getStringAttr(ANDROID_URI, ATTR_BASELINE_ALIGNED); boolean isAligned = current == null || Boolean.valueOf(current); - actions.add(RuleAction.createToggle(null, "Toggle Baseline Alignment", + actions.add(RuleAction.createToggle(ACTION_BASELINE, "Toggle Baseline Alignment", isAligned, new PropertyCallback(Collections.singletonList(parentNode), "Change Baseline Alignment", @@ -167,11 +171,14 @@ public class LinearLayoutRule extends BaseLayoutRule { // Weights 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("Change Weight", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { String id = action.getId(); if (id.equals(ACTION_WEIGHT)) { String weight = @@ -266,8 +273,8 @@ public class LinearLayoutRule extends BaseLayoutRule { // ==== Drag'n'drop support ==== @Override - public DropFeedback onDropEnter(final INode targetNode, Object targetView, - final IDragElement[] elements) { + public DropFeedback onDropEnter(final @NonNull INode targetNode, @Nullable Object targetView, + final @Nullable IDragElement[] elements) { if (elements.length == 0) { return null; @@ -345,7 +352,8 @@ public class LinearLayoutRule extends BaseLayoutRule { new IFeedbackPainter() { @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { // Paint callback for the LinearLayout. This is called // by the canvas when a draw is needed. drawFeedback(gc, node, elements, feedback); @@ -466,8 +474,8 @@ public class LinearLayoutRule extends BaseLayoutRule { } @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) { Rect b = targetNode.getBounds(); if (!b.isValid()) { return feedback; @@ -532,13 +540,14 @@ public class LinearLayoutRule extends BaseLayoutRule { } @Override - public void onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback) { + public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback) { // ignore } @Override - public void onDropped(final INode targetNode, final IDragElement[] elements, - final DropFeedback feedback, final Point p) { + public void onDropped(final @NonNull INode targetNode, final @NonNull IDragElement[] elements, + final @Nullable DropFeedback feedback, final @NonNull Point p) { LinearDropData data = (LinearDropData) feedback.userData; final int initialInsertPos = data.getInsertPos(); @@ -546,7 +555,8 @@ public class LinearLayoutRule 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 // LinearLayout @@ -775,7 +785,8 @@ public class LinearLayoutRule extends BaseLayoutRule { unweightedSizes = mRulesEngine.measureChildren(layout, new IClientRulesEngine.AttributeFilter() { @Override - public String getAttribute(INode n, String namespace, String localName) { + public String getAttribute(@NonNull INode n, @Nullable String namespace, + @NonNull String localName) { // Clear out layout weights; we need to measure the unweighted sizes // of the children if (ATTR_LAYOUT_WEIGHT.equals(localName) diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java index 7420714..4088ab8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ListViewRule.java @@ -16,9 +16,10 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -32,7 +33,8 @@ import com.android.ide.common.api.InsertType; public class ListViewRule extends AdapterViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); node.setAttribute(ANDROID_URI, ATTR_LAYOUT_WIDTH, getFillParentValueName()); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java index b6d0ba2..c2e78a4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MapViewRule.java @@ -18,6 +18,7 @@ package com.android.ide.common.layout; import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -31,7 +32,8 @@ import com.android.ide.common.api.InsertType; public class MapViewRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java index 12358f9..9cef9c4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java @@ -16,6 +16,7 @@ package com.android.ide.common.layout; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.RuleAction; @@ -29,7 +30,8 @@ public class MergeRule extends FrameLayoutRule { // on top of each other at (0,0) @Override - public void addContextMenuActions(List<RuleAction> actions, final INode selectedNode) { + public void addContextMenuActions(@NonNull List<RuleAction> actions, + final @NonNull INode selectedNode) { // Deliberately ignore super.getContextMenu(); we don't want to attempt to list // properties for the <merge> tag } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java index ac1635c..da2614e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertyCallback.java @@ -16,6 +16,8 @@ package com.android.ide.common.layout; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IMenuCallback; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; @@ -54,8 +56,8 @@ public class PropertyCallback implements IMenuCallback { // ---- Implements IMenuCallback ---- @Override - public void action(RuleAction action, List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + public void action(@NonNull RuleAction action, @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, final @Nullable Boolean newValue) { if (mTargetNodes != null && mTargetNodes.size() > 0) { selectedNodes = mTargetNodes; } @@ -65,7 +67,7 @@ public class PropertyCallback implements IMenuCallback { final List<? extends INode> nodes = selectedNodes; selectedNodes.get(0).editXml(mUndoLabel, new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { for (INode targetNode : nodes) { if (valueId != null) { targetNode.setAttribute(mUri, mAttribute, valueId); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertySettingNodeHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertySettingNodeHandler.java index ad3ddad..13c8842 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertySettingNodeHandler.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/PropertySettingNodeHandler.java @@ -15,6 +15,7 @@ */ package com.android.ide.common.layout; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; @@ -35,7 +36,7 @@ class PropertySettingNodeHandler implements INodeHandler { } @Override - public void handle(INode node) { + public void handle(@NonNull INode node) { node.setAttribute(mNamespaceUri, mAttribute, mValue); } }
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/QuickContactBadgeRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/QuickContactBadgeRule.java index f6372fd..0164794 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/QuickContactBadgeRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/QuickContactBadgeRule.java @@ -15,6 +15,7 @@ */ package com.android.ide.common.layout; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -24,7 +25,8 @@ import com.android.ide.common.api.InsertType; */ public class QuickContactBadgeRule extends ImageViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { // Deliberately override onCreate such that we don't populate a default // image; at design time layoutlib will supply the system default contacts // image. diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RadioGroupRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RadioGroupRule.java index 280019e..5ae0e92 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RadioGroupRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RadioGroupRule.java @@ -15,11 +15,12 @@ */ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_CHECKED; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; 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.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -30,7 +31,8 @@ import com.android.ide.common.api.InsertType; */ public class RadioGroupRule extends LinearLayoutRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java index f587bef..e9cd5d5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/RelativeLayoutRule.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_GRAVITY; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_ABOVE; @@ -40,7 +39,10 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_TO_RIGHT import static com.android.ide.common.layout.LayoutConstants.ID_PREFIX; import static com.android.ide.common.layout.LayoutConstants.NEW_ID_PREFIX; 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.DropFeedback; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.IGraphics; @@ -93,7 +95,7 @@ public class RelativeLayoutRule extends BaseLayoutRule { // ==== Selection ==== @Override - public List<String> getSelectionHint(INode parentNode, INode childNode) { + public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode) { List<String> infos = new ArrayList<String>(18); addAttr(ATTR_LAYOUT_ABOVE, childNode, infos); addAttr(ATTR_LAYOUT_BELOW, childNode, infos); @@ -131,8 +133,8 @@ public class RelativeLayoutRule 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); boolean showDependents = true; @@ -150,14 +152,15 @@ public class RelativeLayoutRule extends BaseLayoutRule { // ==== Drag'n'drop support ==== @Override - public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + @Nullable IDragElement[] elements) { return new DropFeedback(new MoveHandler(targetNode, elements, mRulesEngine), new GuidelinePainter()); } @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) { if (elements == null || elements.length == 0) { return null; } @@ -174,12 +177,13 @@ public class RelativeLayoutRule extends BaseLayoutRule { } @Override - public void onDropLeave(INode targetNode, IDragElement[] elements, DropFeedback feedback) { + public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback) { } @Override - public void onDropped(final INode targetNode, final IDragElement[] elements, - final DropFeedback feedback, final Point p) { + public void onDropped(final @NonNull INode targetNode, final @NonNull IDragElement[] elements, + final @Nullable DropFeedback feedback, final @NonNull Point p) { final MoveHandler state = (MoveHandler) feedback.userData; final Map<String, Pair<String, String>> idMap = getDropIdMap(targetNode, elements, @@ -187,7 +191,7 @@ public class RelativeLayoutRule extends BaseLayoutRule { targetNode.editXml("Dropped", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { int index = -1; // Remove cycles @@ -235,7 +239,8 @@ public class RelativeLayoutRule extends BaseLayoutRule { } @Override - public void onChildInserted(INode node, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { // TODO: Handle more generically some way to ensure that widgets with no // intrinsic size get some minimum size until they are attached on multiple // opposing sides. @@ -246,7 +251,7 @@ public class RelativeLayoutRule 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); // Remove any attachments pointing to the deleted nodes. @@ -286,29 +291,30 @@ public class RelativeLayoutRule extends BaseLayoutRule { // ==== Resize Support ==== @Override - public DropFeedback onResizeBegin(INode child, INode parent, - SegmentType horizontalEdgeType, SegmentType verticalEdgeType, - Object childView, Object parentView) { + public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, + @Nullable SegmentType horizontalEdgeType, @Nullable SegmentType verticalEdgeType, + @Nullable Object childView, @Nullable Object parentView) { ResizeHandler state = new ResizeHandler(parent, child, mRulesEngine, horizontalEdgeType, verticalEdgeType); return new DropFeedback(state, new GuidelinePainter()); } @Override - public void onResizeUpdate(DropFeedback feedback, INode child, INode parent, Rect newBounds, + public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child, + @NonNull INode parent, @NonNull Rect newBounds, int modifierMask) { ResizeHandler state = (ResizeHandler) feedback.userData; state.updateResize(feedback, child, newBounds, modifierMask); } @Override - public void onResizeEnd(DropFeedback feedback, INode child, INode parent, - final Rect newBounds) { + public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child, + @NonNull INode parent, final @NonNull Rect newBounds) { final ResizeHandler state = (ResizeHandler) feedback.userData; child.editXml("Resize", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { state.removeCycles(); state.applyConstraints(n); } @@ -318,8 +324,10 @@ public class RelativeLayoutRule extends BaseLayoutRule { // ==== Layout Actions Bar ==== @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); actions.add(createGravityAction(Collections.<INode>singletonList(parentNode), @@ -329,13 +337,15 @@ public class RelativeLayoutRule extends BaseLayoutRule { IMenuCallback callback = new IMenuCallback() { @Override - public void action(RuleAction action, List<? extends INode> selectedNodes, - final String valueId, final Boolean newValue) { + public void action(@NonNull RuleAction action, + @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, + final @Nullable Boolean newValue) { final String id = action.getId(); if (id.equals(ACTION_CENTER_VERTICAL)|| id.equals(ACTION_CENTER_HORIZONTAL)) { parentNode.editXml("Center", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { if (id.equals(ACTION_CENTER_VERTICAL)) { for (INode child : children) { centerVertically(child); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java index 2114f39..1296c76 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ScrollViewRule.java @@ -16,11 +16,13 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; +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; @@ -37,7 +39,8 @@ import com.android.ide.common.api.Rect; public class ScrollViewRule extends FrameLayoutRule { @Override - public void onChildInserted(INode child, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, + @NonNull InsertType insertType) { super.onChildInserted(child, parent, insertType); // The child of the ScrollView should fill in both directions @@ -47,7 +50,8 @@ public class ScrollViewRule extends FrameLayoutRule { } @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { @@ -59,8 +63,8 @@ public class ScrollViewRule extends FrameLayoutRule { } @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) { DropFeedback f = super.onDropMove(targetNode, elements, feedback, p); // ScrollViews only allow a single child diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java index c65dec9..7c26859 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SeekBarRule.java @@ -16,9 +16,10 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -29,7 +30,8 @@ import com.android.ide.common.api.InsertType; public class SeekBarRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); // A SeekBar isn't useful with wrap_content because it packs itself down to diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SlidingDrawerRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SlidingDrawerRule.java index 73a5031..12ab448 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SlidingDrawerRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/SlidingDrawerRule.java @@ -15,14 +15,15 @@ */ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_CONTENT; import static com.android.ide.common.layout.LayoutConstants.ATTR_HANDLE; import static com.android.ide.common.layout.LayoutConstants.ATTR_ID; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -34,7 +35,8 @@ import com.android.ide.common.api.InsertType; public class SlidingDrawerRule extends BaseLayoutRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java index 099a760..6724392 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TabHostRule.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_ID; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; @@ -26,7 +25,9 @@ import static com.android.ide.common.layout.LayoutConstants.FQCN_LINEAR_LAYOUT; import static com.android.ide.common.layout.LayoutConstants.FQCN_TAB_WIDGET; import static com.android.ide.common.layout.LayoutConstants.VALUE_VERTICAL; import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -40,7 +41,8 @@ public class TabHostRule extends IgnoredLayoutRule { // the child elements yourself, e.g. via addTab() etc. @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java index ceb562d..b2cb1e4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableLayoutRule.java @@ -17,6 +17,8 @@ package com.android.ide.common.layout; import static com.android.ide.common.layout.LayoutConstants.FQCN_TABLE_ROW; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IClientRulesEngine; import com.android.ide.common.api.IMenuCallback; @@ -60,7 +62,8 @@ public class TableLayoutRule extends LinearLayoutRule { } @Override - public void onChildInserted(INode child, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, + @NonNull InsertType insertType) { // Overridden to inhibit the setting of layout_width/layout_height since // it should always be match_parent } @@ -69,13 +72,17 @@ public class TableLayoutRule extends LinearLayoutRule { * Add an explicit "Add Row" action to the context menu */ @Override - public void addContextMenuActions(List<RuleAction> actions, final INode selectedNode) { + public void addContextMenuActions(@NonNull List<RuleAction> actions, + final @NonNull INode selectedNode) { super.addContextMenuActions(actions, selectedNode); IMenuCallback addTab = new IMenuCallback() { @Override - public void action(RuleAction action, List<? extends INode> selectedNodes, - final String valueId, Boolean newValue) { + public void action( + @NonNull RuleAction action, + @NonNull List<? extends INode> selectedNodes, + final @Nullable String valueId, + @Nullable Boolean newValue) { final INode node = selectedNode; INode newRow = node.appendChild(FQCN_TABLE_ROW); mRulesEngine.select(Collections.singletonList(newRow)); @@ -85,8 +92,10 @@ public class TableLayoutRule extends LinearLayoutRule { } @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); addTableLayoutActions(mRulesEngine, actions, parentNode, children); } @@ -99,11 +108,14 @@ public class TableLayoutRule extends LinearLayoutRule { final List<? extends INode> children) { 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 Table Row", new INodeHandler() { @Override - public void handle(INode n) { + public void handle(@NonNull INode n) { if (action.getId().equals(ACTION_ADD_ROW)) { // Determine the index of the selection, if any; if there is // a selection, insert the row before the current row, otherwise @@ -171,7 +183,8 @@ public class TableLayoutRule extends LinearLayoutRule { } @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { @@ -183,8 +196,9 @@ public class TableLayoutRule extends LinearLayoutRule { } @Override - public DropFeedback onResizeBegin(INode child, INode parent, SegmentType horizontalEdge, - SegmentType verticalEdge, Object childView, Object parentView) { + public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, + @Nullable SegmentType horizontalEdge, @Nullable SegmentType verticalEdge, + @Nullable Object childView, @Nullable Object parentView) { // Children of a table layout cannot set their widths (it is controlled by column // settings on the table). They can set their heights (though for TableRow, the // height is always wrap_content). diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableRowRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableRowRule.java index f372866..af6f7a0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableRowRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/TableRowRule.java @@ -17,6 +17,8 @@ package com.android.ide.common.layout; import static com.android.ide.common.layout.LayoutConstants.FQCN_TABLE_LAYOUT; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; @@ -41,15 +43,18 @@ public class TableRowRule extends LinearLayoutRule { } @Override - public void onChildInserted(INode child, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, + @NonNull InsertType insertType) { // Overridden to inhibit the setting of layout_width/layout_height since // the table row will enforce match_parent and wrap_content for width and height // respectively. } @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); // Also apply table-specific actions on the table row such that you can @@ -65,8 +70,9 @@ public class TableRowRule extends LinearLayoutRule { } @Override - public DropFeedback onResizeBegin(INode child, INode parent, SegmentType horizontalEdge, - SegmentType verticalEdge, Object childView, Object parentView) { + public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, + @Nullable SegmentType horizontalEdge, @Nullable SegmentType verticalEdge, + @Nullable Object childView, @Nullable Object parentView) { // No resizing in TableRows; the width is *always* match_parent and the height is // *always* wrap_content. return null; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/WebViewRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/WebViewRule.java index 5224df0..b2c8413 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/WebViewRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/WebViewRule.java @@ -16,10 +16,11 @@ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.IViewRule; import com.android.ide.common.api.InsertType; @@ -32,7 +33,8 @@ public class WebViewRule extends IgnoredLayoutRule { // into; it's an AbsoluteLayout for implementation purposes. @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ZoomButtonRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ZoomButtonRule.java index 5714392..3456fb9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ZoomButtonRule.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/ZoomButtonRule.java @@ -15,15 +15,17 @@ */ package com.android.ide.common.layout; -import static com.android.util.XmlUtils.ANDROID_URI; import static com.android.ide.common.layout.LayoutConstants.ATTR_SRC; +import static com.android.util.XmlUtils.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode; import com.android.ide.common.api.InsertType; public class ZoomButtonRule extends BaseViewRule { @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { super.onCreate(node, parent, insertType); if (insertType.isCreate()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridLayoutPainter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridLayoutPainter.java index 3a73558..461ca2b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridLayoutPainter.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/grid/GridLayoutPainter.java @@ -19,6 +19,7 @@ import static com.android.ide.common.layout.GridLayoutRule.GRID_SIZE; import static com.android.ide.common.layout.GridLayoutRule.MARGIN_SIZE; import static com.android.ide.common.layout.grid.GridModel.UNDEFINED; +import com.android.annotations.NonNull; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IDragElement; @@ -127,7 +128,8 @@ public class GridLayoutPainter { // Implements IFeedbackPainter @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, + @NonNull DropFeedback feedback) { Rect b = node.getBounds(); if (!b.isValid()) { return; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelinePainter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelinePainter.java index b37a6ed..46038ee 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelinePainter.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelinePainter.java @@ -23,6 +23,7 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_PREFIX; import static com.android.ide.common.layout.LayoutConstants.ID_PREFIX; import static com.android.ide.common.layout.LayoutConstants.NEW_ID_PREFIX; +import com.android.annotations.NonNull; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.DropFeedback; import com.android.ide.common.api.IFeedbackPainter; @@ -45,7 +46,7 @@ import java.util.Set; public final class GuidelinePainter implements IFeedbackPainter { // ---- Implements IFeedbackPainter ---- @Override - public void paint(IGraphics gc, INode node, DropFeedback feedback) { + public void paint(@NonNull IGraphics gc, @NonNull INode node, @NonNull DropFeedback feedback) { GuidelineHandler state = (GuidelineHandler) feedback.userData; for (INode dragged : state.mDraggedNodes) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java index 7b3e8a3..05f0adf 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/resources/platform/AttributeInfo.java @@ -86,13 +86,13 @@ public class AttributeInfo implements IAttributeInfo { /** Returns the XML Name of the attribute */ @Override - public String getName() { + public @NonNull String getName() { return mName; } /** Returns the formats of the attribute. Cannot be null. * Should have at least one format. */ @Override - public EnumSet<Format> getFormats() { + public @NonNull EnumSet<Format> getFormats() { return mFormats; } /** Returns the values for enums. null for other types. */ @@ -107,7 +107,7 @@ public class AttributeInfo implements IAttributeInfo { } /** Returns a short javadoc, .i.e. the first sentence. */ @Override - public String getJavaDoc() { + public @NonNull String getJavaDoc() { return mJavaDoc; } /** Returns the documentation for deprecated attributes. Null if not deprecated. */ @@ -157,7 +157,7 @@ public class AttributeInfo implements IAttributeInfo { * this attribute */ @Override - public String getDefinedBy() { + public @NonNull String getDefinedBy() { return mDefinedBy; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java index 7345a04..48e01df 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.actions; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtUtils; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity; @@ -172,7 +173,7 @@ public class DexDumpAction implements IObjectActionDelegate { Wait.WAIT_FOR_READERS, new IProcessOutput() { @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { try { writer.write(line); @@ -182,7 +183,7 @@ public class DexDumpAction implements IObjectActionDelegate { } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, line); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java index 0ff50b5..ce9030e 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.actions;
+import com.android.annotations.Nullable;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.build.DexWrapper;
import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog;
@@ -98,12 +99,12 @@ public class SdkManagerAction implements IWorkbenchWindowActionDelegate, IObject Wait.ASYNC,
new IProcessOutput() {
@Override
- public void out(String line) {
+ public void out(@Nullable String line) {
// Ignore stdout
}
@Override
- public void err(String line) {
+ public void err(@Nullable String line) {
if (line != null) {
logger.printf("[SDK Manager] %s", line);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java index 0f556f9..799cf0e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.build; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AndroidPrintStream; @@ -1065,7 +1066,7 @@ public class BuildHelper { @SuppressWarnings("unused") @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { // If benchmarking always print the lines that // correspond to benchmarking info returned by ADT @@ -1080,7 +1081,7 @@ public class BuildHelper { } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { results.add(line); if (BuildVerbosity.VERBOSE == AdtPrefs.getPrefs().getBuildVerbosity()) { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java index 153bc79..7c7051d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java @@ -18,6 +18,8 @@ package com.android.ide.eclipse.adt.internal.editors.animator; import static com.android.ide.eclipse.adt.AdtConstants.EDITORS_NAMESPACE; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtUtils; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor; @@ -41,8 +43,8 @@ public class AnimationEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public AnimationEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.ANIM == type || ResourceFolderType.ANIMATOR == type) { return new AnimationEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java index 53edea9..3389683 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java @@ -18,6 +18,8 @@ package com.android.ide.eclipse.adt.internal.editors.color; import static com.android.ide.eclipse.adt.AdtConstants.EDITORS_NAMESPACE; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor; import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; @@ -39,8 +41,8 @@ public class ColorEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public ColorEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.COLOR == type) { return new ColorEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java index 69d82bd..a54fa8c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java @@ -18,6 +18,8 @@ package com.android.ide.eclipse.adt.internal.editors.drawable; import static com.android.ide.eclipse.adt.AdtConstants.EDITORS_NAMESPACE; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor; import com.android.ide.eclipse.adt.internal.editors.descriptors.DocumentDescriptor; @@ -40,8 +42,8 @@ public class DrawableEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public DrawableEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.DRAWABLE == type) { return new DrawableEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java index 23a5d35..41795d2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java @@ -270,7 +270,7 @@ public class AndroidXmlFormattingStrategy extends ContextBasedFormattingStrategy replaceEnd = document.getLength(); } else { root = DomUtilities.getCommonAncestor(startNode, endNode); - initialDepth = DomUtilities.getDepth(root) - 1; + initialDepth = root != null ? DomUtilities.getDepth(root) - 1 : 0; // Regions must be non-null since the DOM nodes are non null, but Eclipse null // analysis doesn't realize it: diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java index 89dd263..8d7b02e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java @@ -100,8 +100,8 @@ public class LayoutEditorDelegate extends CommonXmlDelegate @Override @SuppressWarnings("unchecked") public LayoutEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.LAYOUT == type) { return new LayoutEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java index 664d473..354517e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GCWrapper.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import com.android.annotations.NonNull; import com.android.ide.common.api.DrawingStyle; import com.android.ide.common.api.IColor; import com.android.ide.common.api.IGraphics; @@ -135,7 +136,7 @@ public class GCWrapper implements IGraphics { //------------- @Override - public IColor registerColor(int rgb) { + public @NonNull IColor registerColor(int rgb) { checkGC(); Integer key = Integer.valueOf(rgb); @@ -163,13 +164,13 @@ public class GCWrapper implements IGraphics { } @Override - public IColor getForeground() { + public @NonNull IColor getForeground() { Color c = getGc().getForeground(); return new ColorWrapper(c); } @Override - public IColor getBackground() { + public @NonNull IColor getBackground() { Color c = getGc().getBackground(); return new ColorWrapper(c); } @@ -180,13 +181,13 @@ public class GCWrapper implements IGraphics { } @Override - public void setForeground(IColor color) { + public void setForeground(@NonNull IColor color) { checkGC(); getGc().setForeground(((ColorWrapper) color).getColor()); } @Override - public void setBackground(IColor color) { + public void setBackground(@NonNull IColor color) { checkGC(); getGc().setBackground(((ColorWrapper) color).getColor()); } @@ -203,7 +204,7 @@ public class GCWrapper implements IGraphics { } @Override - public void setLineStyle(LineStyle style) { + public void setLineStyle(@NonNull LineStyle style) { int swtStyle = 0; switch (style) { case LINE_SOLID: @@ -254,7 +255,7 @@ public class GCWrapper implements IGraphics { } @Override - public void drawLine(Point p1, Point p2) { + public void drawLine(@NonNull Point p1, @NonNull Point p2) { drawLine(p1.x, p1.y, p2.x, p2.y); } @@ -272,12 +273,12 @@ public class GCWrapper implements IGraphics { } @Override - public void drawRect(Point p1, Point p2) { + public void drawRect(@NonNull Point p1, @NonNull Point p2) { drawRect(p1.x, p1.y, p2.x, p2.y); } @Override - public void drawRect(Rect r) { + public void drawRect(@NonNull Rect r) { checkGC(); useStrokeAlpha(); int x = mHScale.translate(r.x); @@ -299,12 +300,12 @@ public class GCWrapper implements IGraphics { } @Override - public void fillRect(Point p1, Point p2) { + public void fillRect(@NonNull Point p1, @NonNull Point p2) { fillRect(p1.x, p1.y, p2.x, p2.y); } @Override - public void fillRect(Rect r) { + public void fillRect(@NonNull Rect r) { checkGC(); useFillAlpha(); int x = mHScale.translate(r.x); @@ -368,7 +369,7 @@ public class GCWrapper implements IGraphics { // strings @Override - public void drawString(String string, int x, int y) { + public void drawString(@NonNull String string, int x, int y) { checkGC(); useStrokeAlpha(); x = mHScale.translate(x); @@ -382,7 +383,7 @@ public class GCWrapper implements IGraphics { } @Override - public void drawBoxedStrings(int x, int y, List<?> strings) { + public void drawBoxedStrings(int x, int y, @NonNull List<?> strings) { checkGC(); x = mHScale.translate(x); @@ -414,14 +415,14 @@ public class GCWrapper implements IGraphics { } @Override - public void drawString(String string, Point topLeft) { + public void drawString(@NonNull String string, @NonNull Point topLeft) { drawString(string, topLeft.x, topLeft.y); } // Styles @Override - public void useStyle(DrawingStyle style) { + public void useStyle(@NonNull DrawingStyle style) { checkGC(); // Look up the specific SWT style which defines the actual diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleAttribute.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleAttribute.java index b4a4772..198c164 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleAttribute.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleAttribute.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import com.android.annotations.NonNull; import com.android.ide.common.api.INode.IAttribute; import java.util.regex.Matcher; @@ -58,19 +59,19 @@ public class SimpleAttribute implements IAttribute { * Can be empty for an attribute without a namespace but is never null. */ @Override - public String getUri() { + public @NonNull String getUri() { return mUri; } /** Returns the XML local name of the attribute. Cannot be null nor empty. */ @Override - public String getName() { + public @NonNull String getName() { return mName; } /** Returns the value of the attribute. Cannot be null. Can be empty. */ @Override - public String getValue() { + public @NonNull String getValue() { return mValue; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java index e9abb06..4feff25 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/SimpleElement.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.Rect; @@ -69,7 +71,7 @@ public class SimpleElement implements IDragElement { * a View to inflate. */ @Override - public String getFqcn() { + public @NonNull String getFqcn() { return mFqcn; } @@ -79,7 +81,7 @@ public class SimpleElement implements IDragElement { * from the object palette (unless it successfully rendered a preview) */ @Override - public Rect getBounds() { + public @NonNull Rect getBounds() { return mBounds; } @@ -98,12 +100,12 @@ public class SimpleElement implements IDragElement { * is no suitable parent. This is null when {@link #getParentFqcn()} is null. */ @Override - public Rect getParentBounds() { + public @NonNull Rect getParentBounds() { return mParentBounds; } @Override - public IDragAttribute[] getAttributes() { + public @NonNull IDragAttribute[] getAttributes() { if (mCachedAttributes == null) { mCachedAttributes = mAttributes.toArray(new IDragAttribute[mAttributes.size()]); } @@ -111,7 +113,7 @@ public class SimpleElement implements IDragElement { } @Override - public IDragAttribute getAttribute(String uri, String localName) { + public IDragAttribute getAttribute(@Nullable String uri, @NonNull String localName) { for (IDragAttribute attr : mAttributes) { if (attr.getUri().equals(uri) && attr.getName().equals(localName)) { return attr; @@ -122,7 +124,7 @@ public class SimpleElement implements IDragElement { } @Override - public IDragElement[] getInnerElements() { + public @NonNull IDragElement[] getInnerElements() { if (mCachedElements == null) { mCachedElements = mElements.toArray(new IDragElement[mElements.size()]); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java index e08bfc1..e793983 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/ClientRulesEngine.java @@ -21,6 +21,8 @@ import static com.android.sdklib.SdkConstants.CLASS_V4_FRAGMENT; import static com.android.tools.lint.detector.api.LintConstants.AUTO_URI; import static com.android.tools.lint.detector.api.LintConstants.URI_PREFIX; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IClientRulesEngine; import com.android.ide.common.api.INode; import com.android.ide.common.api.IValidator; @@ -110,12 +112,12 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String getFqcn() { + public @NonNull String getFqcn() { return mFqcn; } @Override - public void debugPrintf(String msg, Object... params) { + public void debugPrintf(@NonNull String msg, Object... params) { AdtPlugin.printToConsole( mFqcn == null ? "<unknown>" : mFqcn, String.format(msg, params) @@ -123,12 +125,12 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public IViewRule loadRule(String fqcn) { + public IViewRule loadRule(@NonNull String fqcn) { return mRulesEngine.loadRule(fqcn, fqcn); } @Override - public void displayAlert(String message) { + public void displayAlert(@NonNull String message) { MessageDialog.openInformation( AdtPlugin.getDisplay().getActiveShell(), mFqcn, // title @@ -136,7 +138,8 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String displayInput(String message, String value, final IValidator filter) { + public String displayInput(@NonNull String message, @Nullable String value, + final @Nullable IValidator filter) { IInputValidator validator = null; if (filter != null) { validator = new IInputValidator() { @@ -166,26 +169,26 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public IViewMetadata getMetadata(final String fqcn) { + public @NonNull IViewMetadata getMetadata(final @NonNull String fqcn) { return new IViewMetadata() { @Override - public String getDisplayName() { + public @NonNull String getDisplayName() { // This also works when there is no "." return fqcn.substring(fqcn.lastIndexOf('.') + 1); } @Override - public FillPreference getFillPreference() { + public @NonNull FillPreference getFillPreference() { return ViewMetadataRepository.get().getFillPreference(fqcn); } @Override - public Margins getInsets() { + public @NonNull Margins getInsets() { return mRulesEngine.getEditor().getCanvasControl().getInsets(fqcn); } @Override - public List<String> getTopAttributes() { + public @NonNull List<String> getTopAttributes() { return ViewMetadataRepository.get().getTopAttributes(fqcn); } }; @@ -205,10 +208,9 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public IValidator getResourceValidator() { - // When https://review.source.android.com/#change,20168 is integrated, - // change this to - //return ResourceNameValidator.create(false, mDelegate.getProject(), ResourceType.ID); + public @Nullable IValidator getResourceValidator() { + //return ResourceNameValidator.create(false, mRulesEngine.getEditor().getProject(), + // ResourceType.ID); return null; } @@ -242,7 +244,8 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String displayResourceInput(String resourceTypeName, String currentValue) { + public String displayResourceInput(@NonNull String resourceTypeName, + @Nullable String currentValue) { return displayResourceInput(resourceTypeName, currentValue, null); } @@ -254,8 +257,8 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String[] displayMarginInput(String all, String left, String right, String top, - String bottom) { + public String[] displayMarginInput(@Nullable String all, @Nullable String left, + @Nullable String right, @Nullable String top, @Nullable String bottom) { GraphicalEditorPart editor = mRulesEngine.getEditor(); IProject project = editor.getProject(); if (project != null) { @@ -282,7 +285,7 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public void select(final Collection<INode> nodes) { + public void select(final @NonNull Collection<INode> nodes) { LayoutCanvas layoutCanvas = mRulesEngine.getEditor().getCanvasControl(); final SelectionManager selectionManager = layoutCanvas.getSelectionManager(); selectionManager.select(nodes); @@ -440,8 +443,8 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public Map<INode, Rect> measureChildren(INode parent, - IClientRulesEngine.AttributeFilter filter) { + public Map<INode, Rect> measureChildren(@NonNull INode parent, + @Nullable IClientRulesEngine.AttributeFilter filter) { RenderService renderService = RenderService.create(mRulesEngine.getEditor()); Map<INode, Rect> map = renderService.measureChildren(parent, filter); if (map == null) { @@ -502,7 +505,7 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String getUniqueId(String fqcn) { + public @NonNull String getUniqueId(@NonNull String fqcn) { UiDocumentNode root = mRulesEngine.getEditor().getModel(); String prefix = fqcn.substring(fqcn.lastIndexOf('.') + 1); prefix = Character.toLowerCase(prefix.charAt(0)) + prefix.substring(1); @@ -510,7 +513,7 @@ class ClientRulesEngine implements IClientRulesEngine { } @Override - public String getAppNameSpace() { + public @NonNull String getAppNameSpace() { IProject project = mRulesEngine.getEditor().getProject(); ProjectState projectState = Sdk.getProjectState(project); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeProxy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeProxy.java index ea464c1..3cd9729 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeProxy.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gre/NodeProxy.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gre; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IAttributeInfo; import com.android.ide.common.api.INode; import com.android.ide.common.api.INodeHandler; @@ -86,16 +88,19 @@ public class NodeProxy implements INode { } @Override - public Rect getBounds() { + public @NonNull Rect getBounds() { return mBounds; } @Override - public Margins getMargins() { + public @NonNull Margins getMargins() { ViewHierarchy viewHierarchy = mFactory.getCanvas().getViewHierarchy(); CanvasViewInfo view = viewHierarchy.findViewInfoFor(this); if (view != null) { - return view.getMargins(); + Margins margins = view.getMargins(); + if (margins != null) { + return margins; + } } return NO_MARGINS; @@ -133,14 +138,15 @@ public class NodeProxy implements INode { } @Override - public String getFqcn() { + public @NonNull String getFqcn() { if (mNode != null) { ElementDescriptor desc = mNode.getDescriptor(); if (desc instanceof ViewElementDescriptor) { return ((ViewElementDescriptor) desc).getFullClassName(); } } - return null; + + return ""; } @@ -189,7 +195,7 @@ public class NodeProxy implements INode { } @Override - public INode[] getChildren() { + public @NonNull INode[] getChildren() { if (mNode != null) { List<UiElementNode> uiChildren = mNode.getUiChildren(); List<INode> nodes = new ArrayList<INode>(uiChildren.size()); @@ -209,7 +215,7 @@ public class NodeProxy implements INode { // ---- XML Editing --- @Override - public void editXml(String undoName, final INodeHandler c) { + public void editXml(@NonNull String undoName, final @NonNull INodeHandler c) { final AndroidXmlEditor editor = mNode.getEditor(); if (editor != null) { @@ -238,17 +244,17 @@ public class NodeProxy implements INode { } @Override - public INode appendChild(String viewFqcn) { + public @NonNull INode appendChild(@NonNull String viewFqcn) { return insertOrAppend(viewFqcn, -1); } @Override - public INode insertChildAt(String viewFqcn, int index) { + public @NonNull INode insertChildAt(@NonNull String viewFqcn, int index) { return insertOrAppend(viewFqcn, index); } @Override - public void removeChild(INode node) { + public void removeChild(@NonNull INode node) { checkEditOK(); ((NodeProxy) node).mNode.deleteXmlNode(); @@ -320,7 +326,10 @@ public class NodeProxy implements INode { } @Override - public boolean setAttribute(String uri, String name, String value) { + public boolean setAttribute( + @Nullable String uri, + @NonNull String name, + @Nullable String value) { checkEditOK(); UiAttributeNode attr = mNode.setAttributeValue(name, uri, value, true /* override */); @@ -345,7 +354,7 @@ public class NodeProxy implements INode { } @Override - public String getStringAttr(String uri, String attrName) { + public String getStringAttr(@Nullable String uri, @NonNull String attrName) { UiElementNode uiNode = mNode; if (attrName == null) { @@ -378,7 +387,7 @@ public class NodeProxy implements INode { } @Override - public IAttributeInfo getAttributeInfo(String uri, String attrName) { + public IAttributeInfo getAttributeInfo(@Nullable String uri, @NonNull String attrName) { UiElementNode uiNode = mNode; if (attrName == null) { @@ -399,7 +408,7 @@ public class NodeProxy implements INode { } @Override - public IAttributeInfo[] getDeclaredAttributes() { + public @NonNull IAttributeInfo[] getDeclaredAttributes() { AttributeDescriptor[] descs = mNode.getAttributeDescriptors(); int n = descs.length; @@ -413,7 +422,7 @@ public class NodeProxy implements INode { } @Override - public List<String> getAttributeSources() { + public @NonNull List<String> getAttributeSources() { ElementDescriptor descriptor = mNode.getDescriptor(); if (descriptor instanceof ViewElementDescriptor) { return ((ViewElementDescriptor) descriptor).getAttributeSources(); @@ -423,7 +432,7 @@ public class NodeProxy implements INode { } @Override - public IAttribute[] getLiveAttributes() { + public @NonNull IAttribute[] getLiveAttributes() { UiElementNode uiNode = mNode; if (uiNode.getXmlNode() != null) { @@ -446,7 +455,8 @@ public class NodeProxy implements INode { } } } - return null; + + return new IAttribute[0]; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/properties/XmlPropertyEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/properties/XmlPropertyEditor.java index 628cda6..a7a863c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/properties/XmlPropertyEditor.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/properties/XmlPropertyEditor.java @@ -309,21 +309,26 @@ class XmlPropertyEditor extends AbstractTextPropertyEditor { ResourceType type = null; List<ResourceType> types = null; if (formats.contains(Format.FLAG)) { - FlagXmlPropertyDialog dialog = + String[] flagValues = attributeInfo.getFlagValues(); + if (flagValues != null) { + FlagXmlPropertyDialog dialog = new FlagXmlPropertyDialog(propertyTable.getShell(), "Select Flag Values", false /* radio */, - attributeInfo.getFlagValues(), xmlProperty); - - dialog.open(); - return; + flagValues, xmlProperty); + dialog.open(); + return; + } } else if (formats.contains(Format.ENUM)) { - FlagXmlPropertyDialog dialog = + String[] enumValues = attributeInfo.getEnumValues(); + if (enumValues != null) { + FlagXmlPropertyDialog dialog = new FlagXmlPropertyDialog(propertyTable.getShell(), "Select Enum Value", true /* radio */, - attributeInfo.getEnumValues(), xmlProperty); - dialog.open(); - return; + enumValues, xmlProperty); + dialog.open(); + return; + } } else { for (Format format : formats) { ResourceType t = format.getResourceType(); @@ -379,16 +384,18 @@ class XmlPropertyEditor extends AbstractTextPropertyEditor { } else if (type != null) { // Single resource type: use a resource chooser GraphicalEditorPart graphicalEditor = xmlProperty.getGraphicalEditor(); - String currentValue = (String) property.getValue(); - // TODO: Add validator factory? - String resource = ResourceChooser.chooseResource(graphicalEditor, - type, currentValue, null /* validator */); - // Returns null for cancel, "" for clear and otherwise a new value - if (resource != null) { - if (resource.length() > 0) { - property.setValue(resource); - } else { - property.setValue(null); + if (graphicalEditor != null) { + String currentValue = (String) property.getValue(); + // TODO: Add validator factory? + String resource = ResourceChooser.chooseResource(graphicalEditor, + type, currentValue, null /* validator */); + // Returns null for cancel, "" for clear and otherwise a new value + if (resource != null) { + if (resource.length() > 0) { + property.setValue(resource); + } else { + property.setValue(null); + } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java index abbfa11..99369ee 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoring.java @@ -39,6 +39,7 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML; import static com.android.util.XmlUtils.ANDROID_NS_NAME_PREFIX; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor; @@ -218,7 +219,7 @@ public class ChangeLayoutRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { String name = getViewClass(mTypeFqcn); IFile file = mDelegate.getEditor().getInputFile(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoring.java index 967a880..9cf3a3f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoring.java @@ -21,6 +21,7 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_PREFIX; import static com.android.ide.common.layout.LayoutConstants.ATTR_TEXT; import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate; @@ -150,7 +151,7 @@ public class ChangeViewRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { String name = getViewClass(mTypeFqcn); IFile file = mDelegate.getEditor().getInputFile(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoring.java index eb89304..657c9ec 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoring.java @@ -34,6 +34,7 @@ import static com.android.util.XmlUtils.XMLNS; import static com.android.util.XmlUtils.XMLNS_COLON; import com.android.AndroidConstants; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; @@ -221,7 +222,7 @@ public class ExtractIncludeRefactoring extends VisualRefactoring { // ---- Actual implementation of Extract as Include modification computation ---- @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { String extractedText = getExtractedText(); String namespaceDeclarations = computeNamespaceDeclarations(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoring.java index c6e965d..1c7dd72 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoring.java @@ -36,6 +36,7 @@ import static com.android.util.XmlUtils.ANDROID_NS_NAME; import static com.android.util.XmlUtils.ANDROID_NS_NAME_PREFIX; import static com.android.util.XmlUtils.XMLNS_COLON; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.resources.ResourceResolver; @@ -322,7 +323,7 @@ public class ExtractStyleRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { List<Change> changes = new ArrayList<Change>(); if (mChosenAttributes.size() == 0) { return changes; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoring.java index 050a787..e333629 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoring.java @@ -20,6 +20,7 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_HEIGHT; import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_WIDTH; import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.internal.editors.formatting.XmlFormatStyle; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate; @@ -166,7 +167,7 @@ public class UnwrapRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { // (1) If the removed parent is the root container, transfer its // namespace declarations // (2) Remove the root element completely diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java index 8f9beab..453daa8 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java @@ -33,6 +33,7 @@ import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML; import static com.android.tools.lint.detector.api.LintConstants.IMAGE_VIEW; import static com.android.tools.lint.detector.api.LintConstants.TEXT_VIEW; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.internal.editors.formatting.XmlFormatPreferences; import com.android.ide.eclipse.adt.internal.editors.formatting.XmlFormatStyle; @@ -189,7 +190,7 @@ public class UseCompoundDrawableRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { String androidNsPrefix = getAndroidNamespacePrefix(); IFile file = mDelegate.getEditor().getInputFile(); List<Change> changes = new ArrayList<Change>(); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoring.java index d043085..08a951b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoring.java @@ -26,6 +26,7 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_WRAP_CONTENT; import static com.android.ide.eclipse.adt.AdtConstants.EXT_XML; import static com.android.util.XmlUtils.ANDROID_NS_NAME_PREFIX; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor; import com.android.ide.eclipse.adt.internal.editors.formatting.XmlFormatStyle; @@ -175,7 +176,7 @@ public class WrapInRefactoring extends VisualRefactoring { } @Override - protected List<Change> computeChanges(IProgressMonitor monitor) { + protected @NonNull List<Change> computeChanges(IProgressMonitor monitor) { // (1) Insert the new container in front of the beginning of the // first wrapped view // (2) If the container is the new root, transfer namespace declarations diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java index 2f10f68..8479b0d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java @@ -78,6 +78,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -488,7 +489,7 @@ public class ManifestInfo { try { IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); if (javaProject == null) { - return null; + return Collections.emptyList(); } // TODO - look around a bit more and see if we can figure out whether the // call if from within a setContentView call! diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java index faca295..b5056d9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.editors.menu; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; @@ -43,8 +45,8 @@ public class MenuEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public MenuEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.MENU == type) { return new MenuEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java index 138ff95..7d74516 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.editors.otherxml; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; @@ -36,8 +38,8 @@ public class OtherXmlEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public OtherXmlEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.XML == type) { return new OtherXmlEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java index f253b30..94a6771 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java @@ -16,6 +16,8 @@ package com.android.ide.eclipse.adt.internal.editors.values; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtConstants; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlDelegate; @@ -43,8 +45,8 @@ public class ValuesEditorDelegate extends CommonXmlDelegate { @Override @SuppressWarnings("unchecked") public ValuesEditorDelegate createForFile( - CommonXmlEditor delegator, - ResourceFolderType type) { + @NonNull CommonXmlEditor delegator, + @Nullable ResourceFolderType type) { if (ResourceFolderType.VALUES == type) { return new ValuesEditorDelegate(delegator); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java index b5810a4..e7c81c5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java @@ -188,7 +188,8 @@ public class EclipseLintClient extends LintClient implements IDomParser { // ----- Extends LintClient ----- @Override - public void log(Severity severity, Throwable exception, String format, Object... args) { + public void log(@NonNull Severity severity, @Nullable Throwable exception, + @Nullable String format, @Nullable Object... args) { if (exception == null) { AdtPlugin.log(IStatus.WARNING, format, args); } else { @@ -213,7 +214,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { // ----- Implements IDomParser ----- @Override - public Document parseXml(XmlContext context) { + public Document parseXml(@NonNull XmlContext context) { // Map File to IFile IFile file = AdtUtils.fileToIFile(context.file); if (file == null || !file.exists()) { @@ -277,7 +278,19 @@ public class EclipseLintClient extends LintClient implements IDomParser { @NonNull @Override - public Configuration getConfiguration(Project project) { + public Configuration getConfiguration(@NonNull Project project) { + return getConfigurationFor(project); + } + + /** + * Same as {@link #getConfiguration(Project)}, but {@code project} can be + * null in which case the global configuration is returned. + * + * @param project the project to look up + * @return a corresponding configuration + */ + @NonNull + public Configuration getConfigurationFor(@Nullable Project project) { if (project != null) { IProject eclipseProject = getProject(project); if (eclipseProject != null) { @@ -287,10 +300,10 @@ public class EclipseLintClient extends LintClient implements IDomParser { return GlobalLintConfiguration.get(); } - @Override - public void report(Context context, Issue issue, Severity s, Location location, - String message, Object data) { + public void report(@NonNull Context context, @NonNull Issue issue, @NonNull Severity s, + @Nullable Location location, + @NonNull String message, @Nullable Object data) { int severity = getMarkerSeverity(s); IMarker marker = null; if (location != null) { @@ -399,7 +412,8 @@ public class EclipseLintClient extends LintClient implements IDomParser { } } - LayoutEditorDelegate delegate = LayoutEditorDelegate.fromEditor(AdtUtils.getActiveEditor()); + IEditorPart activeEditor = AdtUtils.getActiveEditor(); + LayoutEditorDelegate delegate = LayoutEditorDelegate.fromEditor(activeEditor); if (delegate != null) { delegate.getGraphicalEditor().getLayoutActionBar().updateErrorIndicator(); } @@ -645,7 +659,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public String readFile(File f) { + public @NonNull String readFile(@NonNull File f) { // Map File to IFile IFile file = AdtUtils.fileToIFile(f); if (file == null || !file.exists()) { @@ -684,13 +698,14 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public Location getLocation(XmlContext context, Node node) { + public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node) { IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY); return new LazyLocation(context.file, model.getStructuredDocument(), (IndexedRegion) node); } @Override - public Handle createLocationHandle(final XmlContext context, final Node node) { + public @NonNull Handle createLocationHandle(final @NonNull XmlContext context, + final @NonNull Node node) { IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY); return new LazyLocation(context.file, model.getStructuredDocument(), (IndexedRegion) node); } @@ -810,12 +825,13 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public Class<? extends Detector> replaceDetector(Class<? extends Detector> detectorClass) { + public @NonNull Class<? extends Detector> replaceDetector( + @NonNull Class<? extends Detector> detectorClass) { return detectorClass; } @Override - public void dispose(XmlContext context, Document document) { + public void dispose(@NonNull XmlContext context, @NonNull Document document) { IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY); assert model != null : context.file; if (model != null) { @@ -885,7 +901,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public Location resolve() { + public @NonNull Location resolve() { return this; } } @@ -915,7 +931,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public lombok.ast.Node parseJava(JavaContext context) { + public lombok.ast.Node parseJava(@NonNull JavaContext context) { if (USE_ECLIPSE_PARSER) { // Use Eclipse's compiler EcjTreeConverter converter = new EcjTreeConverter(); @@ -1010,19 +1026,22 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public Location getLocation(JavaContext context, lombok.ast.Node node) { + public @NonNull Location getLocation(@NonNull JavaContext context, + @NonNull lombok.ast.Node node) { lombok.ast.Position position = node.getPosition(); return Location.create(context.file, context.getContents(), position.getStart(), position.getEnd()); } @Override - public Handle createLocationHandle(JavaContext context, lombok.ast.Node node) { + public @NonNull Handle createLocationHandle(@NonNull JavaContext context, + @NonNull lombok.ast.Node node) { return new LocationHandle(context.file, node); } @Override - public void dispose(JavaContext context, lombok.ast.Node compilationUnit) { + public void dispose(@NonNull JavaContext context, + @NonNull lombok.ast.Node compilationUnit) { } /* Handle for creating positions cheaply and returning full fledged locations later */ @@ -1037,7 +1056,7 @@ public class EclipseLintClient extends LintClient implements IDomParser { } @Override - public Location resolve() { + public @NonNull Location resolve() { lombok.ast.Position pos = mNode.getPosition(); return Location.create(mFile, null /*contents*/, pos.getStart(), pos.getEnd()); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/GlobalLintConfiguration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/GlobalLintConfiguration.java index 646d752..5870501 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/GlobalLintConfiguration.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/GlobalLintConfiguration.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.lint; import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; import com.android.tools.lint.client.api.Configuration; @@ -54,7 +55,7 @@ class GlobalLintConfiguration extends Configuration { } @Override - public Severity getSeverity(Issue issue) { + public Severity getSeverity(@NonNull Issue issue) { if (mSeverities == null) { IssueRegistry registry = EclipseLintClient.getRegistry(); mSeverities = new HashMap<Issue, Severity>(); @@ -94,14 +95,15 @@ class GlobalLintConfiguration extends Configuration { } @Override - public void ignore(Context context, Issue issue, Location location, String message, - Object data) { + public void ignore(@NonNull Context context, @NonNull Issue issue, + @Nullable Location location, @NonNull String message, + @Nullable Object data) { throw new UnsupportedOperationException( "Can't ignore() in global configurations"); //$NON-NLS-1$ } @Override - public void setSeverity(Issue issue, Severity severity) { + public void setSeverity(@NonNull Issue issue, @Nullable Severity severity) { if (mSeverities == null) { // Force initialization getSeverity(issue); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintColumn.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintColumn.java index 34af83b..297d94b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintColumn.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintColumn.java @@ -146,7 +146,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Description"; } @@ -156,12 +156,12 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { return getStyledValue(marker).toString(); } @Override - public StyledString getStyledValue(IMarker marker) { + public StyledString getStyledValue(@NonNull IMarker marker) { StyledString styledString = new StyledString(); String message = marker.getAttribute(IMarker.MESSAGE, ""); @@ -177,7 +177,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public Image getImage(IMarker marker) { + public Image getImage(@NonNull IMarker marker) { int severity = marker.getAttribute(IMarker.SEVERITY, 0); ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); switch (severity) { @@ -199,7 +199,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public Font getFont(IMarker marker) { + public Font getFont(@NonNull IMarker marker) { int severity = marker.getAttribute(IMarker.SEVERITY, 0); if (severity == IMarker.SEVERITY_ERROR) { return JFaceResources.getFontRegistry().getBold( @@ -277,7 +277,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Category"; } @@ -287,7 +287,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { Issue issue = mList.getIssue(marker); if (issue != null) { return issue.getCategory().getFullName(); @@ -303,7 +303,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Location"; } @@ -313,12 +313,12 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { return getStyledValue(marker).toString(); } @Override - public StyledString getStyledValue(IMarker marker) { + public StyledString getStyledValue(@NonNull IMarker marker) { StyledString styledString = new StyledString(); // Combined location @@ -378,7 +378,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "File"; } @@ -393,7 +393,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { if (marker.getResource() instanceof IFile) { return marker.getResource().getName(); } else { @@ -408,7 +408,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Path"; } @@ -423,7 +423,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { return marker.getResource().getFullPath().toOSString(); } } @@ -434,7 +434,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Line"; } @@ -454,7 +454,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { int line = getLine(marker); if (line >= 1) { return Integer.toString(line); @@ -483,7 +483,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getColumnHeaderText() { + public @NonNull String getColumnHeaderText() { return "Priority"; } @@ -503,7 +503,7 @@ abstract class LintColumn implements Comparator<IMarker> { } @Override - public String getValue(IMarker marker) { + public String getValue(@NonNull IMarker marker) { int priority = getPriority(marker); if (priority > 0) { return Integer.toString(priority); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java index c81c0fc..32da203 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFixGenerator.java @@ -226,7 +226,7 @@ public class LintFixGenerator implements IMarkerResolutionGenerator2, IQuickAssi File dir = AdtUtils.getAbsolutePath(eclipseProject).toFile(); project = mClient.getProject(dir, dir); } - Configuration configuration = mClient.getConfiguration(project); + Configuration configuration = mClient.getConfigurationFor(project); if (thisFileOnly && configuration instanceof DefaultConfiguration) { File file = AdtUtils.getAbsolutePath(resource).toFile(); ((DefaultConfiguration) configuration).ignore(issue, file); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfiguration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfiguration.java index 77cd115..9e4ca12 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfiguration.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfiguration.java @@ -15,6 +15,7 @@ */ package com.android.ide.eclipse.adt.internal.lint; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.AdtUtils; @@ -79,7 +80,7 @@ class ProjectLintConfiguration extends DefaultConfiguration { } @Override - public Severity getSeverity(Issue issue) { + public @NonNull Severity getSeverity(@NonNull Issue issue) { Severity severity = super.getSeverity(issue); if (mFatalOnly && severity != Severity.FATAL) { return Severity.IGNORE; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/LintPreferencePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/LintPreferencePage.java index b2d7361..0bc2bfd 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/LintPreferencePage.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/preferences/LintPreferencePage.java @@ -165,7 +165,7 @@ public class LintPreferencePage extends PropertyPage implements IWorkbenchPrefer File dir = AdtUtils.getAbsolutePath(mProject).toFile(); project = mClient.getProject(dir, dir); } - mConfiguration = mClient.getConfiguration(project); + mConfiguration = mClient.getConfigurationFor(project); mSearch = new Text(container, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH); mSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java index 8fcf902..d7ace9a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.adt.internal.wizards.export; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity; import com.android.ide.eclipse.adt.internal.project.ExportHelper; @@ -547,7 +548,7 @@ public final class ExportWizard extends Wizard implements IExportWizard { Wait.WAIT_FOR_READERS, new IProcessOutput() { @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, project, line); @@ -555,7 +556,7 @@ public final class ExportWizard extends Wizard implements IExportWizard { } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { output.add(line); } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java index dc0c898..4f107fb 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java @@ -532,6 +532,9 @@ class TemplateHandler { xml = out.toString(); } else { xml = readTemplateTextResource(from); + if (xml == null) { + return; + } } String currentXml = Files.toString(to, Charsets.UTF_8); |