Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 2960 #2965

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix issue 2960 #2965

wants to merge 2 commits into from

Conversation

qzchenwl
Copy link
Contributor

Fixes #2960.

@qzchenwl
Copy link
Contributor Author

qzchenwl commented Nov 30, 2020

This breaks the test case:

Expected :Line 93) commentsInserter.insertComments(resultNode, comments.copy().getComments()) ==> com.github.javaparser.CommentsInserter.insertComments(com.github.javaparser.ast.Node, java.util.TreeSet<com.github.javaparser.ast.comments.Comment>)
Actual   :Line 93) commentsInserter.insertComments(resultNode, comments.copy().getComments()) ==> com.github.javaparser.CommentsInserter.insertComments(com.github.javaparser.ast.CompilationUnit, java.util.TreeSet<com.github.javaparser.ast.comments.Comment>)

parsing

	public <N extends Node> ParseResult<N> parse(ParseStart<N> start, Provider provider) {
		try {
            final ASTParser parser = getParserForProvider(provider);
			N resultNode = start.parse(parser);
            final CommentsCollection comments = astParser.getCommentsCollection();
            commentsInserter.insertComments(resultNode, comments.copy().getComments());
            
			return new ParseResult<>(Optional.of(resultNode), parser.problems, Optional.of(astParser.getTokens()), Optional.of(astParser.getCommentsCollection()));
		} catch (ParseException e) {
			return new ParseResult<>(e);
        } catch (TokenMgrException e) {
            return new ParseResult<>(e);
		} finally {
			try {
				provider.close();
			} catch (IOException e) {
				// Since we're done parsing and have our result, we don't care about any errors.
			}
		}
	}

There are two cases when argument is type variable:

  1. result of evaluating a template function.
  2. variable defined in template function body (same as MethodCallExpr).

They should be treat differently. Case 1 is a type waitting to be inferred, case 2 is a fixed type.

@jlerbsc
Copy link
Collaborator

jlerbsc commented Jan 26, 2021

This PR seems correct but there are few errors in unit tests.

When i try to report your correction on the current version i got this errors.

[ERROR]   AnalyseJavaSymbolSolver060Test.parseCoreJavaparsermodelContexts:182->parse:121 Line 34 of javaparser\javaparser-symbol-solver-testing\src\test\test_sourcecode\javasymbolsolver_0_6_0\expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_contexts_StatementContext.txt is different from what is expected ==> expected: <Line 104) JavaParserFactory.getSymbolDeclarator(wrappedNode, typeSolver) ==> com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFactory.getSymbolDeclarator(com.github.javaparser.ast.Node, com.github.javaparser.symbolsolver.model.resolution.TypeSolver)> but was: <Line 104) JavaParserFactory.getSymbolDeclarator(wrappedNode, typeSolver) ==> UNSOLVED>
[ERROR]   AnalyseJavaSymbolSolver060Test.parseCoreJavaparsermodelDeclarations:218->parse:121 Line 1 of javaparser\javaparser-symbol-solver-testing\src\test\test_sourcecode\javasymbolsolver_0_6_0\expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserTypeAdapter.txt is different from what is expected ==> expected: <Line 39) Helper.getPackageName(wrappedNode) ==> com.github.javaparser.symbolsolver.javaparsermodel.declarations.Helper.getPackageName(com.github.javaparser.ast.Node)> but was: <Line 39) Helper.getPackageName(wrappedNode) ==> UNSOLVED>
[ERROR]   AnalyseNewJavaParserTest.parseAllOtherNodes:315->parse:104 Line 5 of javaparser\javaparser-symbol-solver-testing\src\test\test_sourcecode\javaparser_new_src\expected_output\com_github_javaparser_JavaParser.txt is different from what is expected ==> expected: <Line 93) commentsInserter.insertComments(resultNode, comments.copy().getComments()) ==> com.github.javaparser.CommentsInserter.insertComments(com.github.javaparser.ast.Node, java.util.TreeSet<com.github.javaparser.ast.comments.Comment>)> but was: <Line 93) commentsInserter.insertComments(resultNode, comments.copy().getComments()) ==> com.github.javaparser.CommentsInserter.insertComments(com.github.javaparser.ast.CompilationUnit, java.util.TreeSet<com.github.javaparser.ast.comments.Comment>)>
[ERROR]   AnalyseNewJavaParserTest.parseAstRest:250->parse:104 Line 41 of javaparser\javaparser-symbol-solver-testing\src\test\test_sourcecode\javaparser_new_src\expected_output\com_github_javaparser_ast_Node.txt is different from what is expected ==> expected: <Line 351) nodes.add(clazz.cast(child)) ==> java.util.List.add(E)> but was: <Line 351) nodes.add(clazz.cast(child)) ==> UNSOLVED>
[ERROR]   AnalyseNewJavaParserTest.parseAstVisitor:292->parse:104 Line 689 of javaparser\javaparser-symbol-solver-testing\src\test\test_sourcecode\javaparser_new_src\expected_output\com_github_javaparser_ast_visitor_CloneVisitor.txt is different from what is expected ==> expected: <Line 1282) r.add(rN) ==> java.util.List.add(E)> but was: <Line 1282) r.add(rN) ==> UNSOLVED>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot resolve MethodCallExpr with generic type argument.
2 participants