diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-30 17:38:29 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-05-30 17:38:29 -0700 |
commit | c82d08bf40baaec3c6f02381d3866492231b8704 (patch) | |
tree | 2da5fccd6c1e00c972c69323e3cf10df2e5ab264 | |
parent | 5ee7da2ae31dcbe781ed81c07f31b31d0a0a7d7f (diff) | |
parent | 7e4b8e9d595e45baa9d87cdb8282f02759e73abc (diff) | |
download | sdk-c82d08bf40baaec3c6f02381d3866492231b8704.zip sdk-c82d08bf40baaec3c6f02381d3866492231b8704.tar.gz sdk-c82d08bf40baaec3c6f02381d3866492231b8704.tar.bz2 |
Merge "Fix nullness annotations"
166 files changed, 1117 insertions, 766 deletions
diff --git a/common/src/com/android/annotations/NonNull.java b/common/src/com/android/annotations/NonNull.java index e306a31..973ebb6 100644 --- a/common/src/com/android/annotations/NonNull.java +++ b/common/src/com/android/annotations/NonNull.java @@ -32,7 +32,7 @@ import java.lang.annotation.Target; * This is a marker annotation and it has no specific attributes. */ @Documented -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.CLASS) @Target({METHOD,PARAMETER,LOCAL_VARIABLE,FIELD}) public @interface NonNull { } diff --git a/common/src/com/android/annotations/NonNullByDefault.java b/common/src/com/android/annotations/NonNullByDefault.java index 23903d1..3db891c 100644 --- a/common/src/com/android/annotations/NonNullByDefault.java +++ b/common/src/com/android/annotations/NonNullByDefault.java @@ -41,7 +41,7 @@ import java.lang.annotation.Target; * This is a marker annotation and it has no specific attributes. */ @Documented -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.CLASS) @Target({PACKAGE, TYPE}) public @interface NonNullByDefault { } diff --git a/common/src/com/android/annotations/Nullable.java b/common/src/com/android/annotations/Nullable.java index 376c1f6..d9c3861 100755 --- a/common/src/com/android/annotations/Nullable.java +++ b/common/src/com/android/annotations/Nullable.java @@ -43,7 +43,7 @@ import java.lang.annotation.Target; * This is a marker annotation and it has no specific attributes. */ @Documented -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.CLASS) @Target({METHOD, PARAMETER, LOCAL_VARIABLE, FIELD}) public @interface Nullable { } diff --git a/common/src/com/android/util/PositionXmlParser.java b/common/src/com/android/util/PositionXmlParser.java index 052348d..6eee96f 100644 --- a/common/src/com/android/util/PositionXmlParser.java +++ b/common/src/com/android/util/PositionXmlParser.java @@ -677,7 +677,7 @@ public class PositionXmlParser { } @Override - public void setEnd(Position end) { + public void setEnd(@NonNull Position end) { mEnd = end; } } 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); diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs index 5381a0e..bc45534 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs +++ b/eclipse/plugins/com.android.ide.eclipse.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,10 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve @@ -36,7 +37,9 @@ org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled @@ -45,9 +48,11 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=error org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java index 202d768..9f0783f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java @@ -15,6 +15,8 @@ */ package com.android.ide.eclipse.adt.internal.lint; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; import com.android.tools.lint.checks.DuplicateIdDetector; import com.android.tools.lint.checks.UnusedResourceDetector; @@ -208,12 +210,14 @@ public class ProjectLintConfigurationTest extends AdtProjectTest { private static class TestClient extends LintClient { @Override - public void report(Context context, Issue issue, Severity severity, Location location, - String message, Object data) { + public void report(@NonNull Context context, @NonNull Issue issue, + @NonNull Severity severity, @Nullable Location location, + @NonNull String message, @Nullable Object data) { } @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) { } @Override @@ -222,7 +226,7 @@ public class ProjectLintConfigurationTest extends AdtProjectTest { } @Override - public String readFile(File file) { + public @NonNull String readFile(@NonNull File file) { return null; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java index e382132..312df7d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/LayoutTestBase.java @@ -19,6 +19,8 @@ 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 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.IDragElement; @@ -198,47 +200,48 @@ public class LayoutTestBase extends TestCase { } @Override - public void debugPrintf(String msg, Object... params) { + public void debugPrintf(@NonNull String msg, Object... params) { fail("Not supported in tests yet"); } @Override - public void displayAlert(String message) { + public void displayAlert(@NonNull String message) { fail("Not supported in tests yet"); } @Override - public String displayInput(String message, String value, IValidator filter) { + public String displayInput(@NonNull String message, @Nullable String value, + @Nullable IValidator filter) { fail("Not supported in tests yet"); return null; } @Override - public String getFqcn() { + public @NonNull String getFqcn() { return mFqn; } @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 null; } @Override - public List<String> getTopAttributes() { + public @NonNull List<String> getTopAttributes() { return ViewMetadataRepository.get().getTopAttributes(fqcn); } }; @@ -250,7 +253,7 @@ public class LayoutTestBase extends TestCase { } @Override - public IViewRule loadRule(String fqcn) { + public IViewRule loadRule(@NonNull String fqcn) { fail("Not supported in tests yet"); return null; } @@ -262,20 +265,21 @@ public class LayoutTestBase extends TestCase { } @Override - public IValidator getResourceValidator() { + public @NonNull IValidator getResourceValidator() { fail("Not supported in tests yet"); return null; } @Override - public String displayResourceInput(String resourceTypeName, String currentValue) { + public String displayResourceInput(@NonNull String resourceTypeName, + @Nullable String currentValue) { fail("Not supported in tests yet"); return null; } @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) { fail("Not supported in tests yet"); return null; } @@ -287,7 +291,7 @@ public class LayoutTestBase extends TestCase { } @Override - public void select(Collection<INode> nodes) { + public void select(@NonNull Collection<INode> nodes) { fail("Not supported in tests yet"); } @@ -308,7 +312,8 @@ public class LayoutTestBase extends TestCase { } @Override - public Map<INode, Rect> measureChildren(INode parent, AttributeFilter filter) { + public Map<INode, Rect> measureChildren(@NonNull INode parent, + @Nullable AttributeFilter filter) { return null; } @@ -319,7 +324,7 @@ public class LayoutTestBase extends TestCase { } @Override - public String getUniqueId(String prefix) { + public @NonNull String getUniqueId(@NonNull String prefix) { fail("Not supported in tests yet"); return null; } @@ -337,7 +342,7 @@ public class LayoutTestBase extends TestCase { } @Override - public String getAppNameSpace() { + public @NonNull String getAppNameSpace() { fail("Not supported in tests yet"); return null; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttribute.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttribute.java index a1a2af7..76840b1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttribute.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttribute.java @@ -15,6 +15,7 @@ */ package com.android.ide.common.layout; +import com.android.annotations.NonNull; import com.android.ide.common.api.IDragElement.IDragAttribute; import com.android.ide.common.api.INode.IAttribute; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode; @@ -35,17 +36,17 @@ public class TestAttribute implements IAttribute, IDragAttribute { } @Override - public String getName() { + public @NonNull String getName() { return mName; } @Override - public String getUri() { + public @NonNull String getUri() { return mUri; } @Override - public String getValue() { + public @NonNull String getValue() { return mValue; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java index f4f83c1..69984bd 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestAttributeInfo.java @@ -15,6 +15,7 @@ */ package com.android.ide.common.layout; +import com.android.annotations.NonNull; import com.android.ide.common.api.IAttributeInfo; import java.util.EnumSet; @@ -59,22 +60,22 @@ public class TestAttributeInfo implements IAttributeInfo { } @Override - public EnumSet<Format> getFormats() { + public @NonNull EnumSet<Format> getFormats() { return mFormats; } @Override - public String getJavaDoc() { + public @NonNull String getJavaDoc() { return mJavadoc; } @Override - public String getName() { + public @NonNull String getName() { return mName; } @Override - public String getDefinedBy() { + public @NonNull String getDefinedBy() { return mDefinedBy; } }
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestDragElement.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestDragElement.java index 4a3b4e8..eb0a432 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestDragElement.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestDragElement.java @@ -18,6 +18,8 @@ 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 com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.ide.common.api.IDragElement; import com.android.ide.common.api.Rect; @@ -100,7 +102,7 @@ public class TestDragElement implements IDragElement { // ==== IDragElement ==== @Override - public IDragAttribute getAttribute(String uri, String localName) { + public IDragAttribute getAttribute(@Nullable String uri, @NonNull String localName) { if (mAttributes == null) { return new TestAttribute(uri, localName, ""); } @@ -109,22 +111,22 @@ public class TestDragElement implements IDragElement { } @Override - public IDragAttribute[] getAttributes() { + public @NonNull IDragAttribute[] getAttributes() { return mAttributes.values().toArray(new IDragAttribute[mAttributes.size()]); } @Override - public Rect getBounds() { + public @NonNull Rect getBounds() { return mRect; } @Override - public String getFqcn() { + public @NonNull String getFqcn() { return mFqcn; } @Override - public IDragElement[] getInnerElements() { + public @NonNull IDragElement[] getInnerElements() { if (mChildren == null) { return new IDragElement[0]; } @@ -133,7 +135,7 @@ public class TestDragElement implements IDragElement { } @Override - public Rect getParentBounds() { + public @NonNull Rect getParentBounds() { return mParent != null ? mParent.getBounds() : null; } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestGraphics.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestGraphics.java index 04f6259..ec93210 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestGraphics.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestGraphics.java @@ -16,6 +16,7 @@ package com.android.ide.common.layout; +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; @@ -51,7 +52,7 @@ public class TestGraphics implements IGraphics { // ==== IGraphics ==== @Override - public void drawBoxedStrings(int x, int y, List<?> strings) { + public void drawBoxedStrings(int x, int y, @NonNull List<?> strings) { mDrawn.add("drawBoxedStrings(" + x + "," + y + "," + strings + ")"); } @@ -61,7 +62,7 @@ public class TestGraphics implements IGraphics { } @Override - public void drawLine(Point p1, Point p2) { + public void drawLine(@NonNull Point p1, @NonNull Point p2) { mDrawn.add("drawLine(" + p1 + "," + p2 + ")"); } @@ -71,22 +72,22 @@ public class TestGraphics implements IGraphics { } @Override - public void drawRect(Point p1, Point p2) { + public void drawRect(@NonNull Point p1, @NonNull Point p2) { mDrawn.add("drawRect(" + p1 + "," + p2 + ")"); } @Override - public void drawRect(Rect r) { + public void drawRect(@NonNull Rect r) { mDrawn.add("drawRect(" + rectToString(r) + ")"); } @Override - public void drawString(String string, int x, int y) { + public void drawString(@NonNull String string, int x, int y) { mDrawn.add("drawString(" + x + "," + y + "," + string + ")"); } @Override - public void drawString(String string, Point topLeft) { + public void drawString(@NonNull String string, @NonNull Point topLeft) { mDrawn.add("drawString(" + string + "," + topLeft + ")"); } @@ -96,12 +97,12 @@ public class TestGraphics implements IGraphics { } @Override - public void fillRect(Point p1, Point p2) { + public void fillRect(@NonNull Point p1, @NonNull Point p2) { mDrawn.add("fillRect(" + p1 + "," + p2 + ")"); } @Override - public void fillRect(Rect r) { + public void fillRect(@NonNull Rect r) { mDrawn.add("fillRect(" + rectToString(r) + ")"); } @@ -111,7 +112,7 @@ public class TestGraphics implements IGraphics { } @Override - public IColor getBackground() { + public @NonNull IColor getBackground() { return mBackground; } @@ -121,12 +122,12 @@ public class TestGraphics implements IGraphics { } @Override - public IColor getForeground() { + public @NonNull IColor getForeground() { return mForeground; } @Override - public IColor registerColor(int rgb) { + public @NonNull IColor registerColor(int rgb) { mDrawn.add("registerColor(" + Integer.toHexString(rgb) + ")"); return new TestColor(rgb); } @@ -138,19 +139,19 @@ public class TestGraphics implements IGraphics { } @Override - public void setBackground(IColor color) { + public void setBackground(@NonNull IColor color) { mDrawn.add("setBackground(" + color + ")"); mBackground = color; } @Override - public void setForeground(IColor color) { + public void setForeground(@NonNull IColor color) { mDrawn.add("setForeground(" + color + ")"); mForeground = color; } @Override - public void setLineStyle(LineStyle style) { + public void setLineStyle(@NonNull LineStyle style) { mDrawn.add("setLineStyle(" + style + ")"); } @@ -160,7 +161,7 @@ public class TestGraphics implements IGraphics { } @Override - public void useStyle(DrawingStyle style) { + public void useStyle(@NonNull DrawingStyle style) { mDrawn.add("useStyle(" + style + ")"); } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestNode.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestNode.java index 575c958..8984f38 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestNode.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/common/layout/TestNode.java @@ -18,6 +18,8 @@ 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 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; @@ -94,12 +96,12 @@ public class TestNode implements INode { // ==== INODE ==== @Override - public INode appendChild(String viewFqcn) { + public @NonNull INode appendChild(@NonNull String viewFqcn) { return insertChildAt(viewFqcn, mChildren.size()); } @Override - public void editXml(String undoName, INodeHandler callback) { + public void editXml(@NonNull String undoName, @NonNull INodeHandler callback) { callback.handle(this); } @@ -108,32 +110,32 @@ public class TestNode implements INode { } @Override - public IAttributeInfo getAttributeInfo(String uri, String attrName) { + public IAttributeInfo getAttributeInfo(@Nullable String uri, @NonNull String attrName) { return mAttributeInfos.get(uri + attrName); } @Override - public Rect getBounds() { + public @NonNull Rect getBounds() { return mBounds; } @Override - public INode[] getChildren() { + public @NonNull INode[] getChildren() { return mChildren.toArray(new INode[mChildren.size()]); } @Override - public IAttributeInfo[] getDeclaredAttributes() { + public @NonNull IAttributeInfo[] getDeclaredAttributes() { return mAttributeInfos.values().toArray(new IAttributeInfo[mAttributeInfos.size()]); } @Override - public String getFqcn() { + public @NonNull String getFqcn() { return mFqcn; } @Override - public IAttribute[] getLiveAttributes() { + public @NonNull IAttribute[] getLiveAttributes() { return mAttributes.values().toArray(new IAttribute[mAttributes.size()]); } @@ -153,7 +155,7 @@ public class TestNode implements INode { } @Override - public String getStringAttr(String uri, String attrName) { + public String getStringAttr(@Nullable String uri, @NonNull String attrName) { IAttribute attr = mAttributes.get(uri + attrName); if (attr == null) { return null; @@ -163,7 +165,7 @@ public class TestNode implements INode { } @Override - public INode insertChildAt(String viewFqcn, int index) { + public @NonNull INode insertChildAt(@NonNull String viewFqcn, int index) { TestNode child = new TestNode(viewFqcn); if (index == -1) { mChildren.add(child); @@ -175,7 +177,7 @@ public class TestNode implements INode { } @Override - public void removeChild(INode node) { + public void removeChild(@NonNull INode node) { int index = mChildren.indexOf(node); if (index != -1) { removeChild(index); @@ -183,7 +185,8 @@ public class TestNode implements INode { } @Override - public boolean setAttribute(String uri, String localName, String value) { + public boolean setAttribute(@Nullable String uri, @NonNull String localName, + @Nullable String value) { mAttributes.put(uri + localName, new TestAttribute(uri, localName, value)); return true; } @@ -200,12 +203,12 @@ public class TestNode implements INode { } @Override - public Margins getMargins() { + public @NonNull Margins getMargins() { return null; } @Override - public List<String> getAttributeSources() { + public @NonNull List<String> getAttributeSources() { return mAttributeSources != null ? mAttributeSources : Collections.<String>emptyList(); } diff --git a/lint/cli/src/com/android/tools/lint/LintCliXmlParser.java b/lint/cli/src/com/android/tools/lint/LintCliXmlParser.java index e777e99..c13c41d 100644 --- a/lint/cli/src/com/android/tools/lint/LintCliXmlParser.java +++ b/lint/cli/src/com/android/tools/lint/LintCliXmlParser.java @@ -16,6 +16,7 @@ package com.android.tools.lint; +import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.tools.lint.client.api.IDomParser; import com.android.tools.lint.client.api.IssueRegistry; @@ -40,7 +41,7 @@ import java.io.UnsupportedEncodingException; */ public class LintCliXmlParser extends PositionXmlParser implements IDomParser { @Override - public Document parseXml(XmlContext context) { + public Document parseXml(@NonNull XmlContext context) { try { // Do we need to provide an input stream for encoding? String xml = context.getContents(); @@ -70,22 +71,22 @@ public class LintCliXmlParser extends PositionXmlParser implements IDomParser { } @Override - public Location getLocation(XmlContext context, Node node) { + public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node) { OffsetPosition pos = (OffsetPosition) getPosition(node); if (pos != null) { return Location.create(context.file, pos, (OffsetPosition) pos.getEnd()); } - return null; + return Location.create(context.file); } @Override - public Handle createLocationHandle(XmlContext context, Node node) { + public @NonNull Handle createLocationHandle(@NonNull XmlContext context, @NonNull Node node) { return new LocationHandle(context.file, node); } @Override - protected OffsetPosition createPosition(int line, int column, int offset) { + protected @NonNull OffsetPosition createPosition(int line, int column, int offset) { return new OffsetPosition(line, column, offset); } @@ -143,7 +144,7 @@ public class LintCliXmlParser extends PositionXmlParser implements IDomParser { } @Override - public void setEnd(com.android.util.PositionXmlParser.Position end) { + public void setEnd(@NonNull com.android.util.PositionXmlParser.Position end) { mEnd = end; } @@ -155,7 +156,7 @@ public class LintCliXmlParser extends PositionXmlParser implements IDomParser { } @Override - public void dispose(XmlContext context, Document document) { + public void dispose(@NonNull XmlContext context, @NonNull Document document) { } /* Handle for creating DOM positions cheaply and returning full fledged locations later */ @@ -170,13 +171,13 @@ public class LintCliXmlParser extends PositionXmlParser implements IDomParser { } @Override - public Location resolve() { + public @NonNull Location resolve() { OffsetPosition pos = (OffsetPosition) getPosition(mNode); if (pos != null) { return Location.create(mFile, pos, (OffsetPosition) pos.getEnd()); } - return null; + return Location.create(mFile); } @Override diff --git a/lint/cli/src/com/android/tools/lint/LombokParser.java b/lint/cli/src/com/android/tools/lint/LombokParser.java index 15b1073..2c263c6 100644 --- a/lint/cli/src/com/android/tools/lint/LombokParser.java +++ b/lint/cli/src/com/android/tools/lint/LombokParser.java @@ -16,6 +16,7 @@ package com.android.tools.lint; +import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.tools.lint.client.api.IJavaParser; import com.android.tools.lint.detector.api.JavaContext; @@ -39,7 +40,7 @@ import lombok.ast.grammar.Source; public class LombokParser implements IJavaParser { @Override - public Node parseJava(JavaContext context) { + public Node parseJava(@NonNull JavaContext context) { try { Source source = new Source(context.getContents(), context.file.getName()); List<Node> nodes = source.getNodes(); @@ -95,19 +96,21 @@ public class LombokParser implements IJavaParser { } @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, Node node) { + public @NonNull Handle createLocationHandle(@NonNull JavaContext context, @NonNull Node node) { return new LocationHandle(context.file, node); } @Override - public void dispose(JavaContext context, Node compilationUnit) { + public void dispose(@NonNull JavaContext context, @NonNull Node compilationUnit) { } /* Handle for creating positions cheaply and returning full fledged locations later */ @@ -122,7 +125,7 @@ public class LombokParser implements IJavaParser { } @Override - public Location resolve() { + public @NonNull Location resolve() { Position pos = mNode.getPosition(); return Location.create(mFile, null /*contents*/, pos.getStart(), pos.getEnd()); } diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java index 6a40cb3..68d68b4 100644 --- a/lint/cli/src/com/android/tools/lint/Main.java +++ b/lint/cli/src/com/android/tools/lint/Main.java @@ -21,6 +21,7 @@ import static com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR; import static com.android.tools.lint.detector.api.LintConstants.DOT_XML; import static com.android.tools.lint.detector.api.LintUtils.endsWith; +import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.android.tools.lint.checks.BuiltinIssueRegistry; import com.android.tools.lint.client.api.Configuration; @@ -886,7 +887,11 @@ public class Main 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) { System.out.flush(); if (!mQuiet) { // Place the error message on a line of its own since we're printing '.' etc @@ -907,7 +912,7 @@ public class Main extends LintClient { } @Override - public Configuration getConfiguration(Project project) { + public Configuration getConfiguration(@NonNull Project project) { return new CliConfiguration(mDefaultConfiguration, project); } @@ -934,8 +939,13 @@ public class Main extends LintClient { } @Override - public void report(Context context, Issue issue, Severity severity, Location location, - String message, Object data) { + public void report( + @NonNull Context context, + @NonNull Issue issue, + @NonNull Severity severity, + @Nullable Location location, + @NonNull String message, + @Nullable Object data) { assert context.isEnabled(issue); if (severity == Severity.IGNORE) { @@ -1041,7 +1051,7 @@ public class Main extends LintClient { } @Override - public String readFile(File file) { + public @NonNull String readFile(@NonNull File file) { try { return LintUtils.getEncodedString(file); } catch (IOException e) { @@ -1067,7 +1077,7 @@ public class Main extends LintClient { } @Override - public Severity getSeverity(Issue issue) { + public @NonNull Severity getSeverity(@NonNull Issue issue) { Severity severity = computeSeverity(issue); if (mAllErrors && severity != Severity.IGNORE) { @@ -1082,7 +1092,7 @@ public class Main extends LintClient { } @Override - protected Severity getDefaultSeverity(Issue issue) { + protected @NonNull Severity getDefaultSeverity(@NonNull Issue issue) { if (mWarnAll) { return issue.getDefaultSeverity(); } @@ -1090,7 +1100,7 @@ public class Main extends LintClient { return super.getDefaultSeverity(issue); } - private Severity computeSeverity(Issue issue) { + private Severity computeSeverity(@NonNull Issue issue) { Severity severity = super.getSeverity(issue); String id = issue.getId(); @@ -1123,25 +1133,32 @@ public class Main extends LintClient { private class ProgressPrinter implements LintListener { @Override - public void update(LintDriver lint, EventType type, Context context) { + public void update( + @NonNull LintDriver lint, + @NonNull EventType type, + @Nullable Context context) { switch (type) { - case SCANNING_PROJECT: + case SCANNING_PROJECT: { + String name = context != null ? context.getProject().getName() : "?"; if (lint.getPhase() > 1) { System.out.print(String.format( "\nScanning %1$s (Phase %2$d): ", - context.getProject().getName(), + name, lint.getPhase())); } else { System.out.print(String.format( "\nScanning %1$s: ", - context.getProject().getName())); + name)); } break; - case SCANNING_LIBRARY_PROJECT: + } + case SCANNING_LIBRARY_PROJECT: { + String name = context != null ? context.getProject().getName() : "?"; System.out.print(String.format( "\n - %1$s: ", - context.getProject().getName())); + name)); break; + } case SCANNING_FILE: System.out.print('.'); break; diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/DefaultConfiguration.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/DefaultConfiguration.java index 6dc4804..665368c 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/DefaultConfiguration.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/DefaultConfiguration.java @@ -202,7 +202,12 @@ public class DefaultConfiguration extends Configuration { message = String.format(message, args); } message = "Failed to parse lint.xml configuration file: " + message; - mClient.report(new Context(null, mProject, mProject, mConfigFile), + LintDriver driver = new LintDriver(new IssueRegistry() { + @Override @NonNull public List<Issue> getIssues() { + return Collections.emptyList(); + } + }, mClient); + mClient.report(new Context(driver, mProject, mProject, mConfigFile), IssueRegistry.LINT_ERROR, mProject.getConfiguration().getSeverity(IssueRegistry.LINT_ERROR), Location.create(mConfigFile), message, null); diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java index 74df385..cf45b2e 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java @@ -57,7 +57,7 @@ public abstract class IssueRegistry { Category.CORRECTNESS, 10, Severity.ERROR, - null, + Detector.class, Scope.RESOURCE_FILE_SCOPE); /** @@ -78,7 +78,7 @@ public abstract class IssueRegistry { Category.LINT, 10, Severity.ERROR, - null, + Detector.class, Scope.RESOURCE_FILE_SCOPE); /** diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/JavaVisitor.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/JavaVisitor.java index 1dbf915..3b641d0 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/JavaVisitor.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/JavaVisitor.java @@ -1172,7 +1172,7 @@ public class JavaVisitor { } @Override - public boolean visitMethodInvocation(@NonNull MethodInvocation node) { + public boolean visitMethodInvocation(MethodInvocation node) { if (mVisitMethods) { String methodName = node.astName().getDescription(); List<VisitingDetector> list = mMethodDetectors.get(methodName); diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java index 27741b1..93e311e 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java @@ -232,7 +232,7 @@ public abstract class LintClient { * the create flag was false, or if for some reason the directory * could not be created */ - @NonNull + @Nullable public File getCacheDir(boolean create) { String home = System.getProperty("user.home"); String relative = ".android" + File.separator + "cache"; //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java index f0bbae6..05c5765 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java @@ -538,7 +538,7 @@ public class LintDriver { continue; } else { parent = parent.getParentFile(); - if (isProjectDir(parent)) { + if (parent != null && isProjectDir(parent)) { registerProjectFile(fileToProject, file, parent, parent); continue; } @@ -718,7 +718,7 @@ public class LintDriver { // Must provide an issue since API guarantees that the issue parameter // is valid Issue.create("Lint", "", "", Category.PERFORMANCE, 0, Severity.INFORMATIONAL, //$NON-NLS-1$ - null, EnumSet.noneOf(Scope.class)), + Detector.class, EnumSet.noneOf(Scope.class)), Severity.INFORMATIONAL, null /*range*/, "Lint canceled by user", null); @@ -762,9 +762,9 @@ public class LintDriver { } } if (xmlDetectors.size() > 0) { - if (project.getSubset() != null) { - checkIndividualResources(project, main, xmlDetectors, - project.getSubset()); + List<File> files = project.getSubset(); + if (files != null) { + checkIndividualResources(project, main, xmlDetectors, files); } else { File res = new File(project.getDir(), RES_FOLDER); if (res.exists() && xmlDetectors.size() > 0) { @@ -783,9 +783,9 @@ public class LintDriver { List<Detector> checks = union(mScopeDetectors.get(Scope.JAVA_FILE), mScopeDetectors.get(Scope.ALL_JAVA_FILES)); if (checks != null && checks.size() > 0) { - if (project.getSubset() != null) { - checkIndividualJavaFiles(project, main, checks, - project.getSubset()); + List<File> files = project.getSubset(); + if (files != null) { + checkIndividualJavaFiles(project, main, checks, files); } else { List<File> sourceFolders = project.getJavaSourceFolders(); checkJava(project, main, sourceFolders, checks); @@ -931,8 +931,9 @@ public class LintDriver { /** Check the classes in this project (and if applicable, in any library projects */ private void checkClasses(Project project, Project main) { - if (project.getSubset() != null) { - checkIndividualClassFiles(project, main, project.getSubset()); + List<File> files = project.getSubset(); + if (files != null) { + checkIndividualClassFiles(project, main, files); return; } @@ -1119,7 +1120,8 @@ public class LintDriver { for (ClassEntry entry : entries) { try { ClassReader reader = new ClassReader(entry.bytes); - int flags = ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES; + int flags = ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG + | ClassReader.SKIP_FRAMES; reader.accept(visitor, flags); } catch (Throwable t) { mClient.log(null, "Error processing %1$s: broken class file?", entry.path()); @@ -1345,7 +1347,10 @@ public class LintDriver { return null; } - mCurrentVisitor = new XmlVisitor(mClient.getDomParser(), applicableChecks); + IDomParser parser = mClient.getDomParser(); + if (parser != null) { + mCurrentVisitor = new XmlVisitor(parser, applicableChecks); + } } return mCurrentVisitor; @@ -1466,7 +1471,7 @@ public class LintDriver { } /** Notifies listeners, if any, that the given event has occurred */ - private void fireEvent(@NonNull LintListener.EventType type, @NonNull Context context) { + private void fireEvent(@NonNull LintListener.EventType type, @Nullable Context context) { if (mListeners != null) { for (int i = 0, n = mListeners.size(); i < n; i++) { LintListener listener = mListeners.get(i); @@ -1553,7 +1558,7 @@ public class LintDriver { } @Override - public List<File> getJavaLibraries(Project project) { + public @NonNull List<File> getJavaLibraries(@NonNull Project project) { return mDelegate.getJavaLibraries(project); } @@ -1565,13 +1570,14 @@ public class LintDriver { @Override @NonNull - public Class<? extends Detector> replaceDetector(Class<? extends Detector> detectorClass) { + public Class<? extends Detector> replaceDetector( + @NonNull Class<? extends Detector> detectorClass) { return mDelegate.replaceDetector(detectorClass); } @Override @NonNull - public SdkInfo getSdkInfo(Project project) { + public SdkInfo getSdkInfo(@NonNull Project project) { return mDelegate.getSdkInfo(project); } @@ -1588,7 +1594,7 @@ public class LintDriver { } @Override - public File findResource(String relativePath) { + public File findResource(@NonNull String relativePath) { return mDelegate.findResource(relativePath); } } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintListener.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintListener.java index 777100d..2247a6d 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintListener.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintListener.java @@ -17,6 +17,7 @@ package com.android.tools.lint.client.api; import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Context; import com.google.common.annotations.Beta; @@ -65,5 +66,5 @@ public interface LintListener { * @param context the context providing additional information */ public void update(@NonNull LintDriver driver, @NonNull EventType type, - @NonNull Context context); + @Nullable Context context); } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/SdkInfo.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/SdkInfo.java index b16747c..5ff7f90 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/SdkInfo.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/SdkInfo.java @@ -42,11 +42,12 @@ public abstract class SdkInfo { if (parentViewFqcn.equals(childViewFqcn)) { return true; } - childViewFqcn = getParentViewClass(childViewFqcn); - if (childViewFqcn == null) { + String parent = getParentViewClass(childViewFqcn); + if (parent == null) { // Unknown view - err on the side of caution return true; } + childViewFqcn = parent; } return false; diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Category.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Category.java index 6978ef0..ba8e5b5 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Category.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Category.java @@ -125,7 +125,7 @@ public final class Category implements Comparable<Category> { } @Override - public int compareTo(@NonNull Category other) { + public int compareTo(Category other) { if (other.mPriority == mPriority) { if (mParent == other) { return 1; diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java index 7b3cffd..3c6842e 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java @@ -254,7 +254,11 @@ public class ClassContext extends Context { * @param data any associated data, or null */ @Override - public void report(Issue issue, Location location, String message, Object data) { + public void report( + @NonNull Issue issue, + @Nullable Location location, + @NonNull String message, + @Nullable Object data) { if (mDriver.isSuppressed(issue, mClassNode)) { return; } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Detector.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Detector.java index c795606..c8f9fd2 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Detector.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Detector.java @@ -372,7 +372,9 @@ public abstract class Detector { * @return the expected speed of this detector */ @NonNull - public abstract Speed getSpeed(); + public Speed getSpeed() { + return Speed.NORMAL; + } // ---- Dummy implementations to make implementing XmlScanner easier: ---- diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Issue.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Issue.java index 9f42fb4..0ac8805 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Issue.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Issue.java @@ -219,7 +219,7 @@ public final class Issue implements Comparable<Issue> { * @param other the {@link Issue} to compare this issue to */ @Override - public int compareTo(@NonNull Issue other) { + public int compareTo(Issue other) { return getId().compareTo(other.getId()); } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/JavaContext.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/JavaContext.java index d7c1e6e..ae86568 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/JavaContext.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/JavaContext.java @@ -74,7 +74,8 @@ public class JavaContext extends Context { } @Override - public void report(Issue issue, Location location, String message, Object data) { + public void report(@NonNull Issue issue, @Nullable Location location, + @NonNull String message, @Nullable Object data) { if (mDriver.isSuppressed(issue, compilationUnit)) { return; } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java index 9d61047..167de42 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java @@ -110,7 +110,7 @@ public class Location { * * @param secondary a secondary location associated with this location */ - public void setSecondary(@NonNull Location secondary) { + public void setSecondary(@Nullable Location secondary) { this.mSecondary = secondary; } @@ -197,7 +197,7 @@ public class Location { public static Location create( @NonNull File file, @NonNull Position start, - @NonNull Position end) { + @Nullable Position end) { return new Location(file, start, end); } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Severity.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Severity.java index d0bbd7b..cde61bd 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Severity.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Severity.java @@ -31,30 +31,36 @@ public enum Severity { * Fatal: Use sparingly because a warning marked as fatal will be * considered critical and will abort Export APK etc in ADT */ + @NonNull FATAL("Fatal"), /** * Errors: The issue is known to be a real error that must be addressed. */ + @NonNull ERROR("Error"), /** * Warning: Probably a problem. */ + @NonNull WARNING("Warning"), /** * Information only: Might not be a problem, but the check has found * something interesting to say about the code. */ + @NonNull INFORMATIONAL("Information"), /** * Ignore: The user doesn't want to see this issue */ + @NonNull IGNORE("Ignore"); - private String mDisplay; + @NonNull + private final String mDisplay; private Severity(@NonNull String display) { mDisplay = display; @@ -65,8 +71,7 @@ public enum Severity { * * @return a description of the severity */ - @NonNull - public String getDescription() { + public @NonNull String getDescription() { return mDisplay; } }
\ No newline at end of file diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java index abc08b2..323f88a 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java @@ -21,6 +21,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_CONTENT_DES import static com.android.tools.lint.detector.api.LintConstants.IMAGE_BUTTON; import static com.android.tools.lint.detector.api.LintConstants.IMAGE_VIEW; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -62,7 +63,7 @@ public class AccessibilityDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -75,7 +76,7 @@ public class AccessibilityDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (!element.hasAttributeNS(ANDROID_URI, ATTR_CONTENT_DESCRIPTION)) { context.report(ISSUE, element, context.getLocation(element), "[Accessibility] Missing contentDescription attribute on image", null); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AlwaysShowActionDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AlwaysShowActionDetector.java index 9bbb4c1..bc5eaae 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AlwaysShowActionDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AlwaysShowActionDetector.java @@ -98,7 +98,7 @@ public class AlwaysShowActionDetector extends ResourceXmlDetector implements Jav } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -108,12 +108,12 @@ public class AlwaysShowActionDetector extends ResourceXmlDetector implements Jav } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { mFileAttributes = null; } @Override - public void afterCheckFile(Context context) { + public void afterCheckFile(@NonNull Context context) { if (mFileAttributes != null) { assert context instanceof XmlContext; // mAFilettributes is only set in XML files @@ -161,7 +161,7 @@ public class AlwaysShowActionDetector extends ResourceXmlDetector implements Jav } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mAlwaysFields != null && !mHasIfRoomRefs) { for (Location location : mAlwaysFields) { context.report(ISSUE, location, @@ -174,7 +174,7 @@ public class AlwaysShowActionDetector extends ResourceXmlDetector implements Jav // ---- Implements XmlScanner ---- @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { if (mFileAttributes == null) { mFileAttributes = new ArrayList<Attr>(); } @@ -190,7 +190,7 @@ public class AlwaysShowActionDetector extends ResourceXmlDetector implements Jav } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new FieldAccessChecker(context); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java index 4f6df4f..9eae7c4 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java @@ -94,17 +94,17 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.SLOW; } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { mApiDatabase = ApiLookup.get(context.getClient()); // We can't look up the minimum API required by the project here: // The manifest file hasn't been processed yet in the -before- project hook. @@ -130,7 +130,7 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { if (mApiDatabase == null) { return; } @@ -158,7 +158,7 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (mApiDatabase == null) { return; } @@ -234,7 +234,7 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc @SuppressWarnings("rawtypes") @Override - public void checkClass(final ClassContext context, ClassNode classNode) { + public void checkClass(final @NonNull ClassContext context, @NonNull ClassNode classNode) { if (mApiDatabase == null) { return; } @@ -319,7 +319,7 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc owner = classNode.superName; } - do { + while (owner != null) { int api = mApiDatabase.getCallVersion(owner, name, desc); if (api > minSdk) { String fqcn = owner.replace('/', '.') + '#' + name; @@ -339,7 +339,7 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc } else { owner = null; } - } while (owner != null); + } } else if (type == AbstractInsnNode.FIELD_INSN) { FieldInsnNode node = (FieldInsnNode) instruction; String name = node.name; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiLookup.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiLookup.java index dd5585b..4186028 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiLookup.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiLookup.java @@ -739,7 +739,7 @@ public class ApiLookup { return -1; } - private int findMember(int classNumber, @NonNull String name, @NonNull String desc) { + private int findMember(int classNumber, @NonNull String name, @Nullable String desc) { // The index array contains class indexes from 0 to classCount and // member indices from classCount to mIndices.length. int low = mClassCount; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java index 568e885..92743b8 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_ARRAY; import static com.android.tools.lint.detector.api.LintConstants.TAG_INTEGER_ARRAY; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING_ARRAY; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.client.api.LintDriver; import com.android.tools.lint.detector.api.Category; @@ -32,7 +33,6 @@ import com.android.tools.lint.detector.api.Location; import com.android.tools.lint.detector.api.ResourceXmlDetector; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; import com.android.tools.lint.detector.api.XmlContext; import com.android.util.Pair; @@ -91,16 +91,11 @@ public class ArraySizeDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.VALUES; } @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - - @Override public Collection<String> getApplicableElements() { return Arrays.asList( TAG_ARRAY, @@ -110,14 +105,14 @@ public class ArraySizeDetector extends ResourceXmlDetector { } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToArrayCount = new HashMap<File, Pair<String,Integer>>(30); } } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // Check that all arrays for the same name have the same number of translations @@ -222,7 +217,7 @@ public class ArraySizeDetector extends ResourceXmlDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int phase = context.getPhase(); Attr attribute = element.getAttributeNode(ATTR_NAME); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/BuiltinIssueRegistry.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/BuiltinIssueRegistry.java index 0645d56..146da7f 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/BuiltinIssueRegistry.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/BuiltinIssueRegistry.java @@ -19,6 +19,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintUtils.assertionsEnabled; import static com.android.tools.lint.detector.api.LintUtils.endsWith; +import com.android.annotations.NonNull; import com.android.prefs.AndroidLocation; import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.tools.lint.client.api.IssueRegistry; @@ -173,7 +174,7 @@ public class BuiltinIssueRegistry extends IssueRegistry { } @Override - public List<Issue> getIssues() { + public @NonNull List<Issue> getIssues() { return sIssues; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ButtonDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ButtonDetector.java index 9321561..b644b14 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ButtonDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ButtonDetector.java @@ -178,7 +178,7 @@ public class ButtonDetector extends ResourceXmlDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -193,7 +193,7 @@ public class ButtonDetector extends ResourceXmlDetector { } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { int phase = context.getPhase(); if (phase == 1 && mApplicableResources != null) { // We found resources for the string "Cancel"; perform a second pass @@ -214,7 +214,7 @@ public class ButtonDetector extends ResourceXmlDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { // This detector works in two passes. // In pass 1, it looks in layout files for hardcoded strings of "Cancel", or // references to @string/cancel or @android:string/cancel. diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java index 5a14f75..2f4503b 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.LIST_VIEW; import static com.android.tools.lint.detector.api.LintConstants.REQUEST_FOCUS; import static com.android.tools.lint.detector.api.LintConstants.SCROLL_VIEW; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -74,7 +75,7 @@ public class ChildCountDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -90,7 +91,7 @@ public class ChildCountDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int childCount = LintUtils.getChildCount(element); String tagName = element.getTagName(); if (tagName.equals(SCROLL_VIEW) || tagName.equals(HORIZONTAL_SCROLL_VIEW)) { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ColorUsageDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ColorUsageDetector.java index e6d077a..dc3410b 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ColorUsageDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ColorUsageDetector.java @@ -18,6 +18,8 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.RESOURCE_CLZ_COLOR; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -60,12 +62,12 @@ public class ColorUsageDetector extends Detector implements Detector.JavaScanner } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -77,8 +79,8 @@ public class ColorUsageDetector extends Detector implements Detector.JavaScanner } @Override - public void visitResourceReference(JavaContext context, AstVisitor visitor, - Node select, String type, String name, boolean isFramework) { + public void visitResourceReference(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull Node select, @NonNull String type, @NonNull String name, boolean isFramework) { if (type.equals(RESOURCE_CLZ_COLOR)) { while (select.getParent() instanceof Select) { select = select.getParent(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java index 25c247d..952224c 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java @@ -28,6 +28,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_PASSWORD; import static com.android.tools.lint.detector.api.LintConstants.ATTR_PHONE_NUMBER; import static com.android.tools.lint.detector.api.LintConstants.ATTR_SINGLE_LINE; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -64,7 +65,7 @@ public class DeprecationDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -119,13 +120,13 @@ public class DeprecationDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { context.report(ISSUE, element, context.getLocation(element), String.format("%1$s is deprecated", element.getTagName()), null); } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { if (!ANDROID_URI.equals(attribute.getNamespaceURI())) { return; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DetectMissingPrefix.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DetectMissingPrefix.java index 6ea7899..8a9c0a9 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DetectMissingPrefix.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DetectMissingPrefix.java @@ -23,6 +23,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_STYLE; import static com.android.tools.lint.detector.api.LintConstants.VIEW_TAG; import static com.android.tools.lint.detector.api.LintConstants.XMLNS_PREFIX; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -70,7 +71,7 @@ public class DetectMissingPrefix extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -80,7 +81,7 @@ public class DetectMissingPrefix extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String uri = attribute.getNamespaceURI(); if (uri == null || uri.length() == 0) { String name = attribute.getName(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DuplicateIdDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DuplicateIdDetector.java index bbb3de5..c8e34c5 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DuplicateIdDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DuplicateIdDetector.java @@ -24,6 +24,7 @@ import static com.android.tools.lint.detector.api.LintConstants.INCLUDE; import static com.android.tools.lint.detector.api.LintConstants.LAYOUT_RESOURCE_PREFIX; import static com.android.tools.lint.detector.api.LintConstants.NEW_ID_RESOURCE_PREFIX; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; @@ -103,12 +104,12 @@ public class DuplicateIdDetector extends LayoutDetector { @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -123,14 +124,14 @@ public class DuplicateIdDetector extends LayoutDetector { } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mIds = new HashSet<String>(); } } @Override - public void afterCheckFile(Context context) { + public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject mFileToIds.put(context.file, mIds); @@ -140,7 +141,7 @@ public class DuplicateIdDetector extends LayoutDetector { } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToIds = new HashMap<File, Set<String>>(); mIncludes = new HashMap<File, List<String>>(); @@ -148,7 +149,7 @@ public class DuplicateIdDetector extends LayoutDetector { } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // Look for duplicates if (mIncludes.size() > 0) { @@ -201,7 +202,7 @@ public class DuplicateIdDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { // Record include graph such that we can look for inter-layout duplicates after the // project has been fully checked @@ -241,7 +242,7 @@ public class DuplicateIdDetector extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { assert attribute.getName().equals(ATTR_ID) || attribute.getLocalName().equals(ATTR_ID); String id = attribute.getValue(); if (context.getPhase() == 1) { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ExtraTextDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ExtraTextDetector.java index e0665df..7e2ecb2 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ExtraTextDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ExtraTextDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.DefaultPosition; @@ -59,7 +60,7 @@ public class ExtraTextDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.MENU || folderType == ResourceFolderType.ANIMATOR @@ -69,12 +70,12 @@ public class ExtraTextDetector extends ResourceXmlDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public void visitDocument(XmlContext context, Document document) { + public void visitDocument(@NonNull XmlContext context, @NonNull Document document) { mFoundText = false; visitNode(context, document); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java index 656c226..7d8deab 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; import com.android.tools.lint.detector.api.Context; @@ -72,12 +73,12 @@ public class FieldGetterDetector extends Detector implements Detector.ClassScann } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -85,7 +86,7 @@ public class FieldGetterDetector extends Detector implements Detector.ClassScann @SuppressWarnings("rawtypes") @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { List<Entry> pendingCalls = null; int currentLine = 0; List methodList = classNode.methods; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FragmentDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FragmentDetector.java index 37b22ea..6839004 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FragmentDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FragmentDetector.java @@ -20,6 +20,7 @@ import static com.android.tools.lint.detector.api.LintConstants.CONSTRUCTOR_NAME import static com.android.tools.lint.detector.api.LintConstants.FRAGMENT; import static com.android.tools.lint.detector.api.LintConstants.FRAGMENT_V4; +import com.android.annotations.NonNull; import com.android.tools.lint.client.api.LintDriver; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; @@ -77,19 +78,19 @@ public class FragmentDetector extends Detector implements ClassScanner { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } // ---- Implements ClassScanner ---- @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { // Ignore abstract classes since they are clearly (and by definition) not intended to // be instantiated. We're looking for accidental non-static or missing constructor diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java index 762a4b5..6e8d8a3 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_LAYOUT_COLU import static com.android.tools.lint.detector.api.LintConstants.ATTR_LAYOUT_ROW; import static com.android.tools.lint.detector.api.LintConstants.ATTR_ROW_COUNT; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -60,7 +61,7 @@ public class GridLayoutDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -85,7 +86,7 @@ public class GridLayoutDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int declaredRowCount = getInt(element, ATTR_ROW_COUNT, -1); int declaredColumnCount = getInt(element, ATTR_COLUMN_COUNT, -1); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HandlerDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HandlerDetector.java index 425edac..9efd666 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HandlerDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HandlerDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; import com.android.tools.lint.detector.api.Context; @@ -60,19 +61,19 @@ public class HandlerDetector extends Detector implements ClassScanner { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } // ---- Implements ClassScanner ---- @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if (classNode.name.indexOf('$') == -1) { return; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedDebugModeDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedDebugModeDetector.java index df8c728..1237e1b 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedDebugModeDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedDebugModeDetector.java @@ -20,6 +20,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ANDROID_MANIFEST import static com.android.tools.lint.detector.api.LintConstants.ANDROID_URI; import static com.android.tools.lint.detector.api.LintConstants.ATTR_DEBUGGABLE; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -65,12 +66,12 @@ public class HardcodedDebugModeDetector extends Detector implements Detector.Xml } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return file.getName().equals(ANDROID_MANIFEST_XML); } @@ -82,7 +83,7 @@ public class HardcodedDebugModeDetector extends Detector implements Detector.Xml } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { if (attribute.getNamespaceURI().equals(ANDROID_URI)) { //if (attribute.getOwnerElement().getTagName().equals(TAG_APPLICATION)) { context.report(ISSUE, attribute, context.getLocation(attribute), diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java index 09a3ffc..3665303 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java @@ -23,6 +23,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_LABEL; import static com.android.tools.lint.detector.api.LintConstants.ATTR_PROMPT; import static com.android.tools.lint.detector.api.LintConstants.ATTR_TEXT; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -66,7 +67,7 @@ public class HardcodedValuesDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -82,7 +83,7 @@ public class HardcodedValuesDetector extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String value = attribute.getValue(); if (value.length() > 0 && (value.charAt(0) != '@' && value.charAt(0) != '?')) { // Make sure this is really one of the android: attributes diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/IconDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/IconDetector.java index c687d74..adee77d 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/IconDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/IconDetector.java @@ -34,6 +34,7 @@ import static com.android.tools.lint.detector.api.LintConstants.RES_FOLDER; import static com.android.tools.lint.detector.api.LintConstants.TAG_APPLICATION; import static com.android.tools.lint.detector.api.LintUtils.endsWith; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -258,22 +259,22 @@ public class IconDetector extends Detector implements Detector.XmlScanner { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.SLOW; } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { mApplicationIcon = null; } @Override - public void afterCheckLibraryProject(Context context) { + public void afterCheckLibraryProject(@NonNull Context context) { checkResourceFolder(context, context.getProject().getDir()); } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { checkResourceFolder(context, context.getProject().getDir()); } @@ -1203,7 +1204,7 @@ public class IconDetector extends Detector implements Detector.XmlScanner { // XML detector: Skim manifest @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return file.getName().equals(ANDROID_MANIFEST_XML); } @@ -1213,7 +1214,7 @@ public class IconDetector extends Detector implements Detector.XmlScanner { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { assert element.getTagName().equals(TAG_APPLICATION); mApplicationIcon = element.getAttributeNS(ANDROID_URI, ATTR_ICON); if (mApplicationIcon.startsWith(DRAWABLE_RESOURCE_PREFIX)) { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/InefficientWeightDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/InefficientWeightDetector.java index 84216d1..3fd5573 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/InefficientWeightDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/InefficientWeightDetector.java @@ -25,6 +25,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_ORIENTATION import static com.android.tools.lint.detector.api.LintConstants.LINEAR_LAYOUT; import static com.android.tools.lint.detector.api.LintConstants.VALUE_VERTICAL; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -100,7 +101,7 @@ public class InefficientWeightDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -110,7 +111,7 @@ public class InefficientWeightDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { List<Element> children = LintUtils.getChildren(element); // See if there is exactly one child with a weight boolean multipleWeights = false; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java index e99005c..0073d06 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -139,12 +140,12 @@ public class JavaPerformanceDetector extends Detector implements Detector.JavaSc } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -160,7 +161,7 @@ public class JavaPerformanceDetector extends Detector implements Detector.JavaSc } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new PerformanceVisitor(context); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java index cf75ae5..b116eb9 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java @@ -31,6 +31,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_USES_LIBRARY import static com.android.tools.lint.detector.api.LintConstants.TAG_USES_PERMISSION; import static com.android.tools.lint.detector.api.LintConstants.TAG_USES_SDK; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -159,23 +160,23 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann private String mPackage; @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return file.getName().equals(ANDROID_MANIFEST_XML); } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { mSeenApplication = false; mSeenUsesSdk = 0; } @Override - public void afterCheckFile(Context context) { + public void afterCheckFile(@NonNull Context context) { if (mSeenUsesSdk == 0 && context.isEnabled(USES_SDK)) { context.report(USES_SDK, Location.create(context.file), "Manifest should specify a minimum API level with " + @@ -209,7 +210,7 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String tag = element.getTagName(); Node parentNode = element.getParentNode(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java index 06258dd..daefda7 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; import com.android.tools.lint.detector.api.Context; @@ -68,12 +69,12 @@ public class MathDetector extends Detector implements Detector.ClassScanner { } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -81,7 +82,7 @@ public class MathDetector extends Detector implements Detector.ClassScanner { @SuppressWarnings("rawtypes") @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { List methodList = classNode.methods; for (Object m : methodList) { MethodNode method = (MethodNode) m; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MergeRootFrameLayoutDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MergeRootFrameLayoutDetector.java index 4cb96b5..5ed0257 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MergeRootFrameLayoutDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MergeRootFrameLayoutDetector.java @@ -103,17 +103,18 @@ public class MergeRootFrameLayoutDetector extends LayoutDetector implements Dete } @Override + @NonNull public Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return LintUtils.isXmlFile(file) || LintUtils.endsWith(file.getName(), DOT_JAVA); } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mPending != null && mWhitelistedLayouts != null) { // Process all the root FrameLayouts that are eligible, and generate // suggestions for <merge> replacements for any layouts that are included @@ -146,7 +147,7 @@ public class MergeRootFrameLayoutDetector extends LayoutDetector implements Dete } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String tag = element.getTagName(); if (tag.equals(INCLUDE)) { String layout = element.getAttribute(ATTR_LAYOUT); // NOTE: Not in android: namespace diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NamespaceDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NamespaceDetector.java index 88a9dd5..e760a9c 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NamespaceDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NamespaceDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.AUTO_URI; import static com.android.tools.lint.detector.api.LintConstants.URI_PREFIX; import static com.android.tools.lint.detector.api.LintConstants.XMLNS_PREFIX; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -102,12 +103,12 @@ public class NamespaceDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public void visitDocument(XmlContext context, Document document) { + public void visitDocument(@NonNull XmlContext context, @NonNull Document document) { boolean haveCustomNamespace = false; Element root = document.getDocumentElement(); NamedNodeMap attributes = root.getAttributes(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java index 9ca8017..d6cdbd6 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.HORIZONTAL_SCROL import static com.android.tools.lint.detector.api.LintConstants.LIST_VIEW; import static com.android.tools.lint.detector.api.LintConstants.SCROLL_VIEW; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Issue; @@ -62,13 +63,13 @@ public class NestedScrollingWidgetDetector extends LayoutDetector { } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { mVisitingHorizontalScroll = 0; mVisitingVerticalScroll = 0; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -103,7 +104,7 @@ public class NestedScrollingWidgetDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { boolean vertical = isVerticalScroll(element); if (vertical) { mVisitingVerticalScroll++; @@ -129,7 +130,7 @@ public class NestedScrollingWidgetDetector extends LayoutDetector { } @Override - public void visitElementAfter(XmlContext context, Element element) { + public void visitElementAfter(@NonNull XmlContext context, @NonNull Element element) { if (isVerticalScroll(element)) { mVisitingVerticalScroll--; assert mVisitingVerticalScroll >= 0; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ObsoleteLayoutParamsDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ObsoleteLayoutParamsDetector.java index 4002bd5..9972604 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ObsoleteLayoutParamsDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ObsoleteLayoutParamsDetector.java @@ -63,6 +63,7 @@ import static com.android.tools.lint.detector.api.LintConstants.RELATIVE_LAYOUT; import static com.android.tools.lint.detector.api.LintConstants.TABLE_ROW; import static com.android.tools.lint.detector.api.LintConstants.VIEW_TAG; +import com.android.annotations.NonNull; import com.android.tools.lint.client.api.IDomParser; import com.android.tools.lint.client.api.SdkInfo; import com.android.tools.lint.detector.api.Category; @@ -218,7 +219,7 @@ public class ObsoleteLayoutParamsDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -233,7 +234,7 @@ public class ObsoleteLayoutParamsDetector extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String name = attribute.getLocalName(); if (name != null && name.startsWith(ATTR_LAYOUT_PREFIX) && ANDROID_URI.equals(attribute.getNamespaceURI())) { @@ -296,7 +297,7 @@ public class ObsoleteLayoutParamsDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String layout = element.getAttribute(ATTR_LAYOUT); if (layout.startsWith(LAYOUT_RESOURCE_PREFIX)) { // Ignore @android:layout/ layouts layout = layout.substring(LAYOUT_RESOURCE_PREFIX.length()); @@ -320,7 +321,7 @@ public class ObsoleteLayoutParamsDetector extends LayoutDetector { } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mIncludes == null) { return; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OnClickDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OnClickDetector.java index 14370f3..75fda79 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OnClickDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OnClickDetector.java @@ -18,6 +18,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.ATTR_ON_CLICK; +import com.android.annotations.NonNull; import com.android.tools.lint.client.api.LintDriver; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; @@ -81,17 +82,17 @@ public class OnClickDetector extends LayoutDetector implements ClassScanner { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mNames != null && mNames.size() > 0 && mHaveBytecode) { List<String> names = new ArrayList<String>(mNames.keySet()); Collections.sort(names); @@ -129,7 +130,7 @@ public class OnClickDetector extends LayoutDetector implements ClassScanner { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String value = attribute.getValue(); if (value.isEmpty() || value.trim().isEmpty()) { context.report(ISSUE, attribute, context.getLocation(attribute), @@ -170,7 +171,7 @@ public class OnClickDetector extends LayoutDetector implements ClassScanner { @SuppressWarnings("rawtypes") @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if (mNames == null) { // No onClick attributes in the XML files return; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java index 51790e5..12f9b04 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java @@ -35,6 +35,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TRANSPARENT_COLO import static com.android.tools.lint.detector.api.LintConstants.VALUE_DISABLED; import static com.android.tools.lint.detector.api.LintUtils.endsWith; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; @@ -148,7 +149,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { // Look in layouts for drawable resources return super.appliesTo(folderType) // and in resource files for theme definitions @@ -158,12 +159,12 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return LintUtils.isXmlFile(file) || LintUtils.endsWith(file.getName(), DOT_JAVA); } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -194,7 +195,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mRootAttributes != null) { for (Pair<Location, String> pair : mRootAttributes) { Location location = pair.getFirst(); @@ -260,7 +261,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca // ---- Implements XmlScanner ---- @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { // Only consider the root element's background if (attribute.getOwnerDocument().getDocumentElement() == attribute.getOwnerElement()) { // If the drawable is a non-repeated pattern then the overdraw might be @@ -321,7 +322,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { if (endsWith(context.file.getName(), DOT_XML)) { // Drawable XML files should not be considered for overdraw, except for <bitmap>'s. // The bitmap elements are handled in the scanBitmap() method; it will clear @@ -339,7 +340,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String tag = element.getTagName(); if (tag.equals(TAG_STYLE)) { scanTheme(element); @@ -470,7 +471,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new OverdrawVisitor(); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PrivateResourceDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PrivateResourceDetector.java index 2b37f82..7d909ae 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PrivateResourceDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PrivateResourceDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.ResourceXmlDetector; @@ -52,7 +53,7 @@ public class PrivateResourceDetector extends ResourceXmlDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -62,7 +63,7 @@ public class PrivateResourceDetector extends ResourceXmlDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String value = attribute.getNodeValue(); if (value.startsWith("@*android:")) { //$NON-NLS-1$ context.report(ISSUE, attribute, context.getLocation(attribute), diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ProguardDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ProguardDetector.java index c062507..41af3b1 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ProguardDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ProguardDetector.java @@ -19,6 +19,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.PROGUARD_CONFIG; import static com.android.tools.lint.detector.api.LintConstants.PROJECT_PROPERTIES; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -91,7 +92,7 @@ public class ProguardDetector extends Detector { EnumSet.of(Scope.PROGUARD_FILE)); @Override - public void run(Context context) { + public void run(@NonNull Context context) { String contents = context.getContents(); if (contents != null) { if (context.isEnabled(WRONGKEEP)) { @@ -151,12 +152,12 @@ public class ProguardDetector extends Detector { } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java index cb37d5f..f87abcc 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/PxUsageDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -59,7 +60,7 @@ public class PxUsageDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -69,7 +70,7 @@ public class PxUsageDetector extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String value = attribute.getValue(); if (value.endsWith("px") && value.matches("\\d+px")) { //$NON-NLS-1$ if (value.charAt(0) == '0') { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/RegistrationDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/RegistrationDetector.java index 0f16244..1d55109 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/RegistrationDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/RegistrationDetector.java @@ -24,6 +24,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_PROVIDER; import static com.android.tools.lint.detector.api.LintConstants.TAG_RECEIVER; import static com.android.tools.lint.detector.api.LintConstants.TAG_SERVICE; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; import com.android.tools.lint.detector.api.Context; @@ -85,12 +86,12 @@ public class RegistrationDetector extends LayoutDetector implements ClassScanner } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @@ -102,7 +103,7 @@ public class RegistrationDetector extends LayoutDetector implements ClassScanner } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String fqcn = getFqcn(element); String tag = element.getTagName(); String frameworkClass = tagToClass(tag); @@ -148,7 +149,7 @@ public class RegistrationDetector extends LayoutDetector implements ClassScanner // ---- Implements ClassScanner ---- @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { // Abstract classes do not need to be registered if ((classNode.access & Opcodes.ACC_ABSTRACT) != 0) { return; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java index 8ba2bc4..e5db5f1 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java @@ -24,6 +24,7 @@ import static com.android.tools.lint.detector.api.LintConstants.SCROLL_VIEW; import static com.android.tools.lint.detector.api.LintConstants.VALUE_FILL_PARENT; import static com.android.tools.lint.detector.api.LintConstants.VALUE_MATCH_PARENT; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -64,7 +65,7 @@ public class ScrollViewChildDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -77,13 +78,16 @@ public class ScrollViewChildDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { List<Element> children = LintUtils.getChildren(element); boolean isHorizontal = HORIZONTAL_SCROLL_VIEW.equals(element.getTagName()); String attributeName = isHorizontal ? ATTR_LAYOUT_WIDTH : ATTR_LAYOUT_HEIGHT; for (Element child : children) { Attr sizeNode = child.getAttributeNodeNS(ANDROID_URI, attributeName); - String value = sizeNode != null ? sizeNode.getValue() : null; + if (sizeNode == null) { + return; + } + String value = sizeNode.getValue(); if (VALUE_FILL_PARENT.equals(value) || VALUE_MATCH_PARENT.equals(value)) { String msg = String.format("This %1$s should use android:%2$s=\"wrap_content\"", child.getTagName(), attributeName); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SdCardDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SdCardDetector.java index b239d57..d5e3a88 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SdCardDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SdCardDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -59,12 +60,12 @@ public class SdCardDetector extends Detector implements Detector.JavaScanner { } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -76,7 +77,7 @@ public class SdCardDetector extends Detector implements Detector.JavaScanner { } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new StringChecker(context); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java index 807d515..c9848eb 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java @@ -32,6 +32,8 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_PATH_PERMISS import static com.android.tools.lint.detector.api.LintConstants.TAG_PROVIDER; import static com.android.tools.lint.detector.api.LintConstants.TAG_SERVICE; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -147,11 +149,11 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner, } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return file.getName().equals(ANDROID_MANIFEST_XML); } @@ -167,7 +169,7 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner, } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { String tag = element.getTagName(); if (tag.equals(TAG_SERVICE)) { checkService(context, element); @@ -264,7 +266,8 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner, } if (!hasPermission) { - context.report(EXPORTED_PROVIDER, element, context.getLocation(element), + context.report(EXPORTED_PROVIDER, element, + context.getLocation(element), "Exported content providers can provide access to " + "potentially sensitive data", null); @@ -288,7 +291,8 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner, } @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { StrictListAccessor<Expression,MethodInvocation> args = node.astArguments(); Iterator<Expression> iterator = args.iterator(); while (iterator.hasNext()) { @@ -297,7 +301,7 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner, } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new IdentifierVisitor(context); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SetJavaScriptEnabledDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SetJavaScriptEnabledDetector.java index e711816..8653944 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SetJavaScriptEnabledDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SetJavaScriptEnabledDetector.java @@ -16,20 +16,20 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Detector; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.JavaContext; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; - -import lombok.ast.MethodInvocation; import java.util.Collections; import java.util.List; import lombok.ast.AstVisitor; +import lombok.ast.MethodInvocation; /** * Looks for invocations of android.webkit.WebSettings.setJavaScriptEnabled. @@ -52,15 +52,11 @@ public class SetJavaScriptEnabledDetector extends Detector implements Detector.J public SetJavaScriptEnabledDetector() { } - @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - // ---- Implements JavaScanner ---- @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { if (node.astArguments().size() == 1 && !node.astArguments().first().toString().equals("false")) { //$NON-NLS-1$ context.report(ISSUE, node, context.getLocation(node), diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SharedPrefsDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SharedPrefsDetector.java index 525ab6d..b8c86bf 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SharedPrefsDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SharedPrefsDetector.java @@ -15,6 +15,8 @@ */ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -22,7 +24,6 @@ import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.JavaContext; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; import java.io.File; import java.util.Collections; @@ -61,16 +62,11 @@ public class SharedPrefsDetector extends Detector implements Detector.JavaScanne } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } - @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - // ---- Implements JavaScanner ---- @Override @@ -94,7 +90,8 @@ public class SharedPrefsDetector extends Detector implements Detector.JavaScanne } @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { assert node.astName().astValue().equals("edit"); if (node.astOperand() == null) { return; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java index 3235c9a..d7f0d99 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java @@ -18,6 +18,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.ANDROID_URI; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; @@ -57,17 +58,17 @@ public class StateListDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.DRAWABLE; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public void visitDocument(XmlContext context, Document document) { + public void visitDocument(@NonNull XmlContext context, @NonNull Document document) { // TODO: Look for views that don't specify // Display the error token somewhere so it can be suppressed // Emit warning at the end "run with --help to learn how to suppress types of errors/checks"; diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StringFormatDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StringFormatDetector.java index 5fae363..f5d6d80 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StringFormatDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StringFormatDetector.java @@ -20,6 +20,8 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_NAME; import static com.android.tools.lint.detector.api.LintConstants.DOT_JAVA; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.annotations.VisibleForTesting; import com.android.resources.ResourceFolderType; import com.android.tools.lint.client.api.IJavaParser; @@ -35,7 +37,6 @@ import com.android.tools.lint.detector.api.Position; import com.android.tools.lint.detector.api.ResourceXmlDetector; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; import com.android.tools.lint.detector.api.XmlContext; import com.android.util.Pair; @@ -162,12 +163,12 @@ public class StringFormatDetector extends ResourceXmlDetector implements Detecto } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.VALUES; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { if (LintUtils.endsWith(file.getName(), DOT_JAVA)) { return mFormatStrings != null; } @@ -176,17 +177,12 @@ public class StringFormatDetector extends ResourceXmlDetector implements Detecto } @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - - @Override public Collection<String> getApplicableElements() { return Collections.singletonList(TAG_STRING); } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { NodeList childNodes = element.getChildNodes(); if (childNodes.getLength() > 0) { if (childNodes.getLength() == 1) { @@ -309,7 +305,7 @@ public class StringFormatDetector extends ResourceXmlDetector implements Detecto } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mFormatStrings != null) { Formatter formatter = new Formatter(); @@ -773,7 +769,8 @@ public class StringFormatDetector extends ResourceXmlDetector implements Detecto } @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { if (mFormatStrings == null) { return; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StyleCycleDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StyleCycleDetector.java index f248d6e..03766b7 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StyleCycleDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StyleCycleDetector.java @@ -21,6 +21,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_PARENT; import static com.android.tools.lint.detector.api.LintConstants.STYLE_RESOURCE_PREFIX; import static com.android.tools.lint.detector.api.LintConstants.TAG_STYLE; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; @@ -58,12 +59,12 @@ public class StyleCycleDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.VALUES; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -73,7 +74,7 @@ public class StyleCycleDetector extends ResourceXmlDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { Attr parentNode = element.getAttributeNode(ATTR_PARENT); if (parentNode != null) { String parent = parentNode.getValue(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextFieldDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextFieldDetector.java index 2cc81ab..c133ce2 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextFieldDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextFieldDetector.java @@ -22,6 +22,7 @@ import static com.android.tools.lint.detector.api.LintConstants.ATTR_INPUT_METHO import static com.android.tools.lint.detector.api.LintConstants.ATTR_INPUT_TYPE; import static com.android.tools.lint.detector.api.LintConstants.EDIT_TEXT; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -63,7 +64,7 @@ public class TextFieldDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -73,7 +74,7 @@ public class TextFieldDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (!element.hasAttributeNS(ANDROID_URI, ATTR_INPUT_TYPE) && !element.hasAttributeNS(ANDROID_URI, ATTR_HINT)) { // Also make sure the EditText does not set an inputMethod in which case diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextViewDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextViewDetector.java index 09608b1..e6e0371 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextViewDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TextViewDetector.java @@ -44,6 +44,7 @@ import static com.android.tools.lint.detector.api.LintConstants.VALUE_EDITABLE; import static com.android.tools.lint.detector.api.LintConstants.VALUE_NONE; import static com.android.tools.lint.detector.api.LintConstants.VALUE_TRUE; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -91,7 +92,7 @@ public class TextViewDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -109,7 +110,7 @@ public class TextViewDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { NamedNodeMap attributes = element.getAttributes(); for (int i = 0, n = attributes.getLength(); i < n; i++) { Attr attribute = (Attr) attributes.item(i); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ToastDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ToastDetector.java index f199438..d876c53 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ToastDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ToastDetector.java @@ -15,6 +15,8 @@ */ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -22,7 +24,6 @@ import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.JavaContext; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; import java.io.File; import java.util.Collections; @@ -60,16 +61,11 @@ public class ToastDetector extends Detector implements Detector.JavaScanner { } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } - @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - // ---- Implements JavaScanner ---- @Override @@ -93,7 +89,8 @@ public class ToastDetector extends Detector implements Detector.JavaScanner { } @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { assert node.astName().astValue().equals("makeText"); if (node.astOperand() == null) { // "makeText()" in the code with no operand diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TooManyViewsDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TooManyViewsDetector.java index 257d06c..ed3480a 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TooManyViewsDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TooManyViewsDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Issue; @@ -102,12 +103,12 @@ public class TooManyViewsDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { mViewCount = mDepth = 0; mWarnedAboutDepth = false; } @@ -118,7 +119,7 @@ public class TooManyViewsDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { mViewCount++; mDepth++; @@ -140,7 +141,7 @@ public class TooManyViewsDetector extends LayoutDetector { } @Override - public void visitElementAfter(XmlContext context, Element element) { + public void visitElementAfter(@NonNull XmlContext context, @NonNull Element element) { mDepth--; } } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java index 98d56b0..70e0723 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java @@ -24,6 +24,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_ITEM; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING_ARRAY; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; @@ -33,7 +34,6 @@ import com.android.tools.lint.detector.api.Location; import com.android.tools.lint.detector.api.ResourceXmlDetector; import com.android.tools.lint.detector.api.Scope; import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.Speed; import com.android.tools.lint.detector.api.XmlContext; import com.google.common.collect.Sets; @@ -116,16 +116,11 @@ public class TranslationDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.VALUES; } @Override - public Speed getSpeed() { - return Speed.NORMAL; - } - - @Override public Collection<String> getApplicableElements() { return Arrays.asList( TAG_STRING, @@ -134,14 +129,14 @@ public class TranslationDetector extends ResourceXmlDetector { } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { if (context.getDriver().getPhase() == 1) { mFileToNames = new HashMap<File, Set<String>>(); } } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mNames = new HashSet<String>(); } @@ -151,7 +146,7 @@ public class TranslationDetector extends ResourceXmlDetector { } @Override - public void afterCheckFile(Context context) { + public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject mFileToNames.put(context.file, mNames); @@ -161,7 +156,7 @@ public class TranslationDetector extends ResourceXmlDetector { } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it @@ -406,7 +401,7 @@ public class TranslationDetector extends ResourceXmlDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (mIgnoreFile) { return; } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java index c5a9302..5ad52b3 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java @@ -19,6 +19,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING; import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING_ARRAY; +import com.android.annotations.NonNull; import com.android.annotations.VisibleForTesting; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; @@ -192,12 +193,12 @@ public class TypographyDetector extends ResourceXmlDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.VALUES; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -210,7 +211,7 @@ public class TypographyDetector extends ResourceXmlDetector { } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { mCheckDashes = context.isEnabled(DASHES); mCheckQuotes = context.isEnabled(QUOTES); mCheckFractions = context.isEnabled(FRACTIONS); @@ -219,7 +220,7 @@ public class TypographyDetector extends ResourceXmlDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { NodeList childNodes = element.getChildNodes(); for (int i = 0, n = childNodes.getLength(); i < n; i++) { Node child = childNodes.item(i); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UnusedResourceDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UnusedResourceDetector.java index 3ea1c14..f9b5a67 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UnusedResourceDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UnusedResourceDetector.java @@ -38,6 +38,8 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_STRING_ARRAY import static com.android.tools.lint.detector.api.LintConstants.TAG_STYLE; import static com.android.tools.lint.detector.api.LintUtils.endsWith; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.resources.ResourceType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; @@ -121,17 +123,17 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public void run(Context context) { + public void run(@NonNull Context context) { assert false; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public void beforeCheckProject(Context context) { + public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mDeclarations = new HashSet<String>(300); mReferences = new HashSet<String>(300); @@ -141,7 +143,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec // ---- Implements JavaScanner ---- @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { File file = context.file; String fileName = file.getName(); @@ -188,7 +190,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mDeclarations.removeAll(mReferences); Set<String> unused = mDeclarations; @@ -330,7 +332,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (TAG_RESOURCES.equals(element.getTagName())) { for (Element item : LintUtils.getChildren(element)) { String name = item.getAttribute(ATTR_NAME); @@ -401,7 +403,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String value = attribute.getValue(); if (value.startsWith("@+") && !value.startsWith("@+android")) { //$NON-NLS-1$ //$NON-NLS-2$ @@ -437,7 +439,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.SLOW; } @@ -452,8 +454,9 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public void visitResourceReference(JavaContext context, AstVisitor visitor, - lombok.ast.Node node, String type, String name, boolean isFramework) { + public void visitResourceReference(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull lombok.ast.Node node, @NonNull String type, @NonNull String name, + boolean isFramework) { if (mReferences != null && !isFramework) { String reference = R_PREFIX + type + '.' + name; mReferences.add(reference); @@ -461,7 +464,7 @@ public class UnusedResourceDetector extends ResourceXmlDetector implements Detec } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { if (mReferences != null) { return new UnusedResourceVisitor(); } else { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java index 540a0f1..d091ce1 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java @@ -23,6 +23,7 @@ import static com.android.tools.lint.detector.api.LintConstants.IMAGE_VIEW; import static com.android.tools.lint.detector.api.LintConstants.LINEAR_LAYOUT; import static com.android.tools.lint.detector.api.LintConstants.TEXT_VIEW; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -63,7 +64,7 @@ public class UseCompoundDrawableDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -75,7 +76,7 @@ public class UseCompoundDrawableDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int childCount = LintUtils.getChildCount(element); if (childCount == 2) { List<Element> children = LintUtils.getChildren(element); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UselessViewDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UselessViewDetector.java index fd4ff58..b913588 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UselessViewDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UselessViewDetector.java @@ -33,6 +33,7 @@ import static com.android.tools.lint.detector.api.LintConstants.SCROLL_VIEW; import static com.android.tools.lint.detector.api.LintConstants.TABLE_LAYOUT; import static com.android.tools.lint.detector.api.LintConstants.TABLE_ROW; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -85,7 +86,7 @@ public class UselessViewDetector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -127,7 +128,7 @@ public class UselessViewDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int childCount = LintUtils.getChildCount(element); if (childCount == 0) { // Check to see if this is a leaf layout that can be removed diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/Utf8Detector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/Utf8Detector.java index 6a87e94..875de62 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/Utf8Detector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/Utf8Detector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; @@ -57,12 +58,12 @@ public class Utf8Detector extends LayoutDetector { } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @Override - public void visitDocument(XmlContext context, Document document) { + public void visitDocument(@NonNull XmlContext context, @NonNull Document document) { String xml = context.getContents(); // AAPT: The prologue must be in the first line diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewConstructorDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewConstructorDetector.java index 72aaa77..538c0d6 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewConstructorDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewConstructorDetector.java @@ -18,6 +18,7 @@ package com.android.tools.lint.checks; import static com.android.tools.lint.detector.api.LintConstants.CONSTRUCTOR_NAME; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.ClassContext; import com.android.tools.lint.detector.api.Context; @@ -73,19 +74,19 @@ public class ViewConstructorDetector extends Detector implements Detector.ClassS } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { return true; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } // ---- Implements ClassScanner ---- @Override - public void checkClass(ClassContext context, ClassNode classNode) { + public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) { if (classNode.name.indexOf('$') != -1 && (classNode.access & Opcodes.ACC_STATIC) == 0) { // Ignore inner classes that aren't static: we can't create these diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewTypeDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewTypeDetector.java index 78a06af..30def17 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewTypeDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ViewTypeDetector.java @@ -23,6 +23,8 @@ import static com.android.tools.lint.detector.api.LintConstants.ID_RESOURCE_PREF import static com.android.tools.lint.detector.api.LintConstants.NEW_ID_RESOURCE_PREFIX; import static com.android.tools.lint.detector.api.LintConstants.VIEW_TAG; +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; import com.android.resources.ResourceFolderType; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; @@ -69,17 +71,17 @@ public class ViewTypeDetector extends ResourceXmlDetector implements Detector.Ja private Map<String, String> mIdToViewTag = new HashMap<String, String>(50); @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.SLOW; } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.LAYOUT; } @Override - public boolean appliesTo(Context context, File file) { + public boolean appliesTo(@NonNull Context context, @NonNull File file) { if (LintUtils.endsWith(file.getName(), DOT_JAVA)) { return true; } @@ -100,7 +102,7 @@ public class ViewTypeDetector extends ResourceXmlDetector implements Detector.Ja private static final String IGNORE = "#ignore#"; @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { String view = attribute.getOwnerElement().getTagName(); String value = attribute.getValue(); String id = null; @@ -131,7 +133,8 @@ public class ViewTypeDetector extends ResourceXmlDetector implements Detector.Ja } @Override - public void visitMethod(JavaContext context, AstVisitor visitor, MethodInvocation node) { + public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, + @NonNull MethodInvocation node) { assert node.astName().getDescription().equals("findViewById"); if (node.getParent() instanceof Cast) { Cast cast = (Cast) node.getParent(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongIdDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongIdDetector.java index ef45c09..a9652d1 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongIdDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongIdDetector.java @@ -28,6 +28,7 @@ import static com.android.tools.lint.detector.api.LintConstants.TAG_ITEM; import static com.android.tools.lint.detector.api.LintConstants.VALUE_ID; import static com.android.tools.lint.detector.api.LintUtils.stripIdPrefix; +import com.android.annotations.NonNull; import com.android.resources.ResourceFolderType; import com.android.tools.lint.client.api.IDomParser; import com.android.tools.lint.detector.api.Category; @@ -127,12 +128,12 @@ public class WrongIdDetector extends LayoutDetector { } @Override - public boolean appliesTo(ResourceFolderType folderType) { + public boolean appliesTo(@NonNull ResourceFolderType folderType) { return folderType == ResourceFolderType.LAYOUT || folderType == ResourceFolderType.VALUES; } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -147,13 +148,13 @@ public class WrongIdDetector extends LayoutDetector { } @Override - public void beforeCheckFile(Context context) { + public void beforeCheckFile(@NonNull Context context) { mFileIds = new HashSet<String>(); mRelativeLayouts = null; } @Override - public void afterCheckFile(Context context) { + public void afterCheckFile(@NonNull Context context) { if (mRelativeLayouts != null) { for (Element layout : mRelativeLayouts) { NodeList children = layout.getChildNodes(); @@ -196,7 +197,7 @@ public class WrongIdDetector extends LayoutDetector { } @Override - public void afterCheckProject(Context context) { + public void afterCheckProject(@NonNull Context context) { if (mHandles != null) { boolean checkSameLayout = context.isEnabled(UNKNOWN_ID_LAYOUT); boolean checkExists = context.isEnabled(UNKNOWN_ID); @@ -257,7 +258,7 @@ public class WrongIdDetector extends LayoutDetector { } @Override - public void visitElement(XmlContext context, Element element) { + public void visitElement(@NonNull XmlContext context, @NonNull Element element) { if (element.getTagName().equals(RELATIVE_LAYOUT)) { if (mRelativeLayouts == null) { mRelativeLayouts = new ArrayList<Element>(); @@ -279,7 +280,7 @@ public class WrongIdDetector extends LayoutDetector { } @Override - public void visitAttribute(XmlContext context, Attr attribute) { + public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) { assert attribute.getName().equals(ATTR_ID) || attribute.getLocalName().equals(ATTR_ID); String id = attribute.getValue(); mFileIds.add(id); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongImportDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongImportDetector.java index 2aa416c..fc6cde2 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongImportDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/WrongImportDetector.java @@ -16,6 +16,7 @@ package com.android.tools.lint.checks; +import com.android.annotations.NonNull; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Detector; import com.android.tools.lint.detector.api.Issue; @@ -67,7 +68,7 @@ public class WrongImportDetector extends Detector implements Detector.JavaScanne } @Override - public Speed getSpeed() { + public @NonNull Speed getSpeed() { return Speed.FAST; } @@ -80,7 +81,7 @@ public class WrongImportDetector extends Detector implements Detector.JavaScanne } @Override - public AstVisitor createJavaVisitor(JavaContext context) { + public AstVisitor createJavaVisitor(@NonNull JavaContext context) { return new ImportVisitor(context); } diff --git a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java b/rule_api/src/com/android/ide/common/api/AbstractViewRule.java index 3bbf8e7..7f05809 100644 --- a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java +++ b/rule_api/src/com/android/ide/common/api/AbstractViewRule.java @@ -15,6 +15,7 @@ */ package com.android.ide.common.api; +import com.android.annotations.NonNull; import com.android.annotations.Nullable; import com.google.common.annotations.Beta; @@ -31,7 +32,7 @@ import java.util.List; @Beta public class AbstractViewRule implements IViewRule { @Override - public boolean onInitialize(String fqcn, IClientRulesEngine engine) { + public boolean onInitialize(@NonNull String fqcn, @NonNull IClientRulesEngine engine) { return true; } @@ -50,22 +51,22 @@ public class AbstractViewRule implements IViewRule { @Override @Nullable - public List<String> getSelectionHint(INode parentNode, INode childNode) { + public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode) { return null; } @Override - public void addLayoutActions(List<RuleAction> actions, INode parentNode, - List<? extends INode> children) { + public void addLayoutActions(@NonNull List<RuleAction> actions, @NonNull INode parentNode, + @NonNull List<? extends INode> children) { } @Override - public void addContextMenuActions(List<RuleAction> actions, INode node) { + public void addContextMenuActions(@NonNull List<RuleAction> actions, @NonNull INode node) { } @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) { } // ==== Drag & drop support ==== @@ -73,66 +74,66 @@ public class AbstractViewRule implements IViewRule { // By default Views do not accept drag'n'drop. @Override @Nullable - public DropFeedback onDropEnter(INode targetNode, Object targetView, IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, @Nullable IDragElement[] elements) { return null; } @Override @Nullable - 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) { return null; } @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( - INode targetNode, - IDragElement[] elements, - DropFeedback feedback, - Point p) { + @NonNull INode targetNode, + @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback, + @NonNull Point p) { // ignore } @Override - public void onPaste(INode targetNode, Object targetView, IDragElement[] pastedElements) { + public void onPaste(@NonNull INode targetNode, @Nullable Object targetView, @NonNull IDragElement[] pastedElements) { } // ==== Create/Remove hooks ==== @Override - public void onCreate(INode node, INode parent, InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, @NonNull InsertType insertType) { } @Override - public void onChildInserted(INode child, INode parent, InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, @NonNull InsertType insertType) { } @Override - public void onRemovingChildren(List<INode> deleted, INode parent) { + public void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent) { } // ==== Resizing ==== @Override @Nullable - 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) { return null; } @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) { } @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) { } } diff --git a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java b/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java index ec28520..b9ea6cb 100644 --- a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java +++ b/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java @@ -106,10 +106,10 @@ public interface IClientRulesEngine { /** * Returns a resource name validator for the current project * - * @return an {@link IValidator} for validating new resource name in the current + * @return an {@link IValidator} for validating a new resource name in the current * project */ - @NonNull + @Nullable IValidator getResourceValidator(); /** diff --git a/rule_api/src/com/android/ide/common/api/IMenuCallback.java b/rule_api/src/com/android/ide/common/api/IMenuCallback.java index fd100ee..2ff3f8d 100644 --- a/rule_api/src/com/android/ide/common/api/IMenuCallback.java +++ b/rule_api/src/com/android/ide/common/api/IMenuCallback.java @@ -49,4 +49,17 @@ public interface IMenuCallback { @NonNull List<? extends INode> selectedNodes, @Nullable String valueId, @Nullable Boolean newValue); + + /** Callback which does nothing */ + @NonNull + public static final IMenuCallback NONE = new IMenuCallback() { + @Override + public void action( + @NonNull RuleAction action, + @NonNull + List<? extends INode> selectedNodes, + @Nullable String valueId, + @Nullable Boolean newValue) { + } + }; } diff --git a/rule_api/src/com/android/ide/common/api/INode.java b/rule_api/src/com/android/ide/common/api/INode.java index d957419..b137699 100644 --- a/rule_api/src/com/android/ide/common/api/INode.java +++ b/rule_api/src/com/android/ide/common/api/INode.java @@ -180,7 +180,7 @@ public interface INode { * @param value It's value. Cannot be null. An empty value <em>removes</em> the attribute. * @return Whether the attribute was actually set or not. */ - boolean setAttribute(@Nullable String uri, @NonNull String localName, @NonNull String value); + boolean setAttribute(@Nullable String uri, @NonNull String localName, @Nullable String value); /** * Returns a given XML attribute. diff --git a/rule_api/src/com/android/ide/common/api/RuleAction.java b/rule_api/src/com/android/ide/common/api/RuleAction.java index f6c7e8c..489a3cc 100644 --- a/rule_api/src/com/android/ide/common/api/RuleAction.java +++ b/rule_api/src/com/android/ide/common/api/RuleAction.java @@ -448,9 +448,9 @@ public class RuleAction implements Comparable<RuleAction> { return mCallback; } - // Implements Comparable<MenuAciton> + // Implements Comparable<MenuAction> @Override - public int compareTo(@NonNull RuleAction other) { + public int compareTo(RuleAction other) { if (mSortPriority != other.mSortPriority) { return mSortPriority - other.mSortPriority; } @@ -468,7 +468,7 @@ public class RuleAction implements Comparable<RuleAction> { public static class Separator extends RuleAction { /** Construct using the factory {@link #createSeparator(int)} */ private Separator(int sortPriority, boolean supportsMultipleNodes) { - super("_separator", "", null, sortPriority, //$NON-NLS-1$ //$NON-NLS-2$ + super("_separator", "", IMenuCallback.NONE, sortPriority, //$NON-NLS-1$ //$NON-NLS-2$ supportsMultipleNodes); } } @@ -689,13 +689,13 @@ public class RuleAction implements Comparable<RuleAction> { } @Override - public List<String> getIds() { + public @NonNull List<String> getIds() { ensureInitialized(); return mIds; } @Override - public List<String> getTitles() { + public @NonNull List<String> getTitles() { ensureInitialized(); return mTitles; } diff --git a/rule_api/src/com/android/ide/common/api/Segment.java b/rule_api/src/com/android/ide/common/api/Segment.java index 9f03286..d31d9f8 100644 --- a/rule_api/src/com/android/ide/common/api/Segment.java +++ b/rule_api/src/com/android/ide/common/api/Segment.java @@ -51,7 +51,7 @@ public class Segment { public final MarginType marginType; /** The node that contains this edge */ - @NonNull + @Nullable public final INode node; /** @@ -61,7 +61,7 @@ public class Segment { @Nullable public final String id; - public Segment(int at, int from, int to, @NonNull INode node, @Nullable String id, + public Segment(int at, int from, int to, @Nullable INode node, @Nullable String id, @NonNull SegmentType edgeType, @NonNull MarginType marginType) { this.at = at; this.from = from; diff --git a/rule_api/src/com/android/ide/common/api/SegmentType.java b/rule_api/src/com/android/ide/common/api/SegmentType.java index 25635c7..9da248a 100644 --- a/rule_api/src/com/android/ide/common/api/SegmentType.java +++ b/rule_api/src/com/android/ide/common/api/SegmentType.java @@ -27,7 +27,22 @@ import com.google.common.annotations.Beta; */ @Beta public enum SegmentType { - LEFT, TOP, RIGHT, BOTTOM, BASELINE, CENTER_VERTICAL, CENTER_HORIZONTAL, UNKNOWN; + /** Segment is on the left edge */ + @NonNull LEFT, + /** Segment is on the top edge */ + @NonNull TOP, + /** Segment is on the right edge */ + @NonNull RIGHT, + /** Segment is on the bottom edge */ + @NonNull BOTTOM, + /** Segment is along the baseline */ + @NonNull BASELINE, + /** Segment is along the center vertically */ + @NonNull CENTER_VERTICAL, + /** Segment is along the center horizontally */ + @NonNull CENTER_HORIZONTAL, + /** Segment is on an unknown edge */ + @NonNull UNKNOWN; public boolean isHorizontal() { return this == TOP || this == BOTTOM || this == BASELINE || this == CENTER_HORIZONTAL; diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java index dc19287..768a835 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java @@ -16,6 +16,7 @@ package com.android.sdklib.internal.avd; +import com.android.annotations.Nullable; import com.android.io.FileWrapper; import com.android.prefs.AndroidLocation; import com.android.prefs.AndroidLocation.AndroidLocationException; @@ -1404,14 +1405,14 @@ public class AvdManager { Wait.WAIT_FOR_READERS, new IProcessOutput() { @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { stdOutput.add(line); } } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { errorOutput.add(line); } diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/KeystoreHelper.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/KeystoreHelper.java index af5b401..ba4ce8c 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/KeystoreHelper.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/KeystoreHelper.java @@ -16,6 +16,7 @@ package com.android.sdklib.internal.build; +import com.android.annotations.Nullable; import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput; import com.android.sdklib.internal.build.DebugKeyProvider.KeytoolException; import com.android.sdklib.util.GrabProcessOutput; @@ -111,7 +112,7 @@ public final class KeystoreHelper { Wait.WAIT_FOR_READERS, new IProcessOutput() { @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { if (output != null) { output.out(line); @@ -122,7 +123,7 @@ public final class KeystoreHelper { } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { if (output != null) { output.err(line); diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/archives/ArchiveInstaller.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/archives/ArchiveInstaller.java index 3addb31..c2e11cd 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/archives/ArchiveInstaller.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/archives/ArchiveInstaller.java @@ -16,6 +16,7 @@ package com.android.sdklib.internal.repository.archives;
+import com.android.annotations.Nullable;
import com.android.annotations.VisibleForTesting;
import com.android.annotations.VisibleForTesting.Visibility;
import com.android.sdklib.SdkConstants;
@@ -609,14 +610,14 @@ public class ArchiveInstaller { Wait.WAIT_FOR_READERS,
new IProcessOutput() {
@Override
- public void out(String line) {
+ public void out(@Nullable String line) {
if (line != null) {
result.append(line).append("\n");
}
}
@Override
- public void err(String line) {
+ public void err(@Nullable String line) {
if (line != null) {
monitor.logError("[find_lock] Error: %1$s", line);
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java index 8ae469e..e2052c4 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java @@ -16,6 +16,7 @@ package com.android.sdklib.internal.repository.packages;
+import com.android.annotations.Nullable;
import com.android.annotations.VisibleForTesting;
import com.android.annotations.VisibleForTesting.Visibility;
import com.android.sdklib.SdkConstants;
@@ -315,14 +316,14 @@ public class ToolPackage extends FullRevisionPackage implements IMinPlatformTool Wait.WAIT_FOR_PROCESS,
new IProcessOutput() {
@Override
- public void out(String line) {
+ public void out(@Nullable String line) {
if (line != null) {
monitor.log("[%1$s] %2$s", tag, line);
}
}
@Override
- public void err(String line) {
+ public void err(@Nullable String line) {
if (line != null) {
monitor.logError("[%1$s] Error: %2$s", tag, line);
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java index daacf10..5d24a07 100644 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdSelector.java @@ -16,6 +16,7 @@ package com.android.sdkuilib.internal.widgets; +import com.android.annotations.Nullable; import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.ISdkLog; @@ -1112,14 +1113,14 @@ public final class AvdSelector { Wait.ASYNC, new IProcessOutput() { @Override - public void out(String line) { + public void out(@Nullable String line) { if (line != null) { filterStdOut(line); } } @Override - public void err(String line) { + public void err(@Nullable String line) { if (line != null) { filterStdErr(line); } |