mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
cleanup
improved error handling
This commit is contained in:
parent
22dcf4b013
commit
181ceb45e7
4 changed files with 11 additions and 12 deletions
|
@ -21,7 +21,7 @@ public interface IMakeTargetManager {
|
||||||
void renameTarget(IMakeTarget target, String name) throws CoreException;
|
void renameTarget(IMakeTarget target, String name) throws CoreException;
|
||||||
|
|
||||||
IMakeTarget[] getTargets(IContainer container) throws CoreException;
|
IMakeTarget[] getTargets(IContainer container) throws CoreException;
|
||||||
IMakeTarget findTarget(IContainer container, String name);
|
IMakeTarget findTarget(IContainer container, String name) throws CoreException;
|
||||||
|
|
||||||
IProject[] getTargetBuilderProjects() throws CoreException;
|
IProject[] getTargetBuilderProjects() throws CoreException;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class MakeBuilder extends ACBuilder {
|
||||||
public class MyResourceDeltaVisitor implements IResourceDeltaVisitor {
|
public class MyResourceDeltaVisitor implements IResourceDeltaVisitor {
|
||||||
boolean bContinue;
|
boolean bContinue;
|
||||||
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
public boolean visit(IResourceDelta delta) {
|
||||||
IResource resource = delta.getResource();
|
IResource resource = delta.getResource();
|
||||||
if (resource != null && resource.getProject() == getProject()) {
|
if (resource != null && resource.getProject() == getProject()) {
|
||||||
bContinue = true;
|
bContinue = true;
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
||||||
return projectTargets.get(container);
|
return projectTargets.get(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMakeTarget findTarget(IContainer container, String name) {
|
public IMakeTarget findTarget(IContainer container, String name) throws CoreException {
|
||||||
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
|
ProjectTargets projectTargets = (ProjectTargets)projectMap.get(container.getProject());
|
||||||
if (projectTargets == null) {
|
if (projectTargets == null) {
|
||||||
projectTargets = readTargets(container.getProject());
|
projectTargets = readTargets(container.getProject());
|
||||||
|
@ -256,7 +256,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ProjectTargets readTargets(IProject project) {
|
protected ProjectTargets readTargets(IProject project) throws CoreException {
|
||||||
IPath targetFilePath =
|
IPath targetFilePath =
|
||||||
MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
|
MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT);
|
||||||
File targetFile = targetFilePath.toFile();
|
File targetFile = targetFilePath.toFile();
|
||||||
|
@ -268,7 +268,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (projectTargets == null) {
|
if (projectTargets == null) {
|
||||||
projectTargets = new ProjectTargets(this, project);
|
projectTargets = new ProjectTargets(project);
|
||||||
}
|
}
|
||||||
projectMap.put(project, projectTargets);
|
projectMap.put(project, projectTargets);
|
||||||
return projectTargets;
|
return projectTargets;
|
||||||
|
|
|
@ -48,22 +48,21 @@ public class ProjectTargets {
|
||||||
private HashMap targetMap = new HashMap();
|
private HashMap targetMap = new HashMap();
|
||||||
|
|
||||||
private IProject project;
|
private IProject project;
|
||||||
private MakeTargetManager manager;
|
|
||||||
|
|
||||||
public ProjectTargets(MakeTargetManager manager, IProject project) {
|
public ProjectTargets(IProject project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.manager = manager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectTargets(MakeTargetManager manager, IProject project, InputStream input) {
|
public ProjectTargets(MakeTargetManager manager, IProject project, InputStream input) throws CoreException {
|
||||||
this(manager, project);
|
this(project);
|
||||||
|
|
||||||
Document document = null;
|
Document document = null;
|
||||||
try {
|
try {
|
||||||
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
document = parser.parse(input);
|
document = parser.parse(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MakeCorePlugin.log(e);
|
throw new CoreException(
|
||||||
|
new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, "Error reading project targets.", e));
|
||||||
}
|
}
|
||||||
Node node = document.getFirstChild();
|
Node node = document.getFirstChild();
|
||||||
if (node.getNodeName().equals(BUILD_TARGET_ELEMENT)) {
|
if (node.getNodeName().equals(BUILD_TARGET_ELEMENT)) {
|
||||||
|
@ -188,7 +187,7 @@ public class ProjectTargets {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Document getAsXML() throws IOException {
|
protected Document getAsXML() {
|
||||||
Document doc = new DocumentImpl();
|
Document doc = new DocumentImpl();
|
||||||
Element targetsRootElement = doc.createElement(BUILD_TARGET_ELEMENT);
|
Element targetsRootElement = doc.createElement(BUILD_TARGET_ELEMENT);
|
||||||
doc.appendChild(targetsRootElement);
|
doc.appendChild(targetsRootElement);
|
||||||
|
|
Loading…
Add table
Reference in a new issue