Skip to content

Commit

Permalink
moving to Path
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Aug 15, 2018
1 parent 0c008e9 commit 710ed40
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -11,18 +11,18 @@
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver;
import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.Assert.assertEquals;

public class Issue1485 extends AbstractTest {

@Test
public void issue1485withoutSpecifyingJARs() throws IOException {
File dir = adaptPath("src/test/resources/issue1485").toFile();
File file = adaptPath("src/test/resources/issue1485/Complex.java").toFile();
Path dir = adaptPath("src/test/resources/issue1485");
Path file = adaptPath("src/test/resources/issue1485/Complex.java");

CombinedTypeSolver typeSolver = new CombinedTypeSolver();
typeSolver.add(new ReflectionTypeSolver());
Expand All @@ -31,7 +31,8 @@ public void issue1485withoutSpecifyingJARs() throws IOException {
JavaParser javaParser = new JavaParser();
javaParser.getParserConfiguration().setSymbolResolver(new JavaSymbolSolver(typeSolver));

CompilationUnit unit = javaParser.parse(ParseStart.COMPILATION_UNIT, new StreamProvider(new FileInputStream(file))).getResult().get();
CompilationUnit unit = javaParser.parse(ParseStart.COMPILATION_UNIT,
new StreamProvider(Files.newInputStream(file))).getResult().get();

MethodCallExpr methodCallExpr = unit.findFirst(MethodCallExpr.class, m -> m.getName().getIdentifier().equals("println")).get();
ResolvedMethodDeclaration resolvedMethodDeclaration = methodCallExpr.resolve();
Expand Down

0 comments on commit 710ed40

Please sign in to comment.