Compare commits
102
Commits
v2.db23.p1
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28813de072 | ||
|
|
93d28e93c2 | ||
|
|
939e078310 | ||
|
|
160af94df9 | ||
|
|
c6c3ce1aee | ||
|
|
fee3a9e9a5 | ||
|
|
4bf4b3b325 | ||
|
|
929669bc03 | ||
|
|
5845070707 | ||
|
|
bf4efefda3 | ||
|
|
e4c723462a | ||
|
|
9fc3382dff | ||
|
|
7fa90c75ec | ||
|
|
06e5347a79 | ||
|
|
aa5faac683 | ||
|
|
278c746b9e | ||
|
|
bf8ad0fc89 | ||
|
|
84dbbae243 | ||
|
|
07735d913b | ||
|
|
f08d448ac7 | ||
|
|
de6544b63b | ||
|
|
9b6e52b1e9 | ||
|
|
aa279dcf7d | ||
|
|
d2adf3e7b7 | ||
|
|
26e13ef053 | ||
|
|
1698eeef1c | ||
|
|
8b588fd6ab | ||
|
|
12c908c95c | ||
|
|
58497e8d04 | ||
|
|
2afb1a81bb | ||
|
|
69c0614a9d | ||
|
|
e2a127b8c0 | ||
|
|
6c20563188 | ||
|
|
9395051095 | ||
|
|
fb2daf3d30 | ||
|
|
ac212e70bf | ||
|
|
2a718377a5 | ||
|
|
eba449fea5 | ||
|
|
9bd4ae7724 | ||
|
|
9815bdd7df | ||
|
|
57c465c67a | ||
|
|
89b656bbca | ||
|
|
044535965c | ||
|
|
844ef8838c | ||
|
|
620f3d3633 | ||
|
|
25a0d82f9a | ||
|
|
6e291ea6dc | ||
|
|
3df948af32 | ||
|
|
a2b1f79fec | ||
|
|
08d04278cd | ||
|
|
32f7c21302 | ||
|
|
0251b6d8a7 | ||
|
|
c87af4a3b1 | ||
|
|
a09bfdce93 | ||
|
|
53d8d0c3fa | ||
|
|
62228e8fb9 | ||
|
|
0ef465c52e | ||
|
|
824e51ded7 | ||
|
|
e3e61dbd7c | ||
|
|
ee7ec51187 | ||
|
|
73ef1190c3 | ||
|
|
fb9115189a | ||
|
|
1e464ac338 | ||
|
|
5b4f4e521e | ||
|
|
9f7e77aa2b | ||
|
|
9cfb354c58 | ||
|
|
01d16568c2 | ||
|
|
af2638fec5 | ||
|
|
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 | ||
|
|
2dad29877f |
-153
@@ -1,153 +0,0 @@
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- 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=0
|
||||
|
||||
- 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.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: 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
|
||||
env:
|
||||
- PYTHON_BINDING=0
|
||||
|
||||
# - os: osx
|
||||
# compiler: clang
|
||||
# env:
|
||||
# - PYTHON_BINDING=1 PYTHON=3.5
|
||||
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env:
|
||||
- PYTHON_BINDING=1 PYTHON=3.6
|
||||
|
||||
# - os: osx
|
||||
# compiler: clang
|
||||
# env:
|
||||
# - PYTHON_BINDING=1 PYTHON=3.7
|
||||
|
||||
before_install:
|
||||
- |
|
||||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
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
|
||||
|
||||
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 [[ "$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
|
||||
fi
|
||||
|
||||
install:
|
||||
- if [[ "${CXX_COMPILER}" != "" ]]; then export CXX=${CXX_COMPILER}; export CXX_FOR_BUILD=${CXX_COMPILER}; fi
|
||||
- if [[ "${CC_COMPILER}" != "" ]]; then export CC=${CC_COMPILER}; export CC_FOR_BUILD=${CC_COMPILER}; fi
|
||||
|
||||
script:
|
||||
- |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_BINDINGS_PYTHON=$PYTHON_BINDING -DPYTHON_VERSION=$PYTHON ..
|
||||
make
|
||||
./core/test_core
|
||||
|
||||
before_deploy:
|
||||
- |
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
|
||||
VERSION=$(head -1 build/version.txt)
|
||||
|
||||
if [[ "$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
|
||||
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
|
||||
cp LICENSE.txt $BUNDLE_NAME/license/license_sourcetraildb.txt
|
||||
cp external/catch/license_catch.txt $BUNDLE_NAME/license/
|
||||
cp external/cpp_sqlite/license_cpp_sqlite.txt $BUNDLE_NAME/license/
|
||||
cp external/json/license_json.txt $BUNDLE_NAME/license/
|
||||
|
||||
zip -r $BUNDLE_NAME $BUNDLE_NAME
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: UwuiE6SrjorpBr1CzTRadX1zq83hwbnur+MvzBueqEHM7Yyu5Y0xMkwchRlX41HzMuSkC0azM0S8GfqJT1E7pIrqgJGvFbXR3t9ZG8HtvrcM4PvTS8b0G0d8aWHfTP2Zv+PAK3MMnYtxmOFPs4IaqO1m+imjQWtpvCRG5tvc4DNIPAMh0S8LCjxUdz35BYAM4pwM7WB9Qt+YhbyP1h3oSQ7qtr1fZYCC0H4G1cjVBLeP9g66/tfg0MIQVf1wxU8KF3H6esilPhFDCnsBYcnYrKyJN9OkMXZvLoxsjqQvTlsSNO2wIQ32dW8fk+1VFebWjN3RnNUV2Zb3wdz2y6e6A08J8T/+QrJ003eUJAGassQEgsuQ85ldcbylbKCVdi+iA+W6pKSJoHIlyr2KQG77OZ+q3obvY09IMNX2qVnUJKG8g9vZHKk8TlvUtIDODUxqJ/XUVwG5aKiUPuE5UMeLnZlO7cWpABb28BjXGehLCDtqg2eu39n+N9hyEjmsJLcOuS03+C55YrjJHW09qZomorMyIa//4jxSAOU9Iah7cRzPGUl/eSwQ2kf0OGWfySd2PreOThWepH0ymvG9htlTUSMM4wRuKnNAmG7NY6TykttJY2KsTLpki+P4MFBlSvL0VvoHQintK69udSVeUrJaGx508w8V59AdZwJjMxhjOXw=
|
||||
file_glob: true
|
||||
file: $TRAVIS_BUILD_DIR/*.zip
|
||||
overwrite: true
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
repo: CoatiSoftware/SourcetrailDB
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
Main Authors
|
||||
============
|
||||
|
||||
Malte Langkabel (@mlangkabel) <mlangkabel@coati.io>
|
||||
|
||||
Code Contributors
|
||||
=================
|
||||
|
||||
Andrew Pam (@xanni) <andrew@sericyb.com.au>
|
||||
Jørgen Lund (@strangebroadcasts) <jlund@strangebroadcasts.com>
|
||||
|
||||
Note: (@user) means a github user name.
|
||||
@@ -1,5 +1,59 @@
|
||||
# Changelog
|
||||
|
||||
## v4.db25.p1
|
||||
|
||||
**2021-03-08**
|
||||
|
||||
* Added C# bindings for API
|
||||
* Fixed typo in package names of Windows build artifacts
|
||||
* Changed implementation of getFileContent() to match Sourcetrail code
|
||||
|
||||
|
||||
## 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**
|
||||
|
||||
+50
-27
@@ -2,7 +2,10 @@ 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_BINDINGS_CSHARP OFF CACHE BOOL "Build the SourcetrailDB C# bindings.")
|
||||
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
|
||||
|
||||
set(PROJECT_NAME "SourcetrailDB")
|
||||
@@ -22,28 +25,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 +37,63 @@ 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()
|
||||
|
||||
# --- C# Binding ---
|
||||
if (BUILD_BINDINGS_CSHARP)
|
||||
message(STATUS "The SourcetrailDB C# bindings will be built.")
|
||||
|
||||
set(CSHARP_BINDING_TARGET_NAME "bindings_csharp")
|
||||
set(CSHARP_BINDING_OUTPUT_DIR "")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_csharp" "${CMAKE_BINARY_DIR}/bindings_csharp")
|
||||
else()
|
||||
message(STATUS "Building the SourcetrailDB C# bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_CSHARP' to 'ON'.")
|
||||
endif()
|
||||
|
||||
# --- Examples ---
|
||||
|
||||
@@ -90,6 +107,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,12 +1,11 @@
|
||||
# SourcetrailDB
|
||||
|
||||
Library to export [Sourcetrail](https://www.sourcetrail.com/) compatible database files for writing custom indexers
|
||||
|
||||
|
||||
## CI Pipelines
|
||||
|
||||
Windows: [](https://ci.appveyor.com/project/mlangkabel/sourcetraildb/branch/master)
|
||||
|
||||
Linux and macOS: [](https://travis-ci.org/CoatiSoftware/SourcetrailDB)
|
||||
[](https://ci.appveyor.com/project/mlangkabel/sourcetraildb/branch/master)
|
||||
|
||||
|
||||
## Introduction
|
||||
@@ -17,19 +16,33 @@ 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 in a stable state and it has a direct Sourcetrail integration via the Python Source Group.
|
||||
* [SourcetrailDotnetIndexer](https://github.com/packdat/SourcetrailDotnetIndexer) is a Sourcetrail language extension that allows to index all kinds of .NET assemblies, regardless of the language they are created from (e.g. C#, VB.NET, ...). Because it does not (need to) know the source code, it does not provide any code snippets for the indexed assemblies, but it already works well at generating graphs.
|
||||
* [SourcetrailPerlIndexer](https://github.com/xanni/SourcetrailPerlIndexer) is a Sourcetrail language extension that brings Perl support to Sourcetrail. This project is still in a prototype state, but you can already run it on your Perl code via the Custom Source Group.
|
||||
* [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*).
|
||||
* [SourcetrailGolangIndexer](https://github.com/TOMATOFAQ/SourcetrailGolangIndexer) is a Golang Indexer for Sourcetrail (*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/))
|
||||
* C# (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.
|
||||
|
||||
|
||||
## Versioning
|
||||
|
||||
The SourcetrailDB version format consists of three numbers in the format `vXX.dbYY.pZZ`.
|
||||
@@ -40,6 +53,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 +96,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 +132,38 @@ $ 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.
|
||||
|
||||
### C# Bindings
|
||||
|
||||
Requirements:
|
||||
* [SWIG 3.0.12](http://www.swig.org/) is used to automatically generate C# binding code. Make sure that SWIG is added to your path environment variable.
|
||||
|
||||
If you want to build the C# bindings run:
|
||||
```
|
||||
$ cd path/to/SourcetrailDB
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake -DBUILD_BINDINGS_CSHARP=ON ..
|
||||
$ make
|
||||
```
|
||||
|
||||
### 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 +171,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 +315,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");
|
||||
|
||||
+152
-129
@@ -1,59 +1,44 @@
|
||||
version: 0.0.0.{build}
|
||||
image: Visual Studio 2017
|
||||
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Ubuntu
|
||||
- macos
|
||||
|
||||
|
||||
environment:
|
||||
PYTHON_BINDINGS: 1
|
||||
JAVA_BINDINGS: 1
|
||||
PERL_BINDINGS: 1
|
||||
|
||||
|
||||
platform: x64
|
||||
|
||||
|
||||
configuration: Release
|
||||
|
||||
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
- MBITS: 32
|
||||
PYTHON_VERSION: 37
|
||||
MSVC_VERSION: 15
|
||||
DEPLOY_CORE: 1
|
||||
DEPLOY_PYTHON_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
|
||||
|
||||
- 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:
|
||||
only:
|
||||
- image: Visual Studio 2017
|
||||
install:
|
||||
- cmd: |
|
||||
echo Building on Windows!
|
||||
echo Python: %PYTHON_BINDINGS%
|
||||
echo Java: %JAVA_BINDINGS%
|
||||
echo Perl: %PERL_BINDINGS%
|
||||
- ps: |
|
||||
if ($env:MBITS -eq "32") {
|
||||
$env:PYTHON_VERSION=37
|
||||
$env:MSVC_VERSION=15
|
||||
- ps: |
|
||||
if ($env:PLATFORM -eq "x86") {
|
||||
echo "Architecture set to 32 bit."
|
||||
$env:CMAKE_GENERATOR="Visual Studio $env:MSVC_VERSION"
|
||||
$env:PYTHON_PATH="C:/Python$env:PYTHON_VERSION"
|
||||
} elseif ($env:MBITS -eq "64") {
|
||||
} elseif ($env:PLATFORM -eq "x64") {
|
||||
echo "Architecture set to 64 bit."
|
||||
$env:CMAKE_GENERATOR="Visual Studio $env:MSVC_VERSION Win64"
|
||||
$env:PYTHON_PATH="C:/Python$env:PYTHON_VERSION-x64"
|
||||
@@ -61,91 +46,129 @@ install:
|
||||
echo "No architecture set. Build will be canceled."
|
||||
}
|
||||
# Install SWIG by Choco
|
||||
choco install -y --no-progress swig
|
||||
|
||||
|
||||
before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -G "%CMAKE_GENERATOR%" ../ -DBUILD_BINDINGS_PYTHON=ON -DPYTHON_LIBRARY="%PYTHON_PATH%/libs/python%PYTHON_VERSION%.lib"
|
||||
- cd ../
|
||||
- ps: $env:CORE_VERSION = Get-Content -Path ./build/version.txt
|
||||
- ps: echo "Core version is $env:CORE_VERSION"
|
||||
# TODO: convert the core version into dotted format and update appveyor version here
|
||||
choco install -y --no-progress swig --version 4.0.1
|
||||
choco install -y --no-progress openjdk
|
||||
# Install Strawberry Perl and put before any other Perls in %PATH%
|
||||
if ($env:PLATFORM -eq "x86") {
|
||||
choco install -y --no-progress --forcex86 strawberryperl
|
||||
} elseif ($env:PLATFORM -eq "x64") {
|
||||
choco install -y --no-progress strawberryperl
|
||||
} else {
|
||||
echo "No architecture set. Build will be canceled."
|
||||
}
|
||||
$env:PATH="C:\strawberry\perl\bin;C:\strawberry\perl\site\bin;C:\strawberry\c\bin;$env:PATH"
|
||||
$env:PERL_VERSION=$(perl -e 'print $^V')
|
||||
before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- 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% -DBUILD_BINDINGS_CSHARP=%DEPLOY_CSHARP_BINDINGS%
|
||||
- cd ../
|
||||
- ps: |
|
||||
if ($Env:PERL_BINDINGS -eq "1") {
|
||||
mkdir build-perl
|
||||
cd build-perl
|
||||
# Need to use Unix Makefiles because Strawberry Perl is a MinGW environment
|
||||
cmake -G "Unix Makefiles" ../ -DBUILD_BINDINGS_PERL=$Env:PERL_BINDINGS
|
||||
if ($LastExitCode -ne 0) { throw "Perl bindings: cmake failed with exit code $LastExitCode" }
|
||||
cd ../
|
||||
}
|
||||
- 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: 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
|
||||
build_script:
|
||||
- cd build
|
||||
- msbuild /p:configuration=Release /v:m ALL_BUILD.vcxproj
|
||||
- cd ../
|
||||
- ps: |
|
||||
if ($Env:PERL_BINDINGS -eq "1") {
|
||||
cd build-perl
|
||||
gmake
|
||||
if ($LastExitCode -ne 0) { throw "Perl bindings: gmake failed with exit code $LastExitCode" }
|
||||
cd ../
|
||||
}
|
||||
test_script:
|
||||
- "build\\core\\release\\test_core.exe"
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: Ubuntu
|
||||
install:
|
||||
- sh: |
|
||||
echo Building on Ubuntu!
|
||||
echo Python: $PYTHON_BINDINGS
|
||||
echo Java: $JAVA_BINDINGS
|
||||
echo Perl: $PERL_BINDINGS
|
||||
- sh: |
|
||||
sudo add-apt-repository ppa:deadsnakes/ppa
|
||||
sudo apt-get update
|
||||
sudo apt-get install -qq swig
|
||||
if [[ "$PYTHON_BINDINGS" == "1" ]]; then
|
||||
sudo apt-get -y install python3.5
|
||||
sudo apt-get -y install python3.5-dev
|
||||
alias python="/usr/bin/python3.5"
|
||||
python --version
|
||||
fi
|
||||
if [[ "$JAVA_BINDINGS" == "1" ]]; then
|
||||
#installing Java not required, as image already comes with Java 9
|
||||
#sudo apt-get install openjdk-8-jdk
|
||||
javac -version
|
||||
fi
|
||||
if [[ "$PERL_BINDINGS" == "1" ]]; then
|
||||
#installing Perl not required, as image already comes with Perl 5
|
||||
#sudo apt-get install perl
|
||||
#alias perl="/usr/bin/perl"
|
||||
perl --version
|
||||
fi
|
||||
build_script:
|
||||
- sh: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_BINDINGS_PERL=$PERL_BINDINGS -DBUILD_BINDINGS_PYTHON=$PYTHON_BINDINGS -DPYTHON_VERSION=3.5 -DBUILD_BINDINGS_JAVA=$JAVA_BINDINGS ..
|
||||
make
|
||||
test_script:
|
||||
- sh: |
|
||||
./core/test_core
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- image: macos
|
||||
install:
|
||||
- sh: |
|
||||
echo Building the Java bindings is currently disabled in CI because JNI cannot be found by CMake
|
||||
JAVA_BINDINGS=0
|
||||
- sh: |
|
||||
echo Building on Mac OS!
|
||||
echo Python: $PYTHON_BINDINGS
|
||||
echo Java: $JAVA_BINDINGS
|
||||
echo Perl: $PERL_BINDINGS
|
||||
- sh: |
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install swig
|
||||
brew link --force swig
|
||||
if [[ "$JAVA_BINDINGS" == "1" ]]; then
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install openjdk
|
||||
fi
|
||||
if [[ "$PERL_BINDINGS" == "1" ]]; then
|
||||
# installing Perl not required, as image already comes with Perl 5
|
||||
#HOMEBREW_NO_AUTO_UPDATE=1 brew install perl
|
||||
perl --version
|
||||
fi
|
||||
|
||||
build_script:
|
||||
- sh: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_BINDINGS_PERL=$PERL_BINDINGS -DBUILD_BINDINGS_PYTHON=$PYTHON_BINDINGS -DPYTHON_VERSION=3.6 -DBUILD_BINDINGS_JAVA=$JAVA_BINDINGS ..
|
||||
make
|
||||
test_script:
|
||||
- sh: |
|
||||
./core/test_core
|
||||
|
||||
|
||||
build_script:
|
||||
- cd build
|
||||
- msbuild /p:configuration=Release /v:m ALL_BUILD.vcxproj
|
||||
- cd ../
|
||||
|
||||
|
||||
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: 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: |
|
||||
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 = ""
|
||||
if ($env:DEPLOY_CORE -eq "1") {
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY + "," + $env:CORE_PACKAGE_NAME
|
||||
}
|
||||
if ($env:DEPLOY_PYTHON_BINDINGS -eq "1") {
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY + "," + $env:PYTHON_PACKAGE_NAME
|
||||
}
|
||||
$env:ARTIFACTY_TO_DEPLOY = $env:ARTIFACTY_TO_DEPLOY.substring(1)
|
||||
echo $env:ARTIFACTY_TO_DEPLOY
|
||||
|
||||
|
||||
test_script:
|
||||
- "build\\core\\release\\test_core.exe"
|
||||
|
||||
|
||||
artifacts:
|
||||
- path: artifacts_core
|
||||
name: $(CORE_PACKAGE_NAME)
|
||||
type: Zip
|
||||
- path: artifacts_bindings_python
|
||||
name: $(PYTHON_PACKAGE_NAME)
|
||||
type: Zip
|
||||
|
||||
|
||||
deploy:
|
||||
provider: GitHub
|
||||
artifact: $(ARTIFACTY_TO_DEPLOY)
|
||||
auth_token:
|
||||
secure: 8UwbjFrtR19GxLgL3O3efUT0Su2mp3+X23YioThJITupEvexmQJPAf3Whmmb3eeL
|
||||
on:
|
||||
appveyor_repo_tag: true
|
||||
- echo ERROR - Empty default script was executed!
|
||||
- exit 1
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
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(CSHARP_BINDING_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
||||
|
||||
set(SWIG_INTERFACE_FILE "${RESOURCES_SWIG_DIR}/interface/sourcetraildb.i")
|
||||
set(CSHARP_BINDINGS_NAMESPACE "CoatiSoftware.SourcetrailDB")
|
||||
set(CSHARP_BINDING_TARGET_OUTPUT_NAME "SourcetrailDB")
|
||||
|
||||
# --- Find Swig ---
|
||||
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
# --- Configure Target ---
|
||||
|
||||
set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
set_property(SOURCE ${SWIG_INTERFACE_FILE} PROPERTY COMPILE_OPTIONS -namespace ${CSHARP_BINDINGS_NAMESPACE} -dllimport ${CSHARP_BINDING_TARGET_OUTPUT_NAME})
|
||||
|
||||
include_directories(
|
||||
"${RESOURCES_SWIG_DIR}/include"
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
)
|
||||
|
||||
swig_add_library(
|
||||
${CSHARP_BINDING_TARGET_NAME}
|
||||
TYPE SHARED
|
||||
LANGUAGE csharp
|
||||
OUTPUT_DIR ${CSHARP_BINDING_OUTPUT_DIR}
|
||||
OUTFILE_DIR ${GENERATED_SRC_DIR}
|
||||
SOURCES ${SWIG_INTERFACE_FILE} ${RESOURCES_SWIG_DIR}/src/sourcetraildb.cpp
|
||||
)
|
||||
|
||||
set_target_properties(${CSHARP_BINDING_TARGET_NAME}
|
||||
PROPERTIES OUTPUT_NAME ${CSHARP_BINDING_TARGET_OUTPUT_NAME}
|
||||
SWIG_FLAGS ${CSHARP_BINDINGS_NAMESPACE})
|
||||
|
||||
swig_link_libraries(${CSHARP_BINDING_TARGET_NAME} ${CSHARP_LIBRARIES} ${LIB_CORE_TARGET_NAME})
|
||||
|
||||
configure_file("CoatiSoftware.SourcetrailDB.csproj" "CoatiSoftware.SourcetrailDB.csproj" COPYONLY)
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Content Include="$(ProjectDir)/SourcetrailDB.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Link>SourcetrailDB.dll</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||
<Content Include="$(ProjectDir)/SourcetrailDB.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Link>SourcetrailDB.so</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))'">
|
||||
<Content Include="$(ProjectDir)/SourcetrailDB.dylib">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Link>SourcetrailDB.dylib</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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 ---
|
||||
@@ -21,6 +19,7 @@ find_package(PythonLibs ${PYTHON_VERSION} REQUIRED)
|
||||
find_package(SWIG REQUIRED)
|
||||
include(${SWIG_USE_FILE})
|
||||
|
||||
message("pppp: ${PYTHON_INCLUDE_DIRS}")
|
||||
|
||||
# --- Configure Target ---
|
||||
|
||||
@@ -28,17 +27,20 @@ set_source_files_properties(${SWIG_INTERFACE_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
|
||||
include_directories(
|
||||
"${RESOURCES_SWIG_DIR}/include"
|
||||
"${CORE_SOURCE_DIR}/include"
|
||||
"../core/include"
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
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})
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakInheritanceList: BeforeComma
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 140
|
||||
CompactNamespaces: true
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
PenaltyBreakAssignment: 50
|
||||
PenaltyBreakBeforeFirstCallParameter: 0
|
||||
PenaltyBreakComment: 100
|
||||
PenaltyBreakFirstLessLess: 200
|
||||
PenaltyBreakString: 100
|
||||
PenaltyBreakTemplateDeclaration: 0
|
||||
PenaltyExcessCharacter: 10
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: false
|
||||
SpaceBeforeInheritanceColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 4
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: c++17
|
||||
TabWidth: 4
|
||||
UseTab: Always
|
||||
---
|
||||
Language: Cpp
|
||||
---
|
||||
Language: Java
|
||||
#BasedOnStyle: Google
|
||||
#BreakAfterJavaFieldAnnotations: true
|
||||
+35
-19
@@ -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")
|
||||
@@ -10,12 +10,25 @@ configure_file(
|
||||
${GENERATED_VERSION_FILE}
|
||||
)
|
||||
|
||||
set(EXTERNAL_FILES
|
||||
../external/cpp_sqlite/src/CppSQLite3.cpp
|
||||
../external/json/include/json.hpp
|
||||
../external/cpp_sqlite/include/CppSQLite3.h
|
||||
)
|
||||
|
||||
set(EXTERNAL_C_FILES
|
||||
../external/cpp_sqlite/src/sqlite3.c
|
||||
../external/cpp_sqlite/include/sqlite3.h
|
||||
)
|
||||
|
||||
set_source_files_properties(${EXTERNAL_FILES} PROPERTIES COMPILE_FLAGS "-w")
|
||||
set_source_files_properties(${EXTERNAL_C_FILES} PROPERTIES COMPILE_FLAGS "-std=gnu89 -w")
|
||||
|
||||
set(LIB_SRC_FILES
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/src/CppSQLite3.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/src/sqlite3.c"
|
||||
src/DatabaseStorage.cpp
|
||||
src/DefinitionKind.cpp
|
||||
src/EdgeKind.cpp
|
||||
src/ElementComponentKind.cpp
|
||||
src/LocationKind.cpp
|
||||
src/NameHierarchy.cpp
|
||||
src/NodeKind.cpp
|
||||
@@ -26,12 +39,10 @@ set(LIB_SRC_FILES
|
||||
)
|
||||
|
||||
set(LIB_HDR_FILES
|
||||
"${CMAKE_SOURCE_DIR}/external/json/include/json.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include/CppSQLite3.h"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include/sqlite3.h"
|
||||
include/DatabaseStorage.h
|
||||
include/DefinitionKind.h
|
||||
include/EdgeKind.h
|
||||
include/ElementComponentKind.h
|
||||
include/LocationKind.h
|
||||
include/NameHierarchy.h
|
||||
include/NodeKind.h
|
||||
@@ -40,6 +51,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,30 +64,34 @@ 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} ${EXTERNAL_FILES} ${EXTERNAL_C_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
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/json/include"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include"
|
||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||
set_property(
|
||||
TARGET ${LIB_CORE_TARGET_NAME}
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_CORE_TARGET_NAME} SYSTEM
|
||||
PUBLIC ../external/json/include
|
||||
PUBLIC ../external/cpp_sqlite/include
|
||||
)
|
||||
|
||||
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"
|
||||
"${CMAKE_SOURCE_DIR}/external/cpp_sqlite/include"
|
||||
../external/catch/include
|
||||
../external/json/include
|
||||
../external/cpp_sqlite/include
|
||||
"${GENERATED_INCLUDE_DIRECTORY}"
|
||||
)
|
||||
|
||||
target_link_libraries(${TEST_CORE} ${LIB_CORE} "-ldl")
|
||||
target_link_libraries(${TEST_CORE_TARGET_NAME} ${LIB_CORE_TARGET_NAME} ${CMAKE_DL_LIBS})
|
||||
|
||||
+115
-112
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_DATABASE_STORAGE_H
|
||||
#define SOURCETRAIL_DATABASE_STORAGE_H
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "CppSQLite3.h"
|
||||
|
||||
#include "StorageEdge.h"
|
||||
#include "StorageElementComponent.h"
|
||||
#include "StorageError.h"
|
||||
#include "StorageFile.h"
|
||||
#include "StorageLocalSymbol.h"
|
||||
@@ -34,110 +35,112 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Class wrapping the write and update interface of the Sourcetrail database.
|
||||
*
|
||||
* The DatabaseStorage provides the interface for writing and updating the Sourcetrail database. This interface only
|
||||
* knows about basic data types, more elaborate types like enums, structs and classes need to be converted to basic
|
||||
* types before using this interface.
|
||||
*/
|
||||
class DatabaseStorage
|
||||
/**
|
||||
* Class wrapping the write and update interface of the Sourcetrail database.
|
||||
*
|
||||
* The DatabaseStorage provides the interface for writing and updating the Sourcetrail database. This interface only
|
||||
* knows about basic data types, more elaborate types like enums, structs and classes need to be converted to basic
|
||||
* types before using this interface.
|
||||
*/
|
||||
class DatabaseStorage
|
||||
{
|
||||
public:
|
||||
static int getSupportedDatabaseVersion();
|
||||
static std::unique_ptr<DatabaseStorage> openDatabase(const std::string& dbFilePath);
|
||||
~DatabaseStorage();
|
||||
|
||||
void setupDatabase();
|
||||
void clearDatabase();
|
||||
|
||||
void setProjectSettingsText(const std::string& text);
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isCompatible() const;
|
||||
int getLoadedDatabaseVersion() const;
|
||||
void beginTransaction();
|
||||
void commitTransaction();
|
||||
void rollbackTransaction();
|
||||
void optimizeDatabaseMemory();
|
||||
|
||||
int addElementComponent(const StorageElementComponentData& storageElementComponentData);
|
||||
int addNode(const StorageNodeData& storageNodeData);
|
||||
void addSymbol(const StorageSymbol& storageSymbol);
|
||||
void addFile(const StorageFile& storageFile);
|
||||
int addEdge(const StorageEdgeData& storageEdgeData);
|
||||
int addLocalSymbol(const StorageLocalSymbolData& storageLocalSymbolData);
|
||||
int addSourceLocation(const StorageSourceLocationData& storageSourceLocationData);
|
||||
void addOccurrence(const StorageOccurrence& storageOccurrence);
|
||||
int addError(const StorageErrorData& storageErrorData);
|
||||
|
||||
void setNodeType(int nodeId, int nodeKind);
|
||||
void setFileLanguage(int fileId, const std::string& languageIdentifier);
|
||||
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> getAll() const
|
||||
{
|
||||
public:
|
||||
static int getSupportedDatabaseVersion();
|
||||
static std::unique_ptr<DatabaseStorage> openDatabase(const std::string& dbFilePath);
|
||||
~DatabaseStorage();
|
||||
return doGetAll<ResultType>("");
|
||||
}
|
||||
|
||||
void setupDatabase();
|
||||
void clearDatabase();
|
||||
private:
|
||||
DatabaseStorage() = default;
|
||||
|
||||
void setProjectSettingsText(const std::string& text);
|
||||
void setupTables();
|
||||
void clearTables();
|
||||
void setupIndices();
|
||||
void setupPrecompiledStatements();
|
||||
void clearPrecompiledStatements();
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isCompatible() const;
|
||||
int getLoadedDatabaseVersion() const;
|
||||
void beginTransaction();
|
||||
void commitTransaction();
|
||||
void rollbackTransaction();
|
||||
void optimizeDatabaseMemory();
|
||||
int insertElement();
|
||||
void insertOrUpdateMetaValue(const std::string& key, const std::string& value);
|
||||
CppSQLite3Statement compileStatement(const std::string& statement) const;
|
||||
void executeStatement(const std::string& statement) const;
|
||||
void executeStatement(CppSQLite3Statement& statement) const;
|
||||
CppSQLite3Query executeQuery(const std::string& query) const;
|
||||
CppSQLite3Query executeQuery(CppSQLite3Statement& statement) const;
|
||||
|
||||
int addNode(const StorageNodeData& storageNodeData);
|
||||
void addSymbol(const StorageSymbol& storageSymbol);
|
||||
void addFile(const StorageFile& storageFile);
|
||||
int addEdge(const StorageEdgeData& storageEdgeData);
|
||||
int addLocalSymbol(const StorageLocalSymbolData& storageLocalSymbolData);
|
||||
int addSourceLocation(const StorageSourceLocationData& storageSourceLocationData);
|
||||
void addOccurrence(const StorageOccurrence& storageOccurrence);
|
||||
int addError(const StorageErrorData& storageErrorData);
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> doGetAll(const std::string& query) const;
|
||||
|
||||
void setNodeType(int nodeId, int nodeKind);
|
||||
void setFileLanguage(int fileId, const std::string& languageIdentifier);
|
||||
mutable CppSQLite3DB m_database;
|
||||
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> getAll() const
|
||||
{
|
||||
return doGetAll<ResultType>("");
|
||||
}
|
||||
CppSQLite3Statement m_insertElementStatement;
|
||||
CppSQLite3Statement m_insertElementComponentStatement;
|
||||
CppSQLite3Statement m_findNodeStatement;
|
||||
CppSQLite3Statement m_insertNodeStatement;
|
||||
CppSQLite3Statement m_setNodeTypeStmt;
|
||||
CppSQLite3Statement m_insertSymbolStatement;
|
||||
CppSQLite3Statement m_findFileStatement;
|
||||
CppSQLite3Statement m_insertFileStatement;
|
||||
CppSQLite3Statement m_setFileLanguageStmt;
|
||||
CppSQLite3Statement m_insertFileContentStatement;
|
||||
CppSQLite3Statement m_findEdgeStatement;
|
||||
CppSQLite3Statement m_insertEdgeStatement;
|
||||
CppSQLite3Statement m_findLocalSymbolStmt;
|
||||
CppSQLite3Statement m_insertLocalSymbolStmt;
|
||||
CppSQLite3Statement m_findSourceLocationStmt;
|
||||
CppSQLite3Statement m_insertSourceLocationStmt;
|
||||
CppSQLite3Statement m_insertOccurenceStmt;
|
||||
CppSQLite3Statement m_findErrorStatement;
|
||||
CppSQLite3Statement m_insertErrorStatement;
|
||||
CppSQLite3Statement m_insertOrUpdateMetaValueStmt;
|
||||
};
|
||||
|
||||
private:
|
||||
DatabaseStorage() = default;
|
||||
template <>
|
||||
std::vector<StorageEdge> DatabaseStorage::doGetAll<StorageEdge>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageNode> DatabaseStorage::doGetAll<StorageNode>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSymbol> DatabaseStorage::doGetAll<StorageSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageFile> DatabaseStorage::doGetAll<StorageFile>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageLocalSymbol> DatabaseStorage::doGetAll<StorageLocalSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSourceLocation> DatabaseStorage::doGetAll<StorageSourceLocation>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageOccurrence> DatabaseStorage::doGetAll<StorageOccurrence>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageError> DatabaseStorage::doGetAll<StorageError>(const std::string& query) const;
|
||||
} // namespace sourcetrail
|
||||
|
||||
void setupTables();
|
||||
void clearTables();
|
||||
void setupIndices();
|
||||
void setupPrecompiledStatements();
|
||||
void clearPrecompiledStatements();
|
||||
|
||||
int insertElement();
|
||||
void insertOrUpdateMetaValue(const std::string& key, const std::string& value);
|
||||
CppSQLite3Statement compileStatement(const std::string& statement) const;
|
||||
void executeStatement(const std::string& statement) const;
|
||||
void executeStatement(CppSQLite3Statement& statement) const;
|
||||
CppSQLite3Query executeQuery(const std::string& query) const;
|
||||
CppSQLite3Query executeQuery(CppSQLite3Statement& statement) const;
|
||||
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> doGetAll(const std::string& query) const;
|
||||
|
||||
mutable CppSQLite3DB m_database;
|
||||
|
||||
CppSQLite3Statement m_insertElementStatement;
|
||||
CppSQLite3Statement m_findNodeStatement;
|
||||
CppSQLite3Statement m_insertNodeStatement;
|
||||
CppSQLite3Statement m_setNodeTypeStmt;
|
||||
CppSQLite3Statement m_insertSymbolStatement;
|
||||
CppSQLite3Statement m_findFileStatement;
|
||||
CppSQLite3Statement m_insertFileStatement;
|
||||
CppSQLite3Statement m_setFileLanguageStmt;
|
||||
CppSQLite3Statement m_insertFileContentStatement;
|
||||
CppSQLite3Statement m_findEdgeStatement;
|
||||
CppSQLite3Statement m_insertEdgeStatement;
|
||||
CppSQLite3Statement m_findLocalSymbolStmt;
|
||||
CppSQLite3Statement m_insertLocalSymbolStmt;
|
||||
CppSQLite3Statement m_findSourceLocationStmt;
|
||||
CppSQLite3Statement m_insertSourceLocationStmt;
|
||||
CppSQLite3Statement m_insertOccurenceStmt;
|
||||
CppSQLite3Statement m_findErrorStatement;
|
||||
CppSQLite3Statement m_insertErrorStatement;
|
||||
CppSQLite3Statement m_insertOrUpdateMetaValueStmt;
|
||||
};
|
||||
|
||||
template <>
|
||||
std::vector<StorageEdge> DatabaseStorage::doGetAll<StorageEdge>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageNode> DatabaseStorage::doGetAll<StorageNode>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSymbol> DatabaseStorage::doGetAll<StorageSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageFile> DatabaseStorage::doGetAll<StorageFile>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageLocalSymbol> DatabaseStorage::doGetAll<StorageLocalSymbol>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageSourceLocation> DatabaseStorage::doGetAll<StorageSourceLocation>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageOccurrence> DatabaseStorage::doGetAll<StorageOccurrence>(const std::string& query) const;
|
||||
template <>
|
||||
std::vector<StorageError> DatabaseStorage::doGetAll<StorageError>(const std::string& query) const;
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_DATABASE_STORAGE_H
|
||||
#endif // SOURCETRAIL_DATABASE_STORAGE_H
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_DEFINITION_KIND_H
|
||||
#define SOURCETRAIL_DEFINITION_KIND_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for a symbol's definition kind.
|
||||
*
|
||||
* The DefinitionKind specifies "how" a symbol is defined.
|
||||
* When recording the definition of a symbol, you would usually also record an explicit definition kind.
|
||||
* However, you may also want to record symbols that are implicitly generated by the compiler. In this case you can
|
||||
* record an implicit definition kind for those symbols.
|
||||
* If you do not record any definition kind for a symbol, Sourcetrail will show it as "non-indexed".
|
||||
*/
|
||||
enum class DefinitionKind : int
|
||||
{
|
||||
IMPLICIT = 1,
|
||||
EXPLICIT = 2
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for a symbol's definition kind.
|
||||
*
|
||||
* The DefinitionKind specifies "how" a symbol is defined.
|
||||
* When recording the definition of a symbol, you would usually also record an explicit definition
|
||||
* kind. However, you may also want to record symbols that are implicitly generated by the compiler.
|
||||
* In this case you can record an implicit definition kind for those symbols. If you do not record
|
||||
* any definition kind for a symbol, Sourcetrail will show it as "non-indexed".
|
||||
*/
|
||||
enum class DefinitionKind : int
|
||||
{
|
||||
IMPLICIT = 1,
|
||||
EXPLICIT = 2
|
||||
};
|
||||
|
||||
int definitionKindToInt(DefinitionKind kind);
|
||||
DefinitionKind intToDefinitionKind(int i);
|
||||
}
|
||||
int definitionKindToInt(DefinitionKind kind);
|
||||
DefinitionKind intToDefinitionKind(int i);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_DEFINITION_KIND_H
|
||||
#endif // SOURCETRAIL_DEFINITION_KIND_H
|
||||
|
||||
+43
-47
@@ -1,56 +1,52 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_EDGE_KIND_H
|
||||
#define SOURCETRAIL_EDGE_KIND_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of edges that can be stored to the Sourcetrail database.
|
||||
*
|
||||
* The DatabaseStorage provides the interface for writing and updating the Sourcetrail database. This interface only
|
||||
* The EdgeKind enum should only be used internally and contains a complete list of values that may be written to
|
||||
* the Sourcetrail database file. This enum contains kinds for edges that can be recorded explicitly, but also kinds
|
||||
* for edges that will be created implicitly. For example edges of type "EDGE_MEMBER" will be created while storing parent
|
||||
* child node relations when recording symbols with hierarchical names (see NameHierarchy).
|
||||
*/
|
||||
enum class EdgeKind : int
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
MEMBER = 1 << 0,
|
||||
TYPE_USAGE = 1 << 1,
|
||||
USAGE = 1 << 2,
|
||||
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
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for kinds of edges that can be stored to the Sourcetrail database.
|
||||
*
|
||||
* The DatabaseStorage provides the interface for writing and updating the Sourcetrail database. This interface only
|
||||
* The EdgeKind enum should only be used internally and contains a complete list of values that may be written to
|
||||
* the Sourcetrail database file. This enum contains kinds for edges that can be recorded explicitly, but also kinds
|
||||
* for edges that will be created implicitly. For example edges of type "EDGE_MEMBER" will be created while storing parent
|
||||
* child node relations when recording symbols with hierarchical names (see NameHierarchy).
|
||||
*/
|
||||
enum class EdgeKind : int
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
MEMBER = 1 << 0,
|
||||
TYPE_USAGE = 1 << 1,
|
||||
USAGE = 1 << 2,
|
||||
CALL = 1 << 3,
|
||||
INHERITANCE = 1 << 4,
|
||||
OVERRIDE = 1 << 5,
|
||||
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);
|
||||
EdgeKind intToEdgeKind(int i);
|
||||
}
|
||||
int edgeKindToInt(EdgeKind kind);
|
||||
EdgeKind intToEdgeKind(int i);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_EDGE_KIND_H
|
||||
#endif // SOURCETRAIL_EDGE_KIND_H
|
||||
|
||||
@@ -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);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_ELEMENT_COMPONENT_KIND_H
|
||||
+34
-33
@@ -1,42 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_LOCATION_KIND_H
|
||||
#define SOURCETRAIL_LOCATION_KIND_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of locations that can be stored to the Sourcetrail database.
|
||||
*/
|
||||
enum class LocationKind : int
|
||||
{
|
||||
TOKEN = 0,
|
||||
SCOPE = 1,
|
||||
QUALIFIER = 2,
|
||||
LOCAL_SYMBOL = 3,
|
||||
SIGNATURE = 4,
|
||||
ATOMIC_RANGE = 5,
|
||||
INDEXER_ERROR = 6,
|
||||
FULLTEXT_SEARCH = 7,
|
||||
SCREEN_SEARCH = 8
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for kinds of locations that can be stored to the Sourcetrail database.
|
||||
*/
|
||||
enum class LocationKind : int
|
||||
{
|
||||
TOKEN = 0,
|
||||
SCOPE = 1,
|
||||
QUALIFIER = 2,
|
||||
LOCAL_SYMBOL = 3,
|
||||
SIGNATURE = 4,
|
||||
ATOMIC_RANGE = 5,
|
||||
INDEXER_ERROR = 6,
|
||||
FULLTEXT_SEARCH = 7,
|
||||
SCREEN_SEARCH = 8,
|
||||
UNSOLVED = 9
|
||||
};
|
||||
|
||||
int locationKindToInt(LocationKind kind);
|
||||
LocationKind intToLocationKind(int i);
|
||||
}
|
||||
int locationKindToInt(LocationKind kind);
|
||||
LocationKind intToLocationKind(int i);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_LOCATION_KIND_H
|
||||
#endif // SOURCETRAIL_LOCATION_KIND_H
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_NAME_HIERARCHY_H
|
||||
#define SOURCETRAIL_NAME_HIERARCHY_H
|
||||
@@ -22,77 +22,77 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Struct that represents a single hierarchical element that is part of a symbol's name.
|
||||
*
|
||||
* prefix: optional prefix used for unique identification and shown in tooltips
|
||||
* name: name represented by this element
|
||||
* postfix: optional prefix used for unique identification and shown in tooltips
|
||||
*/
|
||||
struct NameElement
|
||||
{
|
||||
std::string prefix;
|
||||
std::string name;
|
||||
std::string postfix;
|
||||
};
|
||||
/**
|
||||
* Struct that represents a single hierarchical element that is part of a symbol's name.
|
||||
*
|
||||
* prefix: optional prefix used for unique identification and shown in tooltips
|
||||
* name: name represented by this element
|
||||
* postfix: optional prefix used for unique identification and shown in tooltips
|
||||
*/
|
||||
struct NameElement
|
||||
{
|
||||
std::string prefix;
|
||||
std::string name;
|
||||
std::string postfix;
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct that represents an entire name of a symbol.
|
||||
*
|
||||
* nameDelimiter: delimiter added between name elements
|
||||
* nameElements: all name elements that make up the hierarchy
|
||||
*/
|
||||
struct NameHierarchy
|
||||
{
|
||||
std::string nameDelimiter;
|
||||
std::vector<NameElement> nameElements;
|
||||
};
|
||||
/**
|
||||
* Struct that represents an entire name of a symbol.
|
||||
*
|
||||
* nameDelimiter: delimiter added between name elements
|
||||
* nameElements: all name elements that make up the hierarchy
|
||||
*/
|
||||
struct NameHierarchy
|
||||
{
|
||||
std::string nameDelimiter;
|
||||
std::vector<NameElement> nameElements;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a NameHierarchy to a JSON string
|
||||
*
|
||||
* param: nameHierarchy - the name hierarchy to convert to JSON string
|
||||
*
|
||||
* return: a JSON object of the form:
|
||||
* {
|
||||
* "name_delimiter" : "."
|
||||
* "name_elements" : [
|
||||
* {
|
||||
* "prefix" : "",
|
||||
* "name" : "",
|
||||
* "postfix" : ""
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
std::string serializeNameHierarchyToJson(const NameHierarchy& nameHierarchy);
|
||||
/**
|
||||
* Converts a NameHierarchy to a JSON string
|
||||
*
|
||||
* param: nameHierarchy - the name hierarchy to convert to JSON string
|
||||
*
|
||||
* return: a JSON object of the form:
|
||||
* {
|
||||
* "name_delimiter" : "."
|
||||
* "name_elements" : [
|
||||
* {
|
||||
* "prefix" : "",
|
||||
* "name" : "",
|
||||
* "postfix" : ""
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
std::string serializeNameHierarchyToJson(const NameHierarchy& nameHierarchy);
|
||||
|
||||
/**
|
||||
* Converts a JSON string to a NameHierarchy
|
||||
*
|
||||
* param: serializedNameHierarchy - JSON object string of the form:
|
||||
* {
|
||||
* "name_delimiter" : "."
|
||||
* "name_elements" : [
|
||||
* {
|
||||
* "prefix" : "",
|
||||
* "name" : "",
|
||||
* "postfix" : ""
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
* }
|
||||
* param: error - optional pointer to a string, where an error message will be set
|
||||
*
|
||||
* return: NameHierarchy object. Empty on failure.
|
||||
*/
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error = nullptr);
|
||||
/**
|
||||
* Converts a JSON string to a NameHierarchy
|
||||
*
|
||||
* param: serializedNameHierarchy - JSON object string of the form:
|
||||
* {
|
||||
* "name_delimiter" : "."
|
||||
* "name_elements" : [
|
||||
* {
|
||||
* "prefix" : "",
|
||||
* "name" : "",
|
||||
* "postfix" : ""
|
||||
* },
|
||||
* ...
|
||||
* ]
|
||||
* }
|
||||
* param: error - optional pointer to a string, where an error message will be set
|
||||
*
|
||||
* return: NameHierarchy object. Empty on failure.
|
||||
*/
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error = nullptr);
|
||||
|
||||
/**
|
||||
* INTERNAL: Converts a NameHierarchy to a string in Sourcetrail database format
|
||||
*/
|
||||
std::string serializeNameHierarchyToDatabaseString(const NameHierarchy& nameHierarchy);
|
||||
}
|
||||
/**
|
||||
* INTERNAL: Converts a NameHierarchy to a string in Sourcetrail database format
|
||||
*/
|
||||
std::string serializeNameHierarchyToDatabaseString(const NameHierarchy& nameHierarchy);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_NAME_HIERARCHY_H
|
||||
#endif // SOURCETRAIL_NAME_HIERARCHY_H
|
||||
|
||||
+45
-46
@@ -1,55 +1,54 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_NODE_KIND_H
|
||||
#define SOURCETRAIL_NODE_KIND_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of nodes that can be stored to the Sourcetrail database.
|
||||
*/
|
||||
enum class NodeKind : int
|
||||
{
|
||||
UNKNOWN = 1 << 0,
|
||||
TYPE = 1 << 1,
|
||||
BUILTIN_TYPE = 1 << 2,
|
||||
MODULE = 1 << 3,
|
||||
NAMESPACE = 1 << 4,
|
||||
PACKAGE = 1 << 5,
|
||||
STRUCT = 1 << 6,
|
||||
CLASS = 1 << 7,
|
||||
INTERFACE = 1 << 8,
|
||||
ANNOTATION = 1 << 9,
|
||||
GLOBAL_VARIABLE = 1 << 10,
|
||||
FIELD = 1 << 11,
|
||||
FUNCTION = 1 << 12,
|
||||
METHOD = 1 << 13,
|
||||
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
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for kinds of nodes that can be stored to the Sourcetrail database.
|
||||
*/
|
||||
enum class NodeKind : int
|
||||
{
|
||||
UNKNOWN = 1 << 0,
|
||||
TYPE = 1 << 1,
|
||||
BUILTIN_TYPE = 1 << 2,
|
||||
MODULE = 1 << 3,
|
||||
NAMESPACE = 1 << 4,
|
||||
PACKAGE = 1 << 5,
|
||||
STRUCT = 1 << 6,
|
||||
CLASS = 1 << 7,
|
||||
INTERFACE = 1 << 8,
|
||||
ANNOTATION = 1 << 9,
|
||||
GLOBAL_VARIABLE = 1 << 10,
|
||||
FIELD = 1 << 11,
|
||||
FUNCTION = 1 << 12,
|
||||
METHOD = 1 << 13,
|
||||
ENUM = 1 << 14,
|
||||
ENUM_CONSTANT = 1 << 15,
|
||||
TYPEDEF = 1 << 16,
|
||||
TYPE_PARAMETER = 1 << 17,
|
||||
FILE = 1 << 18,
|
||||
MACRO = 1 << 19,
|
||||
UNION = 1 << 20
|
||||
};
|
||||
|
||||
int nodeKindToInt(NodeKind kind);
|
||||
NodeKind intToNodeKind(int i);
|
||||
}
|
||||
int nodeKindToInt(NodeKind kind);
|
||||
NodeKind intToNodeKind(int i);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_NODE_KIND_H
|
||||
#endif // SOURCETRAIL_NODE_KIND_H
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_REFERENCE_KIND_H
|
||||
#define SOURCETRAIL_REFERENCE_KIND_H
|
||||
@@ -21,28 +21,25 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of references that can be recorded using the SourcetrailDBWriter interface.
|
||||
*/
|
||||
enum class ReferenceKind
|
||||
{
|
||||
TYPE_USAGE,
|
||||
USAGE,
|
||||
CALL,
|
||||
INHERITANCE,
|
||||
OVERRIDE,
|
||||
TEMPLATE_ARGUMENT,
|
||||
TYPE_ARGUMENT,
|
||||
TEMPLATE_DEFAULT_ARGUMENT,
|
||||
TEMPLATE_SPECIALIZATION,
|
||||
TEMPLATE_MEMBER_SPECIALIZATION,
|
||||
INCLUDE,
|
||||
IMPORT,
|
||||
MACRO_USAGE,
|
||||
ANNOTATION_USAGE
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for kinds of references that can be recorded using the SourcetrailDBWriter interface.
|
||||
*/
|
||||
enum class ReferenceKind
|
||||
{
|
||||
TYPE_USAGE,
|
||||
USAGE,
|
||||
CALL,
|
||||
INHERITANCE,
|
||||
OVERRIDE,
|
||||
TYPE_ARGUMENT,
|
||||
TEMPLATE_SPECIALIZATION,
|
||||
INCLUDE,
|
||||
IMPORT,
|
||||
MACRO_USAGE,
|
||||
ANNOTATION_USAGE
|
||||
};
|
||||
|
||||
EdgeKind referenceKindToEdgeKind(ReferenceKind kind);
|
||||
}
|
||||
EdgeKind referenceKindToEdgeKind(ReferenceKind kind);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_REFERENCE_KIND_H
|
||||
#endif // SOURCETRAIL_REFERENCE_KIND_H
|
||||
|
||||
+30
-30
@@ -1,38 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SOURCE_RANGE_H
|
||||
#define SOURCETRAIL_SOURCE_RANGE_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Struct that represents the location of a range of characters in a source file.
|
||||
*
|
||||
* note: Line and column numbers start at 1 instead of 0!
|
||||
* note: The SourceRange includes both, the start and the end column number.
|
||||
*/
|
||||
struct SourceRange
|
||||
{
|
||||
int fileId;
|
||||
int startLine;
|
||||
int startColumn;
|
||||
int endLine;
|
||||
int endColumn;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Struct that represents the location of a range of characters in a source file.
|
||||
*
|
||||
* note: Line and column numbers start at 1 instead of 0!
|
||||
* note: The SourceRange includes both, the start and the end column number.
|
||||
*/
|
||||
struct SourceRange
|
||||
{
|
||||
int fileId;
|
||||
int startLine;
|
||||
int startColumn;
|
||||
int endLine;
|
||||
int endColumn;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_SOURCE_RANGE_H
|
||||
#endif // SOURCETRAIL_SOURCE_RANGE_H
|
||||
|
||||
+468
-430
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SRCTRLDB_WRITER_H
|
||||
#define SOURCETRAIL_SRCTRLDB_WRITER_H
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "DefinitionKind.h"
|
||||
#include "EdgeKind.h"
|
||||
#include "ElementComponentKind.h"
|
||||
#include "LocationKind.h"
|
||||
#include "NameHierarchy.h"
|
||||
#include "ReferenceKind.h"
|
||||
@@ -30,457 +31,494 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
class DatabaseStorage;
|
||||
class DatabaseStorage;
|
||||
|
||||
/**
|
||||
* SourcetrailDBWriter
|
||||
*
|
||||
* This class is the main interface for writing data to a Sourcetrail project database.
|
||||
* It be used to manage a Sourcetrail database file and to write information to it.
|
||||
*
|
||||
* The following code snippet illustrates a very basic usage of the SourcetrailDBWriter class:
|
||||
*
|
||||
* sourcetrail::SourcetrailDBWriter writer;
|
||||
* writer.open("MyProject.srctrldb");
|
||||
* writer.recordSymbol({ "::",{ { "void", "foo", "()" } } });
|
||||
* writer.close();
|
||||
*/
|
||||
class SourcetrailDBWriter
|
||||
{
|
||||
public:
|
||||
SourcetrailDBWriter();
|
||||
~SourcetrailDBWriter();
|
||||
|
||||
/**
|
||||
* SourcetrailDBWriter
|
||||
* Provides the version of the SourcetrailDB Core as string with format "vXX.dbYY.pZZ"
|
||||
*
|
||||
* This class is the main interface for writing data to a Sourcetrail project database.
|
||||
* It be used to manage a Sourcetrail database file and to write information to it.
|
||||
* - XX: interface version. This version increases on every change that breaks backwards
|
||||
* compatibility.
|
||||
* - YY: Sourcetrail database version. This version needs to match the database version
|
||||
* of the used Sourcetrail instance. You can find the database version of Sourcetrail
|
||||
* in its About dialog.
|
||||
* - ZZ: patch number of the build. It will increase with every release that publishes
|
||||
* bugfixes and features that don't break any compatibility.
|
||||
*
|
||||
* The following code snippet illustrates a very basic usage of the SourcetrailDBWriter class:
|
||||
*
|
||||
* sourcetrail::SourcetrailDBWriter writer;
|
||||
* writer.open("MyProject.srctrldb");
|
||||
* writer.recordSymbol({ "::",{ { "void", "foo", "()" } } });
|
||||
* writer.close();
|
||||
* return: version string
|
||||
*/
|
||||
class SourcetrailDBWriter
|
||||
{
|
||||
public:
|
||||
SourcetrailDBWriter();
|
||||
~SourcetrailDBWriter();
|
||||
std::string getVersionString() const;
|
||||
|
||||
/**
|
||||
* Provides the version of the SourcetrailDB Core as string with format "vXX.dbYY.pZZ"
|
||||
*
|
||||
* - XX: interface version. This version increases on every change that breaks backwards
|
||||
* compatibility.
|
||||
* - YY: Sourcetrail database version. This version needs to match the database version
|
||||
* of the used Sourcetrail instance. You can find the database version of Sourcetrail
|
||||
* in its About dialog.
|
||||
* - ZZ: patch number of the build. It will increase with every release that publishes
|
||||
* bugfixes and features that don't break any compatibility.
|
||||
*
|
||||
* return: version string
|
||||
*/
|
||||
std::string getVersionString() const;
|
||||
/**
|
||||
* Provides the supported database version as integer
|
||||
*
|
||||
* return: supported database version
|
||||
*
|
||||
* see: getVersionString() for details
|
||||
*/
|
||||
int getSupportedDatabaseVersion() const;
|
||||
|
||||
/**
|
||||
* Provides the supported database version as integer
|
||||
*
|
||||
* return: supported database version
|
||||
*
|
||||
* see: getVersionString() for details
|
||||
*/
|
||||
int getSupportedDatabaseVersion() const;
|
||||
/**
|
||||
* Provides the last error that occurred while using the SourcetrailDBWriter
|
||||
*
|
||||
* The last error is empty if no error occurred since instantiation of the class or since the
|
||||
* error has last been cleared.
|
||||
*
|
||||
* return: error message of last error that occured
|
||||
*
|
||||
* see: clearLastError()
|
||||
*/
|
||||
const std::string& getLastError() const;
|
||||
|
||||
/**
|
||||
* Provides the last error that occurred while using the SourcetrailDBWriter
|
||||
*
|
||||
* The last error is empty if no error occurred since instantiation of the class or since the
|
||||
* error has last been cleared.
|
||||
*
|
||||
* return: error message of last error that occured
|
||||
*
|
||||
* see: clearLastError()
|
||||
*/
|
||||
const std::string& getLastError() const;
|
||||
/**
|
||||
* Modifies the stored error message
|
||||
*
|
||||
* param: error - the new error message
|
||||
*
|
||||
* see: getLastError()
|
||||
*/
|
||||
void setLastError(const std::string& error) const;
|
||||
|
||||
/**
|
||||
* Modifies the stored error message
|
||||
*
|
||||
* param: error - the new error message
|
||||
*
|
||||
* see: getLastError()
|
||||
*/
|
||||
void setLastError(const std::string& error) const;
|
||||
/**
|
||||
* Clears the stored error message
|
||||
*
|
||||
* see: getLastError()
|
||||
*/
|
||||
void clearLastError();
|
||||
|
||||
/**
|
||||
* Clears the stored error message
|
||||
*
|
||||
* see: getLastError()
|
||||
*/
|
||||
void clearLastError();
|
||||
/**
|
||||
* Opens a Sourcetrail database
|
||||
*
|
||||
* Call this method to open a Sourcetrail database file. If the database does not have any
|
||||
* related .srctrlprj project file, a minimal project file will be created that allows for
|
||||
* opening the database with Sourcetrail.
|
||||
*
|
||||
* param: databaseFilePath - absolute file path of the database file, including file extension
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool open(const std::string& databaseFilePath);
|
||||
|
||||
/**
|
||||
* Opens a Sourcetrail database
|
||||
*
|
||||
* Call this method to open a Sourcetrail database file. If the database does not have any
|
||||
* related .srctrlprj project file, a minimal project file will be created that allows for
|
||||
* opening the database with Sourcetrail.
|
||||
*
|
||||
* param: databaseFilePath - absolute file path of the database file, including file extension
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool open(const std::string& databaseFilePath);
|
||||
/**
|
||||
* Closes the currently open Sourcetrail database
|
||||
*
|
||||
* return: Returns true if the operation was successful. Otherwise false is returned and getLastError()
|
||||
* can be checked for more detailed information.
|
||||
*
|
||||
* see: open(const std::string& databaseFilePath)
|
||||
*/
|
||||
bool close();
|
||||
|
||||
/**
|
||||
* Closes the currently open Sourcetrail database
|
||||
*
|
||||
* return: Returns true if the operation was successful. Otherwise false is returned and getLastError()
|
||||
* can be checked for more detailed information.
|
||||
*
|
||||
* see: open(const std::string& databaseFilePath)
|
||||
*/
|
||||
bool close();
|
||||
/**
|
||||
* Clears the currently open Sourcetrail database
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: open(const std::string& databaseFilePath)
|
||||
*/
|
||||
bool clear();
|
||||
|
||||
/**
|
||||
* Clears the currently open Sourcetrail database
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: open(const std::string& databaseFilePath)
|
||||
*/
|
||||
bool clear();
|
||||
/**
|
||||
* Checks if the currently open database file contains any data
|
||||
*
|
||||
* return: true after opening a non-existing database file or clearing the open database
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
|
||||
/**
|
||||
* Checks if the currently open database file contains any data
|
||||
*
|
||||
* return: true after opening a non-existing database file or clearing the open database
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
/**
|
||||
* Checks if the currently open database is compatible with the SourcetrailDBWriter version.
|
||||
*
|
||||
* return: true for an empty database or a database that has been created with the same
|
||||
* database version.
|
||||
*
|
||||
* see: getSupportedDatabaseVersion()
|
||||
* see: getLoadedDatabaseVersion()
|
||||
*/
|
||||
bool isCompatible() const;
|
||||
|
||||
/**
|
||||
* Checks if the currently open database is compatible with the SourcetrailDBWriter version.
|
||||
*
|
||||
* return: true for an empty database or a database that has been created with the same
|
||||
* database version.
|
||||
*
|
||||
* see: getSupportedDatabaseVersion()
|
||||
* see: getLoadedDatabaseVersion()
|
||||
*/
|
||||
bool isCompatible() const;
|
||||
/**
|
||||
* Provides the database version of the loaded database file as an integer
|
||||
*
|
||||
* return: database version of loaded database
|
||||
*/
|
||||
int getLoadedDatabaseVersion() const;
|
||||
|
||||
/**
|
||||
* Provides the database version of the loaded database file as an integer
|
||||
*
|
||||
* return: database version of loaded database
|
||||
*/
|
||||
int getLoadedDatabaseVersion() const;
|
||||
/**
|
||||
* Starts a database transaction on the currently open database
|
||||
*
|
||||
* Apart from allowing to restore the database to the state it was in before this method has
|
||||
* been called, wrapping multiple calls that record data with one transaction significantly
|
||||
* increases the performance of these database operations.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: commitTransaction()
|
||||
* see: rollbackTransaction()
|
||||
*/
|
||||
bool beginTransaction();
|
||||
|
||||
/**
|
||||
* Starts a database transaction on the currently open database
|
||||
*
|
||||
* Apart from allowing to restore the database to the state it was in before this method has
|
||||
* been called, wrapping multiple calls that record data with one transaction significantly
|
||||
* increases the performance of these database operations.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: commitTransaction()
|
||||
* see: rollbackTransaction()
|
||||
*/
|
||||
bool beginTransaction();
|
||||
/**
|
||||
* Ends the current transaction and writes all of its changes persistently to the database
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool commitTransaction();
|
||||
|
||||
/**
|
||||
* Ends the current transaction and writes all of its changes persistently to the database
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool commitTransaction();
|
||||
/**
|
||||
* Reverts the database to the state it was in before the current transaction was started
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool rollbackTransaction();
|
||||
|
||||
/**
|
||||
* Reverts the database to the state it was in before the current transaction was started
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool rollbackTransaction();
|
||||
/**
|
||||
* Reduces the on disk memory consumption of the open database to a minimum
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool optimizeDatabaseMemory();
|
||||
|
||||
/**
|
||||
* Reduces the on disk memory consumption of the open database to a minimum
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool optimizeDatabaseMemory();
|
||||
/**
|
||||
* Stores a symbol to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail
|
||||
* database will always return the same id.
|
||||
*
|
||||
* param: nameHierarchy - the name of the symbol to store.
|
||||
*
|
||||
* return: symbolId - integer id of the stored symbol. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*
|
||||
* see: NameHierarchy
|
||||
*/
|
||||
int recordSymbol(const NameHierarchy& nameHierarchy);
|
||||
|
||||
/**
|
||||
* Stores a symbol to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail
|
||||
* database will always return the same id.
|
||||
*
|
||||
* param: nameHierarchy - the name of the symbol to store.
|
||||
*
|
||||
* return: symbolId - integer id of the stored symbol. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*
|
||||
* see: NameHierarchy
|
||||
*/
|
||||
int recordSymbol(const NameHierarchy& nameHierarchy);
|
||||
/**
|
||||
* Stores a definition kind for a specific symbol to the database
|
||||
*
|
||||
* Calling this method allows to store a DefinitionKind (e.g. explicitly defined, implicitly
|
||||
* defined) for a symbol referenced by id to the database. Calling this method with the same
|
||||
* symbolId multiple times overwrites the symbol's previously recorded DefinitionKind. If no
|
||||
* DefinitionKind is recorded for a symbol, Sourcetrail treats this symbol as "non-indexed".
|
||||
* This may be desired while recording a reference to a symbol with a definition that is located
|
||||
* outside of the indexed source files.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a DefinitionKind shall be recorded.
|
||||
* param: definitionKind - the DefinitionKind that shall be recorded for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: DefinitionKind
|
||||
*/
|
||||
bool recordSymbolDefinitionKind(int symbolId, DefinitionKind definitionKind);
|
||||
|
||||
/**
|
||||
* Stores a definition kind for a specific symbol to the database
|
||||
*
|
||||
* Calling this method allows to store a DefinitionKind (e.g. explicitly defined, implicitly
|
||||
* defined) for a symbol referenced by id to the database. Calling this method with the same
|
||||
* symbolId multiple times overwrites the symbol's previously recorded DefinitionKind. If no
|
||||
* DefinitionKind is recorded for a symbol, Sourcetrail treats this symbol as "non-indexed".
|
||||
* This may be desired while recording a reference to a symbol with a definition that is located
|
||||
* outside of the indexed source files.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a DefinitionKind shall be recorded.
|
||||
* param: definitionKind - the DefinitionKind that shall be recorded for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: DefinitionKind
|
||||
*/
|
||||
bool recordSymbolDefinitionKind(int symbolId, DefinitionKind definitionKind);
|
||||
/**
|
||||
* Stores a symbol kind for a specific symbol to the database
|
||||
*
|
||||
* Calling this method allows to store a SymbolKind (e.g. "class", "function", etc.) for a
|
||||
* symbol referenced by id to the database. Calling this method with the same symbolId multiple
|
||||
* times overwrites the symbol's previously recorded SymbolKind. If no SymbolKind is recorded
|
||||
* for a symbol, Sourcetrail displays the type of this symbol as "symbol".
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a SymbolKind shall be recorded.
|
||||
* param: symbolKind - the SymbolKind that shall be recorded for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SymbolKind
|
||||
*/
|
||||
bool recordSymbolKind(int symbolId, SymbolKind symbolKind);
|
||||
|
||||
/**
|
||||
* Stores a symbol kind for a specific symbol to the database
|
||||
*
|
||||
* Calling this method allows to store a SymbolKind (e.g. "class", "function", etc.) for a
|
||||
* symbol referenced by id to the database. Calling this method with the same symbolId multiple
|
||||
* times overwrites the symbol's previously recorded SymbolKind. If no SymbolKind is recorded
|
||||
* for a symbol, Sourcetrail displays the type of this symbol as "symbol".
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a SymbolKind shall be recorded.
|
||||
* param: symbolKind - the SymbolKind that shall be recorded for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SymbolKind
|
||||
*/
|
||||
bool recordSymbolKind(int symbolId, SymbolKind symbolKind);
|
||||
/**
|
||||
* Stores a location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a location for a symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple locations for the
|
||||
* respective symbol. The stored location will be clickable and displayable. When clicked
|
||||
* Sourcetrail will activate the symbol with the specified id. When the symbol with the specified
|
||||
* id is activated, this location will be displayed and highlighted by Sourcetrail.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolLocation(int symbolId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores a location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a location for a symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple locations for the
|
||||
* respective symbol. The stored location will be clickable and displayable. When clicked
|
||||
* Sourcetrail will activate the symbol with the specified id. When the symbol with the specified
|
||||
* id is activated, this location will be displayed and highlighted by Sourcetrail.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolLocation(int symbolId, const SourceRange& location);
|
||||
/**
|
||||
* Stores a scope location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a scope location for a symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple scope locations for the
|
||||
* respective symbol. The stored location will only be displayable and not clickable. When the
|
||||
* symbol with the specified id is activated, this location will be fully displayed but not
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a scope location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as scope location for the respective
|
||||
* symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolScopeLocation(int symbolId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores a scope location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a scope location for a symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple scope locations for the
|
||||
* respective symbol. The stored location will only be displayable and not clickable. When the
|
||||
* symbol with the specified id is activated, this location will be fully displayed but not
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a scope location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as scope location for the respective
|
||||
* symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolScopeLocation(int symbolId, const SourceRange& location);
|
||||
/**
|
||||
* Stores a signature location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a signature location for a symbol referenced by id to the
|
||||
* database. If a signature location is recorded for a symbol, Sourcetrail will display the
|
||||
* respective source code in a tooltip whenever the symbol with the referenced id or any of
|
||||
* that symbol's locations gets hovered.
|
||||
* If no signature location is recorded for a symbol, Sourcetrail will show its name hierarchy.
|
||||
*
|
||||
* note: Calling this method with the same symbolId multiple times adds multiple signature
|
||||
* locations for the respective symbol. It is not guaranteed which one will be used, so it is
|
||||
* advised to call it only once per symbol.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a signature location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as signature location for the
|
||||
* respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolSignatureLocation(int symbolId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores a signature location for a specific symbol to the database
|
||||
*
|
||||
* This method allows to store a signature location for a symbol referenced by id to the
|
||||
* database. If a signature location is recorded for a symbol, Sourcetrail will display the
|
||||
* respective source code in a tooltip whenever the symbol with the referenced id or any of
|
||||
* that symbol's locations gets hovered.
|
||||
* If no signature location is recorded for a symbol, Sourcetrail will show its name hierarchy.
|
||||
*
|
||||
* note: Calling this method with the same symbolId multiple times adds multiple signature
|
||||
* locations for the respective symbol. It is not guaranteed which one will be used, so it is
|
||||
* advised to call it only once per symbol.
|
||||
*
|
||||
* param: symbolId - the id of the symbol for which a signature location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as signature location for the
|
||||
* respective symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordSymbolSignatureLocation(int symbolId, const SourceRange& location);
|
||||
/**
|
||||
* Stores a reference between two symbols to the database
|
||||
*
|
||||
* This method allows to store the information of symbols referencing one another to the database.
|
||||
* For each recorded reference Sourcetrail's graph view will display an edge that originates at
|
||||
* the reference's recorded context symbol and points to the recorded referenced symbol. The
|
||||
* recorded ReferenceKind is used to determine the type of the displayed edge and to generate a
|
||||
* description in the hover tooltip of the edge.
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: contextSymbolId - the id of the source of the recorded reference edge
|
||||
* param: referencedSymbolId - the id of the target of the recorded reference edge
|
||||
* param: referenceKind - kind of the recorded reference edge
|
||||
*
|
||||
* return: referenceId - integer id of the stored reference. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*
|
||||
* see: ReferenceKind
|
||||
*/
|
||||
int recordReference(int contextSymbolId, int referencedSymbolId, ReferenceKind referenceKind);
|
||||
|
||||
/**
|
||||
* Stores a reference between two symbols to the database
|
||||
*
|
||||
* This method allows to store the information of symbols referencing one another to the database.
|
||||
* For each recorded reference Sourcetrail's graph view will display an edge that originates at
|
||||
* the reference's recorded context symbol and points to the recorded referenced symbol. The
|
||||
* recorded ReferenceKind is used to determine the type of the displayed edge and to generate a
|
||||
* description in the hover tooltip of the edge.
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: contextSymbolId - the id of the source of the recorded reference edge
|
||||
* param: referencedSymbolId - the id of the target of the recorded reference edge
|
||||
* param: referenceKind - kind of the recorded reference edge
|
||||
*
|
||||
* return: referenceId - integer id of the stored reference. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*
|
||||
* see: ReferenceKind
|
||||
*/
|
||||
int recordReference(int contextSymbolId, int referencedSymbolId, ReferenceKind referenceKind);
|
||||
/**
|
||||
* Stores a location for a specific reference to the database
|
||||
*
|
||||
* This method allows to store a location for a reference to the database.
|
||||
* Calling this method with the same referenceId multiple times adds multiple locations for the
|
||||
* respective reference. The stored location will be clickable and displayable. When the reference
|
||||
* location is clicked Sourcetrail will activate the symbol referenced by the respective reference.
|
||||
* When the reference with the specified id is activated, this location will be displayed and
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: referenceId - the id of the reference for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective
|
||||
* reference.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordReferenceLocation(int referenceId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores a location for a specific reference to the database
|
||||
*
|
||||
* This method allows to store a location for a reference to the database.
|
||||
* Calling this method with the same referenceId multiple times adds multiple locations for the
|
||||
* respective reference. The stored location will be clickable and displayable. When the reference
|
||||
* location is clicked Sourcetrail will activate the symbol referenced by the respective reference.
|
||||
* When the reference with the specified id is activated, this location will be displayed and
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: referenceId - the id of the reference for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective
|
||||
* reference.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
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 for the usage of a symbol's name as qualifier to the database
|
||||
*
|
||||
* This method allows to store a location where a specific symbol is used as a qualifier to the
|
||||
* database. Calling this method with the same referencedSymbolId multiple times adds multiple locations
|
||||
* for the respective reference. The stored location will be clickable but not displayable: When the
|
||||
* reference location is clicked Sourcetrail will activate the symbol referenced by the respective
|
||||
* reference. When the symbol with the specified id is activated, this location will NOT be displayed and
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: referencedSymbolId - the id of the symbol that is used as qualifier at the current location.
|
||||
* param: location - the SourceRange that shall be recorded as location for the symbol's occurrence as
|
||||
* qualifier
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordQualifierLocation(int referencedSymbolId, const SourceRange& location);
|
||||
/**
|
||||
* 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 file to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: filePath - the absolute path to the file to store.
|
||||
*
|
||||
* return: fileId - integer id of the stored file. 0 on failure. getLastError() provides the
|
||||
* error message.
|
||||
*/
|
||||
int recordFile(const std::string& filePath);
|
||||
/**
|
||||
* Stores a location for the usage of a symbol's name as qualifier to the database
|
||||
*
|
||||
* This method allows to store a location where a specific symbol is used as a qualifier to the
|
||||
* database. Calling this method with the same referencedSymbolId multiple times adds multiple locations
|
||||
* for the respective reference. The stored location will be clickable but not displayable: When the
|
||||
* reference location is clicked Sourcetrail will activate the symbol referenced by the respective
|
||||
* reference. When the symbol with the specified id is activated, this location will NOT be displayed and
|
||||
* highlighted by Sourcetrail.
|
||||
*
|
||||
* param: referencedSymbolId - the id of the symbol that is used as qualifier at the current location.
|
||||
* param: location - the SourceRange that shall be recorded as location for the symbol's occurrence as
|
||||
* qualifier
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordQualifierLocation(int referencedSymbolId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores language information for a specific file to the database
|
||||
*
|
||||
* This method allows to store language information for a file to the database. Language information
|
||||
* is passed and stored as string (e.g. "cpp", "java", etc.) and allows Sourcetrail to pick the
|
||||
* correct syntax highlighting rules when displaying the respective source file.
|
||||
*
|
||||
* param: fileId - the id of the file for which language information shall be recorded.
|
||||
* param: languageIdentifier - a string that denotes the programming language the respective file
|
||||
* is written in.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool recordFileLanguage(int fileId, const std::string& languageIdentifier);
|
||||
/**
|
||||
* Stores a file to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: filePath - the absolute path to the file to store.
|
||||
*
|
||||
* return: fileId - integer id of the stored file. 0 on failure. getLastError() provides the
|
||||
* error message.
|
||||
*/
|
||||
int recordFile(const std::string& filePath);
|
||||
|
||||
/**
|
||||
* Stores a local symbol to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: name - a name that is unique for this local symbol (e.g. the string encoded location
|
||||
* of the local symbol's definition).
|
||||
*
|
||||
* return: localSymbolId - integer id of the stored local symbol. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*/
|
||||
int recordLocalSymbol(const std::string& name);
|
||||
/**
|
||||
* Stores language information for a specific file to the database
|
||||
*
|
||||
* This method allows to store language information for a file to the database. Language information
|
||||
* is passed and stored as string (e.g. "cpp", "java", etc.) and allows Sourcetrail to pick the
|
||||
* correct syntax highlighting rules when displaying the respective source file.
|
||||
*
|
||||
* param: fileId - the id of the file for which language information shall be recorded.
|
||||
* param: languageIdentifier - a string that denotes the programming language the respective file
|
||||
* is written in.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*/
|
||||
bool recordFileLanguage(int fileId, const std::string& languageIdentifier);
|
||||
|
||||
/**
|
||||
* Stores a location for a specific local symbol to the database
|
||||
*
|
||||
* This method allows to store a location for a local symbol symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple locations for the
|
||||
* respective local symbol. The stored location will be clickable and displayable. When clicked
|
||||
* Sourcetrail will activate this and all other local symbol locations that share the same local
|
||||
* symbol id.
|
||||
*
|
||||
* param: localSymbolId - the id of the local symbol for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective
|
||||
* local symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordLocalSymbolLocation(int localSymbolId, const SourceRange& location);
|
||||
/**
|
||||
* Stores a local symbol to the database
|
||||
*
|
||||
* note: Calling this method multiple times with the same input on the same Sourcetrail database
|
||||
* will always return the same id.
|
||||
*
|
||||
* param: name - a name that is unique for this local symbol (e.g. the string encoded location
|
||||
* of the local symbol's definition).
|
||||
*
|
||||
* return: localSymbolId - integer id of the stored local symbol. 0 on failure. getLastError()
|
||||
* provides the error message.
|
||||
*/
|
||||
int recordLocalSymbol(const std::string& name);
|
||||
|
||||
/**
|
||||
* Stores an atomic SourceRange to the database
|
||||
*
|
||||
* This method allows to store an atomic SourceRange to the database. These ranges will
|
||||
* be used by Sourcetrail to prevent the code view from displaying only a part of the range. Thus,
|
||||
* if any line that lies within one of the project's atomic ranges is dispayed, the remaining
|
||||
* lines will be displayed as well. This may be useful for dealing with multi-line comments or
|
||||
* multi-line strings.
|
||||
*
|
||||
* param: sourceRange - the SourceRange to record.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordAtomicSourceRange(const SourceRange& sourceRange);
|
||||
/**
|
||||
* Stores a location for a specific local symbol to the database
|
||||
*
|
||||
* This method allows to store a location for a local symbol symbol referenced by id to the database.
|
||||
* Calling this method with the same symbolId multiple times adds multiple locations for the
|
||||
* respective local symbol. The stored location will be clickable and displayable. When clicked
|
||||
* Sourcetrail will activate this and all other local symbol locations that share the same local
|
||||
* symbol id.
|
||||
*
|
||||
* param: localSymbolId - the id of the local symbol for which a location shall be recorded.
|
||||
* param: location - the SourceRange that shall be recorded as location for the respective
|
||||
* local symbol.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordLocalSymbolLocation(int localSymbolId, const SourceRange& location);
|
||||
|
||||
/**
|
||||
* Stores an indexing error to the database
|
||||
*
|
||||
* This method allows to store an indexing error to the database. Errors will be shown by
|
||||
* Sourcetrail's error view. When clicking the error in Sourcetrail's error list, the code view
|
||||
* will display this location.
|
||||
*
|
||||
* param: message - an error message that will be displayed in Sourcetrail's error list.
|
||||
* param: fatal - boolean fatal indicates whether parsing/indexing was aborted at this point.
|
||||
* param: location - the SourceRange of the error encountered.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordError(const std::string& message, bool fatal, const SourceRange& location);
|
||||
/**
|
||||
* Stores an atomic SourceRange to the database
|
||||
*
|
||||
* This method allows to store an atomic SourceRange to the database. These ranges will
|
||||
* be used by Sourcetrail to prevent the code view from displaying only a part of the range. Thus,
|
||||
* if any line that lies within one of the project's atomic ranges is dispayed, the remaining
|
||||
* lines will be displayed as well. This may be useful for dealing with multi-line comments or
|
||||
* multi-line strings.
|
||||
*
|
||||
* param: sourceRange - the SourceRange to record.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordAtomicSourceRange(const SourceRange& sourceRange);
|
||||
|
||||
private:
|
||||
void openDatabase();
|
||||
void closeDatabase();
|
||||
void setupDatabaseTables();
|
||||
void clearDatabaseTables();
|
||||
void createOrResetProjectFile();
|
||||
void updateProjectSettingsText();
|
||||
int addNodeHierarchy(const NameHierarchy& nameHierarchy);
|
||||
int addFile(const std::string& filePath);
|
||||
int addEdge(int sourceId, int targetId, EdgeKind edgeKind);
|
||||
void addSourceLocation(int elementId, const SourceRange& location, LocationKind kind);
|
||||
/**
|
||||
* Stores an indexing error to the database
|
||||
*
|
||||
* This method allows to store an indexing error to the database. Errors will be shown by
|
||||
* Sourcetrail's error view. When clicking the error in Sourcetrail's error list, the code view
|
||||
* will display this location.
|
||||
*
|
||||
* param: message - an error message that will be displayed in Sourcetrail's error list.
|
||||
* param: fatal - boolean fatal indicates whether parsing/indexing was aborted at this point.
|
||||
* param: location - the SourceRange of the error encountered.
|
||||
*
|
||||
* return: true if successful. false on failure. getLastError() provides the error message.
|
||||
*
|
||||
* see: SourceRange
|
||||
*/
|
||||
bool recordError(const std::string& message, bool fatal, const SourceRange& location);
|
||||
|
||||
std::string m_projectFilePath;
|
||||
std::string m_databaseFilePath;
|
||||
std::unique_ptr<DatabaseStorage> m_storage;
|
||||
mutable std::string m_lastError;
|
||||
};
|
||||
}
|
||||
private:
|
||||
void openDatabase();
|
||||
void closeDatabase();
|
||||
void setupDatabaseTables();
|
||||
void clearDatabaseTables();
|
||||
void createOrResetProjectFile();
|
||||
void updateProjectSettingsText();
|
||||
int addNodeHierarchy(const NameHierarchy& nameHierarchy);
|
||||
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);
|
||||
|
||||
#endif // SOURCETRAIL_SRCTRLDB_WRITER_H
|
||||
std::string m_projectFilePath;
|
||||
std::string m_databaseFilePath;
|
||||
std::unique_ptr<DatabaseStorage> m_storage;
|
||||
mutable std::string m_lastError;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_SRCTRLDB_WRITER_H
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SOURCETRAIL_EXCEPTION_H
|
||||
#define SOURCETRAIL_SOURCETRAIL_EXCEPTION_H
|
||||
@@ -21,19 +21,22 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Exception type that is thrown by the SourcetrailDBWriter API.
|
||||
*/
|
||||
class SourcetrailException
|
||||
/**
|
||||
* Exception type that is thrown by the SourcetrailDBWriter API.
|
||||
*/
|
||||
class SourcetrailException
|
||||
{
|
||||
public:
|
||||
SourcetrailException(std::string message): m_message(message) {}
|
||||
virtual ~SourcetrailException() = default;
|
||||
std::string getMessage() const
|
||||
{
|
||||
public:
|
||||
SourcetrailException(std::string message) : m_message(message) {}
|
||||
virtual ~SourcetrailException() = default;
|
||||
std::string getMessage() const { return m_message; }
|
||||
return m_message;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_message;
|
||||
};
|
||||
}
|
||||
private:
|
||||
std::string m_message;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_SOURCETRAIL_EXCEPTION_H
|
||||
#endif // SOURCETRAIL_SOURCETRAIL_EXCEPTION_H
|
||||
|
||||
+34
-48
@@ -1,62 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_EDGE_H
|
||||
#define SOURCETRAIL_STORAGE_EDGE_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageEdgeData
|
||||
struct StorageEdgeData
|
||||
{
|
||||
StorageEdgeData(): sourceNodeId(0), targetNodeId(0), edgeKind(0) {}
|
||||
|
||||
StorageEdgeData(int sourceNodeId, int targetNodeId, int edgeKind)
|
||||
: sourceNodeId(sourceNodeId), targetNodeId(targetNodeId), edgeKind(edgeKind)
|
||||
{
|
||||
StorageEdgeData()
|
||||
: sourceNodeId(0)
|
||||
, targetNodeId(0)
|
||||
, edgeKind(0)
|
||||
{}
|
||||
}
|
||||
|
||||
StorageEdgeData(int sourceNodeId, int targetNodeId, int edgeKind)
|
||||
: sourceNodeId(sourceNodeId)
|
||||
, targetNodeId(targetNodeId)
|
||||
, edgeKind(edgeKind)
|
||||
{}
|
||||
int sourceNodeId;
|
||||
int targetNodeId;
|
||||
int edgeKind;
|
||||
};
|
||||
|
||||
int sourceNodeId;
|
||||
int targetNodeId;
|
||||
int edgeKind;
|
||||
};
|
||||
struct StorageEdge: public StorageEdgeData
|
||||
{
|
||||
StorageEdge(): StorageEdgeData(), id(0) {}
|
||||
|
||||
struct StorageEdge : public StorageEdgeData
|
||||
{
|
||||
StorageEdge()
|
||||
: StorageEdgeData()
|
||||
, id(0)
|
||||
{}
|
||||
StorageEdge(int id, const StorageEdgeData& data): StorageEdgeData(data), id(id) {}
|
||||
|
||||
StorageEdge(int id, const StorageEdgeData& data)
|
||||
: StorageEdgeData(data)
|
||||
, id(id)
|
||||
{}
|
||||
StorageEdge(int id, int sourceNodeId, int targetNodeId, int edgeKind): StorageEdgeData(sourceNodeId, targetNodeId, edgeKind), id(id) {}
|
||||
|
||||
StorageEdge(int id, int sourceNodeId, int targetNodeId, int edgeKind)
|
||||
: StorageEdgeData(sourceNodeId, targetNodeId, edgeKind)
|
||||
, id(id)
|
||||
{}
|
||||
int id;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_EDGE_H
|
||||
#endif // SOURCETRAIL_STORAGE_EDGE_H
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_ELEMENT_COMPONENT_H
|
||||
+37
-67
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_ERROR_H
|
||||
#define SOURCETRAIL_STORAGE_ERROR_H
|
||||
@@ -21,64 +21,34 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageErrorData
|
||||
struct StorageErrorData
|
||||
{
|
||||
StorageErrorData(): message(""), translationUnit(""), fatal(0), indexed(0) {}
|
||||
|
||||
StorageErrorData(std::string message, std::string translationUnit, bool fatal, bool indexed)
|
||||
: message(std::move(message)), translationUnit(std::move(translationUnit)), fatal(fatal), indexed(indexed)
|
||||
{
|
||||
StorageErrorData()
|
||||
: message("")
|
||||
, translationUnit("")
|
||||
, fatal(0)
|
||||
, indexed(0)
|
||||
}
|
||||
|
||||
{}
|
||||
std::string message;
|
||||
std::string translationUnit;
|
||||
bool fatal;
|
||||
bool indexed;
|
||||
};
|
||||
|
||||
StorageErrorData(
|
||||
std::string message,
|
||||
std::string translationUnit,
|
||||
bool fatal,
|
||||
bool indexed
|
||||
)
|
||||
: message(std::move(message))
|
||||
, translationUnit(std::move(translationUnit))
|
||||
, fatal(fatal)
|
||||
, indexed(indexed)
|
||||
{}
|
||||
struct StorageError: public StorageErrorData
|
||||
{
|
||||
StorageError(): StorageErrorData(), id(0) {}
|
||||
|
||||
std::string message;
|
||||
std::string translationUnit;
|
||||
bool fatal;
|
||||
bool indexed;
|
||||
};
|
||||
StorageError(int id, const StorageErrorData& data): StorageErrorData(data), id(id) {}
|
||||
|
||||
struct StorageError : public StorageErrorData
|
||||
StorageError(int id, std::string message, std::string translationUnit, bool fatal, bool indexed)
|
||||
: StorageErrorData(std::move(message), std::move(translationUnit), fatal, indexed), id(id)
|
||||
{
|
||||
StorageError()
|
||||
: StorageErrorData()
|
||||
, id(0)
|
||||
{}
|
||||
}
|
||||
|
||||
StorageError(int id, const StorageErrorData& data)
|
||||
: StorageErrorData(data)
|
||||
, id(id)
|
||||
{}
|
||||
int id;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
StorageError(
|
||||
int id,
|
||||
std::string message,
|
||||
std::string translationUnit,
|
||||
bool fatal,
|
||||
bool indexed
|
||||
)
|
||||
: StorageErrorData(
|
||||
std::move(message),
|
||||
std::move(translationUnit),
|
||||
fatal,
|
||||
indexed
|
||||
)
|
||||
, id(id)
|
||||
{}
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_ERROR_H
|
||||
#endif // SOURCETRAIL_STORAGE_ERROR_H
|
||||
|
||||
+35
-41
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_FILE_H
|
||||
#define SOURCETRAIL_STORAGE_FILE_H
|
||||
@@ -21,33 +21,27 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageFile
|
||||
struct StorageFile
|
||||
{
|
||||
StorageFile(): id(0), filePath(""), languageIdentifier(""), modificationTime(""), indexed(true), complete(true) {}
|
||||
|
||||
StorageFile(int id, std::string filePath, std::string languageIdentifier, std::string modificationTime, bool indexed, bool complete)
|
||||
: id(id)
|
||||
, filePath(std::move(filePath))
|
||||
, languageIdentifier(std::move(languageIdentifier))
|
||||
, modificationTime(std::move(modificationTime))
|
||||
, indexed(indexed)
|
||||
, complete(complete)
|
||||
{
|
||||
StorageFile()
|
||||
: id(0)
|
||||
, filePath("")
|
||||
, languageIdentifier("")
|
||||
, modificationTime("")
|
||||
, indexed(true)
|
||||
, complete(true)
|
||||
{}
|
||||
}
|
||||
|
||||
StorageFile(int id, std::string filePath, std::string languageIdentifier, std::string modificationTime, bool indexed, bool complete)
|
||||
: id(id)
|
||||
, filePath(std::move(filePath))
|
||||
, languageIdentifier(std::move(languageIdentifier))
|
||||
, modificationTime(std::move(modificationTime))
|
||||
, indexed(indexed)
|
||||
, complete(complete)
|
||||
{}
|
||||
int id;
|
||||
std::string filePath;
|
||||
std::string languageIdentifier;
|
||||
std::string modificationTime;
|
||||
bool indexed;
|
||||
bool complete;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
int id;
|
||||
std::string filePath;
|
||||
std::string languageIdentifier;
|
||||
std::string modificationTime;
|
||||
bool indexed;
|
||||
bool complete;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_FILE_H
|
||||
#endif // SOURCETRAIL_STORAGE_FILE_H
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_LOCAL_SYMBOL_H
|
||||
#define SOURCETRAIL_STORAGE_LOCAL_SYMBOL_H
|
||||
@@ -21,38 +21,25 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageLocalSymbolData
|
||||
{
|
||||
StorageLocalSymbolData()
|
||||
: name("")
|
||||
{}
|
||||
struct StorageLocalSymbolData
|
||||
{
|
||||
StorageLocalSymbolData(): name("") {}
|
||||
|
||||
StorageLocalSymbolData(std::string name)
|
||||
: name(std::move(name))
|
||||
{}
|
||||
StorageLocalSymbolData(std::string name): name(std::move(name)) {}
|
||||
|
||||
std::string name;
|
||||
};
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct StorageLocalSymbol : public StorageLocalSymbolData
|
||||
{
|
||||
StorageLocalSymbol()
|
||||
: StorageLocalSymbolData()
|
||||
, id(0)
|
||||
{}
|
||||
struct StorageLocalSymbol: public StorageLocalSymbolData
|
||||
{
|
||||
StorageLocalSymbol(): StorageLocalSymbolData(), id(0) {}
|
||||
|
||||
StorageLocalSymbol(int id, const StorageLocalSymbolData& data)
|
||||
: StorageLocalSymbolData(data)
|
||||
, id(id)
|
||||
{}
|
||||
StorageLocalSymbol(int id, const StorageLocalSymbolData& data): StorageLocalSymbolData(data), id(id) {}
|
||||
|
||||
StorageLocalSymbol(int id, std::string name)
|
||||
: StorageLocalSymbolData(std::move(name))
|
||||
, id(id)
|
||||
{}
|
||||
StorageLocalSymbol(int id, std::string name): StorageLocalSymbolData(std::move(name)), id(id) {}
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
int id;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_LOCAL_SYMBOL_H
|
||||
#endif // SOURCETRAIL_STORAGE_LOCAL_SYMBOL_H
|
||||
|
||||
+30
-45
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_NODE_H
|
||||
#define SOURCETRAIL_STORAGE_NODE_H
|
||||
@@ -21,41 +21,26 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageNodeData
|
||||
{
|
||||
StorageNodeData()
|
||||
: nodeKind(0)
|
||||
, serializedName("")
|
||||
{}
|
||||
struct StorageNodeData
|
||||
{
|
||||
StorageNodeData(): nodeKind(0), serializedName("") {}
|
||||
|
||||
StorageNodeData(int nodeKind, std::string serializedName)
|
||||
: nodeKind(nodeKind)
|
||||
, serializedName(std::move(serializedName))
|
||||
{}
|
||||
StorageNodeData(int nodeKind, std::string serializedName): nodeKind(nodeKind), serializedName(std::move(serializedName)) {}
|
||||
|
||||
int nodeKind;
|
||||
std::string serializedName;
|
||||
};
|
||||
int nodeKind;
|
||||
std::string serializedName;
|
||||
};
|
||||
|
||||
struct StorageNode : public StorageNodeData
|
||||
{
|
||||
StorageNode()
|
||||
: StorageNodeData()
|
||||
, id(0)
|
||||
{}
|
||||
struct StorageNode: public StorageNodeData
|
||||
{
|
||||
StorageNode(): StorageNodeData(), id(0) {}
|
||||
|
||||
StorageNode(int id, int nodeKind, std::string serializedName)
|
||||
: StorageNodeData(nodeKind, std::move(serializedName))
|
||||
, id(id)
|
||||
{}
|
||||
StorageNode(int id, int nodeKind, std::string serializedName): StorageNodeData(nodeKind, std::move(serializedName)), id(id) {}
|
||||
|
||||
StorageNode(int id, const StorageNodeData& data)
|
||||
: StorageNodeData(data)
|
||||
, id(id)
|
||||
{}
|
||||
StorageNode(int id, const StorageNodeData& data): StorageNodeData(data), id(id) {}
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
int id;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_NODE_H
|
||||
#endif // SOURCETRAIL_STORAGE_NODE_H
|
||||
|
||||
@@ -1,39 +1,33 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_OCCURRENCE_H
|
||||
#define SOURCETRAIL_STORAGE_OCCURRENCE_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageOccurrence
|
||||
{
|
||||
StorageOccurrence()
|
||||
: elementId(0)
|
||||
, sourceLocationId(0)
|
||||
{}
|
||||
struct StorageOccurrence
|
||||
{
|
||||
StorageOccurrence(): elementId(0), sourceLocationId(0) {}
|
||||
|
||||
StorageOccurrence(int elementId, int sourceLocationId)
|
||||
: elementId(elementId)
|
||||
, sourceLocationId(sourceLocationId)
|
||||
{}
|
||||
StorageOccurrence(int elementId, int sourceLocationId): elementId(elementId), sourceLocationId(sourceLocationId) {}
|
||||
|
||||
int elementId;
|
||||
int sourceLocationId;
|
||||
};
|
||||
}
|
||||
int elementId;
|
||||
int sourceLocationId;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_OCCURRENCE_H
|
||||
#endif // SOURCETRAIL_STORAGE_OCCURRENCE_H
|
||||
|
||||
@@ -1,71 +1,63 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SOURCE_LOCATION_H
|
||||
#define SOURCETRAIL_STORAGE_SOURCE_LOCATION_H
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageSourceLocationData
|
||||
struct StorageSourceLocationData
|
||||
{
|
||||
StorageSourceLocationData()
|
||||
: fileNodeId(0), startLineNumber(-1), startColumnNumber(-1), endLineNumber(-1), endColumnNumber(-1), locationKind(0)
|
||||
{
|
||||
StorageSourceLocationData()
|
||||
: fileNodeId(0)
|
||||
, startLineNumber(-1)
|
||||
, startColumnNumber(-1)
|
||||
, endLineNumber(-1)
|
||||
, endColumnNumber(-1)
|
||||
, locationKind(0)
|
||||
{}
|
||||
}
|
||||
|
||||
StorageSourceLocationData(int fileNodeId, int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber, int locationKind)
|
||||
: fileNodeId(fileNodeId)
|
||||
, startLineNumber(startLineNumber)
|
||||
, startColumnNumber(startColumnNumber)
|
||||
, endLineNumber(endLineNumber)
|
||||
, endColumnNumber(endColumnNumber)
|
||||
, locationKind(locationKind)
|
||||
{}
|
||||
|
||||
int fileNodeId;
|
||||
int startLineNumber;
|
||||
int startColumnNumber;
|
||||
int endLineNumber;
|
||||
int endColumnNumber;
|
||||
int locationKind;
|
||||
};
|
||||
|
||||
struct StorageSourceLocation : public StorageSourceLocationData
|
||||
StorageSourceLocationData(int fileNodeId, int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber, int locationKind)
|
||||
: fileNodeId(fileNodeId)
|
||||
, startLineNumber(startLineNumber)
|
||||
, startColumnNumber(startColumnNumber)
|
||||
, endLineNumber(endLineNumber)
|
||||
, endColumnNumber(endColumnNumber)
|
||||
, locationKind(locationKind)
|
||||
{
|
||||
StorageSourceLocation()
|
||||
: StorageSourceLocationData()
|
||||
, id(0)
|
||||
{}
|
||||
}
|
||||
|
||||
StorageSourceLocation(int id, const StorageSourceLocationData& data)
|
||||
: StorageSourceLocationData(data)
|
||||
, id(id)
|
||||
{}
|
||||
int fileNodeId;
|
||||
int startLineNumber;
|
||||
int startColumnNumber;
|
||||
int endLineNumber;
|
||||
int endColumnNumber;
|
||||
int locationKind;
|
||||
};
|
||||
|
||||
StorageSourceLocation(int id, int fileNodeId, int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber, int locationKind)
|
||||
: StorageSourceLocationData(fileNodeId, startLineNumber, startColumnNumber, endLineNumber, endColumnNumber, locationKind)
|
||||
, id(id)
|
||||
{}
|
||||
struct StorageSourceLocation: public StorageSourceLocationData
|
||||
{
|
||||
StorageSourceLocation(): StorageSourceLocationData(), id(0) {}
|
||||
|
||||
int id;
|
||||
};
|
||||
}
|
||||
StorageSourceLocation(int id, const StorageSourceLocationData& data): StorageSourceLocationData(data), id(id) {}
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_SOURCE_LOCATION_H
|
||||
StorageSourceLocation(
|
||||
int id, int fileNodeId, int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber, int locationKind)
|
||||
: StorageSourceLocationData(fileNodeId, startLineNumber, startColumnNumber, endLineNumber, endColumnNumber, locationKind), id(id)
|
||||
{
|
||||
}
|
||||
|
||||
int id;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_SOURCE_LOCATION_H
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SYMBOL_H
|
||||
#define SOURCETRAIL_STORAGE_SYMBOL_H
|
||||
@@ -21,21 +21,15 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
struct StorageSymbol
|
||||
{
|
||||
StorageSymbol()
|
||||
: id(0)
|
||||
, definitionKind(definitionKindToInt(DefinitionKind::EXPLICIT))
|
||||
{}
|
||||
struct StorageSymbol
|
||||
{
|
||||
StorageSymbol(): id(0), definitionKind(definitionKindToInt(DefinitionKind::EXPLICIT)) {}
|
||||
|
||||
StorageSymbol(int id, int definitionKind)
|
||||
: id(id)
|
||||
, definitionKind(definitionKind)
|
||||
{}
|
||||
StorageSymbol(int id, int definitionKind): id(id), definitionKind(definitionKind) {}
|
||||
|
||||
int id;
|
||||
int definitionKind;
|
||||
};
|
||||
}
|
||||
int id;
|
||||
int definitionKind;
|
||||
};
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_STORAGE_SYMBOL_H
|
||||
#endif // SOURCETRAIL_STORAGE_SYMBOL_H
|
||||
|
||||
+42
-43
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_SYMBOL_KIND_H
|
||||
#define SOURCETRAIL_SYMBOL_KIND_H
|
||||
@@ -21,34 +21,33 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
/**
|
||||
* Enum providing all possible values for kinds of symbols that can be recorded using the SourcetrailDBWriter interface.
|
||||
*/
|
||||
enum class SymbolKind
|
||||
{
|
||||
TYPE,
|
||||
BUILTIN_TYPE,
|
||||
MODULE,
|
||||
NAMESPACE,
|
||||
PACKAGE,
|
||||
STRUCT,
|
||||
CLASS,
|
||||
INTERFACE,
|
||||
ANNOTATION,
|
||||
GLOBAL_VARIABLE,
|
||||
FIELD,
|
||||
FUNCTION,
|
||||
METHOD,
|
||||
ENUM,
|
||||
ENUM_CONSTANT,
|
||||
TYPEDEF,
|
||||
TEMPLATE_PARAMETER,
|
||||
TYPE_PARAMETER,
|
||||
MACRO,
|
||||
UNION
|
||||
};
|
||||
/**
|
||||
* Enum providing all possible values for kinds of symbols that can be recorded using the SourcetrailDBWriter interface.
|
||||
*/
|
||||
enum class SymbolKind
|
||||
{
|
||||
TYPE,
|
||||
BUILTIN_TYPE,
|
||||
MODULE,
|
||||
NAMESPACE,
|
||||
PACKAGE,
|
||||
STRUCT,
|
||||
CLASS,
|
||||
INTERFACE,
|
||||
ANNOTATION,
|
||||
GLOBAL_VARIABLE,
|
||||
FIELD,
|
||||
FUNCTION,
|
||||
METHOD,
|
||||
ENUM,
|
||||
ENUM_CONSTANT,
|
||||
TYPEDEF,
|
||||
TYPE_PARAMETER,
|
||||
MACRO,
|
||||
UNION
|
||||
};
|
||||
|
||||
NodeKind symbolKindToNodeKind(SymbolKind kind);
|
||||
}
|
||||
NodeKind symbolKindToNodeKind(SymbolKind kind);
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_SYMBOL_KIND_H
|
||||
#endif // SOURCETRAIL_SYMBOL_KIND_H
|
||||
|
||||
+23
-23
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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_UTILITY_H
|
||||
#define SOURCETRAIL_UTILITY_H
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
bool getFileExists(const std::string& filePath);
|
||||
std::string getFileContent(const std::string& filePath);
|
||||
std::string getDateTimeString(const time_t& time);
|
||||
int getLineCount(const std::string s);
|
||||
}
|
||||
}
|
||||
namespace utility
|
||||
{
|
||||
bool getFileExists(const std::string& filePath);
|
||||
std::string getFileContent(const std::string& filePath);
|
||||
std::string getDateTimeString(const time_t& time);
|
||||
int getLineCount(const std::string s);
|
||||
} // namespace utility
|
||||
} // namespace sourcetrail
|
||||
|
||||
#endif // SOURCETRAIL_UTILITY_H
|
||||
#endif // SOURCETRAIL_UTILITY_H
|
||||
|
||||
+871
-915
File diff suppressed because it is too large
Load Diff
+33
-33
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "DefinitionKind.h"
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
int definitionKindToInt(DefinitionKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
DefinitionKind intToDefinitionKind(int i)
|
||||
{
|
||||
const DefinitionKind kinds[] = { DefinitionKind::IMPLICIT, DefinitionKind::EXPLICIT };
|
||||
|
||||
for (DefinitionKind kind : kinds)
|
||||
{
|
||||
if (i == definitionKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return DefinitionKind::EXPLICIT;
|
||||
}
|
||||
int definitionKindToInt(DefinitionKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
DefinitionKind intToDefinitionKind(int i)
|
||||
{
|
||||
const DefinitionKind kinds[] = {DefinitionKind::IMPLICIT, DefinitionKind::EXPLICIT};
|
||||
|
||||
for (DefinitionKind kind: kinds)
|
||||
{
|
||||
if (i == definitionKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return DefinitionKind::EXPLICIT;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+44
-49
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "EdgeKind.h"
|
||||
|
||||
@@ -20,39 +20,34 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
int edgeKindToInt(EdgeKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
EdgeKind intToEdgeKind(int i)
|
||||
{
|
||||
const EdgeKind kinds[] = {
|
||||
EdgeKind::MEMBER,
|
||||
EdgeKind::TYPE_USAGE,
|
||||
EdgeKind::USAGE,
|
||||
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
|
||||
};
|
||||
|
||||
for (EdgeKind kind : kinds)
|
||||
{
|
||||
if (i == edgeKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return EdgeKind::UNKNOWN;
|
||||
}
|
||||
int edgeKindToInt(EdgeKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
EdgeKind intToEdgeKind(int i)
|
||||
{
|
||||
const EdgeKind kinds[] = {
|
||||
EdgeKind::MEMBER,
|
||||
EdgeKind::TYPE_USAGE,
|
||||
EdgeKind::USAGE,
|
||||
EdgeKind::CALL,
|
||||
EdgeKind::INHERITANCE,
|
||||
EdgeKind::OVERRIDE,
|
||||
EdgeKind::TYPE_ARGUMENT,
|
||||
EdgeKind::TEMPLATE_SPECIALIZATION,
|
||||
EdgeKind::INCLUDE,
|
||||
EdgeKind::IMPORT,
|
||||
EdgeKind::MACRO_USAGE};
|
||||
|
||||
for (EdgeKind kind: kinds)
|
||||
{
|
||||
if (i == edgeKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return EdgeKind::UNKNOWN;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.");
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
+43
-43
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "LocationKind.h"
|
||||
|
||||
@@ -20,33 +20,33 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
int locationKindToInt(LocationKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
LocationKind intToLocationKind(int i)
|
||||
{
|
||||
const LocationKind kinds[] = {
|
||||
LocationKind::TOKEN,
|
||||
LocationKind::SCOPE,
|
||||
LocationKind::QUALIFIER,
|
||||
LocationKind::LOCAL_SYMBOL,
|
||||
LocationKind::SIGNATURE,
|
||||
LocationKind::ATOMIC_RANGE,
|
||||
LocationKind::INDEXER_ERROR,
|
||||
LocationKind::FULLTEXT_SEARCH,
|
||||
LocationKind::SCREEN_SEARCH
|
||||
};
|
||||
|
||||
for (LocationKind kind : kinds)
|
||||
{
|
||||
if (i == locationKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
throw SourcetrailException("Unable to convert integer \"" + std::to_string(i) + "\" to location kind.");
|
||||
}
|
||||
int locationKindToInt(LocationKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
LocationKind intToLocationKind(int i)
|
||||
{
|
||||
const LocationKind kinds[] = {
|
||||
LocationKind::TOKEN,
|
||||
LocationKind::SCOPE,
|
||||
LocationKind::QUALIFIER,
|
||||
LocationKind::LOCAL_SYMBOL,
|
||||
LocationKind::SIGNATURE,
|
||||
LocationKind::ATOMIC_RANGE,
|
||||
LocationKind::INDEXER_ERROR,
|
||||
LocationKind::FULLTEXT_SEARCH,
|
||||
LocationKind::SCREEN_SEARCH,
|
||||
LocationKind::UNSOLVED};
|
||||
|
||||
for (LocationKind kind: kinds)
|
||||
{
|
||||
if (i == locationKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
throw SourcetrailException("Unable to convert integer \"" + std::to_string(i) + "\" to location kind.");
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+113
-118
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "NameHierarchy.h"
|
||||
|
||||
@@ -20,111 +20,106 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
std::string serializeNameHierarchyToJson(const NameHierarchy& nameHierarchy)
|
||||
std::string serializeNameHierarchyToJson(const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
typedef nlohmann::json json;
|
||||
|
||||
nlohmann::json j;
|
||||
|
||||
j["name_delimiter"] = nameHierarchy.nameDelimiter;
|
||||
|
||||
for (const NameElement& nameElement: nameHierarchy.nameElements)
|
||||
{
|
||||
typedef nlohmann::json json;
|
||||
|
||||
nlohmann::json j;
|
||||
|
||||
j["name_delimiter"] = nameHierarchy.nameDelimiter;
|
||||
|
||||
for (const NameElement& nameElement : nameHierarchy.nameElements)
|
||||
{
|
||||
j["name_elements"].push_back(
|
||||
{
|
||||
{ "prefix", nameElement.prefix } ,
|
||||
{ "name", nameElement.name } ,
|
||||
{ "postfix", nameElement.postfix }
|
||||
});
|
||||
}
|
||||
|
||||
return j.dump(4);
|
||||
j["name_elements"].push_back({{"prefix", nameElement.prefix}, {"name", nameElement.name}, {"postfix", nameElement.postfix}});
|
||||
}
|
||||
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error)
|
||||
{
|
||||
typedef nlohmann::json json;
|
||||
|
||||
NameHierarchy nameHierarchy;
|
||||
try
|
||||
{
|
||||
json j = nlohmann::json::parse(serializedNameHierarchy);
|
||||
{
|
||||
json jDelimiter = j["name_delimiter"];
|
||||
if (jDelimiter.is_string())
|
||||
{
|
||||
nameHierarchy.nameDelimiter = jDelimiter.get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
json jNameElements = j["name_elements"];
|
||||
if (jNameElements.is_array())
|
||||
{
|
||||
for (json::iterator it = jNameElements.begin(); it != jNameElements.end(); ++it)
|
||||
{
|
||||
NameElement nameElement;
|
||||
{
|
||||
json jPrefix = it.value()["prefix"];
|
||||
if (jPrefix.is_string())
|
||||
{
|
||||
nameElement.prefix = jPrefix.get<std::string>();
|
||||
}
|
||||
}
|
||||
{
|
||||
json jName = it.value()["name"];
|
||||
if (jName.is_string())
|
||||
{
|
||||
nameElement.name = jName.get<std::string>();
|
||||
}
|
||||
}
|
||||
{
|
||||
json jPostfix = it.value()["postfix"];
|
||||
if (jPostfix.is_string())
|
||||
{
|
||||
nameElement.postfix = jPostfix.get<std::string>();
|
||||
}
|
||||
}
|
||||
nameHierarchy.nameElements.push_back(nameElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (json::exception& e)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = e.what();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = "Exception thrown during NameHierarchy deserialization";
|
||||
}
|
||||
}
|
||||
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
std::string serializeNameHierarchyToDatabaseString(const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
static std::string META_DELIMITER = "\tm";
|
||||
static std::string NAME_DELIMITER = "\tn";
|
||||
static std::string PARTS_DELIMITER = "\ts";
|
||||
static std::string SIGNATURE_DELIMITER = "\tp";
|
||||
|
||||
std::string serialized = nameHierarchy.nameDelimiter + META_DELIMITER;
|
||||
for (size_t i = 0; i < nameHierarchy.nameElements.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
serialized += NAME_DELIMITER;
|
||||
}
|
||||
const NameElement& nameElement = nameHierarchy.nameElements[i];
|
||||
serialized += nameElement.name + PARTS_DELIMITER + nameElement.prefix + SIGNATURE_DELIMITER + nameElement.postfix;
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
return j.dump(4);
|
||||
}
|
||||
|
||||
NameHierarchy deserializeNameHierarchyFromJson(const std::string& serializedNameHierarchy, std::string* error)
|
||||
{
|
||||
typedef nlohmann::json json;
|
||||
|
||||
NameHierarchy nameHierarchy;
|
||||
try
|
||||
{
|
||||
json j = nlohmann::json::parse(serializedNameHierarchy);
|
||||
{
|
||||
json jDelimiter = j["name_delimiter"];
|
||||
if (jDelimiter.is_string())
|
||||
{
|
||||
nameHierarchy.nameDelimiter = jDelimiter.get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
json jNameElements = j["name_elements"];
|
||||
if (jNameElements.is_array())
|
||||
{
|
||||
for (json::iterator it = jNameElements.begin(); it != jNameElements.end(); ++it)
|
||||
{
|
||||
NameElement nameElement;
|
||||
{
|
||||
json jPrefix = it.value()["prefix"];
|
||||
if (jPrefix.is_string())
|
||||
{
|
||||
nameElement.prefix = jPrefix.get<std::string>();
|
||||
}
|
||||
}
|
||||
{
|
||||
json jName = it.value()["name"];
|
||||
if (jName.is_string())
|
||||
{
|
||||
nameElement.name = jName.get<std::string>();
|
||||
}
|
||||
}
|
||||
{
|
||||
json jPostfix = it.value()["postfix"];
|
||||
if (jPostfix.is_string())
|
||||
{
|
||||
nameElement.postfix = jPostfix.get<std::string>();
|
||||
}
|
||||
}
|
||||
nameHierarchy.nameElements.push_back(nameElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (json::exception& e)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = e.what();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = "Exception thrown during NameHierarchy deserialization";
|
||||
}
|
||||
}
|
||||
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
std::string serializeNameHierarchyToDatabaseString(const NameHierarchy& nameHierarchy)
|
||||
{
|
||||
static std::string META_DELIMITER = "\tm";
|
||||
static std::string NAME_DELIMITER = "\tn";
|
||||
static std::string PARTS_DELIMITER = "\ts";
|
||||
static std::string SIGNATURE_DELIMITER = "\tp";
|
||||
|
||||
std::string serialized = nameHierarchy.nameDelimiter + META_DELIMITER;
|
||||
for (size_t i = 0; i < nameHierarchy.nameElements.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
serialized += NAME_DELIMITER;
|
||||
}
|
||||
const NameElement& nameElement = nameHierarchy.nameElements[i];
|
||||
serialized += nameElement.name + PARTS_DELIMITER + nameElement.prefix + SIGNATURE_DELIMITER + nameElement.postfix;
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+53
-56
@@ -1,63 +1,60 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "NodeKind.h"
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
int nodeKindToInt(NodeKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
NodeKind intToNodeKind(int i)
|
||||
{
|
||||
const NodeKind kinds[] = {
|
||||
NodeKind::UNKNOWN,
|
||||
NodeKind::TYPE,
|
||||
NodeKind::BUILTIN_TYPE,
|
||||
NodeKind::MODULE,
|
||||
NodeKind::NAMESPACE,
|
||||
NodeKind::PACKAGE,
|
||||
NodeKind::STRUCT,
|
||||
NodeKind::CLASS,
|
||||
NodeKind::INTERFACE,
|
||||
NodeKind::ANNOTATION,
|
||||
NodeKind::GLOBAL_VARIABLE,
|
||||
NodeKind::FIELD,
|
||||
NodeKind::FUNCTION,
|
||||
NodeKind::METHOD,
|
||||
NodeKind::ENUM,
|
||||
NodeKind::ENUM_CONSTANT,
|
||||
NodeKind::TYPEDEF,
|
||||
NodeKind::TEMPLATE_PARAMETER,
|
||||
NodeKind::TYPE_PARAMETER,
|
||||
NodeKind::FILE,
|
||||
NodeKind::MACRO,
|
||||
NodeKind::UNION
|
||||
};
|
||||
|
||||
for (NodeKind kind : kinds)
|
||||
{
|
||||
if (i == nodeKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return NodeKind::UNKNOWN;
|
||||
}
|
||||
int nodeKindToInt(NodeKind kind)
|
||||
{
|
||||
return static_cast<int>(kind);
|
||||
}
|
||||
|
||||
NodeKind intToNodeKind(int i)
|
||||
{
|
||||
const NodeKind kinds[] = {NodeKind::UNKNOWN,
|
||||
NodeKind::TYPE,
|
||||
NodeKind::BUILTIN_TYPE,
|
||||
NodeKind::MODULE,
|
||||
NodeKind::NAMESPACE,
|
||||
NodeKind::PACKAGE,
|
||||
NodeKind::STRUCT,
|
||||
NodeKind::CLASS,
|
||||
NodeKind::INTERFACE,
|
||||
NodeKind::ANNOTATION,
|
||||
NodeKind::GLOBAL_VARIABLE,
|
||||
NodeKind::FIELD,
|
||||
NodeKind::FUNCTION,
|
||||
NodeKind::METHOD,
|
||||
NodeKind::ENUM,
|
||||
NodeKind::ENUM_CONSTANT,
|
||||
NodeKind::TYPEDEF,
|
||||
NodeKind::TYPE_PARAMETER,
|
||||
NodeKind::FILE,
|
||||
NodeKind::MACRO,
|
||||
NodeKind::UNION};
|
||||
|
||||
for (NodeKind kind: kinds)
|
||||
{
|
||||
if (i == nodeKindToInt(kind))
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
}
|
||||
|
||||
return NodeKind::UNKNOWN;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+41
-47
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "ReferenceKind.h"
|
||||
|
||||
@@ -20,39 +20,33 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
EdgeKind referenceKindToEdgeKind(ReferenceKind kind)
|
||||
EdgeKind referenceKindToEdgeKind(ReferenceKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case ReferenceKind::TYPE_USAGE:
|
||||
return EdgeKind::TYPE_USAGE;
|
||||
case ReferenceKind::USAGE:
|
||||
return EdgeKind::USAGE;
|
||||
case ReferenceKind::CALL:
|
||||
return EdgeKind::CALL;
|
||||
case ReferenceKind::INHERITANCE:
|
||||
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:
|
||||
return EdgeKind::IMPORT;
|
||||
case ReferenceKind::MACRO_USAGE:
|
||||
return EdgeKind::MACRO_USAGE;
|
||||
case ReferenceKind::ANNOTATION_USAGE:
|
||||
return EdgeKind::ANNOTATION_USAGE;
|
||||
}
|
||||
return EdgeKind::UNKNOWN;
|
||||
case ReferenceKind::TYPE_USAGE:
|
||||
return EdgeKind::TYPE_USAGE;
|
||||
case ReferenceKind::USAGE:
|
||||
return EdgeKind::USAGE;
|
||||
case ReferenceKind::CALL:
|
||||
return EdgeKind::CALL;
|
||||
case ReferenceKind::INHERITANCE:
|
||||
return EdgeKind::INHERITANCE;
|
||||
case ReferenceKind::OVERRIDE:
|
||||
return EdgeKind::OVERRIDE;
|
||||
case ReferenceKind::TYPE_ARGUMENT:
|
||||
return EdgeKind::TYPE_ARGUMENT;
|
||||
case ReferenceKind::TEMPLATE_SPECIALIZATION:
|
||||
return EdgeKind::TEMPLATE_SPECIALIZATION;
|
||||
case ReferenceKind::INCLUDE:
|
||||
return EdgeKind::INCLUDE;
|
||||
case ReferenceKind::IMPORT:
|
||||
return EdgeKind::IMPORT;
|
||||
case ReferenceKind::MACRO_USAGE:
|
||||
return EdgeKind::MACRO_USAGE;
|
||||
case ReferenceKind::ANNOTATION_USAGE:
|
||||
return EdgeKind::ANNOTATION_USAGE;
|
||||
}
|
||||
return EdgeKind::UNKNOWN;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+770
-737
File diff suppressed because it is too large
Load Diff
+57
-59
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "SymbolKind.h"
|
||||
|
||||
@@ -20,51 +20,49 @@
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
NodeKind symbolKindToNodeKind(SymbolKind kind)
|
||||
NodeKind symbolKindToNodeKind(SymbolKind kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
switch (kind)
|
||||
{
|
||||
case SymbolKind::TYPE:
|
||||
return NodeKind::TYPE;
|
||||
case SymbolKind::BUILTIN_TYPE:
|
||||
return NodeKind::BUILTIN_TYPE;
|
||||
case SymbolKind::MODULE:
|
||||
return NodeKind::MODULE;
|
||||
case SymbolKind::NAMESPACE:
|
||||
return NodeKind::NAMESPACE;
|
||||
case SymbolKind::PACKAGE:
|
||||
return NodeKind::PACKAGE;
|
||||
case SymbolKind::STRUCT:
|
||||
return NodeKind::STRUCT;
|
||||
case SymbolKind::CLASS:
|
||||
return NodeKind::CLASS;
|
||||
case SymbolKind::INTERFACE:
|
||||
return NodeKind::INTERFACE;
|
||||
case SymbolKind::ANNOTATION:
|
||||
return NodeKind::ANNOTATION;
|
||||
case SymbolKind::GLOBAL_VARIABLE:
|
||||
return NodeKind::GLOBAL_VARIABLE;
|
||||
case SymbolKind::FIELD:
|
||||
return NodeKind::FIELD;
|
||||
case SymbolKind::FUNCTION:
|
||||
return NodeKind::FUNCTION;
|
||||
case SymbolKind::METHOD:
|
||||
return NodeKind::METHOD;
|
||||
case SymbolKind::ENUM:
|
||||
return NodeKind::ENUM;
|
||||
case SymbolKind::ENUM_CONSTANT:
|
||||
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:
|
||||
return NodeKind::MACRO;
|
||||
case SymbolKind::UNION:
|
||||
return NodeKind::UNION;
|
||||
}
|
||||
return NodeKind::UNKNOWN;
|
||||
case SymbolKind::TYPE:
|
||||
return NodeKind::TYPE;
|
||||
case SymbolKind::BUILTIN_TYPE:
|
||||
return NodeKind::BUILTIN_TYPE;
|
||||
case SymbolKind::MODULE:
|
||||
return NodeKind::MODULE;
|
||||
case SymbolKind::NAMESPACE:
|
||||
return NodeKind::NAMESPACE;
|
||||
case SymbolKind::PACKAGE:
|
||||
return NodeKind::PACKAGE;
|
||||
case SymbolKind::STRUCT:
|
||||
return NodeKind::STRUCT;
|
||||
case SymbolKind::CLASS:
|
||||
return NodeKind::CLASS;
|
||||
case SymbolKind::INTERFACE:
|
||||
return NodeKind::INTERFACE;
|
||||
case SymbolKind::ANNOTATION:
|
||||
return NodeKind::ANNOTATION;
|
||||
case SymbolKind::GLOBAL_VARIABLE:
|
||||
return NodeKind::GLOBAL_VARIABLE;
|
||||
case SymbolKind::FIELD:
|
||||
return NodeKind::FIELD;
|
||||
case SymbolKind::FUNCTION:
|
||||
return NodeKind::FUNCTION;
|
||||
case SymbolKind::METHOD:
|
||||
return NodeKind::METHOD;
|
||||
case SymbolKind::ENUM:
|
||||
return NodeKind::ENUM;
|
||||
case SymbolKind::ENUM_CONSTANT:
|
||||
return NodeKind::ENUM_CONSTANT;
|
||||
case SymbolKind::TYPEDEF:
|
||||
return NodeKind::TYPEDEF;
|
||||
case SymbolKind::TYPE_PARAMETER:
|
||||
return NodeKind::TYPE_PARAMETER;
|
||||
case SymbolKind::MACRO:
|
||||
return NodeKind::MACRO;
|
||||
case SymbolKind::UNION:
|
||||
return NodeKind::UNION;
|
||||
}
|
||||
return NodeKind::UNKNOWN;
|
||||
}
|
||||
} // namespace sourcetrail
|
||||
|
||||
+126
-50
@@ -1,70 +1,146 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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 "utility.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "SourcetrailException.h"
|
||||
|
||||
namespace sourcetrail
|
||||
namespace
|
||||
{
|
||||
namespace utility
|
||||
std::istream& safeGetline(std::istream& is, std::string& t)
|
||||
{
|
||||
t.clear();
|
||||
|
||||
// The characters in the stream are read one-by-one using a std::streambuf.
|
||||
// That is faster than reading them one-by-one using the std::istream.
|
||||
// Code that uses streambuf this way must be guarded by a sentry object.
|
||||
// The sentry object performs various tasks,
|
||||
// such as thread synchronization and updating the stream state.
|
||||
|
||||
std::istream::sentry se(is, true);
|
||||
std::streambuf* sb = is.rdbuf();
|
||||
|
||||
while (true)
|
||||
{
|
||||
bool getFileExists(const std::string& filePath)
|
||||
int c = sb->sbumpc();
|
||||
switch (c)
|
||||
{
|
||||
std::ifstream file(filePath);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
std::string getFileContent(const std::string& filePath)
|
||||
{
|
||||
std::string content;
|
||||
|
||||
std::ifstream file;
|
||||
file.open(filePath);
|
||||
|
||||
if (file.fail())
|
||||
case '\n':
|
||||
return is;
|
||||
case '\r':
|
||||
if (sb->sgetc() == '\n')
|
||||
{
|
||||
throw SourcetrailException("Could not open file " + filePath);
|
||||
sb->sbumpc();
|
||||
}
|
||||
|
||||
for (std::string line; std::getline(file, line); )
|
||||
return is;
|
||||
case std::streambuf::traits_type::eof():
|
||||
// Also handle the case when the last line has no line ending
|
||||
if (t.empty())
|
||||
{
|
||||
content += line + "\n";
|
||||
is.setstate(std::ios::eofbit);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string getDateTimeString(const time_t& time)
|
||||
{
|
||||
std::tm* ptm = std::localtime(&time);
|
||||
char buffer[32];
|
||||
std::strftime(buffer, 32, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int getLineCount(const std::string s)
|
||||
{
|
||||
return std::count(s.begin(), s.end(), '\n');
|
||||
return is;
|
||||
default:
|
||||
t += (char)c;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace sourcetrail
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
bool getFileExists(const std::string& filePath)
|
||||
{
|
||||
std::ifstream file(filePath);
|
||||
return file.good();
|
||||
}
|
||||
|
||||
std::string getFileContent(const std::string& filePath)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
|
||||
try
|
||||
{
|
||||
std::ifstream srcFile;
|
||||
srcFile.open(filePath, std::ios::binary | std::ios::in);
|
||||
|
||||
if (srcFile.fail())
|
||||
{
|
||||
throw SourcetrailException("Could not open file " + filePath);
|
||||
}
|
||||
|
||||
while (!srcFile.eof())
|
||||
{
|
||||
std::string line;
|
||||
safeGetline(srcFile, line);
|
||||
lines.push_back(line + '\n');
|
||||
}
|
||||
|
||||
srcFile.close();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
throw SourcetrailException("Exception thrown while reading file \"" + filePath + "\": " + e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
throw SourcetrailException("Unknown exception thrown while reading file \"" + filePath + "\"");
|
||||
}
|
||||
|
||||
if (!lines.empty())
|
||||
{
|
||||
std::string last = lines.back().substr(0, lines.back().size() - 1);
|
||||
lines.pop_back();
|
||||
if (!last.empty())
|
||||
{
|
||||
lines.push_back(last);
|
||||
}
|
||||
}
|
||||
|
||||
std::string content;
|
||||
|
||||
for (const std::string& line: lines)
|
||||
{
|
||||
content += line;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string getDateTimeString(const time_t& time)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
std::tm* ptm = std::localtime(&time);
|
||||
#pragma warning(pop)
|
||||
char buffer[32];
|
||||
std::strftime(buffer, 32, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int getLineCount(const std::string s)
|
||||
{
|
||||
return static_cast<int>(std::count(s.begin(), s.end(), '\n'));
|
||||
}
|
||||
} // namespace utility
|
||||
} // namespace sourcetrail
|
||||
|
||||
@@ -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} ${CMAKE_DL_LIBS})
|
||||
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
@@ -28,6 +28,7 @@ int main(int argc, const char *argv[])
|
||||
if (argc < 3 || argc > 4)
|
||||
{
|
||||
std::cout << "usage: cpp_api_example <database_path> <source_path> <optional:database_version>";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string dbPath = argv[1];
|
||||
|
||||
@@ -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} ${CMAKE_DL_LIBS})
|
||||
|
||||
|
||||
# --- Configure Sourcetrail Project File ---
|
||||
|
||||
@@ -33,6 +33,7 @@ int main(int argc, const char *argv[])
|
||||
if (argc < 3 || argc > 4)
|
||||
{
|
||||
std::cout << "usage: poetry_indexer <database_path> <source_path> <optional:database_version>";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string dbPath = argv[1];
|
||||
|
||||
@@ -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,17 +39,16 @@ 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,
|
||||
REFERENCE_ANNOTATION_USAGE
|
||||
};
|
||||
|
||||
std::string getVersionString();
|
||||
|
||||
int getSupportedDatabaseVersion();
|
||||
|
||||
std::string getLastError();
|
||||
@@ -93,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:
|
||||
@@ -108,6 +100,11 @@ namespace
|
||||
|
||||
sourcetrail::SourcetrailDBWriter dbWriter;
|
||||
|
||||
std::string getVersionString()
|
||||
{
|
||||
return dbWriter.getVersionString();
|
||||
}
|
||||
|
||||
int getSupportedDatabaseVersion()
|
||||
{
|
||||
return dbWriter.getSupportedDatabaseVersion();
|
||||
@@ -220,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.p1
|
||||
@@ -1 +0,0 @@
|
||||
@VERSION_STRING_UNDERSCORE@
|
||||
Reference in New Issue
Block a user