diff --git a/.gitignore b/.gitignore
index 0b7c2351f..fb62cc43e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,7 +50,6 @@ compile_commands.json
/emake.data.bak
/emake.data
/.emake/sched/Linux/emake.sched
-/src/lua-prefix
/CTestTestfile.cmake
/DartConfiguration.tcl
/Testing
diff --git a/.gitmodules b/.gitmodules
index 1e89c9e05..c68928d5b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,11 +2,3 @@
path = src/rct
url = https://github.com/Andersbakken/rct
branch = master
-[submodule "src/selene"]
- path = src/selene
- url = https://github.com/jeremyong/Selene.git
- branch = master
-[submodule "src/lua"]
- path = src/lua
- url = https://github.com/LuaDist/lua.git
- branch = master
diff --git a/configure b/configure
index 269716d4a..104d1d9f7 100755
--- a/configure
+++ b/configure
@@ -21,8 +21,6 @@ function usage ()
echo " --clang-libdir [arg] Sets the libdir RTags will use for clang."
echo " --cotire Enable cotire when building RTags"
echo " --emacs Use arg instead of \"emacs\" when byte-compiling elisp"
- echo " --lua-enabled Enable LUA AST scripting"
- echo " --no-lua-files-install Don't install RTags lua files"
echo " --no-elisp-files-install Don't install RTags elisp files"
echo " --no-elisp-bytecompile Don't bytecompile RTags elisp files"
echo " --elisp-install-location [arg] Install elisp files to this location"
@@ -77,9 +75,6 @@ while [ -n "$1" ]; do
shift
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=\"$1\""
;;
- --lua-enabled)
- CMAKE_ARGS="${CMAKE_ARGS} -DLUA_ENABLED=1"
- ;;
--clang-libraries)
shift
CMAKE_ARGS="${CMAKE_ARGS} -DLIBCLANG_LIBRARIES=\"$1\""
@@ -99,9 +94,6 @@ while [ -n "$1" ]; do
shift
CMAKE_ARGS="${CMAKE_ARGS} -DEMACS=\"$1\""
;;
- --no-lua-files-install)
- CMAKE_ARGS="${CMAKE_ARGS} -DRTAGS_NO_LUA_FILES=1"
- ;;
--no-elisp-files-install)
CMAKE_ARGS="${CMAKE_ARGS} -DRTAGS_NO_ELISP_FILES=1"
;;
diff --git a/scripts/travis.sh b/scripts/travis.sh
index b027d7635..4a391f40e 100755
--- a/scripts/travis.sh
+++ b/scripts/travis.sh
@@ -22,9 +22,6 @@
#
# Description: The following variables can be changed from the build matrix:
# - ASAN (default value is "1")
-# - LUA_VERSION (default value is "5.3.2")
-# - LUA_DISABLE (default value is "", set it to anything to disable lua
-# extension for that matrix)
declare -a CMAKE_PARAMS=("-DCMAKE_CXX_COMPILER=$CXX$COMPILER_VERSION"
"-DCMAKE_C_COMPILER=$CC$COMPILER_VERSION"
"-DBUILD_TESTING=1")
@@ -33,14 +30,6 @@ if [ "$ASAN" ]; then
CMAKE_PARAMS+=("-DASAN=address,undefined")
fi
-LUA_DISABLE=${LUA_DISABLE:-""}
-if [ ! $LUA_DISABLE ]; then
- CMAKE_PARAMS+=("-DLUA_ENABLED=1")
- echo "Running build with Lua extension."
-else
- echo "Running build without Lua extension."
-fi # end ! $LUA_DISABLE
-
export CCACHE_DEBUG=1
function build_and_test()
{
diff --git a/src/AST.cpp b/src/AST.cpp
deleted file mode 100644
index 49a505789..000000000
--- a/src/AST.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/* This file is part of RTags (http://rtags.net).
-
- RTags is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- RTags is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with RTags. If not, see . */
-
-#include "AST.h"
-#include "ClangThread.h"
-#include "selene.h"
-
-#define TO_STR1(x) #x
-#define TO_STR(x) TO_STR1(x)
-
-struct UserData {
- List parents;
- AST *ast;
-};
-CXChildVisitResult AST::visitor(CXCursor cursor, CXCursor, CXClientData u)
-{
- UserData *userData = reinterpret_cast(u);
- assert(userData);
- Cursor::Data *p = userData->parents.isEmpty() ? 0 : userData->parents.back().data.get();
- Cursor c = userData->ast->construct(cursor, p);
- userData->parents.push_back(Cursor { c.data } );
- clang_visitChildren(cursor, visitor, u);
- if (userData->parents.size() > 1)
- userData->parents.pop_back();
- return CXChildVisit_Continue;
-}
-
-template static void assign(sel::Selector selector, const T &t) { selector = t; }
-void assign(sel::Selector selector, const String &str) { selector = str.ref(); }
-
-template
-static void exposeArray(sel::Selector selector, const std::vector &array)
-{
- int i = 0;
- for (const T &t : array) {
- assign(selector[i++], t);
- }
-}
-
-static void registerClasses(sel::State &state)
-{
- state["SourceLocation"].SetClass("line", &AST::SourceLocation::line,
- "column", &AST::SourceLocation::column,
- "file", &AST::SourceLocation::file,
- "offset", &AST::SourceLocation::offset,
- "toString", &AST::SourceLocation::toString);
- state["SourceRange"].SetClass("start", &AST::SourceRange::start,
- "end", &AST::SourceRange::end,
- "length", &AST::SourceRange::length,
- "toString", &AST::SourceRange::toString);
-
- auto cursors = state["Cursors"];
- cursors.SetClass("size", &AST::Cursors::size,
- "at", &AST::Cursors::at);
- auto cursor = state["Cursor"];
- cursor.SetClass("location", &AST::Cursor::location,
- "usr", &AST::Cursor::usr,
- "kind", &AST::Cursor::kind,
- "linkage", &AST::Cursor::linkage,
- "availability", &AST::Cursor::availability,
- "language", &AST::Cursor::language,
- "spelling", &AST::Cursor::spelling,
- "displayName", &AST::Cursor::displayName,
- "rawComment", &AST::Cursor::rawComment,
- "briefComment", &AST::Cursor::briefComment,
- "mangledName", &AST::Cursor::mangledName,
- "templateKind", &AST::Cursor::templateKind,
- "range", &AST::Cursor::range,
- "children", &AST::Cursor::children,
- "query", &AST::Cursor::query,
- "None", &AST::Cursor::none,
- "Add", &AST::Cursor::add,
- "Recurse", &AST::Cursor::recurse,
- "overriddenCount", &AST::Cursor::overriddenCount,
- "overriddenCursors", &AST::Cursor::overriddenCursors,
- "argumentCount", &AST::Cursor::argumentCount,
- "arguments", &AST::Cursor::arguments,
- "fieldBitWidth", &AST::Cursor::fieldBitWidth,
- "typedefUnderlyingType", &AST::Cursor::typedefUnderlyingType,
- "enumIntegerType", &AST::Cursor::enumIntegerType,
- "enumConstantValue", &AST::Cursor::enumConstantValue,
- "includedFile", &AST::Cursor::includedFile,
- "templateArgumentCount", &AST::Cursor::templateArgumentCount,
- "templateArgumentType", &AST::Cursor::templateArgumentType,
- "templateArgumentValue", &AST::Cursor::templateArgumentValue,
- "templateArgumentKind", &AST::Cursor::templateArgumentKind,
- "referenced", &AST::Cursor::referenced,
- "canonical", &AST::Cursor::canonical,
- "lexicalParent", &AST::Cursor::lexicalParent,
- "semanticParent", &AST::Cursor::semanticParent,
- "definitionCursor", &AST::Cursor::definitionCursor,
- "specializedCursorTemplate", &AST::Cursor::specializedCursorTemplate,
- "childCount", &AST::Cursor::childCount,
- "child", &AST::Cursor::child,
- "isBitField", &AST::Cursor::isBitField,
- "isVirtualBase", &AST::Cursor::isVirtualBase,
- "isStatic", &AST::Cursor::isStatic,
- "isVirtual", &AST::Cursor::isVirtual,
- "isPureVirtual", &AST::Cursor::isPureVirtual,
- "isConst", &AST::Cursor::isConst,
- "isDefinition", &AST::Cursor::isDefinition,
- "isDynamicCall", &AST::Cursor::isDynamicCall);
-}
-
-std::shared_ptr AST::create(const Source &source, const String &sourceCode, CXTranslationUnit unit)
-{
- std::shared_ptr ast(new AST);
- ast->mState.reset(new sel::State {true});
- sel::State &state = *ast->mState;
- registerClasses(state);
- ast->mSourceCode = sourceCode;
- state["sourceFile"] = source.sourceFile().ref();
- state["sourceCode"] = sourceCode.ref();
- state["write"] = [ast](const std::string &str) {
- // error() << "writing" << str;
- ast->mReturnValues.append(str);
- };
-
- exposeArray(state["commandLine"], source.toCommandLine(Source::Default|Source::IncludeCompiler|Source::IncludeSourceFile));
-
- if (unit) {
- UserData userData;
- userData.ast = ast.get();
- visitor(clang_getTranslationUnitCursor(unit), clang_getNullCursor(), &userData);
-
- const Cursor root = userData.parents.front();
- state["root"] = [root]() { return root; };
- state["findByUsr"] = [ast](const std::string &usr) {
- return ast->mByUsr.value(usr);
- };
-
- state["findByOffset"] = [ast](const std::string &str) {
- // int offset = atoi(str.c_str());
- // if (offset) {
-
- // } else
- // sscanf
- // return mByUsr.value(usr);
- };
- const String script = Path(TO_STR(RTAGS_SOURCE_DIR) "/rtags.lua").readAll();
- state(script.constData());
- }
- return ast;
-}
-
-List AST::diagnostics() const
-{
- return List();
-}
-
-List AST::skippedRanges() const
-{
- return List();
-}
-
-List AST::evaluate(const String &script)
-{
- assert(mReturnValues.isEmpty());
- try {
- mState->operator()(script.constData());
- } catch (...) {
- error() << "Got exception";
- }
- return std::move(mReturnValues);
-}
diff --git a/src/AST.h b/src/AST.h
deleted file mode 100644
index faddefe46..000000000
--- a/src/AST.h
+++ /dev/null
@@ -1,460 +0,0 @@
-#ifndef AST_h
-#define AST_h
-
-/* This file is part of RTags (http://rtags.net).
-
- RTags is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- RTags is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with RTags. If not, see . */
-
-#include
-#include "Source.h"
-#include "Location.h"
-#include "RTags.h"
-#include "rct/String.h"
-#include "rct/List.h"
-
-namespace sel {
-class State;
-};
-class AST
-{
-public:
- template
- static std::string toString(T t)
- {
- String str;
- Log(&str) << t;
- return str.ref();
- }
- static std::string toString(CXString str)
- {
- return RTags::eatString(str).ref();
- }
- struct SourceLocation {
- SourceLocation()
- : offset(-1)
- {}
-
- bool operator<(const SourceLocation &other) const { return location < other.location; }
-
- bool isNull() const { return location.isNull(); }
- Location location;
- int offset;
-
- int line() const { return location.line(); }
- int column() const { return location.column(); }
- std::string file() const { return location.path(); }
- std::string toString() const
- {
- return String::format<256>("%s,%d",
- location.toString(Location::AbsolutePath|Location::NoColor).constData(),
- offset);
- }
-
- };
-
- struct SourceRange {
- SourceRange(const CXSourceRange &r = clang_getNullRange())
- : range(r)
- {}
- CXSourceRange range;
-
- SourceLocation start() const { return AST::createLocation(clang_getRangeStart(range)); }
- SourceLocation end() const { return AST::createLocation(clang_getRangeEnd(range)); }
- int length() const { return end().offset - start().offset; }
- std::string toString() const { return start().toString() + " - " + end().toString(); }
- };
- struct CursorType;
- struct Cursors;
- struct Cursor {
- struct Data : public std::enable_shared_from_this {
- Data(AST *a, Data *p, const CXCursor &c, const SourceLocation &loc, const std::string &u = std::string())
- : ast(a), parent(p), cursor(c), location(loc), usr(u)
- {
- }
- ~Data()
- {
- for (Data *child : children)
- delete child;
- }
-
- AST *ast;
- Data *parent;
- List children;
- CXCursor cursor;
- SourceLocation location;
- std::string usr;
- };
-
- SourceLocation location() const { return data ? data->location : SourceLocation(); }
- std::string usr() const { return data ? data->usr : std::string(); }
- std::string kind() const { return stringProperty(&clang_getCursorKind); }
- std::string linkage() const { return stringProperty(&clang_getCursorLinkage); }
- std::string availability() const { return stringProperty(&clang_getCursorAvailability); }
- std::string language() const { return stringProperty(&clang_getCursorAvailability); }
- std::string spelling() const { return stringProperty(&clang_getCursorSpelling); }
- std::string displayName() const { return stringProperty(&clang_getCursorDisplayName); }
- std::string rawComment() const { return stringProperty(&clang_Cursor_getRawCommentText); }
- std::string briefComment() const { return stringProperty(&clang_Cursor_getBriefCommentText); }
-
- std::string mangledName() const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 28)
- return stringProperty(&clang_Cursor_getMangling);
-#else
- return std::string();
-#endif
- }
- std::string templateKind() const { return stringProperty(&clang_getTemplateCursorKind); }
- SourceRange range() const { return data ? SourceRange { clang_getCursorExtent(data->cursor) } : SourceRange(); }
- unsigned overriddenCount() const
- {
- unsigned count = 0;
- if (data) {
- CXCursor *overridden = 0;
- clang_getOverriddenCursors(data->cursor, &overridden, &count);
- if (overridden)
- clang_disposeOverriddenCursors(overridden);
- }
- return count;
- }
- Cursors overriddenCursors() const
- {
- Cursors ret;
- if (data) {
- CXCursor *overridden = 0;
- unsigned count;
- clang_getOverriddenCursors(data->cursor, &overridden, &count);
- ret.resize(count);
- for (unsigned i=0; iast->create(overridden[i]);
- clang_disposeOverriddenCursors(overridden);
- }
- return ret;
- }
-
- unsigned argumentCount() const { return data ? RTags::cursorArguments(data->cursor) : 0; }
- inline Cursors arguments() const;
-
- int fieldBitWidth() const { return intProperty(&clang_getFieldDeclBitWidth); }
- CursorType typedefUnderlyingType() const { return cursorTypeProperty(&clang_getTypedefDeclUnderlyingType); }
- CursorType enumIntegerType() const { return cursorTypeProperty(&clang_getEnumDeclIntegerType); }
- long long enumConstantValue() const { return intProperty(&clang_getEnumConstantDeclValue); }
- std::string includedFile() const
- {
- if (data && clang_getCursorKind(data->cursor) == CXCursor_InclusionDirective) {
- CXFile includedFile = clang_getIncludedFile(data->cursor);
- if (includedFile) {
- CXStringScope fn = clang_getFileName(includedFile);
- const char *cstr = clang_getCString(fn);
- if (cstr)
- return Path::resolved(cstr).ref();
- }
- }
- return std::string();
- }
-
- unsigned templateArgumentCount() const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 28)
- return data ? clang_Cursor_getNumTemplateArguments(data->cursor) : 0;
-#else
- return 0;
-#endif
- }
- CursorType templateArgumentType(unsigned idx) const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 28)
- return data ? CursorType(data->ast, clang_Cursor_getTemplateArgumentType(data->cursor, idx)) : CursorType();
-#else
- (void)idx;
- return CursorType();
-#endif
- }
- long long templateArgumentValue(unsigned idx) const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 28)
- return data ? clang_Cursor_getTemplateArgumentValue(data->cursor, idx) : -1;
-#else
- (void)idx;
- return -1;
-#endif
- }
- std::string templateArgumentKind(unsigned idx) const
- {
- std::string ret;
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 28)
- if (data)
- ret = toString(clang_Cursor_getTemplateArgumentKind(data->cursor, idx));
-#else
- (void)idx;
-#endif
- return ret;
- }
-
- Cursor referenced() const { return cursorProperty(&clang_getCursorReferenced); }
- Cursor canonical() const { return cursorProperty(&clang_getCanonicalCursor); }
- Cursor lexicalParent() const { return cursorProperty(&clang_getCursorLexicalParent); }
- Cursor semanticParent() const { return cursorProperty(&clang_getCursorSemanticParent); }
- Cursor definitionCursor() const { return cursorProperty(& clang_getCursorDefinition); }
- Cursor specializedCursorTemplate() const { return cursorProperty(&clang_getSpecializedCursorTemplate); }
- int childCount() const { return data ? data->children.size() : 0; }
- Cursor child(int idx) const { return data ? Cursor{ data->children.value(idx)->shared_from_this() } : Cursor(); }
- Cursors children() const;
- enum QueryResult {
- None = 0x0,
- Add = 0x1,
- Recurse = 0x2
- };
- unsigned none() const { return None; };
- unsigned add() const { return Add; };
- unsigned recurse() const { return Recurse; };
- Cursors query(const std::function callback, int depth = INT_MAX) const
- {
- Cursors ret;
- if (data) {
- const unsigned result = callback(*this);
- if (result & Add)
- ret.append(*this);
- if (result & Recurse && depth > 0) {
- for (Data *childData : data->children) {
- const Cursor child = { childData->shared_from_this() };
- ret.append(child.query(callback, depth - 1));
- }
- }
- }
- return ret;
- }
-
- bool isBitField() const { return intProperty(&clang_Cursor_isBitField); }
- bool isVirtualBase() const { return intProperty(&clang_isVirtualBase); }
- bool isStatic() const { return intProperty(&clang_CXXMethod_isStatic); }
- bool isVirtual() const { return intProperty(&clang_CXXMethod_isVirtual); }
- bool isPureVirtual() const
- {
-#if CINDEX_VERSION >= CINDEX_VERSION_ENCODE(0, 20)
- return intProperty(&clang_CXXMethod_isPureVirtual);
-#else
- return false;
-#endif
- }
- bool isConst() const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 20)
- return intProperty(&clang_CXXMethod_isConst);
-#else
- return false;
-#endif
- }
- bool isDefinition() const { return intProperty(&clang_isCursorDefinition); }
- bool isDynamicCall() const { return intProperty(&clang_Cursor_isDynamicCall); }
-
- template std::string stringProperty(Func func) const { return data ? toString(func(data->cursor)) : std::string(); }
- template Ret intProperty(Type (*func)(CXCursor), Type defaultValue = Type()) const { return data ? func(data->cursor) : defaultValue; }
- template Cursor cursorProperty(Func func) const { return data ? data->ast->create(func(data->cursor)) : Cursor(); }
- template CursorType cursorTypeProperty(Func func) const { return data ? CursorType(data->ast, func(data->cursor)) : CursorType(); }
-
- std::shared_ptr data;
- };
-
- struct Cursors : public List
- {
- int size() const { return List::size(); }
- Cursor at(int idx) const { return value(idx); }
- };
-
- struct CursorType {
- CursorType(const AST *a, const CXType &t) : ast(a), type(t) {}
- CursorType(const AST *a = 0) : ast(a) { memset(&type, 0, sizeof(type)); }
-
- std::string spelling() const { return toString(clang_getTypeSpelling(type)); }
- Cursor declaration() const { return ast ? ast->create(clang_getTypeDeclaration(type)) : Cursor(); }
- std::string callingConvention() const { return toString(clang_getFunctionTypeCallingConv(type)); }
- std::string referenceType() const
- {
-#if CINDEX_VERSION >= CINDEX_VERSION_ENCODE(0, 20)
- return toString(clang_Type_getCXXRefQualifier(type));
-#else
- return std::string();
-#endif
- }
- unsigned argumentCount() const { return clang_getNumArgTypes(type); }
- CursorType argument(unsigned idx) const { return CursorType(ast, clang_getArgType(type, idx)); }
- unsigned templateArgumentCount() const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 20)
- return clang_Type_getNumTemplateArguments(type);
-#else
- return 0;
-#endif
- }
- CursorType templateArgument(unsigned idx) const
- {
-#if CINDEX_VERSION > CINDEX_VERSION_ENCODE(0, 20)
- return CursorType(ast, clang_Type_getTemplateArgumentAsType(type, idx));
-#else
- (void)idx;
- return CursorType();
-#endif
- }
- CursorType canonicalType() const { return CursorType(ast, clang_getCanonicalType(type)); }
- CursorType pointeeType() const { return CursorType(ast, clang_getPointeeType(type)); }
- CursorType resultType() const { return CursorType(ast, clang_getResultType(type)); }
- CursorType elementType() const { return CursorType(ast, clang_getElementType(type)); }
- CursorType arrayElementType() const { return CursorType(ast, clang_getElementType(type)); }
- CursorType classType() const
- {
-#if CINDEX_VERSION >= CINDEX_VERSION_ENCODE(0, 20)
- return CursorType(ast, clang_Type_getClassType(type));
-#else
- return CursorType();
-#endif
- }
-
- bool isConstQualified() const { return clang_isConstQualifiedType(type); }
- bool isEstrictQualified() const { return clang_isRestrictQualifiedType(type); }
- bool isVolatileQualified() const { return clang_isVolatileQualifiedType(type); }
- bool isVariadic() const { return clang_isFunctionTypeVariadic(type); }
- bool isPod() const { return clang_isPODType(type); }
- long long numElements() const { return clang_getNumElements(type); }
- long long arraySize() const { return clang_getArraySize(type); }
- long long alignOf() const { return clang_Type_getAlignOf(type); }
- long long sizeOf() const { return clang_Type_getSizeOf(type); }
-
- const AST *ast;
- CXType type;
- };
-
- struct Diagnostic {
-
-
- };
-
- struct SkippedRange {
-
-
- };
-
- static std::shared_ptr create(const Source &source, const String &sourceCode, CXTranslationUnit unit);
- List evaluate(const String &script);
- Cursor *root() const { return mRoot; }
- List diagnostics() const;
- List skippedRanges() const;
- static SourceLocation createLocation(const CXCursor &cursor) { return createLocation(clang_getCursorLocation(cursor)); }
- static SourceLocation createLocation(const CXSourceLocation &location)
- {
- SourceLocation loc;
- loc.location = RTags::createLocation(location, &loc.offset);
- return loc;
- }
-
- Cursor create(const CXCursor &cursor) const
- {
- if (clang_isInvalid(clang_getCursorKind(cursor)))
- return Cursor();
-
- auto match = [&cursor](const Cursors &cursors) -> Cursor {
- for (const Cursor &c : cursors) {
- assert(c.data);
- if (clang_equalCursors(c.data->cursor, cursor)) {
- return c;
- }
- }
- // The explicit const cast is here to satisfy travis clang matrix.
- // clang 3.4 does not allow to use two different return types
- return Cursor();
- };
-
- const std::string usr = toString(clang_getCursorUSR(cursor));
- if (!usr.empty()) {
- auto it = mByUsr.find(usr);
- if (it != mByUsr.end()) {
- const Cursor ret = match(it->second);
- if (ret.data)
- return ret;
- }
- }
-
- const SourceLocation loc = createLocation(cursor);
- if (!loc.isNull()) {
- auto it = mByLocation.find(loc);
- if (it != mByLocation.end()) {
- const Cursor ret = match(it->second);
- if (ret.data)
- return ret;
- }
- }
- return construct(cursor, 0, loc, usr);
- }
-private:
- static CXChildVisitResult visitor(CXCursor cursor, CXCursor, CXClientData u);
- Cursor construct(const CXCursor &cursor,
- Cursor::Data *parent = 0,
- SourceLocation loc = SourceLocation(),
- std::string usr = std::string()) const
- {
- Cursor ret;
- if (loc.isNull())
- loc = createLocation(cursor);
- if (usr.empty())
- usr = toString(clang_getCursorUSR(cursor));
- ret.data.reset(new Cursor::Data(const_cast(this), parent, cursor, loc, usr));
- if (!loc.isNull())
- mByLocation[loc].append(ret);
- if (!ret.data->usr.empty())
- mByUsr[usr].append(ret);
- if (parent)
- parent->children.append(ret.data.get());
- return ret;
- }
- AST()
- : mRoot(0)
- {}
- mutable Hash mByUsr;
- mutable Map mByLocation;
- String mSourceCode;
- List mReturnValues;
- Cursor *mRoot;
- std::shared_ptr mState;
-};
-
-
-inline AST::Cursors AST::Cursor::children() const
-{
- Cursors ret;
- if (data) {
- ret.resize(data->children.size());
- int i = 0;
- for (Data *child : data->children) {
- ret[i++] = Cursor { child->shared_from_this() };
- }
- }
- return ret;
-}
-
-inline AST::Cursors AST::Cursor::arguments() const
-{
- AST::Cursors ret;
- if (data) {
- List args;
- const unsigned size = RTags::cursorArguments(data->cursor, &args);
- if (size) {
- ret.resize(size);
- for (unsigned i=0; iast->create(args[i]);
- }
- }
- }
- return ret;
-}
-#endif
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 127c17526..afdf32f42 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -120,14 +120,6 @@ if (EXISTS ${CLANG_COMPILATION_INCLUDE})
add_definitions(-DHAVE_CXCOMPILATIONDATABASE)
endif ()
-if (LUA_ENABLED)
- ExternalProject_Add(lua
- DOWNLOAD_COMMAND ""
- SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lua
- INSTALL_COMMAND ""
- CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DCMAKE_GENERATOR=${CMAKE_GENERATOR})
-endif ()
-
set(RCT_RTTI_ENABLED 1)
set(RCT_NO_INSTALL 1)
set(RCT_STATIC 1)
@@ -195,17 +187,10 @@ set(RTAGS_SOURCES
Token.cpp
TokensJob.cpp)
-if (LUA_ENABLED)
- list(APPEND RTAGS_SOURCES AST.cpp)
-endif ()
-
add_library(rtags STATIC ${RTAGS_SOURCES})
if (RTAGS_BUILD_CLANG)
add_dependencies(rtags llvmclang)
endif ()
-if (LUA_ENABLED)
- add_dependencies(rtags lua)
-endif ()
if (RTAGS_COTIRE)
include(cotire)
@@ -213,12 +198,7 @@ if (RTAGS_COTIRE)
cotire(rtags)
endif ()
-include_directories(
- ${CMAKE_CURRENT_LIST_DIR}
- ${RCT_INCLUDE_DIRS}
- ${CMAKE_CURRENT_LIST_DIR}/selene/include
- ${CMAKE_CURRENT_BINARY_DIR}/lua-prefix/src/lua-build
- ${CMAKE_CURRENT_LIST_DIR}/lua/src)
+include_directories(${CMAKE_CURRENT_LIST_DIR} ${RCT_INCLUDE_DIRS})
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(START_GROUP "")
@@ -229,10 +209,6 @@ else ()
endif ()
set(RTAGS_LIBRARIES rtags ${START_GROUP} ${LIBCLANG_LIBRARIES} ${END_GROUP})
-if (LUA_ENABLED)
- list(APPEND RTAGS_LIBRARIES -L${CMAKE_CURRENT_BINARY_DIR}/lua-prefix/src/lua-build/ liblua.a)
- add_definitions(-DRTAGS_HAS_LUA)
-endif ()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set_source_files_properties(AST.cpp PROPERTIES
@@ -297,13 +273,6 @@ set(RTAGS_ELISP_FILES
company-rtags.el
flycheck-rtags.el)
-if (LUA_ENABLED AND NOT RTAGS_NO_LUA_FILES AND LUA_FOUND AND NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rtags.lua
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/rtags.lua ${CMAKE_CURRENT_BINARY_DIR}/rtags.lua
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/rtags.lua
- COMMENT "Copying ${CMAKE_CURRENT_SOURCE_DIR}/rtags.lua -> ${CMAKE_CURRENT_BINARY_DIR}/rtags.lua")
-endif ()
-
if (NOT RTAGS_NO_ELISP_FILES)
if (NOT RTAGS_ELISP_INSTALL_LOCATION)
set(RTAGS_ELISP_INSTALL_LOCATION ${CMAKE_INSTALL_PREFIX}/share/emacs/site-lisp/rtags/)
diff --git a/src/ClangThread.cpp b/src/ClangThread.cpp
index 0d2bde385..2c29e0fcc 100644
--- a/src/ClangThread.cpp
+++ b/src/ClangThread.cpp
@@ -17,9 +17,6 @@
#include "rct/Connection.h"
#include "RTags.h"
#include "Server.h"
-#ifdef RTAGS_HAS_LUA
-#include "AST.h"
-#endif
struct Dep : public DependencyNode
{
@@ -153,21 +150,6 @@ void ClangThread::run()
const unsigned long long parseTime = sw.restart();
warning() << "parseTime" << parseTime;
-#ifdef RTAGS_HAS_LUA
- if (mQueryMessage->type() == QueryMessage::VisitAST) {
- std::shared_ptr ast = AST::create(mSource, sourceCode, translationUnit->unit);
- if (ast) {
- for (const String script : mQueryMessage->visitASTScripts()) {
- warning() << "evaluating script:\n" << script;
- for (const String &str : ast->evaluate(script)) {
- if (!str.isEmpty()) {
- writeToConnetion(str);
- }
- }
- }
- }
- } else
-#endif
{
if (mQueryMessage->type() == QueryMessage::DumpFile && mQueryMessage->flags() & QueryMessage::DumpCheckIncludes)
writeToConnetion(String::format<128>("Indexed: %s => %s", translationUnit->clangLine.constData(), translationUnit ? "success" : "failure"));
diff --git a/src/QueryMessage.cpp b/src/QueryMessage.cpp
index 67402fc0c..040e8a321 100644
--- a/src/QueryMessage.cpp
+++ b/src/QueryMessage.cpp
@@ -27,22 +27,14 @@ void QueryMessage::encode(Serializer &serializer) const
{
serializer << mCommandLine << mQuery << mCodeCompletePrefix << mType << mFlags << mMax
<< mMinLine << mMaxLine << mBuildIndex << mPathFilters << mKindFilters
- << mCurrentFile << mUnsavedFiles << mTerminalWidth
-#ifdef RTAGS_HAS_LUA
- << mVisitASTScripts
-#endif
- ;
+ << mCurrentFile << mUnsavedFiles << mTerminalWidth;
}
void QueryMessage::decode(Deserializer &deserializer)
{
deserializer >> mCommandLine >> mQuery >> mCodeCompletePrefix >> mType >> mFlags >> mMax
>> mMinLine >> mMaxLine >> mBuildIndex >> mPathFilters >> mKindFilters
- >> mCurrentFile >> mUnsavedFiles >> mTerminalWidth
-#ifdef RTAGS_HAS_LUA
- >> mVisitASTScripts
-#endif
- ;
+ >> mCurrentFile >> mUnsavedFiles >> mTerminalWidth;
}
Flags QueryMessage::locationToStringFlags(Flags queryFlags)
diff --git a/src/QueryMessage.h b/src/QueryMessage.h
index 9f79bc5a7..55a9abdd7 100644
--- a/src/QueryMessage.h
+++ b/src/QueryMessage.h
@@ -72,9 +72,6 @@ class QueryMessage : public RTagsMessage
Suspend,
SymbolInfo,
Validate,
-#ifdef RTAGS_HAS_LUA
- VisitAST,
-#endif
Tokens
};
@@ -178,11 +175,6 @@ class QueryMessage : public RTagsMessage
std::sort(mPathFilters.begin(), mPathFilters.end());
}
-#ifdef RTAGS_HAS_LUA
- void setVisitASTScripts(const List &scripts) { mVisitASTScripts = scripts; }
- List visitASTScripts() const { return mVisitASTScripts; }
-#endif
-
void setKindFilters(const KindFilters &kindFilters) { mKindFilters = kindFilters; }
const KindFilters &kindFilters() const { return mKindFilters; }
@@ -257,9 +249,6 @@ class QueryMessage : public RTagsMessage
Path mCurrentFile;
UnsavedFiles mUnsavedFiles;
int mTerminalWidth;
-#ifdef RTAGS_HAS_LUA
- List mVisitASTScripts;
-#endif
};
DECLARE_NATIVE_TYPE(QueryMessage::Type);
diff --git a/src/RClient.cpp b/src/RClient.cpp
index 31b1a0de5..34cb01e1e 100644
--- a/src/RClient.cpp
+++ b/src/RClient.cpp
@@ -111,9 +111,6 @@ std::initializer_list > opts = {
{ RClient::ListCursorKinds, "list-cursor-kinds", 0, CommandLineParser::NoValue, "List spelling for known cursor kinds." },
{ RClient::ClassHierarchy, "class-hierarchy", 0, CommandLineParser::Required, "Dump class hierarcy for struct/class at location." },
{ RClient::DebugLocations, "debug-locations", 0, CommandLineParser::Optional, "Manipulate debug locations." },
-#ifdef RTAGS_HAS_LUA
- { RClient::VisitAST, "visit-ast", 0, CommandLineParser::Required, "Visit AST of a source file." },
-#endif
{ RClient::Validate, "validate", 0, CommandLineParser::NoValue, "Validate database files for current project." },
{ RClient::Tokens, "tokens", 0, CommandLineParser::Required, "Dump tokens for file. --tokens file.cpp:123-321 for range." },
{ RClient::DeadFunctions, "find-dead-functions", 0, CommandLineParser::Optional, "Find functions declared/defined in the current file that are never in the project." },
@@ -179,9 +176,6 @@ std::initializer_list > opts = {
{ RClient::CodeCompletePrefix, "code-complete-prefix", 0, CommandLineParser::Required, "Filter out code completion results that don't start with this prefix." },
{ RClient::CodeCompletionEnabled, "code-completion-enabled", 'b', CommandLineParser::NoValue, "Inform rdm that we're code-completing. Use with --diagnose" },
{ RClient::NoSpellCheckinging, "no-spell-checking", 0, CommandLineParser::NoValue, "Don't produce spell check info in diagnostics." },
-#ifdef RTAGS_HAS_LUA
- { RClient::VisitASTScript, "visit-ast-script", 0, CommandLineParser::Required, "Use this script visit AST (@file.js|sourcecode)." },
-#endif
{ RClient::TokensIncludeSymbols, "tokens-include-symbols", 0, CommandLineParser::NoValue, "Include symbols for tokens." },
{ RClient::NoRealPath, "no-realpath", 0, CommandLineParser::NoValue, "Don't resolve paths using realpath(3)." },
{ RClient::None, String(), 0, CommandLineParser::NoValue, 0 }
@@ -228,9 +222,6 @@ class QueryCommand : public RCCommand
msg.setTerminalWidth(rc->terminalWidth());
msg.setCurrentFile(rc->currentFile());
msg.setCodeCompletePrefix(rc->codeCompletePrefix());
-#ifdef RTAGS_HAS_LUA
- msg.setVisitASTScripts(rc->visitASTScripts());
-#endif
return connection->send(msg) ? RTags::Success : RTags::NetworkFailure;
}
@@ -1305,32 +1296,6 @@ CommandLineParser::ParseStatus RClient::parse(size_t argc, char **argv)
case ReferenceName: {
addQuery(QueryMessage::ReferencesName, std::move(value));
break; }
- case VisitAST: {
-#ifdef RTAGS_HAS_LUA
- Path p = std::move(value);
- p.resolve(Path::MakeAbsolute);
- if (!p.isFile()) {
- return { String::format<1024>("%s is not a file", p.constData()), CommandLineParser::Parse_Error };
- }
- addQuery(QueryMessage::VisitAST, std::move(p));
-#endif
- break; }
- case VisitASTScript: {
-#ifdef RTAGS_HAS_LUA
- String code = std::move(value);
- if (code.startsWith("@")) {
- const Path p = code.mid(1);
- if (!p.isFile()) {
- return { String::format<1024>("%s is not a file", p.constData()), CommandLineParser::Parse_Error };
- }
- code = p.readAll();
- }
- if (code.isEmpty()) {
- return { String::format<1024>("Script is empty"), CommandLineParser::Parse_Error };
- }
- mVisitASTScripts.push_back(std::move(code));
-#endif
- break; }
}
return { String(), CommandLineParser::Parse_Exec };
};
diff --git a/src/RClient.h b/src/RClient.h
index 9636ac05e..1137fda68 100644
--- a/src/RClient.h
+++ b/src/RClient.h
@@ -155,8 +155,6 @@ class RClient
Verbose,
VerifyVersion,
Version,
- VisitAST,
- VisitASTScript,
Wait,
WildcardSymbolNames,
XML,
@@ -196,9 +194,6 @@ class RClient
void onNewMessage(const std::shared_ptr &message, const std::shared_ptr &);
List environment() const;
String codeCompletePrefix() const { return mCodeCompletePrefix; }
-#ifdef RTAGS_HAS_LUA
- List visitASTScripts() const { return mVisitASTScripts; }
-#endif
private:
void addQuery(QueryMessage::Type t, String &&query = String(),
Flags extraQueryFlags = Flags());
@@ -225,9 +220,6 @@ class RClient
Path mProjectRoot;
int mTerminalWidth;
int mExitCode;
-#ifdef RTAGS_HAS_LUA
- List mVisitASTScripts;
-#endif
mutable List mEnvironment;
String mCommandLine;
diff --git a/src/Server.cpp b/src/Server.cpp
index 16309550c..b504d7246 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -728,9 +728,6 @@ void Server::handleQueryMessage(const std::shared_ptr &message, co
findFile(message, conn);
break;
case QueryMessage::DumpFile:
-#ifdef RTAGS_HAS_LUA
- case QueryMessage::VisitAST:
-#endif
startClangThread(message, conn);
break;
case QueryMessage::Validate:
diff --git a/src/lua b/src/lua
deleted file mode 160000
index fcdc5efb1..000000000
--- a/src/lua
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit fcdc5efb13f0d6c03d2868b7476b73e63a291ed3
diff --git a/src/selene b/src/selene
deleted file mode 160000
index 1b6b3ff9e..000000000
--- a/src/selene
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 1b6b3ff9ecea0e5ef0df1dfbdb03028d2264ff20