Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
UffeJakobsen committed Jul 19, 2024
1 parent d1ff88d commit c0322bf
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 22 deletions.
12 changes: 9 additions & 3 deletions CodeLite/CTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool CTags::DoGenerate(const wxString& filesContent, const wxString& codelite_in
fields_cxx << "+{macrodef}";
}

options_arr = { "--extras=-p", "--excmd=pattern", "--sort=no",
options_arr = { "--extras=-p", "--excmd=pattern", "--sort=no", // "--links=yes",
"--fields=aKmSsnit", "--language-force=c++", fields_cxx };

wxString kinds_string;
Expand Down Expand Up @@ -142,6 +142,7 @@ bool CTags::DoGenerate(const wxString& filesContent, const wxString& codelite_in
long elapsed = sw.Time();

clDEBUG() << "Parsing took:" << (elapsed / 1000) << "secs," << (elapsed % 1000) << "ms" << endl;
clDEBUG() << "Output size: " << output->size() << endl;
clDEBUG() << "Generating ctags files... Success" << endl;
return true;
}
Expand Down Expand Up @@ -201,9 +202,12 @@ size_t CTags::ParseFiles(const std::vector<wxString>& files, const wxString& cod
}
}

if(tags.empty()) {
clDEBUG() << "tags: " << tags.size() << " ctags:" << lines.size() << "/" << content.size() << endl;

if (tags.empty()) {
clDEBUG() << "0 tags, ctags output:" << content << endl;
}

return tags.size();
}

Expand Down Expand Up @@ -263,7 +267,9 @@ size_t CTags::ParseLocals(const wxFileName& filename, const wxString& buffer, co
tag->SetFile(filename.GetFullPath());
}

if(tags.empty()) {
clDEBUG() << "tags: " << tags.size() << " ctags:" << lines.size() << "/" << content.size() << endl;

if (tags.empty()) {
clDEBUG() << "0 local tags, ctags output:" << content << endl;
}
return tags.size();
Expand Down
6 changes: 6 additions & 0 deletions CodeLite/LSP/WorkspaceSymbolRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class WorkspaceSymbolParams : public Params

LSP::WorkspaceSymbolRequest::WorkspaceSymbolRequest(const wxString& query)
{

std::cout << "WorkspaceSymbolRequest:" << __LINE__ << ": " << query << std::endl;

SetMethod("workspace/symbol");
// set the params
m_params.reset(new WorkspaceSymbolParams());
Expand Down Expand Up @@ -88,6 +91,9 @@ void LSP::WorkspaceSymbolRequest::OnResponse(const LSP::ResponseMessage& respons
SymbolInformation si;
si.FromJSON(result[i]);
symbols.push_back(si);

std::cout << "WorkspaceSymbolRequest::OnResponse:" << __LINE__ << ": " << si.GetName() << std::endl;

}

LOG_IF_TRACE { LSP_TRACE() << symbols_event.GetSymbolsInformation() << endl; }
Expand Down
28 changes: 17 additions & 11 deletions CodeLite/clFilesCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "file_logger.h"
#include "fileutils.h"
//#include "globals.h"

#include <queue>
#include <unordered_set>
Expand All @@ -10,6 +11,11 @@
#include <wx/filename.h>
#include <wx/tokenzr.h>

static wxString CLRealPath(const wxString& str)
{
return str;
}

clFilesScanner::clFilesScanner() {}

clFilesScanner::~clFilesScanner() {}
Expand Down Expand Up @@ -110,19 +116,19 @@ size_t clFilesScanner::Scan(const wxString& rootFolder, std::vector<wxString>& f
filename.MakeLower();
#endif
bool isDirectory = wxFileName::DirExists(fullpath);
// Use FileUtils::RealPath() here to cope with symlinks on Linux
// Use CLRealPath() here to cope with symlinks on Linux
bool isExcludeDir =
isDirectory &&
(
#if defined(__FreeBSD__)
((FileUtils::IsSymlink(fullpath) && excludeFolders.count(FileUtils::RealPath(fullpath)))
((FileUtils::IsSymlink(fullpath) && excludeFolders.count(CLRealPath(fullpath)))
#else
(excludeFolders.count(FileUtils::RealPath(fullpath))
(excludeFolders.count(CLRealPath(fullpath))
#endif
|| IsRelPathContainedInSpec(rootFolder, fullpath, excludeFolders)));
if (isDirectory && !isExcludeDir) {
// Traverse into this folder
wxString realPath = FileUtils::RealPath(fullpath);
wxString realPath = CLRealPath(fullpath);
if (Visited.insert(realPath).second) {
Q.push(fullpath);
}
Expand Down Expand Up @@ -153,8 +159,8 @@ size_t clFilesScanner::Scan(const wxString& rootFolder, const wxString& filespec
std::queue<wxString> Q;
std::unordered_set<wxString> Visited;

Q.push(FileUtils::RealPath(rootFolder));
Visited.insert(FileUtils::RealPath(rootFolder));
Q.push(CLRealPath(rootFolder));
Visited.insert(CLRealPath(rootFolder));

size_t nCount = 0;
while (!Q.empty()) {
Expand All @@ -174,11 +180,11 @@ size_t clFilesScanner::Scan(const wxString& rootFolder, const wxString& filespec
fullpath << dir.GetNameWithSep() << filename;
bool isDirectory = wxFileName::DirExists(fullpath);
bool isFile = !isDirectory;
// Use FileUtils::RealPath() here to cope with symlinks on Linux
// Use CLRealPath() here to cope with symlinks on Linux
if (isDirectory /* a folder */ &&
!FileUtils::WildMatch(excludeFoldersSpecArr, filename) /* does not match the exclude folder spec */) {
// Traverse into this folder
wxString real_path = FileUtils::RealPath(fullpath);
wxString real_path = CLRealPath(fullpath);
if (Visited.count(real_path) == 0) {
Visited.insert(real_path);
Q.push(fullpath);
Expand Down Expand Up @@ -259,8 +265,8 @@ void clFilesScanner::ScanWithCallbacks(const wxString& rootFolder, std::function
std::vector<wxString> Q;
std::unordered_set<wxString> Visited;

Q.push_back(FileUtils::RealPath(rootFolder));
Visited.insert(FileUtils::RealPath(rootFolder));
Q.push_back(CLRealPath(rootFolder));
Visited.insert(CLRealPath(rootFolder));

while (!Q.empty()) {
wxString dirpath = Q.front();
Expand Down Expand Up @@ -299,7 +305,7 @@ void clFilesScanner::ScanWithCallbacks(const wxString& rootFolder, std::function

if (on_folder_cb && on_folder_cb(fullpath)) {
// Traverse into this folder
wxString real_path = FileUtils::RealPath(fullpath);
wxString real_path = CLRealPath(fullpath);
if (Visited.insert(real_path).second) {
Q.push_back(fullpath);
}
Expand Down
1 change: 1 addition & 0 deletions LiteEditor/BuildTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void BuildTab::OnLineActivated(wxDataViewEvent& e)
}
editor->SetActive();
};
std::cout << __func__ << ":" << __LINE__ << ": " << cd->match_pattern.file_path << ":" << line_number << ":" << column << std::endl;
clGetManager()->OpenFileAndAsyncExecute(fn.GetFullPath(), std::move(cb));
}
}
Expand Down
1 change: 1 addition & 0 deletions LiteEditor/cl_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,7 @@ bool clEditor::SaveToFile(const wxFileName& fileName)
// Make sure that the folder does exist
intermediateFile.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
intermediateFile.SetFullName("~" + fileName.GetFullName() + "." + ::wxGetUserId());
std::cout << "SaveToFile:" << __LINE__ << ": " << fileName.GetFullPath() << " " << intermediateFile.GetFullPath() << std::endl;

{
// Ensure that a temporary file with this name does not exist
Expand Down
32 changes: 26 additions & 6 deletions LiteEditor/mainbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ int MainBook::FindEditorIndexByFullPath(const wxString& fullpath)
{
#ifdef __WXGTK__
// On gtk either fileName or the editor filepath (or both) may be (or their paths contain) symlinks
wxString fileNameDest = CLRealPath(fullpath);
wxString fileNameDest = CLRealPath_forced(fullpath);
#endif

for (size_t i = 0; i < m_book->GetPageCount(); ++i) {
Expand Down Expand Up @@ -466,8 +466,9 @@ int MainBook::FindEditorIndexByFullPath(const wxString& fullpath)

#if defined(__WXGTK__)
// Try again, dereferencing the editor fpath
wxString editorDest = CLRealPath(unixStyleFile);
wxString editorDest = CLRealPath_forced(unixStyleFile);
if (editorDest.Cmp(fullpath) == 0 || editorDest.Cmp(fileNameDest) == 0) {
std::cout << __func__ << ":" << __LINE__ << ": " << i << ": " << fullpath << ": " << fileNameDest << std::endl;
return i;
}
#endif
Expand Down Expand Up @@ -595,8 +596,19 @@ clEditor* MainBook::OpenFile(const wxString& file_name, const wxString& projectN
int bmp /*= wxNullBitmap*/, const wxString& tooltip /* wxEmptyString */)
{
wxFileName fileName(CLRealPath(file_name));
std::cout << "OpenFile:" << __LINE__ << ": " << file_name << ": " << fileName.GetFullPath() << ": " << std::endl; // UJ:

if (fileName.IsRelative()) {
if (clWorkspaceManager::Get().IsWorkspaceOpened()) {
wxFileName wsPath = clWorkspaceManager::Get().GetWorkspace()->GetDir();
fileName.MakeAbsolute(wsPath.GetFullPath());
std::cout << "OpenFile:" << __LINE__ << ": " << wsPath.GetFullPath() << ": " << fileName.GetFullPath() << ": " << std::endl; // UJ:
}
}
fileName.MakeAbsolute();

std::cout << "OpenFile:" << __LINE__ << ": " << file_name << ": " << fileName.GetFullPath() << ": " << lineno << position << ": " << std::endl; // UJ:

#ifdef __WXMSW__
// Handle cygwin paths
wxString curpath = fileName.GetFullPath();
Expand Down Expand Up @@ -1746,20 +1758,23 @@ WelcomePage* MainBook::GetWelcomePage(bool createIfMissing)

clEditor* MainBook::OpenFileAsync(const wxString& file_name, std::function<void(IEditor*)>&& callback)
{
wxString real_path = CLRealPath(file_name);
wxString real_path = CLRealPath_forced(file_name);
auto editor = FindEditor(real_path);
if (editor) {
push_callback(std::move(callback), real_path);
std::cout << "OpenFileAsync: " << __LINE__ << std::endl;
bool is_active = GetActiveEditor() == editor;
if (!is_active) {
// make this file the active
int index = m_book->GetPageIndex(editor);
m_book->SetSelection(index);
std::cout << "OpenFileAsync: " << __LINE__ << std::endl;
}
} else {
editor = OpenFile(real_path);
editor = OpenFile(file_name);
if (editor) {
push_callback(std::move(callback), real_path);
std::cout << "OpenFileAsync: " << __LINE__ << std::endl;
}
}
return editor;
Expand All @@ -1773,6 +1788,7 @@ void MainBook::push_callback(std::function<void(IEditor*)>&& callback, const wxS
m_callbacksTable.insert({ key, {} });
}
m_callbacksTable[key].emplace_back(std::move(callback));
std::cout << "push_callbacks: " << __LINE__ << " key: " << key << " path: " << fullpath << std::endl;
}

bool MainBook::has_callbacks(const wxString& fullpath) const
Expand All @@ -1785,9 +1801,12 @@ void MainBook::execute_callbacks_for_file(const wxString& fullpath)
{
wxString key = create_platform_filepath(fullpath);
if (!has_callbacks(key)) {
//std::cout << "execute_callbacks_for_file: has_no_callback: " << __LINE__ << ": " << fullpath << std::endl;
return;
}

std::cout << "execute_callbacks_for_file: " << __LINE__ << " key: " << key << " path: " << fullpath << std::endl;

auto& V = m_callbacksTable[key];
if (V.empty()) {
return; // cant really happen
Expand Down Expand Up @@ -1822,11 +1841,12 @@ void MainBook::OnIdle(wxIdleEvent& event)
auto editor = GetActiveEditor();
CHECK_PTR_RET(editor);

execute_callbacks_for_file(CLRealPath(editor->GetFileName().GetFullPath()));
execute_callbacks_for_file(CLRealPath_forced(editor->GetFileName().GetFullPath()));
}

void MainBook::OnEditorModified(clCommandEvent& event) { event.Skip(); }

void MainBook::OnEditorSaved(clCommandEvent& event) { event.Skip(); }

void MainBook::OnSessionLoaded(clCommandEvent& event) { event.Skip(); }
void MainBook::OnSessionLoaded(clCommandEvent& event) { event.Skip(); }

6 changes: 6 additions & 0 deletions Plugin/clFileSystemWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ void clFileSystemWorkspace::OnBuildEnded(clBuildEvent& event) { event.Skip(); }

void clFileSystemWorkspace::OnOpenWorkspace(clCommandEvent& event)
{
std::cout << __func__ << ":" << __LINE__ << ": " << std::endl;

event.Skip();
if (OpenWorkspace(event.GetFileName())) {
event.Skip(false);
Expand All @@ -254,6 +256,8 @@ void clFileSystemWorkspace::OnOpenWorkspace(clCommandEvent& event)

void clFileSystemWorkspace::OnCloseWorkspace(clCommandEvent& event)
{
std::cout << __func__ << ":" << __LINE__ << ": " << std::endl;

event.Skip();
if (CloseWorkspace()) {
event.Skip(false);
Expand Down Expand Up @@ -1165,6 +1169,8 @@ bool clFileSystemWorkspace::CloseWorkspace()
void clFileSystemWorkspace::OnReloadWorkspace(clCommandEvent& event)
{
if (!IsOpen()) {
std::cout << __func__ << ":" << __LINE__ << ": " << std::endl;

event.Skip();
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Plugin/clFileSystemWorkspaceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ std::pair<JSONItem, JSONItem> clFileSystemWorkspaceConfig::ToJSON() const
shared.addProperty("file_extensions", m_fileExtensions);
shared.addProperty("excludeFilesPattern", m_excludeFilesPattern);
shared.addProperty("excludePaths", m_excludePaths);
shared.addProperty("resolveSymlinks", m_resolveSymlinks);
shared.addProperty("debugger", m_debugger);

// Local items
Expand Down Expand Up @@ -93,6 +94,7 @@ void clFileSystemWorkspaceConfig::FromSharedJSON(const JSONItem& json)
m_fileExtensions = json.namedObject("file_extensions").toString(m_fileExtensions);
m_excludeFilesPattern = json.namedObject("excludeFilesPattern").toString(m_excludeFilesPattern);
m_excludePaths = json.namedObject("excludePaths").toString(m_excludePaths);
m_resolveSymlinks = json.namedObject("resolveSymlinks").toBool(m_resolveSymlinks);
m_debugger = json.namedObject("debugger").toString(m_debugger);
}

Expand Down
3 changes: 3 additions & 0 deletions Plugin/clFileSystemWorkspaceConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WXDLLIMPEXP_SDK clFileSystemWorkspaceConfig
wxString m_debuggerPath;
wxString m_debuggerCommands;
wxArrayString m_lastExecutables;
bool m_resolveSymlinks = false;

public:
typedef wxSharedPtr<clFileSystemWorkspaceConfig> Ptr_t;
Expand Down Expand Up @@ -109,6 +110,8 @@ class WXDLLIMPEXP_SDK clFileSystemWorkspaceConfig
m_flags &= ~kRemoteBuild;
}
}
bool GetResolveSymlinks() const { return m_resolveSymlinks; }
void SetResolveSymlinks(bool b) { m_resolveSymlinks = b; }

wxArrayString ExpandUserCompletionFlags(const wxString& workingDirectory, clBacktickCache::ptr_t backticks,
bool withPrefix = false) const;
Expand Down
Loading

0 comments on commit c0322bf

Please sign in to comment.