logic: fix update of Java indexer to new version of Java dependencies
* reapplied previous reverts * added cache for TypeSolvers in Java code
This commit is contained in:
@@ -673,7 +673,7 @@
|
|||||||
<Directory Id='DataJava' Name='java'>
|
<Directory Id='DataJava' Name='java'>
|
||||||
|
|
||||||
<Component Id='JavaGuavaJar' Guid='*' Win64="$(var.Win64)">
|
<Component Id='JavaGuavaJar' Guid='*' Win64="$(var.Win64)">
|
||||||
<File Id='JavaGuava' Name='guava-18.0.jar' DiskId='1' Source='./../../../bin/app/data/java/guava-18.0.jar' KeyPath='yes' />
|
<File Id='JavaGuava' Name='guava-21.0.jar' DiskId='1' Source='./../../../bin/app/data/java/guava-21.0.jar' KeyPath='yes' />
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id='JavaJavaIndexerJar' Guid='*' Win64="$(var.Win64)">
|
<Component Id='JavaJavaIndexerJar' Guid='*' Win64="$(var.Win64)">
|
||||||
<File Id='JavaJavaIndexer' Name='java-indexer.jar' DiskId='1' Source='./../../../bin/app/data/java/java-indexer.jar' KeyPath='yes' />
|
<File Id='JavaJavaIndexer' Name='java-indexer.jar' DiskId='1' Source='./../../../bin/app/data/java/java-indexer.jar' KeyPath='yes' />
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.lang.String;
|
import java.lang.String;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.github.javaparser.ast.CompilationUnit;
|
import com.github.javaparser.ast.CompilationUnit;
|
||||||
@@ -14,6 +16,7 @@ import com.github.javaparser.Problem;
|
|||||||
import com.github.javaparser.Range;
|
import com.github.javaparser.Range;
|
||||||
import com.github.javaparser.symbolsolver.javaparser.Navigator;
|
import com.github.javaparser.symbolsolver.javaparser.Navigator;
|
||||||
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
|
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
|
||||||
|
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;
|
||||||
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver;
|
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver;
|
||||||
import com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver;
|
import com.github.javaparser.symbolsolver.resolution.typesolvers.JarTypeSolver;
|
||||||
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver;
|
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver;
|
||||||
@@ -21,41 +24,58 @@ import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeS
|
|||||||
|
|
||||||
public class JavaIndexer
|
public class JavaIndexer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static Map<String, TypeSolver> typeSolvers = new HashMap<>();
|
||||||
|
|
||||||
public static void processFile(int address, String filePath, String fileContent, String classPath, int verbose)
|
public static void processFile(int address, String filePath, String fileContent, String classPath, int verbose)
|
||||||
{
|
{
|
||||||
logInfo(address, "indexing source file: " + filePath);
|
logInfo(address, "indexing source file: " + filePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CombinedTypeSolver typeSolver = new CombinedTypeSolver();
|
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
|
||||||
|
|
||||||
typeSolver.add(new ReflectionTypeSolver());
|
combinedTypeSolver.add(new ReflectionTypeSolver());
|
||||||
for (String path: classPath.split("\\;"))
|
for (String path: classPath.split("\\;"))
|
||||||
{
|
{
|
||||||
if (path.endsWith(".jar"))
|
if (typeSolvers.containsKey(path))
|
||||||
{
|
{
|
||||||
try
|
combinedTypeSolver.add(typeSolvers.get(path));
|
||||||
{
|
|
||||||
JarTypeSolver solver = new JarTypeSolver(path);
|
|
||||||
typeSolver.add(solver);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
System.out.println("unable to add jar file: " + path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!path.isEmpty())
|
else
|
||||||
{
|
{
|
||||||
JavaParserTypeSolver solver = new JavaParserTypeSolver(new File(path));
|
TypeSolver typeSolver = null;
|
||||||
typeSolver.add(solver);
|
|
||||||
|
if (path.endsWith(".jar"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
typeSolver = new JarTypeSolver(path);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
System.out.println("unable to add jar file: " + path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!path.isEmpty())
|
||||||
|
{
|
||||||
|
typeSolver = new JavaParserTypeSolver(new File(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeSolver != null)
|
||||||
|
{
|
||||||
|
typeSolvers.put(path, typeSolver);
|
||||||
|
combinedTypeSolver.add(typeSolver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompilationUnit cu = JavaParser.parse(new StringReader(fileContent));
|
CompilationUnit cu = JavaParser.parse(new StringReader(fileContent));
|
||||||
|
|
||||||
JavaAstVisitor astVisitor = (
|
JavaAstVisitor astVisitor = (
|
||||||
verbose == 1 ?
|
verbose == 1 ?
|
||||||
new JavaVerboseAstVisitor(address, filePath, new FileContent(fileContent), typeSolver) :
|
new JavaVerboseAstVisitor(address, filePath, new FileContent(fileContent), combinedTypeSolver) :
|
||||||
new JavaAstVisitor(address, filePath, new FileContent(fileContent), typeSolver)
|
new JavaAstVisitor(address, filePath, new FileContent(fileContent), combinedTypeSolver)
|
||||||
);
|
);
|
||||||
|
|
||||||
cu.accept(astVisitor, null);
|
cu.accept(astVisitor, null);
|
||||||
@@ -95,8 +115,6 @@ public class JavaIndexer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaParserFacade.clearInstances();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPackageName(String fileContent)
|
public static String getPackageName(String fileContent)
|
||||||
@@ -123,6 +141,13 @@ public class JavaIndexer
|
|||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearCaches()
|
||||||
|
{
|
||||||
|
typeSolvers.clear();
|
||||||
|
JavaParserFacade.clearInstances();
|
||||||
|
Runtime.getRuntime().gc();
|
||||||
|
}
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
|
|
||||||
static public void recordSymbol(
|
static public void recordSymbol(
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,8 @@
|
|||||||
#ifndef UNDO_REDO_VIEW_H
|
#ifndef UNDO_REDO_VIEW_H
|
||||||
#define UNDO_REDO_VIEW_H
|
#define UNDO_REDO_VIEW_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "component/view/View.h"
|
#include "component/view/View.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "data/indexer/IndexerBase.h"
|
#include "data/indexer/IndexerBase.h"
|
||||||
#include "data/parser/ParserClientImpl.h"
|
#include "data/indexer/IndexerCommand.h"
|
||||||
#include "utility/file/FileRegister.h"
|
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
|
|
||||||
template <typename IndexerCommandType, typename ParserType>
|
template <typename IndexerCommandType>
|
||||||
class Indexer
|
class Indexer
|
||||||
: public IndexerBase
|
: public IndexerBase
|
||||||
{
|
{
|
||||||
@@ -20,21 +19,25 @@ public:
|
|||||||
virtual std::shared_ptr<IntermediateStorage> index(
|
virtual std::shared_ptr<IntermediateStorage> index(
|
||||||
std::shared_ptr<IndexerCommand> indexerCommand,
|
std::shared_ptr<IndexerCommand> indexerCommand,
|
||||||
std::shared_ptr<FileRegister> fileRegister);
|
std::shared_ptr<FileRegister> fileRegister);
|
||||||
|
|
||||||
|
virtual std::shared_ptr<IntermediateStorage> doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandType> indexerCommand,
|
||||||
|
std::shared_ptr<FileRegister> fileRegister) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename IndexerCommandType, typename ParserType>
|
template <typename IndexerCommandType>
|
||||||
Indexer<IndexerCommandType, ParserType>::~Indexer()
|
Indexer<IndexerCommandType>::~Indexer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename IndexerCommandType, typename ParserType>
|
template <typename IndexerCommandType>
|
||||||
std::string Indexer<IndexerCommandType, ParserType>::getKindString() const
|
std::string Indexer<IndexerCommandType>::getKindString() const
|
||||||
{
|
{
|
||||||
return IndexerCommandType::getIndexerKindString();
|
return IndexerCommandType::getIndexerKindString();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename IndexerCommandType, typename ParserType>
|
template <typename IndexerCommandType>
|
||||||
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::index(
|
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType>::index(
|
||||||
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
||||||
{
|
{
|
||||||
std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand);
|
std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand);
|
||||||
@@ -46,33 +49,7 @@ std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::in
|
|||||||
return std::shared_ptr<IntermediateStorage>();
|
return std::shared_ptr<IntermediateStorage>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
return doIndex(castedCommand, fileRegister);
|
||||||
|
|
||||||
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
|
|
||||||
|
|
||||||
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
|
||||||
parserClient->setStorage(storage);
|
|
||||||
|
|
||||||
parser->buildIndex(castedCommand);
|
|
||||||
|
|
||||||
parserClient->resetStorage();
|
|
||||||
|
|
||||||
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
|
||||||
{
|
|
||||||
storage->setAllFilesIncomplete();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
storage->setFilesWithErrorsIncomplete();
|
|
||||||
fileRegister->markIndexingFilesIndexed();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interrupted())
|
|
||||||
{
|
|
||||||
return std::shared_ptr<IntermediateStorage>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return storage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // INDEXER_H
|
#endif // INDEXER_H
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
#define INDEXER_BASE_H
|
#define INDEXER_BASE_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include "data/indexer/IndexerCommand.h"
|
|
||||||
#include "data/IntermediateStorage.h"
|
|
||||||
|
|
||||||
class FileRegister;
|
class FileRegister;
|
||||||
|
class IndexerCommand;
|
||||||
|
class IntermediateStorage;
|
||||||
|
|
||||||
class IndexerBase
|
class IndexerBase
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#include "data/indexer/IndexerComposite.h"
|
#include "data/indexer/IndexerComposite.h"
|
||||||
|
|
||||||
|
#include "data/indexer/IndexerCommand.h"
|
||||||
#include "utility/logging/logging.h"
|
#include "utility/logging/logging.h"
|
||||||
|
#include "data/IntermediateStorage.h"
|
||||||
|
|
||||||
IndexerComposite::~IndexerComposite()
|
IndexerComposite::~IndexerComposite()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ add_files(
|
|||||||
data/indexer/IndexerCommandCxxCdb.h
|
data/indexer/IndexerCommandCxxCdb.h
|
||||||
data/indexer/IndexerCommandCxxManual.cpp
|
data/indexer/IndexerCommandCxxManual.cpp
|
||||||
data/indexer/IndexerCommandCxxManual.h
|
data/indexer/IndexerCommandCxxManual.h
|
||||||
|
data/indexer/IndexerCxx.h
|
||||||
data/indexer/IndexerFactoryModuleCxxCdb.cpp
|
data/indexer/IndexerFactoryModuleCxxCdb.cpp
|
||||||
data/indexer/IndexerFactoryModuleCxxCdb.h
|
data/indexer/IndexerFactoryModuleCxxCdb.h
|
||||||
data/indexer/IndexerFactoryModuleCxxManual.cpp
|
data/indexer/IndexerFactoryModuleCxxManual.cpp
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#ifndef INDEXER_CXX_H
|
||||||
|
#define INDEXER_CXX_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "data/indexer/Indexer.h"
|
||||||
|
#include "data/parser/ParserClientImpl.h"
|
||||||
|
#include "utility/file/FileRegister.h"
|
||||||
|
|
||||||
|
template <typename IndexerCommandType, typename ParserType>
|
||||||
|
class IndexerCxx: public Indexer<IndexerCommandType>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IndexerCxx();
|
||||||
|
|
||||||
|
virtual std::shared_ptr<IntermediateStorage> doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandType> indexerCommand,
|
||||||
|
std::shared_ptr<FileRegister> fileRegister);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename IndexerCommandType, typename ParserType>
|
||||||
|
IndexerCxx<IndexerCommandType, ParserType>::~IndexerCxx()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename IndexerCommandType, typename ParserType>
|
||||||
|
std::shared_ptr<IntermediateStorage> IndexerCxx<IndexerCommandType, ParserType>::doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandType> indexerCommand,
|
||||||
|
std::shared_ptr<FileRegister> fileRegister)
|
||||||
|
{
|
||||||
|
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
||||||
|
|
||||||
|
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
|
||||||
|
|
||||||
|
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
||||||
|
parserClient->setStorage(storage);
|
||||||
|
|
||||||
|
parser->buildIndex(indexerCommand);
|
||||||
|
|
||||||
|
parserClient->resetStorage();
|
||||||
|
|
||||||
|
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
||||||
|
{
|
||||||
|
storage->setAllFilesIncomplete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storage->setFilesWithErrorsIncomplete();
|
||||||
|
fileRegister->markIndexingFilesIndexed();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interrupted())
|
||||||
|
{
|
||||||
|
return std::shared_ptr<IntermediateStorage>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // INDEXER_CXX_H
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "data/indexer/IndexerFactoryModuleCxxCdb.h"
|
#include "data/indexer/IndexerFactoryModuleCxxCdb.h"
|
||||||
|
|
||||||
#include "data/indexer/Indexer.h"
|
#include "data/indexer/IndexerCxx.h"
|
||||||
#include "data/indexer/IndexerCommandCxxCdb.h"
|
#include "data/indexer/IndexerCommandCxxCdb.h"
|
||||||
#include "data/parser/cxx/CxxParser.h"
|
#include "data/parser/cxx/CxxParser.h"
|
||||||
|
|
||||||
@@ -10,5 +10,5 @@ IndexerFactoryModuleCxxCdb::~IndexerFactoryModuleCxxCdb()
|
|||||||
|
|
||||||
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxCdb::createIndexer()
|
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxCdb::createIndexer()
|
||||||
{
|
{
|
||||||
return std::make_shared<Indexer<IndexerCommandCxxCdb, CxxParser>>();
|
return std::make_shared<IndexerCxx<IndexerCommandCxxCdb, CxxParser>>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "data/indexer/IndexerFactoryModuleCxxManual.h"
|
#include "data/indexer/IndexerFactoryModuleCxxManual.h"
|
||||||
|
|
||||||
#include "data/indexer/Indexer.h"
|
#include "data/indexer/IndexerCxx.h"
|
||||||
#include "data/indexer/IndexerCommandCxxManual.h"
|
#include "data/indexer/IndexerCommandCxxManual.h"
|
||||||
#include "data/parser/cxx/CxxParser.h"
|
#include "data/parser/cxx/CxxParser.h"
|
||||||
|
|
||||||
@@ -10,5 +10,5 @@ IndexerFactoryModuleCxxManual::~IndexerFactoryModuleCxxManual()
|
|||||||
|
|
||||||
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxManual::createIndexer()
|
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxManual::createIndexer()
|
||||||
{
|
{
|
||||||
return std::make_shared<Indexer<IndexerCommandCxxManual, CxxParser>>();
|
return std::make_shared<IndexerCxx<IndexerCommandCxxManual, CxxParser>>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ add_files(
|
|||||||
data/indexer/IndexerCommandJava.h
|
data/indexer/IndexerCommandJava.h
|
||||||
data/indexer/IndexerFactoryModuleJava.cpp
|
data/indexer/IndexerFactoryModuleJava.cpp
|
||||||
data/indexer/IndexerFactoryModuleJava.h
|
data/indexer/IndexerFactoryModuleJava.h
|
||||||
|
data/indexer/IndexerJava.cpp
|
||||||
|
data/indexer/IndexerJava.h
|
||||||
|
|
||||||
data/parser/java/JavaParser.cpp
|
data/parser/java/JavaParser.cpp
|
||||||
data/parser/java/JavaParser.h
|
data/parser/java/JavaParser.h
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "data/indexer/IndexerFactoryModuleJava.h"
|
#include "data/indexer/IndexerFactoryModuleJava.h"
|
||||||
|
|
||||||
#include "data/indexer/Indexer.h"
|
#include "data/indexer/IndexerJava.h"
|
||||||
#include "data/indexer/IndexerCommandJava.h"
|
|
||||||
#include "data/parser/java/JavaParser.h"
|
|
||||||
|
|
||||||
IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
|
IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
|
||||||
{
|
{
|
||||||
@@ -10,5 +8,5 @@ IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
|
|||||||
|
|
||||||
std::shared_ptr<IndexerBase> IndexerFactoryModuleJava::createIndexer()
|
std::shared_ptr<IndexerBase> IndexerFactoryModuleJava::createIndexer()
|
||||||
{
|
{
|
||||||
return std::make_shared<Indexer<IndexerCommandJava, JavaParser>>();
|
return std::make_shared<IndexerJava>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#include "data/indexer/IndexerJava.h"
|
||||||
|
|
||||||
|
#include "data/indexer/IndexerCommandJava.h"
|
||||||
|
#include "data/parser/ParserClientImpl.h"
|
||||||
|
#include "data/parser/java/JavaParser.h"
|
||||||
|
#include "utility/file/FileRegister.h"
|
||||||
|
|
||||||
|
IndexerJava::~IndexerJava()
|
||||||
|
{
|
||||||
|
JavaParser::clearCaches();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IntermediateStorage> IndexerJava::doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandJava> indexerCommand,
|
||||||
|
std::shared_ptr<FileRegister> fileRegister)
|
||||||
|
{
|
||||||
|
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
||||||
|
|
||||||
|
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient, fileRegister);
|
||||||
|
|
||||||
|
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
||||||
|
parserClient->setStorage(storage);
|
||||||
|
|
||||||
|
parser->buildIndex(indexerCommand);
|
||||||
|
|
||||||
|
parserClient->resetStorage();
|
||||||
|
|
||||||
|
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
||||||
|
{
|
||||||
|
storage->setAllFilesIncomplete();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storage->setFilesWithErrorsIncomplete();
|
||||||
|
fileRegister->markIndexingFilesIndexed();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interrupted())
|
||||||
|
{
|
||||||
|
return std::shared_ptr<IntermediateStorage>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef INDEXER_JAVA_H
|
||||||
|
#define INDEXER_JAVA_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "data/indexer/IndexerCommandJava.h"
|
||||||
|
#include "data/indexer/Indexer.h"
|
||||||
|
|
||||||
|
class IndexerJava: public Indexer<IndexerCommandJava>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IndexerJava();
|
||||||
|
|
||||||
|
virtual std::shared_ptr<IntermediateStorage> doIndex(
|
||||||
|
std::shared_ptr<IndexerCommandJava> indexerCommand,
|
||||||
|
std::shared_ptr<FileRegister> fileRegister);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INDEXER_JAVA_H
|
||||||
@@ -10,6 +10,18 @@ JavaEnvironment::~JavaEnvironment()
|
|||||||
JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
|
JavaEnvironmentFactory::getInstance()->unregisterEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName)
|
||||||
|
{
|
||||||
|
jclass javaClass = getJavaClass(className);
|
||||||
|
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "()V");
|
||||||
|
if(javaMethodId != nullptr)
|
||||||
|
{
|
||||||
|
m_env->CallStaticVoidMethod(javaClass, javaMethodId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5)
|
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5)
|
||||||
{
|
{
|
||||||
jclass javaClass = getJavaClass(className);
|
jclass javaClass = getJavaClass(className);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
~JavaEnvironment();
|
~JavaEnvironment();
|
||||||
|
bool callStaticVoidMethod(std::string className, std::string methodName);
|
||||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5);
|
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5);
|
||||||
bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1);
|
bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
|
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
|
||||||
|
|
||||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||||
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
|
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
|
||||||
javaPath,
|
javaPath,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ std::string JavaParser::prepareJavaEnvironment()
|
|||||||
const std::string separator = ":";
|
const std::string separator = ":";
|
||||||
#endif
|
#endif
|
||||||
JavaEnvironmentFactory::createInstance(
|
JavaEnvironmentFactory::createInstance(
|
||||||
ResourcePaths::getJavaPath().str() + "guava-18.0.jar" + separator +
|
ResourcePaths::getJavaPath().str() + "guava-21.0.jar" + separator +
|
||||||
ResourcePaths::getJavaPath().str() + "java-indexer.jar" + separator +
|
ResourcePaths::getJavaPath().str() + "java-indexer.jar" + separator +
|
||||||
ResourcePaths::getJavaPath().str() + "javaparser-core.jar" + separator +
|
ResourcePaths::getJavaPath().str() + "javaparser-core.jar" + separator +
|
||||||
ResourcePaths::getJavaPath().str() + "javaslang-2.0.3.jar" + separator +
|
ResourcePaths::getJavaPath().str() + "javaslang-2.0.3.jar" + separator +
|
||||||
@@ -41,6 +41,22 @@ std::string JavaParser::prepareJavaEnvironment()
|
|||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaParser::clearCaches()
|
||||||
|
{
|
||||||
|
std::shared_ptr<JavaEnvironmentFactory> factory = JavaEnvironmentFactory::getInstance();
|
||||||
|
if (factory)
|
||||||
|
{
|
||||||
|
std::shared_ptr<JavaEnvironment> environment = factory->createEnvironment();
|
||||||
|
if (environment)
|
||||||
|
{
|
||||||
|
environment->callStaticVoidMethod(
|
||||||
|
"com/sourcetrail/JavaIndexer",
|
||||||
|
"clearCaches"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
||||||
: Parser(client)
|
: Parser(client)
|
||||||
, m_id(s_nextParserId++)
|
, m_id(s_nextParserId++)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class JavaParser: public Parser
|
|||||||
public:
|
public:
|
||||||
// returns: error message
|
// returns: error message
|
||||||
static std::string prepareJavaEnvironment();
|
static std::string prepareJavaEnvironment();
|
||||||
|
static void clearCaches();
|
||||||
|
|
||||||
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
|
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
|
||||||
~JavaParser();
|
~JavaParser();
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
|
|||||||
bool SourceGroupJava::prepareJavaEnvironment()
|
bool SourceGroupJava::prepareJavaEnvironment()
|
||||||
{
|
{
|
||||||
const std::string errorString = JavaParser::prepareJavaEnvironment();
|
const std::string errorString = JavaParser::prepareJavaEnvironment();
|
||||||
|
|
||||||
if (errorString.size() > 0)
|
if (errorString.size() > 0)
|
||||||
{
|
{
|
||||||
LOG_ERROR(errorString);
|
LOG_ERROR(errorString);
|
||||||
|
|||||||
@@ -817,7 +817,7 @@ private:
|
|||||||
const std::string separator = ":";
|
const std::string separator = ":";
|
||||||
#endif
|
#endif
|
||||||
JavaEnvironmentFactory::createInstance(
|
JavaEnvironmentFactory::createInstance(
|
||||||
"../app/data/java/guava-18.0.jar" + separator +
|
"../app/data/java/guava-21.0.jar" + separator +
|
||||||
"../app/data/java/java-indexer.jar" + separator +
|
"../app/data/java/java-indexer.jar" + separator +
|
||||||
"../app/data/java/javaparser-core.jar" + separator +
|
"../app/data/java/javaparser-core.jar" + separator +
|
||||||
"../app/data/java/javaslang-2.0.3.jar" + separator +
|
"../app/data/java/javaslang-2.0.3.jar" + separator +
|
||||||
|
|||||||
Reference in New Issue
Block a user