Make CompiledResourcesMonitor#getRClassName more error proof.

This commit is contained in:
Xavier Ducrohet
2009-05-29 15:01:18 -07:00
parent e0fbae303c
commit 3106768f31
2 changed files with 134 additions and 130 deletions

View File

@@ -670,6 +670,7 @@ public class AndroidManifestParser {
boolean markErrors)
throws CoreException {
try {
if (manifestFile != null) {
SAXParser parser = sParserFactory.newSAXParser();
ManifestHandler manifestHandler = new ManifestHandler(manifestFile,
@@ -677,7 +678,6 @@ public class AndroidManifestParser {
parser.parse(new InputSource(manifestFile.getContents()), manifestHandler);
// get the result from the handler
return new AndroidManifestParser(manifestHandler.getPackage(),
manifestHandler.getActivities(),
manifestHandler.getLauncherActivity(),
@@ -686,6 +686,7 @@ public class AndroidManifestParser {
manifestHandler.getApiLevelRequirement(),
manifestHandler.getInstrumentations(),
manifestHandler.getUsesLibraries());
}
} catch (ParserConfigurationException e) {
AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(),
"Bad parser configuration for %s: %s",

View File

@@ -26,6 +26,7 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ResourceMonitor.IP
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -216,11 +217,13 @@ public final class CompiledResourcesMonitor implements IFileListener, IProjectLi
private String getRClassName(IProject project) {
try {
IFile manifestFile = AndroidManifestParser.getManifest(project);
if (manifestFile != null && manifestFile.isSynchronized(IResource.DEPTH_ZERO)) {
AndroidManifestParser data = AndroidManifestParser.parseForData(manifestFile);
if (data != null) {
String javaPackage = data.getPackage();
return javaPackage + ".R"; //$NON-NLS-1$
}
}
} catch (CoreException e) {
// This will typically happen either because the manifest file is not present
// and/or the workspace needs to be refreshed.