Compare commits
33
Commits
v2.db23.p2
...
v4.db25.p0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3f81330eb | ||
|
|
6a6e9b1c63 | ||
|
|
729a8eb89f | ||
|
|
a76526b59e | ||
|
|
e483808e46 | ||
|
|
ac95c79982 | ||
|
|
5bc16dda2d | ||
|
|
962fae6667 | ||
|
|
9ca9131b0e | ||
|
|
b89f735a23 | ||
|
|
5f5da90c0e | ||
|
|
8d0b0c069d | ||
|
|
122efaae98 | ||
|
|
c6eb769a96 | ||
|
|
9749aa2cd0 | ||
|
|
2bd3fb46a7 | ||
|
|
6d5766c791 | ||
|
|
20e3912a5f | ||
|
|
d352c8bf39 | ||
|
|
780a7e2f7a | ||
|
|
28e8cb8f33 | ||
|
|
2ffb5b2af0 | ||
|
|
1e9f34ca89 | ||
|
|
980ea5dafc | ||
|
|
d0545deb20 | ||
|
|
707de37391 | ||
|
|
d18654a70f | ||
|
|
f53330c533 | ||
|
|
c370d6a0cd | ||
|
|
25effc102c | ||
|
|
49e8458d6d | ||
|
|
f78a7186c1 | ||
|
|
f14a8a0a19 |
+70
-46
@@ -12,7 +12,19 @@ matrix:
|
||||
packages:
|
||||
- g++-5
|
||||
env:
|
||||
- CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 PYTHON_BINDING=0
|
||||
- CC_COMPILER=gcc-5 CXX_COMPILER=g++-5
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
dist: trusty
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-5
|
||||
env:
|
||||
- CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 PERL_BINDING=1
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
@@ -26,73 +38,70 @@ matrix:
|
||||
env:
|
||||
- CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 PYTHON_BINDING=1 PYTHON=3.5
|
||||
|
||||
# - os: linux
|
||||
# compiler: gcc
|
||||
# dist: trusty
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - g++-5
|
||||
# env:
|
||||
# - CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 PYTHON_BINDING=1 PYTHON=3.6
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-5
|
||||
env:
|
||||
- CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 JAVA_BINDING=1
|
||||
|
||||
# - os: linux
|
||||
# compiler: gcc
|
||||
# dist: trusty
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - g++-5
|
||||
# env:
|
||||
# - CC_COMPILER=gcc-5 CXX_COMPILER=g++-5 PYTHON_BINDING=1 PYTHON=3.7
|
||||
- os: osx
|
||||
compiler: clang
|
||||
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env:
|
||||
- PYTHON_BINDING=0
|
||||
|
||||
# - os: osx
|
||||
# compiler: clang
|
||||
# env:
|
||||
# - PYTHON_BINDING=1 PYTHON=3.5
|
||||
- PERL_BINDING=1
|
||||
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env:
|
||||
- PYTHON_BINDING=1 PYTHON=3.6
|
||||
|
||||
# - os: osx
|
||||
# compiler: clang
|
||||
# env:
|
||||
# - PYTHON_BINDING=1 PYTHON=3.7
|
||||
- os: osx
|
||||
compiler: clang
|
||||
osx_image: xcode11.2
|
||||
env:
|
||||
- JAVA_BINDING=1
|
||||
|
||||
before_install:
|
||||
- |
|
||||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
brew install swig
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install swig
|
||||
brew link --force swig
|
||||
|
||||
# TODO: find way to install specific python versions on osx
|
||||
# if [[ "$PYTHON_BINDING" == "1" ]]; then
|
||||
# brew install python$PYTHON
|
||||
# python --version
|
||||
# fi
|
||||
if [[ "$PERL_BINDING" == "1" ]]; then
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install perl
|
||||
perl --version
|
||||
fi
|
||||
|
||||
elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -qq swig
|
||||
|
||||
# TODO: this is only working for python3.5, not above
|
||||
if [[ "$PERL_BINDING" == "1" ]]; then
|
||||
sudo apt-get install perl
|
||||
alias perl="/usr/bin/perl"
|
||||
perl --version
|
||||
fi
|
||||
|
||||
# this is only working for python3.5
|
||||
if [[ "$PYTHON_BINDING" == "1" ]]; then
|
||||
sudo apt-get install python$PYTHON
|
||||
sudo apt-get install python$PYTHON-dev
|
||||
alias python="/usr/bin/python$PYTHON"
|
||||
python --version
|
||||
fi
|
||||
|
||||
if [[ "$JAVA_BINDING" == "1" ]]; then
|
||||
sudo apt-get install openjdk-8-jdk
|
||||
javac -version
|
||||
fi
|
||||
fi
|
||||
|
||||
install:
|
||||
@@ -103,7 +112,7 @@ script:
|
||||
- |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_BINDINGS_PYTHON=$PYTHON_BINDING -DPYTHON_VERSION=$PYTHON ..
|
||||
cmake -DBUILD_BINDINGS_PERL=$PERL_BINDING -DBUILD_BINDINGS_PYTHON=$PYTHON_BINDING -DPYTHON_VERSION=$PYTHON -DBUILD_BINDINGS_JAVA=$JAVA_BINDING ..
|
||||
make
|
||||
./core/test_core
|
||||
|
||||
@@ -111,25 +120,40 @@ before_deploy:
|
||||
- |
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
|
||||
VERSION=$(head -1 build/version.txt)
|
||||
VERSION=$(head -1 version.txt)
|
||||
VERSION=${VERSION//./_}
|
||||
|
||||
if [[ "$PYTHON_BINDING" == "1" ]]; then
|
||||
if [[ "$PERL_BINDING" == "1" ]]; then
|
||||
BUNDLE_NAME=sourcetraildb_perl_${VERSION}-${TRAVIS_OS_NAME}-64bit-${TRAVIS_COMPILER}
|
||||
|
||||
mkdir -p $BUNDLE_NAME
|
||||
cp build/bindings_perl/sourcetraildb.* $BUNDLE_NAME
|
||||
|
||||
elif [[ "$PYTHON_BINDING" == "1" ]]; then
|
||||
PYTHON_VERSION=${PYTHON//.}
|
||||
PYTHON_VERSION=${PYTHON_VERSION:0:2}
|
||||
BUNDLE_NAME=sourcetraildb_python${PYTHON_VERSION}_${VERSION}-${TRAVIS_OS_NAME}-64bit-${TRAVIS_COMPILER}
|
||||
|
||||
|
||||
mkdir -p $BUNDLE_NAME
|
||||
cp build/bindings_python/sourcetraildb.py $BUNDLE_NAME
|
||||
cp build/bindings_python/_sourcetraildb* $BUNDLE_NAME/_sourcetraildb.so
|
||||
|
||||
elif [[ "$JAVA_BINDING" == "1" ]]; then
|
||||
BUNDLE_NAME=sourcetraildb_java_${VERSION}-${TRAVIS_OS_NAME}-64bit-${TRAVIS_COMPILER}
|
||||
|
||||
mkdir -p $BUNDLE_NAME
|
||||
cp build/bindings_java/SourcetrailDB.jar $BUNDLE_NAME
|
||||
cp build/bindings_java/lib_sourcetraildb* $BUNDLE_NAME
|
||||
|
||||
else
|
||||
BUNDLE_NAME=sourcetraildb_core_${VERSION}-${TRAVIS_OS_NAME}-64bit-${TRAVIS_COMPILER}
|
||||
|
||||
|
||||
mkdir -p $BUNDLE_NAME/include
|
||||
mkdir -p $BUNDLE_NAME/lib
|
||||
|
||||
cp build/core/*.a $BUNDLE_NAME/lib
|
||||
cp core/include/* $BUNDLE_NAME/include
|
||||
cp build/core/include/* $BUNDLE_NAME/include
|
||||
|
||||
fi
|
||||
|
||||
mkdir -p $BUNDLE_NAME/license
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
Main Authors
|
||||
============
|
||||
|
||||
Malte Langkabel (@mlangkabel) <mlangkabel@coati.io>
|
||||
|
||||
Code Contributors
|
||||
=================
|
||||
|
||||
Andrew Pam (@xanni) <andrew@sericyb.com.au>
|
||||
|
||||
Note: (@user) means a github user name.
|
||||
@@ -1,5 +1,50 @@
|
||||
# Changelog
|
||||
|
||||
## v4.db25.p0
|
||||
|
||||
**2020-10-12**
|
||||
|
||||
* Interface Change: fix "Ambiuous" typo in interface instead of "Ambiguous" (issue #8)
|
||||
* Added Java bindings for API
|
||||
* Added Perl bindings for API
|
||||
|
||||
|
||||
## v3.db25.p0
|
||||
|
||||
**2019-11-04**
|
||||
|
||||
* Interface Change: removed unused node and edge types
|
||||
|
||||
|
||||
## v2.db24.p0
|
||||
|
||||
**2019-05-20**
|
||||
|
||||
* Interface Extension: added methods to record edges as ambiguous with new database version
|
||||
|
||||
|
||||
## v2.db23.p2
|
||||
|
||||
**2019-04-02**
|
||||
|
||||
* Interface Extension: `getVersionString()` is not available via API
|
||||
|
||||
|
||||
## v2.db23.p1
|
||||
|
||||
**2019-03-26**
|
||||
|
||||
* Interface Extension: added method to store a qualifier location to the database
|
||||
|
||||
|
||||
## v2.db23.p0
|
||||
|
||||
**2019-02-26**
|
||||
|
||||
* Interface Change: renamed `recordCommentLocation()` to `recordAtomicSourceRange()` to be more generic
|
||||
* Fix: build issue if tags of this repo are not checked out (issue #1)
|
||||
|
||||
|
||||
## v1.db23.p0
|
||||
|
||||
**2018-12-19**
|
||||
|
||||
+39
-27
@@ -2,7 +2,9 @@ cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
# --- Options ---
|
||||
|
||||
set(BUILD_BINDINGS_PERL OFF CACHE BOOL "Build the SourcetrailDB Perl bindings.")
|
||||
set(BUILD_BINDINGS_PYTHON OFF CACHE BOOL "Build the SourcetrailDB Python bindings.")
|
||||
set(BUILD_BINDINGS_JAVA OFF CACHE BOOL "Build the SourcetrailDB Java bindings.")
|
||||
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
|
||||
|
||||
set(PROJECT_NAME "SourcetrailDB")
|
||||
@@ -22,28 +24,11 @@ endif()
|
||||
|
||||
# --- Version ---
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
find_package(Git)
|
||||
file (STRINGS "version.txt" VERSION_STRING)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --long
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_VERSION_NUMBER
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
else()
|
||||
set(GIT_VERSION_NUMBER "")
|
||||
endif()
|
||||
|
||||
if("${GIT_VERSION_NUMBER}" STREQUAL "")
|
||||
message(WARNING "Unable to derive SourcetrailDB version number from most recent Git tag.")
|
||||
set(GIT_VERSION_NUMBER "v0.db0.p0-0-a")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "v([0-9]+)\\..*" "\\1" INTERFACE_VERSION "${GIT_VERSION_NUMBER}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db([0-9]+)\\..*" "\\1" DATABASE_VERSION "${GIT_VERSION_NUMBER}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db[0-9]+\\.p([0-9]+)-.*" "\\1" PATCH_VERSION "${GIT_VERSION_NUMBER}")
|
||||
set(VERSION_STRING "v${INTERFACE_VERSION}.db${DATABASE_VERSION}.p${PATCH_VERSION}")
|
||||
string(REGEX REPLACE "v([0-9]+)\\..*" "\\1" INTERFACE_VERSION "${VERSION_STRING}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db([0-9]+)\\..*" "\\1" DATABASE_VERSION "${VERSION_STRING}")
|
||||
string(REGEX REPLACE "v[0-9]+\\.db[0-9]+\\.p([0-9]+).*" "\\1" PATCH_VERSION "${VERSION_STRING}")
|
||||
set(VERSION_STRING_UNDERSCORE "v${INTERFACE_VERSION}_db${DATABASE_VERSION}_p${PATCH_VERSION}")
|
||||
|
||||
message(STATUS "SourcetrailDB Version: ${VERSION_STRING}")
|
||||
@@ -51,32 +36,53 @@ message(STATUS "Interface Version: ${INTERFACE_VERSION}")
|
||||
message(STATUS "Database Version: ${DATABASE_VERSION}")
|
||||
message(STATUS "Patch Version: ${PATCH_VERSION}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.txt.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/version.txt"
|
||||
)
|
||||
|
||||
|
||||
# --- Core ---
|
||||
|
||||
set(LIB_CORE "lib_core")
|
||||
set(LIB_CORE_TARGET_NAME "lib_core")
|
||||
set(CORE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/core") # can be accessed in subdirectory CMake files
|
||||
set(CORE_BINARY_DIR "${CMAKE_BINARY_DIR}/core") # can be accessed in subdirectory CMake files
|
||||
|
||||
add_subdirectory(${CORE_SOURCE_DIR} ${CORE_BINARY_DIR})
|
||||
|
||||
|
||||
# --- Perl Binding ---
|
||||
|
||||
if (BUILD_BINDINGS_PERL)
|
||||
message(STATUS "The SourcetrailDB Perl bindings will be built.")
|
||||
|
||||
set(PERL_BINDING_TARGET_NAME "bindings_perl")
|
||||
set(PERL_BINDING_OUTPUT_DIR "")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_perl" "${CMAKE_BINARY_DIR}/bindings_perl")
|
||||
else()
|
||||
message(STATUS "Building the SourcetrailDB Perl bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_PERL' to 'ON'.")
|
||||
endif()
|
||||
|
||||
|
||||
# --- Python Binding ---
|
||||
|
||||
if (BUILD_BINDINGS_PYTHON)
|
||||
message(STATUS "The SourcetrailDB Python bindings will be built.")
|
||||
|
||||
set(PYTHON_BINDING_TARGET_NAME "bindings_python")
|
||||
set(PYTHON_BINDING_OUTPUT_DIR "")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_python" "${CMAKE_BINARY_DIR}/bindings_python")
|
||||
else()
|
||||
message(STATUS "Building the SourcetrailDB Python bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_PYTHON' to 'ON'.")
|
||||
endif()
|
||||
|
||||
# --- Java Binding ---
|
||||
|
||||
if (BUILD_BINDINGS_JAVA)
|
||||
message(STATUS "The SourcetrailDB Java bindings will be built.")
|
||||
|
||||
set(JAVA_BINDING_TARGET_NAME "bindings_java")
|
||||
set(JAVA_BINDING_OUTPUT_DIR "")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_java" "${CMAKE_BINARY_DIR}/bindings_java")
|
||||
else()
|
||||
message(STATUS "Building the SourcetrailDB Java bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_JAVA' to 'ON'.")
|
||||
endif()
|
||||
|
||||
|
||||
# --- Examples ---
|
||||
|
||||
@@ -90,6 +96,12 @@ if (BUILD_EXAMPLES)
|
||||
else()
|
||||
message(STATUS "Skip python binding sample. You can enable building it by setting 'BUILD_BINDINGS_PYTHON' to 'ON'.")
|
||||
endif()
|
||||
|
||||
if (BUILD_BINDINGS_JAVA)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/examples/java_api_example")
|
||||
else()
|
||||
message(STATUS "Skip java binding sample. You can enable building it by setting 'BUILD_BINDINGS_JAVA' to 'ON'.")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Building examples will be skipped. You can enable building examples by setting 'BUILD_EXAMPLES' to 'ON'.")
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# SourcetrailDB
|
||||
|
||||
Library to export [Sourcetrail](https://www.sourcetrail.com/) compatible database files for writing custom indexers
|
||||
|
||||
|
||||
@@ -17,15 +18,26 @@ The SourcetrailDB project provides write access to [Sourcetrail](https://www.sou
|
||||
|
||||
|
||||
## Projects Using SourcetrailDB
|
||||
The following list of projects already use SourcetrailDB API to extend the language support of Sourcetrail. If you plan on starting a language package on your own, take a look at our [Language Extension Guide](LANGUAGE_EXTENSION_GUIDE.md).
|
||||
* [SourcetrailPythonIndexer](https://github.com/CoatiSoftware/SourcetrailPythonIndexer)
|
||||
|
||||
The following list of projects already use SourcetrailDB API to extend the language support of Sourcetrail.
|
||||
* [SourcetrailPythonIndexer](https://github.com/CoatiSoftware/SourcetrailPythonIndexer) is a Sourcetrail language extension that brings Python support to Sourcetrail. This project is still in a prototype state, but you can already run it on your Python code.
|
||||
* [stacktraceflow_sourcetrail](https://github.com/Baranowski/stacktraceflow_sourcetrail) combines the power of Valgrind and Sourcetrail to quickly produce interactive callgraph of software written in any language, as long as it's compiled to ELF/DWARF format (e.g. Rust and Go).
|
||||
* [SourcetrailTypescriptIndexer](https://github.com/LouisStAmour/SourcetrailTypescriptIndexer) is a Typescript Indexer for Sourcetrail using the TypeScript compiler and node bindings contributed to SourcetrailDB (*prototype stage*).
|
||||
|
||||
## Adding new Language Support
|
||||
|
||||
When you plan on starting a Sourcetrail language package on your own, you can use whatever programming language you like for this task. The only requirement is: you need to make calls to SourectrailDB to enter the information your indexer records to the Sourcetrail database.
|
||||
|
||||
__To get an overview on everything involved, please take a look at our [Language Extension Guide](LANGUAGE_EXTENSION_GUIDE.md).__
|
||||
|
||||
|
||||
## Supported Language Bindings
|
||||
|
||||
Even though the core implementation is written in C++, this does not require you to write your indexer in C++ as well. Instead you can use a language binding (e.g. see [SWIG](http://www.swig.org/)). These language bindings are already available:
|
||||
|
||||
* Perl (via [SWIG](http://www.swig.org/))
|
||||
* Python (via [SWIG](http://www.swig.org/))
|
||||
* Java (via [SWIG](http://www.swig.org/))
|
||||
|
||||
If the language of your choice is not covered by this list, feel free to [open an issue](https://github.com/CoatiSoftware/SourcetrailDB/issues) or provide a pull request.
|
||||
|
||||
@@ -40,6 +52,20 @@ The SourcetrailDB version format consists of three numbers in the format `vXX.db
|
||||
You can find a complete list of available releases on the [GitHub release page](https://github.com/CoatiSoftware/SourcetrailDB/releases). If you are interested in the actual changes of every release, please take a look at the [Changelog](CHANGELOG.md).
|
||||
|
||||
|
||||
## Contributing
|
||||
If you like this project and want to get involved, there are lots of ways you can help:
|
||||
|
||||
* __Spread the word.__ The more people want this project to grow, the greater the motivation for the developers to get things done.
|
||||
* __Write some code.__ Don't be shy here. You can implement whole new language bindings, add a features or fix some bugs, but you can also do some refactoring if you think that it benefits the readability or the maintainability of the code. Still, no matter if you just want to work on cosmetics or implement new features, it would be best if you create an issue here on the issue tracker before you actually start handing in pull requests, so that we can discuss those changes first and thus raise the probability that those changes will get pulled quickly.
|
||||
|
||||
To create a pull request, follow these steps:
|
||||
* Fork the Repo on GitHub.
|
||||
* Make your commits.
|
||||
* If you added functionality or fixed a bug, please add a test.
|
||||
* Add your name to the "Code Contributors" section in AUTHORS.txt file.
|
||||
* Push to your fork and submit a pull request.
|
||||
|
||||
|
||||
## Building
|
||||
|
||||
Take a look at [Appveyor (for Windows)](appveyor.yml) or [Travis (for Linux and macOs)](.travis.yml) CI scripts for reference.
|
||||
@@ -69,6 +95,24 @@ $ make test_core
|
||||
$ ./core/test_core
|
||||
```
|
||||
|
||||
### Perl Bindings
|
||||
|
||||
Requirements:
|
||||
* [Perl](https://www.perl.org/) needs to be included and linked against when building the Perl bindings. CMake will auto-detect your Perl installation. If you want to build against a specific version of Perl, please define the `PERL_LIBRARY` variable accordingly when running CMake. Make sure to link to the correct Perl version when building for different architectures (32bit/64bit).
|
||||
|
||||
* [SWIG 3.0.12](http://www.swig.org/) is used to automatically generate Perl binding code. Make sure that SWIG is added to your path environment variable.
|
||||
|
||||
If you want to build the Perl bindings run:
|
||||
```
|
||||
$ cd path/to/SourcetrailDB
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake -DBUILD_BINDINGS_PERL=ON ..
|
||||
$ make sourcetraildb
|
||||
```
|
||||
|
||||
Swig is configured to generate the Perl binding code as a pre-build event, so you don't need to bother with updating manually.
|
||||
|
||||
### Python Bindings
|
||||
|
||||
Requirements:
|
||||
@@ -87,6 +131,24 @@ $ make _sourcetraildb
|
||||
|
||||
Swig is configured to generate the Python binding code as a pre-build event, so you don't need to bother with updating manually.
|
||||
|
||||
### Java Bindings
|
||||
|
||||
Requirements:
|
||||
* [Java JDK](https://openjdk.java.net/) needs to be included and linked against when building the Java bindings. CMake will auto-detect your Java installation.
|
||||
|
||||
* [SWIG 3.0.12](http://www.swig.org/) is used to automatically generate Java binding code. Make sure that SWIG is added to your path environment variable.
|
||||
|
||||
If you want to build the Java bindings run:
|
||||
```
|
||||
$ cd path/to/SourcetrailDB
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake -DBUILD_BINDINGS_JAVA=ON ..
|
||||
$ make
|
||||
```
|
||||
|
||||
Swig is configured to generate the Java binding code as a pre-build event, so you don't need to bother with updating manually.
|
||||
|
||||
### Examples
|
||||
|
||||
The examples help you to understand SourcetrailDB usage in practice. Please take a look at each examples README file for build and use instructions. Each example also provides a Sourcetrail project file `.srctrlprj` showing you how to use a custom indexer directly from Sourcetrail (see [Integrating with Sourcetrail](#integrating-with-sourcetrail)).
|
||||
@@ -94,6 +156,7 @@ The examples help you to understand SourcetrailDB usage in practice. Please take
|
||||
* [C++ API Example](examples/cpp_api_example)
|
||||
* [C++ Poetry Indexer](examples/cpp_poetry_indexer)
|
||||
* [Python API Example](examples/python_api_example)
|
||||
* [Java API Example](examples/java_api_example)
|
||||
|
||||
|
||||
## SourcetrailDB API
|
||||
@@ -237,7 +300,7 @@ int contextSymbolId = writer.recordSymbol({ "::", { { "", "Bar", "" }, { "void",
|
||||
int referencedSymbolId = writer.recordSymbol({ "::", { { "void", "foo", "()" } } });
|
||||
|
||||
// edges always go from the context to the referenced symbol
|
||||
int referenceId = writer.recordReference(contextSymbolId, referencedSymbolId, sourcetrail::REFERENCE_CALL);
|
||||
int referenceId = writer.recordReference(contextSymbolId, referencedSymbolId, sourcetrail::ReferenceKind::CALL);
|
||||
|
||||
// add a location to the reference - highlights the location in the code view when clicking the edge in the graph view
|
||||
int fileId = writer.recordFile("C:/example/Bar.cpp");
|
||||
|
||||
+75
-64
@@ -9,42 +9,22 @@ environment:
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 1
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
DEPLOY_JAVA_BINDINGS: 1
|
||||
- MBITS: 64
|
||||
PYTHON_VERSION: 37
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 1
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
- MBITS: 32
|
||||
PYTHON_VERSION: 36
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 0
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
- MBITS: 64
|
||||
PYTHON_VERSION: 36
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 0
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
- MBITS: 32
|
||||
PYTHON_VERSION: 35
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 0
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
- MBITS: 64
|
||||
PYTHON_VERSION: 35
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 0
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
|
||||
DEPLOY_JAVA_BINDINGS: 1
|
||||
|
||||
- MBITS: 32
|
||||
PYTHON_VERSION: 37
|
||||
MSVC_VERSION: 14
|
||||
DEPLOY_CORE: 1
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
- MBITS: 64
|
||||
PYTHON_VERSION: 37
|
||||
MSVC_VERSION: 14
|
||||
DEPLOY_CORE: 1
|
||||
DEPLOY_PYTHON_BINDINGS: 1
|
||||
|
||||
|
||||
install:
|
||||
@@ -61,17 +41,19 @@ install:
|
||||
echo "No architecture set. Build will be canceled."
|
||||
}
|
||||
# Install SWIG by Choco
|
||||
choco install -y --no-progress swig
|
||||
choco install -y --no-progress swig --version 4.0.1
|
||||
choco install -y --no-progress openjdk
|
||||
|
||||
|
||||
before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -G "%CMAKE_GENERATOR%" ../ -DBUILD_BINDINGS_PYTHON=ON -DPYTHON_LIBRARY="%PYTHON_PATH%/libs/python%PYTHON_VERSION%.lib"
|
||||
- cmake -G "%CMAKE_GENERATOR%" ../ -DBUILD_BINDINGS_PYTHON=%DEPLOY_PYTHON_BINDINGS% -DPYTHON_LIBRARY="%PYTHON_PATH%/libs/python%PYTHON_VERSION%.lib" -DBUILD_BINDINGS_JAVA=%DEPLOY_JAVA_BINDINGS%
|
||||
- cd ../
|
||||
- ps: $env:CORE_VERSION = Get-Content -Path ./build/version.txt
|
||||
- ps: $env:CORE_VERSION = Get-Content -Path ./version.txt
|
||||
- ps: $env:UNDERSCORED_CORE_VERSION = $env:CORE_VERSION.Replace(".", "_")
|
||||
- ps: echo "Core version is $env:CORE_VERSION"
|
||||
# TODO: convert the core version into dotted format and update appveyor version here
|
||||
# TODO: use the core version to update appveyor version here
|
||||
# - ps: $env:BUILD_VERSION = "0.0.1." + $env:APPVEYOR_BUILD_NUMBER
|
||||
# - ps: echo update build version to $env:BUILD_VERSION
|
||||
# - ps: Update-AppveyorBuild -Version $env:BUILD_VERSION
|
||||
@@ -84,49 +66,75 @@ build_script:
|
||||
|
||||
|
||||
after_build:
|
||||
- ps: $env:CORE_PACKAGE_NAME = 'sourcetraildb_core_' + $env:CORE_VERSION + '-windows-' + $env:MBITS + 'bit-msvc' + $env:MSVC_VERSION
|
||||
- ps: $env:PYTHON_PACKAGE_NAME = 'sourcetrailbd_python' + $env:PYTHON_VERSION + '_' + $env:CORE_VERSION + '-windows-' + $env:MBITS + 'bit'
|
||||
- ps: $env:CORE_PACKAGE_NAME = 'sourcetraildb_core_' + $env:UNDERSCORED_CORE_VERSION + '-windows-' + $env:MBITS + 'bit-msvc' + $env:MSVC_VERSION
|
||||
- ps: $env:PYTHON_PACKAGE_NAME = 'sourcetrailbd_python' + $env:PYTHON_VERSION + '_' + $env:UNDERSCORED_CORE_VERSION + '-windows-' + $env:MBITS + 'bit'
|
||||
- ps: $env:JAVA_PACKAGE_NAME = 'sourcetrailbd_java_' + $env:UNDERSCORED_CORE_VERSION + '-windows-' + $env:MBITS + 'bit'
|
||||
- ps: echo $env:CORE_PACKAGE_NAME
|
||||
- ps: echo $env:PYTHON_PACKAGE_NAME
|
||||
- mkdir artifacts_core
|
||||
- cd artifacts_core
|
||||
- mkdir %CORE_PACKAGE_NAME%
|
||||
- cd %CORE_PACKAGE_NAME%
|
||||
- mkdir lib
|
||||
- mkdir include
|
||||
- mkdir license
|
||||
- cd ../..
|
||||
- ps: echo $env:JAVA_PACKAGE_NAME
|
||||
|
||||
- ps: $env:ARTIFACTS_TO_DEPLOY = ""
|
||||
|
||||
- ps: |
|
||||
copy build/core/release/sourcetraildb.lib artifacts_core/$env:CORE_PACKAGE_NAME/lib/
|
||||
copy build/core/include/version.h artifacts_core/$env:CORE_PACKAGE_NAME/include/
|
||||
copy core/include/* artifacts_core/$env:CORE_PACKAGE_NAME/include/
|
||||
copy LICENSE.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/license_sourcetraildb.txt
|
||||
copy external/catch/license_catch.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
copy external/json/license_json.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
- mkdir artifacts_bindings_python
|
||||
- cd artifacts_bindings_python
|
||||
- mkdir %PYTHON_PACKAGE_NAME%
|
||||
- cd %PYTHON_PACKAGE_NAME%
|
||||
- mkdir license
|
||||
- cd ../..
|
||||
- ps: |
|
||||
copy build/bindings_python/release/_sourcetraildb.pyd artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/
|
||||
copy build/bindings_python/sourcetraildb.py artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/
|
||||
copy LICENSE.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/license_sourcetraildb.txt
|
||||
copy external/catch/license_catch.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
copy external/json/license_json.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
- ps: |
|
||||
$env:ARTIFACTY_TO_DEPLOY = ""
|
||||
mkdir artifacts_core
|
||||
if ($env:DEPLOY_CORE -eq "1") {
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY + "," + $env:CORE_PACKAGE_NAME
|
||||
cd artifacts_core
|
||||
mkdir $env:CORE_PACKAGE_NAME
|
||||
cd $env:CORE_PACKAGE_NAME
|
||||
mkdir lib
|
||||
mkdir include
|
||||
mkdir license
|
||||
cd ../..
|
||||
|
||||
copy build/core/release/sourcetraildb.lib artifacts_core/$env:CORE_PACKAGE_NAME/lib/
|
||||
copy build/core/include/version.h artifacts_core/$env:CORE_PACKAGE_NAME/include/
|
||||
copy core/include/* artifacts_core/$env:CORE_PACKAGE_NAME/include/
|
||||
copy LICENSE.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/license_sourcetraildb.txt
|
||||
copy external/catch/license_catch.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
copy external/json/license_json.txt artifacts_core/$env:CORE_PACKAGE_NAME/license/
|
||||
|
||||
$env:ARTIFACTS_TO_DEPLOY = $env:ARTIFACTS_TO_DEPLOY + "," + $env:CORE_PACKAGE_NAME
|
||||
}
|
||||
- ps: |
|
||||
mkdir artifacts_bindings_python
|
||||
if ($env:DEPLOY_PYTHON_BINDINGS -eq "1") {
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY + "," + $env:PYTHON_PACKAGE_NAME
|
||||
cd artifacts_bindings_python
|
||||
mkdir $env:PYTHON_PACKAGE_NAME
|
||||
cd $env:PYTHON_PACKAGE_NAME
|
||||
mkdir license
|
||||
cd ../..
|
||||
|
||||
copy build/bindings_python/release/_sourcetraildb.pyd artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/
|
||||
copy build/bindings_python/sourcetraildb.py artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/
|
||||
copy LICENSE.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/license_sourcetraildb.txt
|
||||
copy external/catch/license_catch.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
copy external/json/license_json.txt artifacts_bindings_python/$env:PYTHON_PACKAGE_NAME/license/
|
||||
|
||||
$env:ARTIFACTS_TO_DEPLOY = $env:ARTIFACTS_TO_DEPLOY + "," + $env:PYTHON_PACKAGE_NAME
|
||||
}
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY.substring(1)
|
||||
echo $env:ARTIFACTY_TO_DEPLOY
|
||||
- ps: |
|
||||
mkdir artifacts_bindings_java
|
||||
if ($env:DEPLOY_JAVA_BINDINGS -eq "1") {
|
||||
cd artifacts_bindings_java
|
||||
mkdir $env:JAVA_PACKAGE_NAME
|
||||
cd $env:JAVA_PACKAGE_NAME
|
||||
mkdir license
|
||||
cd ../..
|
||||
|
||||
copy build/bindings_java/release/_sourcetraildb.dll artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/
|
||||
copy build/bindings_java/SourcetrailDB.jar artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/
|
||||
copy LICENSE.txt artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/license/license_sourcetraildb.txt
|
||||
copy external/catch/license_catch.txt artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/license/
|
||||
copy external/cpp_sqlite/license_cpp_sqlite.txt artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/license/
|
||||
copy external/json/license_json.txt artifacts_bindings_java/$env:JAVA_PACKAGE_NAME/license/
|
||||
|
||||
$env:ARTIFACTS_TO_DEPLOY = $env:ARTIFACTS_TO_DEPLOY + "," + $env:JAVA_PACKAGE_NAME
|
||||
}
|
||||
- ps: |
|
||||
$env:ARTIFACTS_TO_DEPLOY = $env:ARTIFACTS_TO_DEPLOY.substring(1)
|
||||
echo $env:ARTIFACTS_TO_DEPLOY
|
||||
|
||||
|
||||
test_script:
|
||||
@@ -140,11 +148,14 @@ artifacts:
|
||||
- path: artifacts_bindings_python
|
||||
name: $(PYTHON_PACKAGE_NAME)
|
||||
type: Zip
|
||||
- path: artifacts_bindings_java
|
||||
name: $(JAVA_PACKAGE_NAME)
|
||||
type: Zip
|
||||
|
||||
|
||||
deploy:
|
||||
provider: GitHub
|
||||
artifact: $(ARTIFACTY_TO_DEPLOY)
|
||||
artifact: $(ARTIFACTS_TO_DEPLOY)
|
||||
auth_token:
|
||||
secure: 8UwbjFrtR19GxLgL3O3efUT0Su2mp3+X23YioThJITupEvexmQJPAf3Whmmb3eeL
|
||||
on:
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
# --- Setup Paths ---
|
||||
|
||||
set(RESOURCES_SWIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../resources_swig")
|
||||
set(GENERATED_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||
set(JAVA_BINDING_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||
|
||||
set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/sourcetraildb.i")
|
||||
|
||||
set(CMAKE_SWIG_FLAGS -package com.sourcetrail)
|
||||
|
||||
# --- Find Java ---
|
||||
|
||||
find_package(Java REQUIRED COMPONENTS Runtime Development)
|
||||
find_package(JNI REQUIRED)
|
||||
include(UseJava)
|
||||
|
||||
# --- Find Swig ---
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
|
||||
# --- Configure Target ---
|
||||
|
||||
set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
|
||||
include_directories(
|
||||
"${RESOURCES_SWIG_DIR}/include"
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
${JNI_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
swig_add_library(
|
||||
SharedLibrary
|
||||
TYPE SHARED
|
||||
LANGUAGE java
|
||||
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail
|
||||
OUTFILE_DIR ${GENERATED_SRC_DIR}
|
||||
SOURCES ${SWIG_INTERFACE_FILE} ${RESOURCES_SWIG_DIR}/src/sourcetraildb.cpp
|
||||
)
|
||||
|
||||
swig_link_libraries(SharedLibrary ${JNI_LIBRARIES} ${LIB_CORE_TARGET_NAME})
|
||||
|
||||
set_target_properties(SharedLibrary
|
||||
PROPERTIES OUTPUT_NAME _sourcetraildb)
|
||||
|
||||
|
||||
set(CMAKE_JNI_TARGET TRUE)
|
||||
add_jar(
|
||||
${JAVA_BINDING_TARGET_NAME}
|
||||
OUTPUT_NAME SourcetrailDB
|
||||
SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail/DefinitionKind.java
|
||||
${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail/ReferenceKind.java
|
||||
${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail/sourcetraildb.java
|
||||
${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail/sourcetraildbJNI.java
|
||||
${CMAKE_CURRENT_BINARY_DIR}/com/sourcetrail/SymbolKind.java
|
||||
)
|
||||
|
||||
add_dependencies( ${JAVA_BINDING_TARGET_NAME} SharedLibrary )
|
||||
@@ -0,0 +1,45 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
# --- Setup Paths ---
|
||||
|
||||
set(RESOURCES_SWIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../resources_swig")
|
||||
set(GENERATED_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||
set(PERL_BINDING_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||
|
||||
set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/sourcetraildb.i")
|
||||
|
||||
|
||||
# --- Find Perl ---
|
||||
|
||||
find_package(PerlLibs ${PERL_VERSION} REQUIRED)
|
||||
|
||||
|
||||
# --- Find Swig ---
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
|
||||
# --- Configure Target ---
|
||||
|
||||
set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
|
||||
include_directories(
|
||||
"${RESOURCES_SWIG_DIR}/include"
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
${PERL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
swig_add_library(
|
||||
${PERL_BINDING_TARGET_NAME}
|
||||
TYPE SHARED
|
||||
LANGUAGE perl
|
||||
OUTPUT_DIR ${PERL_BINDING_OUTPUT_DIR}
|
||||
OUTFILE_DIR ${GENERATED_SRC_DIR}
|
||||
SOURCES ${SWIG_INTERFACE_FILE} ${RESOURCES_SWIG_DIR}/src/sourcetraildb.cpp
|
||||
)
|
||||
|
||||
set_target_properties(${PERL_BINDING_TARGET_NAME}
|
||||
PROPERTIES OUTPUT_NAME sourcetraildb)
|
||||
|
||||
swig_link_libraries(${PERL_BINDING_TARGET_NAME} ${PERL_LIBRARIES} ${LIB_CORE_TARGET_NAME})
|
||||
@@ -1,14 +1,12 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
set(PACKAGE_NAME "sourcetraildb")
|
||||
|
||||
# --- Setup Paths ---
|
||||
|
||||
set(RESOURCES_SWIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../resources_swig")
|
||||
set(GENERATED_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/src")
|
||||
set(PYTHON_BINDING_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||
|
||||
set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/${PACKAGE_NAME}.i")
|
||||
set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/sourcetraildb.i")
|
||||
|
||||
|
||||
# --- Find Python ---
|
||||
@@ -33,12 +31,15 @@ include_directories(
|
||||
)
|
||||
|
||||
swig_add_library(
|
||||
${PACKAGE_NAME}
|
||||
${PYTHON_BINDING_TARGET_NAME}
|
||||
TYPE SHARED
|
||||
LANGUAGE python
|
||||
OUTPUT_DIR ${PYTHON_BINDING_OUTPUT_DIR}
|
||||
OUTFILE_DIR ${GENERATED_SRC_DIR}
|
||||
SOURCES ${SWIG_INTERFACE_FILE} ${RESOURCES_SWIG_DIR}/src/${PACKAGE_NAME}.cpp
|
||||
SOURCES ${SWIG_INTERFACE_FILE} ${RESOURCES_SWIG_DIR}/src/sourcetraildb.cpp
|
||||
)
|
||||
|
||||
swig_link_libraries(${PACKAGE_NAME} ${PYTHON_LIBRARIES} ${LIB_CORE})
|
||||
set_target_properties(_${PYTHON_BINDING_TARGET_NAME}
|
||||
PROPERTIES OUTPUT_NAME _sourcetraildb)
|
||||
|
||||
swig_link_libraries(${PYTHON_BINDING_TARGET_NAME} ${PYTHON_LIBRARIES} ${LIB_CORE_TARGET_NAME})
|
||||
|
||||
+10
-7
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
set(TEST_CORE "test_core")
|
||||
set(TEST_CORE_TARGET_NAME "test_core")
|
||||
|
||||
set(GENERATED_INCLUDE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||
set(GENERATED_VERSION_FILE "${GENERATED_INCLUDE_DIRECTORY}/version.h")
|
||||
@@ -16,6 +16,7 @@ set(LIB_SRC_FILES
|
||||
src/DatabaseStorage.cpp
|
||||
src/DefinitionKind.cpp
|
||||
src/EdgeKind.cpp
|
||||
src/ElementComponentKind.cpp
|
||||
src/LocationKind.cpp
|
||||
src/NameHierarchy.cpp
|
||||
src/NodeKind.cpp
|
||||
@@ -32,6 +33,7 @@ set(LIB_HDR_FILES
|
||||
include/DatabaseStorage.h
|
||||
include/DefinitionKind.h
|
||||
include/EdgeKind.h
|
||||
include/ElementComponentKind.h
|
||||
include/LocationKind.h
|
||||
include/NameHierarchy.h
|
||||
include/NodeKind.h
|
||||
@@ -40,6 +42,7 @@ set(LIB_HDR_FILES
|
||||
include/SourcetrailDBWriter.h
|
||||
include/SourcetrailException.h
|
||||
include/StorageEdge.h
|
||||
include/StorageElementComponent.h
|
||||
include/StorageError.h
|
||||
include/StorageFile.h
|
||||
include/StorageLocalSymbol.h
|
||||
@@ -52,11 +55,11 @@ set(LIB_HDR_FILES
|
||||
${GENERATED_VERSION_FILE}
|
||||
)
|
||||
|
||||
add_library(${LIB_CORE} STATIC ${LIB_SRC_FILES} ${LIB_HDR_FILES})
|
||||
add_library(${LIB_CORE_TARGET_NAME} STATIC ${LIB_SRC_FILES} ${LIB_HDR_FILES})
|
||||
|
||||
set_target_properties(${LIB_CORE} PROPERTIES OUTPUT_NAME "sourcetraildb")
|
||||
set_target_properties(${LIB_CORE_TARGET_NAME} PROPERTIES OUTPUT_NAME "sourcetraildb")
|
||||
|
||||
target_include_directories(${LIB_CORE} PUBLIC
|
||||
target_include_directories(${LIB_CORE_TARGET_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/json/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include"
|
||||
@@ -68,9 +71,9 @@ set(TEST_SRC_FILES
|
||||
test/test.cpp
|
||||
)
|
||||
|
||||
add_executable(${TEST_CORE} ${TEST_SRC_FILES})
|
||||
add_executable(${TEST_CORE_TARGET_NAME} ${TEST_SRC_FILES})
|
||||
|
||||
target_include_directories(${TEST_CORE} PUBLIC
|
||||
target_include_directories(${TEST_CORE_TARGET_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/catch/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/json/include"
|
||||
@@ -78,4 +81,4 @@ target_include_directories(${TEST_CORE} PUBLIC
|
||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||
)
|
||||
|
||||
target_link_libraries(${TEST_CORE} ${LIB_CORE} "-ldl")
|
||||
target_link_libraries(${TEST_CORE_TARGET_NAME} ${LIB_CORE_TARGET_NAME} "-ldl")
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "CppSQLite3.h"
|
||||
|
||||
#include "StorageEdge.h"
|
||||
#include "StorageElementComponent.h"
|
||||
#include "StorageError.h"
|
||||
#include "StorageFile.h"
|
||||
#include "StorageLocalSymbol.h"
|
||||
@@ -61,6 +62,7 @@ namespace sourcetrail
|
||||
void rollbackTransaction();
|
||||
void optimizeDatabaseMemory();
|
||||
|
||||
int addElementComponent(const StorageElementComponentData& storageElementComponentData);
|
||||
int addNode(const StorageNodeData& storageNodeData);
|
||||
void addSymbol(const StorageSymbol& storageSymbol);
|
||||
void addFile(const StorageFile& storageFile);
|
||||
@@ -102,6 +104,7 @@ namespace sourcetrail
|
||||
mutable CppSQLite3DB m_database;
|
||||
|
||||
CppSQLite3Statement m_insertElementStatement;
|
||||
CppSQLite3Statement m_insertElementComponentStatement;
|
||||
CppSQLite3Statement m_findNodeStatement;
|
||||
CppSQLite3Statement m_insertNodeStatement;
|
||||
CppSQLite3Statement m_setNodeTypeStmt;
|
||||
|
||||
+6
-10
@@ -37,16 +37,12 @@ namespace sourcetrail
|
||||
CALL = 1 << 3,
|
||||
INHERITANCE = 1 << 4,
|
||||
OVERRIDE = 1 << 5,
|
||||
TEMPLATE_ARGUMENT = 1 << 6,
|
||||
TYPE_ARGUMENT = 1 << 7,
|
||||
TEMPLATE_DEFAULT_ARGUMENT = 1 << 8,
|
||||
TEMPLATE_SPECIALIZATION = 1 << 9,
|
||||
TEMPLATE_MEMBER_SPECIALIZATION = 1 << 10,
|
||||
INCLUDE = 1 << 11,
|
||||
IMPORT = 1 << 12,
|
||||
AGGREGATION = 1 << 13,
|
||||
MACRO_USAGE = 1 << 14,
|
||||
ANNOTATION_USAGE = 1 << 15
|
||||
TYPE_ARGUMENT = 1 << 6,
|
||||
TEMPLATE_SPECIALIZATION = 1 << 7,
|
||||
INCLUDE = 1 << 8,
|
||||
IMPORT = 1 << 9,
|
||||
MACRO_USAGE = 1 << 11, // needs new db version if decremented
|
||||
ANNOTATION_USAGE = 1 << 12
|
||||
};
|
||||
|
||||
int edgeKindToInt(EdgeKind kind);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2018 Coati Software KG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
|
||||
#define SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of node and edge components that can be stored to the Sourcetrail database.
|
||||
*/
|
||||
enum class ElementComponentKind : int
|
||||
{
|
||||
IS_AMBIGUOUS = 1 << 0
|
||||
};
|
||||
|
||||
int elementComponentKindToInt(ElementComponentKind kind);
|
||||
ElementComponentKind intToElementComponentKind(int i);
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
|
||||
@@ -32,7 +32,8 @@ namespace sourcetrail
|
||||
ATOMIC_RANGE = 5,
|
||||
INDEXER_ERROR = 6,
|
||||
FULLTEXT_SEARCH = 7,
|
||||
SCREEN_SEARCH = 8
|
||||
SCREEN_SEARCH = 8,
|
||||
UNSOLVED = 9
|
||||
};
|
||||
|
||||
int locationKindToInt(LocationKind kind);
|
||||
|
||||
@@ -41,11 +41,10 @@ namespace sourcetrail
|
||||
ENUM = 1 << 14,
|
||||
ENUM_CONSTANT = 1 << 15,
|
||||
TYPEDEF = 1 << 16,
|
||||
TEMPLATE_PARAMETER = 1 << 17,
|
||||
TYPE_PARAMETER = 1 << 18,
|
||||
FILE = 1 << 19,
|
||||
MACRO = 1 << 20,
|
||||
UNION = 1 << 21
|
||||
TYPE_PARAMETER = 1 << 17,
|
||||
FILE = 1 << 18,
|
||||
MACRO = 1 << 19,
|
||||
UNION = 1 << 20
|
||||
};
|
||||
|
||||
int nodeKindToInt(NodeKind kind);
|
||||
|
||||
@@ -31,11 +31,8 @@ namespace sourcetrail
|
||||
CALL,
|
||||
INHERITANCE,
|
||||
OVERRIDE,
|
||||
TEMPLATE_ARGUMENT,
|
||||
TYPE_ARGUMENT,
|
||||
TEMPLATE_DEFAULT_ARGUMENT,
|
||||
TEMPLATE_SPECIALIZATION,
|
||||
TEMPLATE_MEMBER_SPECIALIZATION,
|
||||
INCLUDE,
|
||||
IMPORT,
|
||||
MACRO_USAGE,
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "DefinitionKind.h"
|
||||
#include "EdgeKind.h"
|
||||
#include "ElementComponentKind.h"
|
||||
#include "LocationKind.h"
|
||||
#include "NameHierarchy.h"
|
||||
#include "ReferenceKind.h"
|
||||
@@ -349,6 +350,42 @@ namespace sourcetrail
|
||||
*/
|
||||
bool recordReferenceLocation(int referenceId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Marks a reference that is stored in the database as "ambiguous"
|
||||
*
|
||||
* This method allows to additional information for a reference to the database. Sourcetrail will
|
||||
* display an "ambiguous" reference with a special style to emphasize that the existance of the
|
||||
* reference is questionable. This method is intended to be called in situations when an indexed
|
||||
* token may have meanings, all of which shall be recorded.
|
||||
*
|
||||
* param: referenceId - the id of the reference that shall be marked as ambiguous.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool recordReferenceIsAmbiguous(int referenceId);
|
||||
|
||||
/**
|
||||
* Stores a location between a specific context and an "unsolved" symbol to the database
|
||||
*
|
||||
* This method allows to store all available information to the database in the case that a symbol
|
||||
* is referenced in a certain context but the referenced symbol could not be resolved to a concrete
|
||||
* name. For each reference recorded by this method, Sourcetrail's graph view will display an edge
|
||||
* that originates at the recorded context symbol and points to a node called "unsolved symbol".
|
||||
* Furthermore Sourcetrail's code view will use a different highlight when the provided source range
|
||||
* gets hovered.
|
||||
*
|
||||
* param: contextSymbolId - the id of the source of the recorded reference edge
|
||||
* param: referenceKind - kind of the recorded reference edge
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective
|
||||
* reference.
|
||||
*
|
||||
* return: referenceId - integer id of the stored reference. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
int recordReferenceToUnsolvedSymhol(int contextSymbolId, ReferenceKind referenceKind, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores a location for the usage of a symbol's name as qualifier to the database
|
||||
*
|
||||
@@ -475,6 +512,7 @@ namespace sourcetrail
|
||||
int addFile(const std::string& filePath);
|
||||
int addEdge(int sourceId, int targetId, EdgeKind edgeKind);
|
||||
void addSourceLocation(int elementId, const SourceRange& location, LocationKind kind);
|
||||
void addElementComponent(int elementId, ElementComponentKind kind, const std::string& data);
|
||||
|
||||
std::string m_projectFilePath;
|
||||
std::string m_databaseFilePath;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2018 Coati Software KG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
|
||||
#define SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageElementComponentData
|
||||
{
|
||||
StorageElementComponentData()
|
||||
: elementId(0)
|
||||
, componentKind(0)
|
||||
, data("")
|
||||
{}
|
||||
|
||||
StorageElementComponentData(int elementId, int componentKind, std::string data)
|
||||
: elementId(elementId)
|
||||
, componentKind(componentKind)
|
||||
, data(std::move(data))
|
||||
{}
|
||||
|
||||
int elementId;
|
||||
int componentKind;
|
||||
std::string data;
|
||||
};
|
||||
|
||||
struct StorageElementComponent : public StorageElementComponentData
|
||||
{
|
||||
StorageElementComponent()
|
||||
: StorageElementComponentData()
|
||||
, id(0)
|
||||
{}
|
||||
|
||||
StorageElementComponent(int id, const StorageElementComponentData& data)
|
||||
: StorageElementComponentData(data)
|
||||
, id(id)
|
||||
{}
|
||||
|
||||
StorageElementComponent(int id, int elementId, int componentKind, std::string data)
|
||||
: StorageElementComponentData(elementId, componentKind, data)
|
||||
, id(id)
|
||||
{}
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
|
||||
@@ -42,7 +42,6 @@ namespace sourcetrail
|
||||
ENUM,
|
||||
ENUM_CONSTANT,
|
||||
TYPEDEF,
|
||||
TEMPLATE_PARAMETER,
|
||||
TYPE_PARAMETER,
|
||||
MACRO,
|
||||
UNION
|
||||
|
||||
@@ -151,6 +151,17 @@ namespace sourcetrail
|
||||
executeStatement("VACUUM;");
|
||||
}
|
||||
|
||||
int DatabaseStorage::addElementComponent(const StorageElementComponentData& storageElementComponentData)
|
||||
{
|
||||
m_insertElementComponentStatement.bind(1, storageElementComponentData.elementId);
|
||||
m_insertElementComponentStatement.bind(2, storageElementComponentData.componentKind);
|
||||
m_insertElementComponentStatement.bind(3, storageElementComponentData.data.c_str());
|
||||
executeStatement(m_insertElementComponentStatement);
|
||||
int id = m_database.lastRowId();
|
||||
m_insertElementComponentStatement.reset();
|
||||
return id;
|
||||
}
|
||||
|
||||
int DatabaseStorage::addNode(const StorageNodeData& storageNodeData)
|
||||
{
|
||||
int id = 0;
|
||||
@@ -393,6 +404,17 @@ namespace sourcetrail
|
||||
");"
|
||||
);
|
||||
|
||||
executeStatement(
|
||||
"CREATE TABLE IF NOT EXISTS element_component("
|
||||
" id INTEGER, "
|
||||
" element_id INTEGER, "
|
||||
" type INTEGER, "
|
||||
" data TEXT, "
|
||||
" PRIMARY KEY(id), "
|
||||
" FOREIGN KEY(element_id) REFERENCES element(id) ON DELETE CASCADE"
|
||||
");"
|
||||
);
|
||||
|
||||
executeStatement(
|
||||
"CREATE TABLE IF NOT EXISTS edge("
|
||||
" id INTEGER NOT NULL, "
|
||||
@@ -518,6 +540,7 @@ namespace sourcetrail
|
||||
"symbol",
|
||||
"node",
|
||||
"edge",
|
||||
"element_component"
|
||||
"element"
|
||||
};
|
||||
|
||||
@@ -557,6 +580,10 @@ namespace sourcetrail
|
||||
"INSERT INTO element(id) VALUES(NULL);"
|
||||
);
|
||||
|
||||
m_insertElementComponentStatement = compileStatement(
|
||||
"INSERT INTO element_component(id, element_id, type, data) VALUES(NULL, ?, ?, ?);"
|
||||
);
|
||||
|
||||
m_findNodeStatement = compileStatement(
|
||||
"SELECT id FROM node WHERE serialized_name == ? LIMIT 1;"
|
||||
);
|
||||
@@ -648,6 +675,7 @@ namespace sourcetrail
|
||||
void DatabaseStorage::clearPrecompiledStatements()
|
||||
{
|
||||
m_insertElementStatement.finalize();
|
||||
m_insertElementComponentStatement.finalize();
|
||||
m_findNodeStatement.finalize();
|
||||
m_insertNodeStatement.finalize();
|
||||
m_setNodeTypeStmt.finalize();
|
||||
|
||||
@@ -34,14 +34,10 @@ namespace sourcetrail
|
||||
EdgeKind::CALL,
|
||||
EdgeKind::INHERITANCE,
|
||||
EdgeKind::OVERRIDE,
|
||||
EdgeKind::TEMPLATE_ARGUMENT,
|
||||
EdgeKind::TYPE_ARGUMENT,
|
||||
EdgeKind::TEMPLATE_DEFAULT_ARGUMENT,
|
||||
EdgeKind::TEMPLATE_SPECIALIZATION,
|
||||
EdgeKind::TEMPLATE_MEMBER_SPECIALIZATION,
|
||||
EdgeKind::INCLUDE,
|
||||
EdgeKind::IMPORT,
|
||||
EdgeKind::AGGREGATION,
|
||||
EdgeKind::MACRO_USAGE
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2018 Coati Software KG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ElementComponentKind.h"
|
||||
|
||||
#include "SourcetrailException.h"
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
int elementComponentKindToInt(ElementComponentKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
ElementComponentKind intToElementComponentKind(int i)
|
||||
{
|
||||
const ElementComponentKind kinds[] = {
|
||||
ElementComponentKind::IS_AMBIGUOUS
|
||||
};
|
||||
|
||||
for (ElementComponentKind kind : kinds)
|
||||
{
|
||||
if (i == elementComponentKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
throw SourcetrailException("Unable to convert integer \"" + std::to_string(i) + "\" to element component kind.");
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,8 @@ namespace sourcetrail
|
||||
LocationKind::ATOMIC_RANGE,
|
||||
LocationKind::INDEXER_ERROR,
|
||||
LocationKind::FULLTEXT_SEARCH,
|
||||
LocationKind::SCREEN_SEARCH
|
||||
LocationKind::SCREEN_SEARCH,
|
||||
LocationKind::UNSOLVED
|
||||
};
|
||||
|
||||
for (LocationKind kind : kinds)
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace sourcetrail
|
||||
NodeKind::ENUM,
|
||||
NodeKind::ENUM_CONSTANT,
|
||||
NodeKind::TYPEDEF,
|
||||
NodeKind::TEMPLATE_PARAMETER,
|
||||
NodeKind::TYPE_PARAMETER,
|
||||
NodeKind::FILE,
|
||||
NodeKind::MACRO,
|
||||
|
||||
@@ -34,16 +34,10 @@ namespace sourcetrail
|
||||
return EdgeKind::INHERITANCE;
|
||||
case ReferenceKind::OVERRIDE:
|
||||
return EdgeKind::OVERRIDE;
|
||||
case ReferenceKind::TEMPLATE_ARGUMENT:
|
||||
return EdgeKind::TEMPLATE_ARGUMENT;
|
||||
case ReferenceKind::TYPE_ARGUMENT:
|
||||
return EdgeKind::TYPE_ARGUMENT;
|
||||
case ReferenceKind::TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return EdgeKind::TEMPLATE_DEFAULT_ARGUMENT;
|
||||
case ReferenceKind::TEMPLATE_SPECIALIZATION:
|
||||
return EdgeKind::TEMPLATE_SPECIALIZATION;
|
||||
case ReferenceKind::TEMPLATE_MEMBER_SPECIALIZATION:
|
||||
return EdgeKind::TEMPLATE_MEMBER_SPECIALIZATION;
|
||||
case ReferenceKind::INCLUDE:
|
||||
return EdgeKind::INCLUDE;
|
||||
case ReferenceKind::IMPORT:
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace sourcetrail
|
||||
if (!m_storage)
|
||||
{
|
||||
m_lastError = "Unable to record reference, because no database is currently open.";
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
@@ -462,6 +462,52 @@ namespace sourcetrail
|
||||
}
|
||||
}
|
||||
|
||||
bool SourcetrailDBWriter::recordReferenceIsAmbiguous(int referenceId)
|
||||
{
|
||||
if (!m_storage)
|
||||
{
|
||||
m_lastError = "Unable to record ambiguity of reference, because no database is currently open.";
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
addElementComponent(referenceId, ElementComponentKind::IS_AMBIGUOUS, "");
|
||||
return false;
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int SourcetrailDBWriter::recordReferenceToUnsolvedSymhol(int contextSymbolId, ReferenceKind referenceKind, const SourceRange& location)
|
||||
{
|
||||
if (!m_storage)
|
||||
{
|
||||
m_lastError = "Unable to record symbol reference, because no database is currently open.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NameHierarchy unsolvedSymbolName;
|
||||
NameElement unsolvedSymbolNameElement;
|
||||
unsolvedSymbolNameElement.name = "unsolved symbol";
|
||||
unsolvedSymbolName.nameElements.push_back(unsolvedSymbolNameElement);
|
||||
int unsolvedSymbolId = addNodeHierarchy(unsolvedSymbolName);
|
||||
int referenceId = addEdge(contextSymbolId, unsolvedSymbolId, referenceKindToEdgeKind(referenceKind));
|
||||
addSourceLocation(referenceId, location, LocationKind::UNSOLVED);
|
||||
return referenceId;
|
||||
}
|
||||
catch (const SourcetrailException e)
|
||||
{
|
||||
m_lastError = e.getMessage();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool SourcetrailDBWriter::recordQualifierLocation(int referencedSymbolId, const SourceRange& location)
|
||||
{
|
||||
if (!m_storage)
|
||||
@@ -785,4 +831,13 @@ namespace sourcetrail
|
||||
sourceLocationId
|
||||
));
|
||||
}
|
||||
|
||||
void SourcetrailDBWriter::addElementComponent(int elementId, ElementComponentKind kind, const std::string& data)
|
||||
{
|
||||
const int sourceLocationId = m_storage->addElementComponent(StorageElementComponentData(
|
||||
elementId,
|
||||
elementComponentKindToInt(kind),
|
||||
data
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,6 @@ namespace sourcetrail
|
||||
return NodeKind::ENUM_CONSTANT;
|
||||
case SymbolKind::TYPEDEF:
|
||||
return NodeKind::TYPEDEF;
|
||||
case SymbolKind::TEMPLATE_PARAMETER:
|
||||
return NodeKind::TEMPLATE_PARAMETER;
|
||||
case SymbolKind::TYPE_PARAMETER:
|
||||
return NodeKind::TYPE_PARAMETER;
|
||||
case SymbolKind::MACRO:
|
||||
|
||||
@@ -17,7 +17,7 @@ target_include_directories(${EXAMPLE_NAME} PUBLIC
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
target_link_libraries(${EXAMPLE_NAME} ${LIB_CORE} "-ldl")
|
||||
target_link_libraries(${EXAMPLE_NAME} ${LIB_CORE_TARGET_NAME} "-ldl")
|
||||
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
@@ -17,7 +17,7 @@ target_include_directories(${EXAMPLE_NAME} PUBLIC
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
target_link_libraries(${EXAMPLE_NAME} ${LIB_CORE} "-ldl")
|
||||
target_link_libraries(${EXAMPLE_NAME} ${LIB_CORE_TARGET_NAME} "-ldl")
|
||||
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
# --- Find Java ---
|
||||
|
||||
find_package(Java REQUIRED COMPONENTS Runtime Development)
|
||||
include(UseJava)
|
||||
|
||||
set(EXAMPLE_NAME "java_api_example")
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/za/co/spazzymoto/example.java ${CMAKE_CURRENT_BINARY_DIR}/za/co/spazzymoto/example.java COPYONLY)
|
||||
|
||||
add_custom_target(
|
||||
CopyJar ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JAVA_BINDING_OUTPUT_DIR}/SourcetrailDB.jar ${CMAKE_CURRENT_BINARY_DIR}/SourcetrailDB.jar
|
||||
)
|
||||
|
||||
add_jar(
|
||||
${EXAMPLE_NAME}
|
||||
SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/za/co/spazzymoto/example.java
|
||||
INCLUDE_JARS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SourcetrailDB.jar
|
||||
ENTRY_POINT za.co.spazzymoto.example
|
||||
)
|
||||
|
||||
add_dependencies( ${EXAMPLE_NAME} CopyJar )
|
||||
add_dependencies( CopyJar ${JAVA_BINDING_TARGET_NAME} )
|
||||
|
||||
if (MSVC)
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_JAVA_BINDING_OUTPUT_DIR ${JAVA_BINDING_OUTPUT_DIR})
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND xcopy \"${BACKSLASHED_JAVA_BINDING_OUTPUT_DIR}\\$(Configuration)\\_sourcetraildb*\" \"${BACKSLASHED_CMAKE_CURRENT_BINARY_DIR}\" /Y
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JAVA_BINDING_OUTPUT_DIR}/lib_sourcetraildb* ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(JAVA_API_EXAMPLE_DATA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${EXAMPLE_NAME}.srctrlprj.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_NAME}.srctrlprj"
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
## Java API Example
|
||||
|
||||
### Requirements
|
||||
|
||||
* CMake
|
||||
* C++ Compiler
|
||||
* Java JDK
|
||||
* SWIG
|
||||
|
||||
### Running from Command Line
|
||||
|
||||
* Run cmake with `BUILD_BINDINGS_JAVA=ON`
|
||||
* Build `make`
|
||||
* Copy two files from the `bindings_java` build directory into `SourcetrailDB/examples/java_api_example`:
|
||||
- SourcetrailDB.jar
|
||||
- Windows: `_sourcetraildb.dll`
|
||||
- Linux: `lib_sourcetraildb.so`
|
||||
- macOS: `lib_sourcetraildb.jnilib`
|
||||
* Run example from the directory `SourcetrailDB/examples/java_api_example` with:
|
||||
|
||||
## Windows
|
||||
```
|
||||
$ javac -cp SourcetrailDB.jar src/za/co/spazzymoto/example.java
|
||||
$ java -cp "SourcetrailDB.jar;src" -Djava.library.path=. za.co.spazzymoto.example --database-file-path=absolute/path/to/SourcetrailDB/examples/java_api_example/src/example.srctrldb --source-file-path=absolute/path/to/SourcetrailDB/examples/java_api_example/data/file.py
|
||||
```
|
||||
|
||||
## Unix/macOS
|
||||
```
|
||||
$ javac -cp SourcetrailDB.jar src/za/co/spazzymoto/example.java
|
||||
$ java -cp "SourcetrailDB.jar:src" -Djava.library.path=. za.co.spazzymoto.example --database-file-path=absolute/path/to/SourcetrailDB/examples/java_api_example/src/example.srctrldb --source-file-path=absolute/path/to/SourcetrailDB/examples/java_api_example/data/file.py
|
||||
```
|
||||
|
||||
### Running with Sourcetrail
|
||||
|
||||
* Run cmake with `BUILD_EXAMPLES=ON` and `BUILD_BINDINGS_JAVA=ON`
|
||||
* Build `make`.
|
||||
* Open `java_api_example.srctrlprj` located in the build directory of `java_api_example` with Sourcetrail and index the project.
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
class MyType:
|
||||
|
||||
my_member = true
|
||||
|
||||
def my_method():
|
||||
return my_member
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<config>
|
||||
<source_groups>
|
||||
<source_group_78efd997-84bf-4db6-9736-f5ddd702053c>
|
||||
<custom_command>java -cp "*" -Djava.library.path=. za.co.spazzymoto.example --database-file-path=%{DATABASE_FILE_PATH} --source-file-path=%{SOURCE_FILE_PATH}</custom_command>
|
||||
<name>Custom Command Source Group</name>
|
||||
<source_extensions>
|
||||
<source_extension>.py</source_extension>
|
||||
</source_extensions>
|
||||
<source_paths>
|
||||
<source_path>@JAVA_API_EXAMPLE_DATA_PATH@/file.py</source_path>
|
||||
</source_paths>
|
||||
<status>enabled</status>
|
||||
<type>Custom Command Source Group</type>
|
||||
</source_group_78efd997-84bf-4db6-9736-f5ddd702053c>
|
||||
</source_groups>
|
||||
<version>7</version>
|
||||
</config>
|
||||
@@ -0,0 +1,120 @@
|
||||
package za.co.spazzymoto;
|
||||
|
||||
import com.sourcetrail.*;
|
||||
|
||||
public class example {
|
||||
private static int DBVersion;
|
||||
private static String DBFilePath;
|
||||
private static String SourceFilePath;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
for (String arg : args) {
|
||||
String name = "";
|
||||
String value = "";
|
||||
try {
|
||||
name = arg.split("=")[0];
|
||||
value = arg.split("=")[1];
|
||||
} catch(Exception e) {
|
||||
System.out.println("Invalid parameter:" + arg);
|
||||
System.exit(1);
|
||||
}
|
||||
switch(name) {
|
||||
case "--database-file-path":
|
||||
example.DBFilePath = value;
|
||||
break;
|
||||
|
||||
case "--source-file-path":
|
||||
example.SourceFilePath = value;
|
||||
break;
|
||||
|
||||
case "--database-version":
|
||||
try {
|
||||
example.DBVersion = Integer.parseInt(value);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid DB version:" + value);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("Invalid parameter:" + name);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("SourcetrailDB Java API Example");
|
||||
System.out.println("Supported database version: " + sourcetraildb.getSupportedDatabaseVersion());
|
||||
|
||||
if (example.DBVersion > 0 && example.DBVersion != sourcetraildb.getSupportedDatabaseVersion()) {
|
||||
System.out.println("ERROR: Only supports database version: " + sourcetraildb.getSupportedDatabaseVersion() +
|
||||
". Requested version: " + example.DBVersion);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
sourcetraildb.open(example.DBFilePath);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
System.out.println("Clearing loaded database now...");
|
||||
sourcetraildb.clear();
|
||||
|
||||
System.out.println("start indexing");
|
||||
sourcetraildb.beginTransaction();
|
||||
|
||||
int fileId = sourcetraildb.recordFile(example.SourceFilePath);
|
||||
sourcetraildb.recordFileLanguage(fileId, "python");
|
||||
|
||||
if (sourcetraildb.getLastError().length() > 0) {
|
||||
System.out.println(sourcetraildb.getLastError());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
int symbolId = sourcetraildb.recordSymbol(
|
||||
"{ \"name_delimiter\": \".\", \"name_elements\": [ " +
|
||||
"{ \"prefix\": \"\", \"name\": \"MyType\", \"postfix\": \"\" } " +
|
||||
"] }");
|
||||
sourcetraildb.recordSymbolDefinitionKind(symbolId, DefinitionKind.DEFINITION_EXPLICIT);
|
||||
sourcetraildb.recordSymbolKind(symbolId, SymbolKind.SYMBOL_CLASS);
|
||||
sourcetraildb.recordSymbolLocation(symbolId, fileId, 2, 7, 2, 12);
|
||||
sourcetraildb.recordSymbolScopeLocation(symbolId, fileId, 2, 1, 7, 1);
|
||||
|
||||
int memberId = sourcetraildb.recordSymbol(
|
||||
"{ \"name_delimiter\": \".\", \"name_elements\": [ " +
|
||||
"{ \"prefix\": \"\", \"name\": \"MyType\", \"postfix\": \"\" }, " +
|
||||
"{ \"prefix\": \"\", \"name\": \"my_member\", \"postfix\": \"\" } " +
|
||||
"] }");
|
||||
sourcetraildb.recordSymbolDefinitionKind(memberId, DefinitionKind.DEFINITION_EXPLICIT);
|
||||
sourcetraildb.recordSymbolKind(memberId, SymbolKind.SYMBOL_FIELD);
|
||||
sourcetraildb.recordSymbolLocation(memberId, fileId, 4, 2, 4, 10);
|
||||
|
||||
int methodId = sourcetraildb.recordSymbol(
|
||||
"{ \"name_delimiter\": \".\", \"name_elements\": [ " +
|
||||
"{ \"prefix\": \"\", \"name\": \"MyType\", \"postfix\": \"\" }, " +
|
||||
"{ \"prefix\": \"\", \"name\": \"my_method\", \"postfix\": \"\" } " +
|
||||
"] }");
|
||||
sourcetraildb.recordSymbolDefinitionKind(methodId, DefinitionKind.DEFINITION_EXPLICIT);
|
||||
sourcetraildb.recordSymbolKind(methodId, SymbolKind.SYMBOL_METHOD);
|
||||
sourcetraildb.recordSymbolLocation(methodId, fileId, 6, 6, 6, 14);
|
||||
sourcetraildb.recordSymbolScopeLocation(methodId, fileId, 6, 1, 7, 1);
|
||||
|
||||
int useageId = sourcetraildb.recordReference(methodId, memberId, ReferenceKind.REFERENCE_USAGE);
|
||||
sourcetraildb.recordReferenceLocation(useageId, fileId, 7, 10, 7, 18);
|
||||
|
||||
sourcetraildb.commitTransaction();
|
||||
|
||||
if (sourcetraildb.getLastError().length() > 0) {
|
||||
System.out.println(sourcetraildb.getLastError());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (!sourcetraildb.close()) {
|
||||
System.out.println(sourcetraildb.getLastError());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
System.out.println("done");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
set(EXAMPLE_NAME "perl_api_example")
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
add_custom_target(
|
||||
${EXAMPLE_NAME} ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/example.pl ${CMAKE_CURRENT_BINARY_DIR}/example.pl
|
||||
)
|
||||
|
||||
add_dependencies(${EXAMPLE_NAME} _${PERL_BINDING_TARGET_NAME})
|
||||
|
||||
if (MSVC)
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_PERL_BINDING_OUTPUT_DIR ${PERL_BINDING_OUTPUT_DIR})
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND xcopy \"${BACKSLASHED_PERL_BINDING_OUTPUT_DIR}\\$(Configuration)\\sourcetraildb*\" \"${BACKSLASHED_CMAKE_CURRENT_BINARY_DIR}\" /Y
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND xcopy \"${BACKSLASHED_PERL_BINDING_OUTPUT_DIR}\\sourcetraildb.pm\" \"${BACKSLASHED_CMAKE_CURRENT_BINARY_DIR}\" /Y
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PERL_BINDING_OUTPUT_DIR}/sourcetraildb* ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
add_custom_command(
|
||||
TARGET ${EXAMPLE_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/sourcetraildb.dylib ${CMAKE_CURRENT_BINARY_DIR}/sourcetraildb.so
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
set(PERL_API_EXAMPLE_DATA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${EXAMPLE_NAME}.srctrlprj.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE_NAME}.srctrlprj"
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
## Perl API Example
|
||||
|
||||
### Requirements
|
||||
|
||||
* CMake
|
||||
* C++ Compiler
|
||||
* Perl
|
||||
* SWIG
|
||||
|
||||
### Running from Command Line
|
||||
|
||||
* Run cmake with `BUILD_BINDINGS_PERL=ON`
|
||||
* Build target `sourcetraildb`
|
||||
* Copy two files from the `bindings_perl` build directory into `SourcetrailDB/examples/perl_api_example/src`:
|
||||
- `sourcetraildb.pm`
|
||||
- Windows: `sourcetraildb.dll`
|
||||
- Linux: `sourcetraildb.so`
|
||||
- macOS: `sourcetraildb.dylib` and rename to `sourcetraildb.so`
|
||||
* Run example from the directory `SourcetrailDB/examples/perl_api_example/src` with:
|
||||
|
||||
```
|
||||
$ perl example.pl --database-file-path=absolute/path/to/SourcetrailDB/examples/perl_api_example/src/example.srctrldb --source-file-path=absolute/path/to/SourcetrailDB/examples/perl_api_example/data/file.pm
|
||||
```
|
||||
|
||||
### Running with Sourcetrail
|
||||
|
||||
* Run cmake with `BUILD_EXAMPLES=ON` and `BUILD_BINDINGS_PERL=ON`
|
||||
* Build target `sourcetraildb` and `perl_api_example`.
|
||||
* Open `perl_api_exampl.srctrlprj` located in the build directory of `perl_api_example` with Sourcetrail and index the project.
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
package MyClass;
|
||||
|
||||
my $my_member = 1;
|
||||
|
||||
sub my_method {
|
||||
return $my_member;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<config>
|
||||
<source_groups>
|
||||
<source_group_2e83e5fa-b0f8-453b-a1fc-2abdb66bd967>
|
||||
<custom_command>perl example.pl --database-file-path=%{DATABASE_FILE_PATH} --source-file-path=%{SOURCE_FILE_PATH} --database-version=%{DATABASE_VERSION}</custom_command>
|
||||
<name>Custom Command Source Group</name>
|
||||
<run_in_parallel>0</run_in_parallel>
|
||||
<source_extensions>
|
||||
<source_extension>.pl</source_extension>
|
||||
<source_extension>.pm</source_extension>
|
||||
</source_extensions>
|
||||
<source_paths>
|
||||
<source_path>@PERL_API_EXAMPLE_DATA_PATH@/file.pm</source_path>
|
||||
</source_paths>
|
||||
<status>enabled</status>
|
||||
<type>Custom Command Source Group</type>
|
||||
</source_group_2e83e5fa-b0f8-453b-a1fc-2abdb66bd967>
|
||||
</source_groups>
|
||||
<version>7</version>
|
||||
</config>
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use v5.10;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Getopt::Long;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use sourcetraildb;
|
||||
|
||||
my ( $database_file_path, $source_file_path );
|
||||
my $db_version = 0;
|
||||
|
||||
GetOptions(
|
||||
'database-file-path=s' => \$database_file_path,
|
||||
'source-file-path=s' => \$source_file_path,
|
||||
'database-version=i' => \$db_version,
|
||||
);
|
||||
|
||||
say "SourcetrailDB Perl API Example";
|
||||
my $supported_db_version = sourcetraildb::getSupportedDatabaseVersion;
|
||||
say "Supported database version: $supported_db_version";
|
||||
|
||||
die "ERROR: Only supports database version: $supported_db_version. Requested version: $db_version\n"
|
||||
if $db_version > 0 and $db_version != $supported_db_version;
|
||||
|
||||
die "ERROR: " . sourcetraildb::getLastError unless sourcetraildb::open($database_file_path);
|
||||
|
||||
say "Clearing loaded database now...";
|
||||
sourcetraildb::clear;
|
||||
|
||||
say "start indexing";
|
||||
sourcetraildb::beginTransaction;
|
||||
|
||||
my $file_id = sourcetraildb::recordFile($source_file_path);
|
||||
sourcetraildb::recordFileLanguage( $file_id, 'perl' );
|
||||
die "ERROR: " . sourcetraildb::getLastError if sourcetraildb::getLastError;
|
||||
|
||||
my $symbol_id = sourcetraildb::recordSymbol(
|
||||
'{ "name_delimiter": "::", "name_elements": [ { "prefix": "", "name": "MyClass", "postfix": "" } ] }');
|
||||
sourcetraildb::recordSymbolDefinitionKind( $symbol_id, $sourcetraildb::DEFINITION_EXPLICIT );
|
||||
sourcetraildb::recordSymbolKind( $symbol_id, $sourcetraildb::SYMBOL_PACKAGE );
|
||||
sourcetraildb::recordSymbolLocation( $symbol_id, $file_id, 1, 9, 1, 15 );
|
||||
sourcetraildb::recordSymbolScopeLocation( $symbol_id, $file_id, 1, 1, 7, 2 );
|
||||
|
||||
my $member_id
|
||||
= sourcetraildb::recordSymbol( '{ "name_delimiter": "::", "name_elements": [ '
|
||||
. '{ "prefix": "", "name": "MyClass", "postfix": "" }, '
|
||||
. '{ "prefix": "$", "name": "my_member", "postfix": "" } '
|
||||
. '] }' );
|
||||
sourcetraildb::recordSymbolDefinitionKind( $member_id, $sourcetraildb::DEFINITION_EXPLICIT );
|
||||
sourcetraildb::recordSymbolKind( $member_id, $sourcetraildb::SYMBOL_FIELD );
|
||||
sourcetraildb::recordSymbolLocation( $member_id, $file_id, 3, 4, 3, 13 );
|
||||
|
||||
my $method_id
|
||||
= sourcetraildb::recordSymbol( '{ "name_delimiter": "::", "name_elements": [ '
|
||||
. '{ "prefix": "", "name": "MyClass", "postfix": "" }, '
|
||||
. '{ "prefix": "&", "name": "my_method", "postfix": "" } '
|
||||
. '] }' );
|
||||
sourcetraildb::recordSymbolDefinitionKind( $method_id, $sourcetraildb::DEFINITION_EXPLICIT );
|
||||
sourcetraildb::recordSymbolKind( $method_id, $sourcetraildb::SYMBOL_METHOD );
|
||||
sourcetraildb::recordSymbolLocation( $method_id, $file_id, 5, 5, 5, 13 );
|
||||
sourcetraildb::recordSymbolScopeLocation( $method_id, $file_id, 6, 1, 7, 1 );
|
||||
|
||||
my $usage_id = sourcetraildb::recordReference( $method_id, $member_id, $sourcetraildb::REFERENCE_USAGE );
|
||||
sourcetraildb::recordReferenceLocation( $usage_id, $file_id, 6, 9, 6, 18 );
|
||||
|
||||
sourcetraildb::commitTransaction;
|
||||
die "ERROR: " . sourcetraildb::getLastError if sourcetraildb::getLastError;
|
||||
die "ERROR: " . sourcetraildb::getLastError unless sourcetraildb::close;
|
||||
|
||||
say "done";
|
||||
@@ -9,6 +9,8 @@ add_custom_target(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/example.py ${CMAKE_CURRENT_BINARY_DIR}/example.py
|
||||
)
|
||||
|
||||
add_dependencies(${EXAMPLE_NAME} _${PYTHON_BINDING_TARGET_NAME})
|
||||
|
||||
if (MSVC)
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_PYTHON_BINDING_OUTPUT_DIR ${PYTHON_BINDING_OUTPUT_DIR})
|
||||
STRING(REGEX REPLACE "/" "\\\\" BACKSLASHED_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -27,4 +27,4 @@ $ python example.py --database-file-path=absolute/path/to/SourcetrailDB/examples
|
||||
|
||||
* Run cmake with `BUILD_EXAMPLES=ON` and `BUILD_BINDINGS_PYTHON=ON`
|
||||
* Build target `_sourcetraildb` and `python_api_example`.
|
||||
* Open `python_api_exampl.srctrlprj` located in the build directory of `python_api_example` with Sourcetrail and index the project.
|
||||
* Open `python_api_example.srctrlprj` located in the build directory of `python_api_example` with Sourcetrail and index the project.
|
||||
|
||||
@@ -27,7 +27,6 @@ enum SymbolKind
|
||||
SYMBOL_ENUM,
|
||||
SYMBOL_ENUM_CONSTANT,
|
||||
SYMBOL_TYPEDEF,
|
||||
SYMBOL_TEMPLATE_PARAMETER,
|
||||
SYMBOL_TYPE_PARAMETER,
|
||||
SYMBOL_MACRO,
|
||||
SYMBOL_UNION
|
||||
@@ -40,11 +39,8 @@ enum ReferenceKind
|
||||
REFERENCE_CALL,
|
||||
REFERENCE_INHERITANCE,
|
||||
REFERENCE_OVERRIDE,
|
||||
REFERENCE_TEMPLATE_ARGUMENT,
|
||||
REFERENCE_TYPE_ARGUMENT,
|
||||
REFERENCE_TEMPLATE_DEFAULT_ARGUMENT,
|
||||
REFERENCE_TEMPLATE_SPECIALIZATION,
|
||||
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION,
|
||||
REFERENCE_INCLUDE,
|
||||
REFERENCE_IMPORT,
|
||||
REFERENCE_MACRO_USAGE,
|
||||
@@ -95,6 +91,10 @@ int recordReference(int contextSymbolId, int referencedSymbolId, ReferenceKind r
|
||||
|
||||
bool recordReferenceLocation(int referenceId, int fileId, int startLine, int startColumn, int endLine, int endColumn);
|
||||
|
||||
bool recordReferenceIsAmbiguous(int referenceId);
|
||||
|
||||
int recordReferenceToUnsolvedSymhol(int contextSymbolId, ReferenceKind referenceKind, int fileId, int startLine, int startColumn, int endLine, int endColumn);
|
||||
|
||||
bool recordQualifierLocation(int referencedSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn);
|
||||
|
||||
int recordFile(std::string filePath);
|
||||
|
||||
@@ -9,4 +9,15 @@
|
||||
%}
|
||||
|
||||
//double-check that this is indeed %include !!!
|
||||
%include "sourcetraildb.h"
|
||||
%include "sourcetraildb.h"
|
||||
|
||||
%pragma(java) jniclasscode=%{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("_sourcetraildb");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. \n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
@@ -57,8 +57,6 @@ namespace
|
||||
return sourcetrail::SymbolKind::ENUM_CONSTANT;
|
||||
case SYMBOL_TYPEDEF:
|
||||
return sourcetrail::SymbolKind::TYPEDEF;
|
||||
case SYMBOL_TEMPLATE_PARAMETER:
|
||||
return sourcetrail::SymbolKind::TEMPLATE_PARAMETER;
|
||||
case SYMBOL_TYPE_PARAMETER:
|
||||
return sourcetrail::SymbolKind::TYPE_PARAMETER;
|
||||
case SYMBOL_MACRO:
|
||||
@@ -83,16 +81,10 @@ namespace
|
||||
return sourcetrail::ReferenceKind::INHERITANCE;
|
||||
case REFERENCE_OVERRIDE:
|
||||
return sourcetrail::ReferenceKind::OVERRIDE;
|
||||
case REFERENCE_TEMPLATE_ARGUMENT:
|
||||
return sourcetrail::ReferenceKind::TEMPLATE_ARGUMENT;
|
||||
case REFERENCE_TYPE_ARGUMENT:
|
||||
return sourcetrail::ReferenceKind::TYPE_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return sourcetrail::ReferenceKind::TEMPLATE_DEFAULT_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_SPECIALIZATION:
|
||||
return sourcetrail::ReferenceKind::TEMPLATE_SPECIALIZATION;
|
||||
case REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION:
|
||||
return sourcetrail::ReferenceKind::TEMPLATE_MEMBER_SPECIALIZATION;
|
||||
case REFERENCE_INCLUDE:
|
||||
return sourcetrail::ReferenceKind::INCLUDE;
|
||||
case REFERENCE_IMPORT:
|
||||
@@ -225,6 +217,16 @@ bool recordReferenceLocation(int referenceId, int fileId, int startLine, int sta
|
||||
return dbWriter.recordReferenceLocation(referenceId, { fileId, startLine, startColumn, endLine, endColumn });
|
||||
}
|
||||
|
||||
bool recordReferenceIsAmbiguous(int referenceId)
|
||||
{
|
||||
return dbWriter.recordReferenceIsAmbiguous(referenceId);
|
||||
}
|
||||
|
||||
int recordReferenceToUnsolvedSymhol(int contextSymbolId, ReferenceKind referenceKind, int fileId, int startLine, int startColumn, int endLine, int endColumn)
|
||||
{
|
||||
return dbWriter.recordReferenceToUnsolvedSymhol(contextSymbolId, convertReferenceKind(referenceKind), { fileId, startLine, startColumn, endLine, endColumn });
|
||||
}
|
||||
|
||||
bool recordQualifierLocation(int referencedSymbolId, int fileId, int startLine, int startColumn, int endLine, int endColumn)
|
||||
{
|
||||
return dbWriter.recordQualifierLocation(referencedSymbolId, { fileId, startLine, startColumn, endLine, endColumn });
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
v4.db25.p0
|
||||
@@ -1 +0,0 @@
|
||||
@VERSION_STRING_UNDERSCORE@
|
||||
Reference in New Issue
Block a user