Skip to content

Commit

Permalink
Roll back ParseResult constructor change
Browse files Browse the repository at this point in the history
  • Loading branch information
matozoid committed May 14, 2018
1 parent 218b720 commit af2c096
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
Expand Up @@ -329,7 +329,7 @@ private static <T extends Node> T simplifiedParse(ParseStart<T> context, Provide
if (result.isSuccessful()) {
return result.getResult().get();
}
throw new ParseProblemException(result);
throw new ParseProblemException(result.getProblems());
}

/**
Expand Down
Expand Up @@ -35,16 +35,14 @@ public class ParseProblemException extends RuntimeException {
* The problems that were encountered during parsing
*/
private final List<Problem> problems;
private final ParseResult<?> result;

public ParseProblemException(ParseResult<?> result) {
super(createMessage(assertNotNull(result.getProblems())));
this.problems = result.getProblems();
this.result = result;
public ParseProblemException(List<Problem> problems) {
super(createMessage(assertNotNull(problems)));
this.problems = problems;
}

public ParseProblemException(Throwable throwable) {
this(new ParseResult<>(null, singletonList(new Problem(throwable.getMessage(), null, throwable)), null, null));
this(singletonList(new Problem(throwable.getMessage(), null, throwable)));
}

private static String createMessage(List<Problem> problems) {
Expand All @@ -58,8 +56,4 @@ private static String createMessage(List<Problem> problems) {
public List<Problem> getProblems() {
return problems;
}

public ParseResult<?> getResult() {
return result;
}
}
Expand Up @@ -253,7 +253,7 @@ public CompilationUnit parse(String startPackage, String filename) {
if (result.isSuccessful()) {
return result.getResult().get();
}
throw new ParseProblemException(result);
throw new ParseProblemException(result.getProblems());
} catch (IOException e) {
throw new ParseProblemException(e);
}
Expand Down
Expand Up @@ -16,14 +16,14 @@

package com.github.javaparser.symbolsolver.resolution.typesolvers;

import com.github.javaparser.*;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration;
import com.github.javaparser.symbolsolver.javaparser.Navigator;
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
import com.github.javaparser.symbolsolver.model.resolution.SymbolReference;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
import com.github.javaparser.utils.Log;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

Expand All @@ -35,8 +35,8 @@
import java.util.Optional;
import java.util.concurrent.ExecutionException;

import static com.github.javaparser.ParseStart.*;
import static com.github.javaparser.ParserConfiguration.LanguageLevel.*;
import static com.github.javaparser.ParseStart.COMPILATION_UNIT;
import static com.github.javaparser.ParserConfiguration.LanguageLevel.BLEEDING_EDGE;
import static com.github.javaparser.Providers.provider;

/**
Expand Down Expand Up @@ -106,9 +106,6 @@ private Optional<CompilationUnit> parse(File srcFile) {
.map(cu -> cu.setStorage(srcFile.toPath()));
} catch (FileNotFoundException e) {
throw new RuntimeException("Issue while parsing while type solving: " + srcFile.getAbsolutePath(), e);
} catch (ParseProblemException e) {
Log.trace("Issue while parsing while type solving: " + srcFile.getAbsolutePath(), e);
return Optional.of((CompilationUnit) e.getResult().getResult().get());
}
});
} catch (ExecutionException e) {
Expand Down

0 comments on commit af2c096

Please sign in to comment.