logic: added support for Java 10

* updated java indexed and dependencies to support java 10
* added java indexer test for java 10 "var" support
This commit is contained in:
mlangkabel
2018-07-10 11:26:51 +02:00
parent 2bbe696af2
commit 6bbb44309d
10 changed files with 46 additions and 18 deletions
+2
View File
@@ -755,6 +755,8 @@ if (WIN32)
COMMAND cd $(ProjectDir)../../bin/test/\n$(OutDir)$(TargetName)$(TargetExt)
COMMENT "Running unittest code"
)
set_target_properties(${TEST_PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/bigobj")
elseif (UNIX)
+1 -1
View File
@@ -898,7 +898,7 @@
<File Id='OrgEclipseEquinoxRegistry' Name='org.eclipse.equinox.registry-3.8.0.jar' DiskId='1' Source='./../../../bin/app/data/java/lib/org.eclipse.equinox.registry-3.8.0.jar' KeyPath='yes' />
</Component>
<Component Id='JavaOrgEclipseJdtCoreJar' Guid='*' Win64="$(var.Win64)">
<File Id='OrgEclipseJdtCore' Name='org.eclipse.jdt.core-3.13.0.jar' DiskId='1' Source='./../../../bin/app/data/java/lib/org.eclipse.jdt.core-3.13.0.jar' KeyPath='yes' />
<File Id='OrgEclipseJdtCore' Name='org.eclipse.jdt.core-3.13.102.jar' DiskId='1' Source='./../../../bin/app/data/java/lib/org.eclipse.jdt.core-3.13.102.jar' KeyPath='yes' />
</Component>
<Component Id='JavaOrgEclipseOsgiJar' Guid='*' Win64="$(var.Win64)">
<File Id='OrgEclipseOsgi' Name='org.eclipse.osgi-3.13.0.jar' DiskId='1' Source='./../../../bin/app/data/java/lib/org.eclipse.osgi-3.13.0.jar' KeyPath='yes' />
+1 -1
View File
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.13.0</version>
<version>3.13.102</version>
</dependency>
<dependency>
@@ -41,7 +41,7 @@ public class JavaIndexer
Path path = Paths.get(filePath);
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setResolveBindings(true); // solve "bindings" like the declatarion of the type used in a var decl
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
@@ -134,7 +134,7 @@ public class JavaIndexer
{
String packageName = "";
ASTParser parser = ASTParser.newParser(AST.JLS8);
ASTParser parser = ASTParser.newParser(AST.JLS10);
parser.setKind(ASTParser.K_COMPILATION_UNIT); // specify to parse the entire compilation unit
parser.setSource(fileContent.toCharArray());
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
@@ -170,8 +170,12 @@ public class JavaIndexer
case "7":
return JavaCore.VERSION_1_7;
case "8":
default:
return JavaCore.VERSION_1_8;
case "9":
return JavaCore.VERSION_9;
case "10":
default:
return JavaCore.VERSION_10;
}
}
+2 -2
View File
@@ -10,7 +10,7 @@ void SourceGroupSettingsJava::load(std::shared_ptr<const ConfigManager> config)
SourceGroupSettings::load(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithSourceExtensions::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithJavaStandard::load(config, key);
@@ -36,7 +36,7 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
SourceGroupSettings::equals(other) &&
SourceGroupSettingsWithSourceExtensions::equals(otherJava) &&
SourceGroupSettingsWithExcludeFilters::equals(otherJava) &&
SourceGroupSettingsWithJavaStandard::equals(otherJava)
SourceGroupSettingsWithJavaStandard::equals(otherJava)
);
}
@@ -12,7 +12,7 @@ std::shared_ptr<SourceGroupSettings> SourceGroupSettingsJavaEmpty::createCopy()
void SourceGroupSettingsJavaEmpty::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettings::load(config);
SourceGroupSettingsJava::load(config);
const std::string key = s_keyPrefix + getId();
@@ -22,7 +22,7 @@ void SourceGroupSettingsJavaEmpty::load(std::shared_ptr<const ConfigManager> con
void SourceGroupSettingsJavaEmpty::save(std::shared_ptr<ConfigManager> config)
{
SourceGroupSettings::save(config);
SourceGroupSettingsJava::save(config);
const std::string key = s_keyPrefix + getId();
@@ -41,7 +41,7 @@ void SourceGroupSettingsWithJavaStandard::setJavaStandard(const std::string& sta
std::vector<std::string> SourceGroupSettingsWithJavaStandard::getAvailableJavaStandards() const
{
return {"1", "2", "3", "4", "5", "6", "7", "8"};
return {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
}
std::string SourceGroupSettingsWithJavaStandard::getDefaultJavaStandard() const
+2 -2
View File
@@ -87,7 +87,7 @@ void JavaParser::buildIndex(std::shared_ptr<IndexerCommandJava> indexerCommand)
void JavaParser::buildIndex(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess)
{
buildIndex(filePath, "8", "", textAccess);
buildIndex(filePath, "10", "", textAccess);
}
void JavaParser::buildIndex(
@@ -264,7 +264,7 @@ void JavaParser::doRecordError(
m_client->recordError(
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
utility::decodeFromUtf8(m_javaEnvironment->toStdString(jMessage)),
fatal,
fatal,
indexed,
FilePath()
);
+1 -1
View File
@@ -31,7 +31,7 @@ namespace utility
L"org.eclipse.equinox.common-3.10.0.jar",
L"org.eclipse.equinox.preferences-3.7.100.jar",
L"org.eclipse.equinox.registry-3.8.0.jar",
L"org.eclipse.jdt.core-3.13.0.jar",
L"org.eclipse.jdt.core-3.13.102.jar",
L"org.eclipse.osgi-3.13.0.jar",
L"org.eclipse.text-3.6.300.jar",
L"slf4j-api-1.7.10.jar",
+27 -5
View File
@@ -34,7 +34,9 @@ public:
ApplicationSettings::getInstance()->setJavaPath(javaPaths[0]);
}
setupJavaEnvironmentFactory();
const std::string errorString = setupJavaEnvironmentFactory();
TS_ASSERT_EQUALS("", errorString);
// if this one fails, maybe your java_path in the test settings is wrong.
TS_ASSERT_LESS_THAN_EQUALS(1, JavaEnvironmentFactory::getInstance().use_count());
@@ -727,7 +729,7 @@ public:
client->qualifiers, L"A.B <17:20 17:20>"
));
}
void test_java_parser_finds_qualifier_location_of_super_method_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -838,6 +840,22 @@ public:
));
}
void test_java_parser_finds_usage_of_string_for_var_type()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A\n"
"{\n"
" public void foo(){\n"
" var a = \"test\";\n"
" }\n"
"}\n"
);
TS_ASSERT(utility::containsElement<std::wstring>(
client->typeUses, L"void A.foo() -> java.lang.String <4:3 4:5>"
));
}
void test_java_parser_finds_type_parameter_in_signature_of_method()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -945,7 +963,7 @@ public:
client->calls, L"foo.Bar.Bar(int) -> foo.Bar.Bar() <10:3 10:6>"
));
}
void test_java_parser_finds_super_constructor_invocation()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -1115,7 +1133,7 @@ public:
));
}
void test_java_parser_finds_no_method_usage_for_type_method_reference()
void test_java_parser_finds_no_method_usage_for_type_method_reference()
{
std::shared_ptr<TestParserClient> client = parseCode(
"public class A {\n"
@@ -1478,7 +1496,7 @@ public:
private:
void setupJavaEnvironmentFactory()
std::string setupJavaEnvironmentFactory()
{
if (!JavaEnvironmentFactory::getInstance())
{
@@ -1505,7 +1523,11 @@ private:
classPath,
errorString
);
return errorString;
}
return "";
}
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)