Browse Source

Moved ClangViewParse to source_clang.*.

merge-requests/365/head
eidheim 10 years ago
parent
commit
b4f4af5af4
  1. 1
      README.md
  2. 2
      src/CMakeLists.txt
  3. 2
      src/notebook.h
  4. 1241
      src/source.cc
  5. 122
      src/source.h
  6. 1236
      src/source_clang.cc
  7. 127
      src/source_clang.h
  8. 1
      src/window.h

1
README.md

@ -24,7 +24,6 @@ towards libclang with speed and ease of use in mind.
* Smart paste, keys and indentation * Smart paste, keys and indentation
* Source minimap * Source minimap
* Full UTF-8 support * Full UTF-8 support
* Write your own plugins in Python (disabled at the moment)
See [enhancements](https://github.com/cppit/jucipp/labels/enhancement) for planned features. See [enhancements](https://github.com/cppit/jucipp/labels/enhancement) for planned features.

2
src/CMakeLists.txt

@ -31,6 +31,8 @@ set(source_files juci.h
menu.cc menu.cc
source.h source.h
source.cc source.cc
source_clang.h
source_clang.cc
selectiondialog.h selectiondialog.h
selectiondialog.cc selectiondialog.cc
config.h config.h

2
src/notebook.h

@ -4,7 +4,7 @@
#include <iostream> #include <iostream>
#include "gtkmm.h" #include "gtkmm.h"
#include "source.h" #include "source.h"
#include <boost/algorithm/string/case_conv.hpp> #include "source_clang.h"
#include <type_traits> #include <type_traits>
#include <map> #include <map>
#include <sigc++/sigc++.h> #include <sigc++/sigc++.h>

1241
src/source.cc

File diff suppressed because it is too large Load Diff

122
src/source.h

@ -1,20 +1,14 @@
#ifndef JUCI_SOURCE_H_ #ifndef JUCI_SOURCE_H_
#define JUCI_SOURCE_H_ #define JUCI_SOURCE_H_
#include <iostream>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "gtkmm.h" #include "gtkmm.h"
#include "clangmm.h" #include "clangmm.h"
#include <thread>
#include <mutex>
#include <string> #include <string>
#include <atomic>
#include "gtksourceviewmm.h" #include "gtksourceviewmm.h"
#include "terminal.h" #include "terminal.h"
#include "tooltips.h" #include "tooltips.h"
#include "selectiondialog.h" #include "selectiondialog.h"
#include <set>
#include <regex>
#include <aspell.h> #include <aspell.h>
#include <boost/property_tree/xml_parser.hpp> #include <boost/property_tree/xml_parser.hpp>
@ -200,119 +194,5 @@ namespace Source {
void parse_language_file(Glib::RefPtr<CompletionBuffer> &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt); void parse_language_file(Glib::RefPtr<CompletionBuffer> &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt);
}; };
}
class ClangViewParse : public View {
public:
class TokenRange {
public:
TokenRange(std::pair<clang::Offset, clang::Offset> offsets, int kind):
offsets(offsets), kind(kind) {}
std::pair<clang::Offset, clang::Offset> offsets;
int kind;
};
ClangViewParse(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
~ClangViewParse();
void configure();
void start_reparse();
bool reparse_needed=false;
protected:
void init_parse();
bool on_key_press_event(GdkEventKey* key);
std::unique_ptr<clang::TranslationUnit> clang_tu;
std::mutex parsing_mutex;
std::unique_ptr<clang::Tokens> clang_tokens;
sigc::connection delayed_reparse_connection;
std::shared_ptr<Terminal::InProgress> parsing_in_progress;
std::thread parse_thread;
std::atomic<bool> parse_thread_stop;
std::atomic<bool> parse_error;
void show_diagnostic_tooltips(const Gdk::Rectangle &rectangle);
void show_type_tooltips(const Gdk::Rectangle &rectangle);
std::regex bracket_regex;
std::regex no_bracket_statement_regex;
std::regex no_bracket_no_para_statement_regex;
std::set<int> diagnostic_offsets;
std::vector<FixIt> fix_its;
private:
std::map<std::string, std::string> get_buffer_map() const;
void update_syntax();
std::set<std::string> last_syntax_tags;
void update_diagnostics();
static clang::Index clang_index;
std::vector<std::string> get_compilation_commands();
Glib::Dispatcher parse_done;
Glib::Dispatcher parse_start;
Glib::Dispatcher parse_fail;
std::map<std::string, std::string> parse_thread_buffer_map;
std::mutex parse_thread_buffer_map_mutex;
std::atomic<bool> parse_thread_go;
std::atomic<bool> parse_thread_mapped;
};
class ClangViewAutocomplete : public ClangViewParse {
public:
class AutoCompleteData {
public:
explicit AutoCompleteData(const std::vector<clang::CompletionChunk> &chunks) :
chunks(chunks) { }
std::vector<clang::CompletionChunk> chunks;
std::string brief_comments;
};
ClangViewAutocomplete(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
void async_delete();
bool restart_parse();
protected:
bool on_key_press_event(GdkEventKey* key);
std::thread autocomplete_thread;
private:
void start_autocomplete();
void autocomplete();
std::unique_ptr<CompletionDialog> completion_dialog;
bool completion_dialog_shown=false;
std::vector<AutoCompleteData> get_autocomplete_suggestions(int line_number, int column, std::map<std::string, std::string>& buffer_map);
Glib::Dispatcher autocomplete_done;
sigc::connection autocomplete_done_connection;
Glib::Dispatcher autocomplete_fail;
sigc::connection autocomplete_fail_connection;
bool autocomplete_starting=false;
std::atomic<bool> autocomplete_cancel_starting;
guint last_keyval=0;
std::string prefix;
std::mutex prefix_mutex;
Glib::Dispatcher do_delete_object;
Glib::Dispatcher do_restart_parse;
std::thread delete_thread;
std::thread restart_parse_thread;
bool restart_parse_running=false;
};
class ClangViewRefactor : public ClangViewAutocomplete {
public:
ClangViewRefactor(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
~ClangViewRefactor();
private:
std::list<std::pair<Glib::RefPtr<Gtk::TextMark>, Glib::RefPtr<Gtk::TextMark> > > similar_token_marks;
void tag_similar_tokens(const Token &token);
Glib::RefPtr<Gtk::TextTag> similar_tokens_tag;
Token last_tagged_token;
sigc::connection delayed_tag_similar_tokens_connection;
std::unique_ptr<SelectionDialog> selection_dialog;
bool renaming=false;
};
class ClangView : public ClangViewRefactor {
public:
ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
};
}; // class Source
#endif // JUCI_SOURCE_H_ #endif // JUCI_SOURCE_H_

1236
src/source_clang.cc

File diff suppressed because it is too large Load Diff

127
src/source_clang.h

@ -0,0 +1,127 @@
#ifndef JUCI_SOURCE_CLANG_H_
#define JUCI_SOURCE_CLANG_H_
#include <thread>
#include <atomic>
#include <mutex>
#include <set>
#include <regex>
#include "source.h"
namespace Source {
class ClangViewParse : public View {
public:
class TokenRange {
public:
TokenRange(std::pair<clang::Offset, clang::Offset> offsets, int kind):
offsets(offsets), kind(kind) {}
std::pair<clang::Offset, clang::Offset> offsets;
int kind;
};
ClangViewParse(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
~ClangViewParse();
void configure();
void start_reparse();
bool reparse_needed=false;
protected:
void init_parse();
bool on_key_press_event(GdkEventKey* key);
std::unique_ptr<clang::TranslationUnit> clang_tu;
std::mutex parsing_mutex;
std::unique_ptr<clang::Tokens> clang_tokens;
sigc::connection delayed_reparse_connection;
std::shared_ptr<Terminal::InProgress> parsing_in_progress;
std::thread parse_thread;
std::atomic<bool> parse_thread_stop;
std::atomic<bool> parse_error;
void show_diagnostic_tooltips(const Gdk::Rectangle &rectangle);
void show_type_tooltips(const Gdk::Rectangle &rectangle);
std::regex bracket_regex;
std::regex no_bracket_statement_regex;
std::regex no_bracket_no_para_statement_regex;
std::set<int> diagnostic_offsets;
std::vector<FixIt> fix_its;
private:
std::map<std::string, std::string> get_buffer_map() const;
void update_syntax();
std::set<std::string> last_syntax_tags;
void update_diagnostics();
static clang::Index clang_index;
std::vector<std::string> get_compilation_commands();
Glib::Dispatcher parse_done;
Glib::Dispatcher parse_start;
Glib::Dispatcher parse_fail;
std::map<std::string, std::string> parse_thread_buffer_map;
std::mutex parse_thread_buffer_map_mutex;
std::atomic<bool> parse_thread_go;
std::atomic<bool> parse_thread_mapped;
};
class ClangViewAutocomplete : public ClangViewParse {
public:
class AutoCompleteData {
public:
explicit AutoCompleteData(const std::vector<clang::CompletionChunk> &chunks) :
chunks(chunks) { }
std::vector<clang::CompletionChunk> chunks;
std::string brief_comments;
};
ClangViewAutocomplete(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
void async_delete();
bool restart_parse();
protected:
bool on_key_press_event(GdkEventKey* key);
std::thread autocomplete_thread;
private:
void start_autocomplete();
void autocomplete();
std::unique_ptr<CompletionDialog> completion_dialog;
bool completion_dialog_shown=false;
std::vector<AutoCompleteData> get_autocomplete_suggestions(int line_number, int column, std::map<std::string, std::string>& buffer_map);
Glib::Dispatcher autocomplete_done;
sigc::connection autocomplete_done_connection;
Glib::Dispatcher autocomplete_fail;
sigc::connection autocomplete_fail_connection;
bool autocomplete_starting=false;
std::atomic<bool> autocomplete_cancel_starting;
guint last_keyval=0;
std::string prefix;
std::mutex prefix_mutex;
Glib::Dispatcher do_delete_object;
Glib::Dispatcher do_restart_parse;
std::thread delete_thread;
std::thread restart_parse_thread;
bool restart_parse_running=false;
};
class ClangViewRefactor : public ClangViewAutocomplete {
public:
ClangViewRefactor(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
~ClangViewRefactor();
private:
std::list<std::pair<Glib::RefPtr<Gtk::TextMark>, Glib::RefPtr<Gtk::TextMark> > > similar_token_marks;
void tag_similar_tokens(const Token &token);
Glib::RefPtr<Gtk::TextTag> similar_tokens_tag;
Token last_tagged_token;
sigc::connection delayed_tag_similar_tokens_connection;
std::unique_ptr<SelectionDialog> selection_dialog;
bool renaming=false;
};
class ClangView : public ClangViewRefactor {
public:
ClangView(const boost::filesystem::path &file_path, const boost::filesystem::path& project_path, Glib::RefPtr<Gsv::Language> language);
};
}
#endif // JUCI_SOURCE_CLANG_H_

1
src/window.h

@ -6,7 +6,6 @@
#include "entrybox.h" #include "entrybox.h"
#include "notebook.h" #include "notebook.h"
#include "menu.h" #include "menu.h"
#include <boost/property_tree/json_parser.hpp>
#include <atomic> #include <atomic>
class Window : public Gtk::Window { class Window : public Gtk::Window {

Loading…
Cancel
Save