Merge change 2472 into donut
* changes: ADT #1877529: Fixes a couple potential NPEs in content assists.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.ide.eclipse.adt.internal.editors;
|
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.AttributeDescriptor;
|
||||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils;
|
import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils;
|
||||||
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
|
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.ide.eclipse.adt.internal.sdk.AndroidTargetData;
|
||||||
import com.android.sdklib.SdkConstants;
|
import com.android.sdklib.SdkConstants;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
@@ -117,6 +119,11 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor {
|
|||||||
|
|
||||||
if (mEditor == null) {
|
if (mEditor == null) {
|
||||||
mEditor = getAndroidEditor(viewer);
|
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();
|
UiElementNode rootUiNode = mEditor.getUiRootNode();
|
||||||
@@ -137,6 +144,11 @@ public abstract class AndroidContentAssist implements IContentAssistProcessor {
|
|||||||
UiElementNode currentUiNode =
|
UiElementNode currentUiNode =
|
||||||
rootUiNode == null ? null : rootUiNode.findXmlNode(currentNode);
|
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) {
|
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
parent = currentNode.getNodeName();
|
parent = currentNode.getNodeName();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user