ADT #1877529: Fixes a couple potential NPEs in content assists.
Can't reproduce the NPE in ContentAssist listed in the bug. However if things go really wrong there are a couple objects that can be null so let's be defensive about them.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.ide.eclipse.adt.internal.editors;
|
||||
|
||||
import com.android.ide.eclipse.adt.AdtPlugin;
|
||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor;
|
||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils;
|
||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
|
||||
@@ -30,6 +31,7 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiFlagAttributeNode;
|
||||
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
@@ -117,6 +119,11 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor {
|
||||
|
||||
if (mEditor == null) {
|
||||
mEditor = getAndroidEditor(viewer);
|
||||
if (mEditor == null) {
|
||||
// This should not happen. Duck and forget.
|
||||
AdtPlugin.log(IStatus.ERROR, "Editor not found during completion");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
UiElementNode rootUiNode = mEditor.getUiRootNode();
|
||||
@@ -137,6 +144,11 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor {
|
||||
UiElementNode currentUiNode =
|
||||
rootUiNode == null ? null : rootUiNode.findXmlNode(currentNode);
|
||||
|
||||
if (currentNode == null) {
|
||||
// Should not happen (an XML doc always has at least a doc node). Just give up.
|
||||
return null;
|
||||
}
|
||||
|
||||
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
parent = currentNode.getNodeName();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user