exception handling

This commit is contained in:
Eugene Zhuravlev
2011-11-04 12:47:26 +01:00
parent 53539ffc9e
commit bf41e38c85
4 changed files with 24 additions and 13 deletions
@@ -1,5 +1,6 @@
package org.jetbrains.jps.server;
import com.intellij.openapi.util.io.FileUtil;
import org.codehaus.groovy.runtime.MethodClosure;
import org.jetbrains.ether.dependencyView.Mappings;
import org.jetbrains.jps.JavaSdk;
@@ -7,6 +8,7 @@ import org.jetbrains.jps.Library;
import org.jetbrains.jps.Module;
import org.jetbrains.jps.Project;
import org.jetbrains.jps.api.BuildParameters;
import org.jetbrains.jps.api.BuildType;
import org.jetbrains.jps.api.GlobalLibrary;
import org.jetbrains.jps.api.SdkLibrary;
import org.jetbrains.jps.idea.IdeaProjectLoader;
@@ -52,6 +54,7 @@ class ServerState {
public void startBuild(String projectPath, Set<String> modules, final BuildParameters params, final MessageHandler msgHandler) throws Throwable{
final String projectName = getProjectName(projectPath);
BuildType buildType = params.buildType;
Project project;
Mappings mappings;
@@ -80,8 +83,10 @@ class ServerState {
mappings = new Mappings(mappingsRoot);
}
catch (IOException e) {
msgHandler.processMessage(new CompilerMessage(IncProjectBuilder.JPS_SERVER_NAME, BuildMessage.Kind.WARNING, e.getMessage()));
FileUtil.delete(mappingsRoot);
msgHandler.processMessage(new CompilerMessage(IncProjectBuilder.JPS_SERVER_NAME, BuildMessage.Kind.WARNING, "Problems reading dependency information, rebuild required: " + e.getMessage()));
mappings = new Mappings(mappingsRoot);
buildType = BuildType.REBUILD;
}
myProjectMappings.put(projectPath, mappings);
@@ -106,7 +111,7 @@ class ServerState {
if (msgHandler != null) {
builder.addMessageHandler(msgHandler);
}
switch (params.buildType) {
switch (buildType) {
case REBUILD:
builder.build(compileScope, false);
break;
@@ -51,15 +51,10 @@ class DependencyContext {
return file;
}
DependencyContext(final File rootDir) {
DependencyContext(final File rootDir) throws IOException {
final File file = getTableFile(rootDir, stringTableName);
try {
enumerator = new PersistentStringEnumerator(file, true);
}
catch (IOException e) {
throw new RuntimeException(e);
}
enumerator = new PersistentStringEnumerator(file, true);
}
static KeyDescriptor<S> descriptorS = new KeyDescriptor<S>() {
@@ -10,6 +10,7 @@ import org.objectweb.asm.Opcodes;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.RetentionPolicy;
import java.util.*;
@@ -80,7 +81,7 @@ public class Mappings implements RW.Writable {
classToForm = new HashMap<DependencyContext.S, DependencyContext.S>();
}
public Mappings(final File rootDir) {
public Mappings(final File rootDir) throws IOException {
context = new DependencyContext(rootDir);
classToSubclasses = new PersistentMaplet<DependencyContext.S, DependencyContext.S>(DependencyContext.getTableFile(rootDir,
@@ -96,7 +97,7 @@ public class Mappings implements RW.Writable {
classToForm = new HashMap<DependencyContext.S, DependencyContext.S>();
}
public Mappings(final File rootDir, final BufferedReader r) {
public Mappings(final File rootDir, final BufferedReader r) throws IOException {
context = new DependencyContext(rootDir);
classToSubclasses = new PersistentMaplet<DependencyContext.S, DependencyContext.S>(DependencyContext.getTableFile(rootDir,
classToSubclassesName), DependencyContext.descriptorS, DependencyContext.descriptorS, stringSetConstructor);
@@ -852,7 +852,12 @@ public class ProjectWrapper {
myProjectSnapshot =
myHomeDir + File.separator + myJPSDir + File.separator + myRoot.replace(File.separatorChar, myFileSeparatorReplacement);
dependencyMapping = new Mappings(getMapDir());
try {
dependencyMapping = new Mappings(getMapDir());
}
catch (IOException e) {
throw new RuntimeException(e);
}
backendCallback = dependencyMapping.getCallback();
for (Module m : myProject.getModules().values()) {
@@ -908,7 +913,12 @@ public class ProjectWrapper {
RW.readMany(r, RW.myStringReader, affectedFiles);
dependencyMapping = new Mappings(getMapDir(), r);
try {
dependencyMapping = new Mappings(getMapDir(), r);
}
catch (IOException e) {
throw new RuntimeException(e);
}
backendCallback = dependencyMapping.getCallback();
}