aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-02-23 10:31:54 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-23 10:31:54 -0800
commitdbf4c45d795d5f5caf99bd015f157909cd3bf59d (patch)
tree61773051358d3b5e06fc289f7c7c7b2321a532e8 /eclipse
parent145dc8fc87c819fc9a1845c4f0f9a13fdf83d8ee (diff)
parentc8e42c3bfdef4941696155e5b333dd6d4075bbf0 (diff)
downloadsdk-dbf4c45d795d5f5caf99bd015f157909cd3bf59d.zip
sdk-dbf4c45d795d5f5caf99bd015f157909cd3bf59d.tar.gz
sdk-dbf4c45d795d5f5caf99bd015f157909cd3bf59d.tar.bz2
Merge "Handle nulls from Element.getAttribute (fix for issue 25668)"
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java23
1 files changed, 11 insertions, 12 deletions
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 fc8d5b1..3da3fc2 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
@@ -97,7 +97,7 @@ import lombok.ast.grammar.Source;
@SuppressWarnings("restriction") // DOM model
public class EclipseLintClient extends LintClient implements IDomParser {
static final String MARKER_CHECKID_PROPERTY = "checkid"; //$NON-NLS-1$
- private static final String DOCUMENT_PROPERTY = "document"; //$NON-NLS-1$
+ private static final String MODEL_PROPERTY = "model"; //$NON-NLS-1$
private final List<? extends IResource> mResources;
private final IDocument mDocument;
private boolean mWasFatal;
@@ -162,7 +162,7 @@ public class EclipseLintClient extends LintClient implements IDomParser {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForRead(file);
if (model instanceof IDOMModel) {
- context.setProperty(DOCUMENT_PROPERTY, model.getStructuredDocument());
+ context.setProperty(MODEL_PROPERTY, model);
IDOMModel domModel = (IDOMModel) model;
return domModel.getDocument();
}
@@ -170,11 +170,6 @@ public class EclipseLintClient extends LintClient implements IDomParser {
AdtPlugin.log(e, "Cannot read XML file");
} catch (CoreException e) {
AdtPlugin.log(e, null);
- } finally {
- if (model != null) {
- // TODO: This may be too early...
- model.releaseFromRead();
- }
}
return null;
@@ -585,14 +580,14 @@ public class EclipseLintClient extends LintClient implements IDomParser {
@Override
public Location getLocation(XmlContext context, Node node) {
- IStructuredDocument doc = (IStructuredDocument) context.getProperty(DOCUMENT_PROPERTY);
- return new LazyLocation(context.file, doc, (IndexedRegion) 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) {
- IStructuredDocument doc = (IStructuredDocument) context.getProperty(DOCUMENT_PROPERTY);
- return new LazyLocation(context.file, doc, (IndexedRegion) node);
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ return new LazyLocation(context.file, model.getStructuredDocument(), (IndexedRegion) node);
}
/**
@@ -611,7 +606,11 @@ public class EclipseLintClient extends LintClient implements IDomParser {
@Override
public void dispose(XmlContext context, Document document) {
- // TODO: Consider leaving read-lock on the document in parse() and freeing it here.
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ assert model != null : context.file;
+ if (model != null) {
+ model.releaseFromRead();
+ }
}
private static class LazyLocation extends Location implements Location.Handle {