Browse Source

Fixes to Find Documentation.

merge-requests/365/head
eidheim 10 years ago
parent
commit
1b5f61b5c7
  1. 49
      src/source.cc

49
src/source.cc

@ -2371,15 +2371,17 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
auto usr=referenced.get_usr(); auto usr=referenced.get_usr();
boost::filesystem::path referenced_path=referenced.get_source_location().get_path(); boost::filesystem::path referenced_path=referenced.get_source_location().get_path();
//Singleton::terminal()->print(usr+'\n', true); //TODO: remove
//Return empty if referenced is within project //Return empty if referenced is within project
if(referenced_path.generic_string().substr(0, this->project_path.generic_string().size()+1)==this->project_path.generic_string()+'/') if(referenced_path.generic_string().substr(0, this->project_path.generic_string().size()+1)==this->project_path.generic_string()+'/')
return data; return data;
data.emplace_back("clang"); data.emplace_back("clang");
//namespace - not working //namespace
size_t pos1=0, pos2; size_t pos1, pos2=0;
while((pos1=usr.find('@', pos1))!=std::string::npos && pos1+1<usr.size() && usr[pos1+1]=='N') { while((pos1=usr.find('@', pos2))!=std::string::npos && pos1+1<usr.size() && usr[pos1+1]=='N') {
pos1+=3; pos1+=3;
pos2=find_non_word_char(usr, pos1); pos2=find_non_word_char(usr, pos1);
if(pos2!=std::string::npos) { if(pos2!=std::string::npos) {
@ -2387,7 +2389,6 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
if(ns=="__1") if(ns=="__1")
break; break;
data.emplace_back(ns); data.emplace_back(ns);
pos1=pos2;
} }
else else
break; break;
@ -2395,32 +2396,46 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
if(data.size()==1) if(data.size()==1)
data.emplace_back(""); data.emplace_back("");
//function //template arguments
pos1=usr.find("@F@"); size_t template_pos=usr.find('$');
size_t function_pos=pos1;
bool found_type_or_function=false;
//type //type
pos1=usr.find("@T@"); pos2=0;
while(((pos1=usr.find("T@", pos2))!=std::string::npos || (pos1=usr.find("S@", pos2))!=std::string::npos) && pos1<template_pos) {
found_type_or_function=true;
pos1+=2;
pos2=find_non_word_char(usr, pos1);
if(pos2!=std::string::npos)
data.emplace_back(usr.substr(pos1, pos2-pos1));
else {
data.emplace_back(usr.substr(pos1));
break;
}
}
//function/constant//variable
pos1=usr.find("F@");
if(pos1==std::string::npos)
pos1=usr.find("C@");
if(pos1==std::string::npos) if(pos1==std::string::npos)
pos1=usr.find("@S@"); pos1=usr.find("I@");
if(pos1!=std::string::npos) { if(pos1!=std::string::npos) {
pos1+=3; pos1+=2;
pos2=find_non_word_char(usr, pos1); pos2=find_non_word_char(usr, pos1);
} }
if(pos1!=std::string::npos && pos1<function_pos) { if(pos1!=std::string::npos) {
found_type_or_function=true;
if(pos2!=std::string::npos) if(pos2!=std::string::npos)
data.emplace_back(usr.substr(pos1, pos2-pos1)); data.emplace_back(usr.substr(pos1, pos2-pos1));
else else
data.emplace_back(usr.substr(pos1)); data.emplace_back(usr.substr(pos1));
} }
//function //Sometimes a method is at end without a identifier it seems:
pos1=function_pos; if(!found_type_or_function && (pos1=usr.rfind('@'))!=std::string::npos) {
if(pos1!=std::string::npos) { pos1++;
pos1+=3;
pos2=find_non_word_char(usr, pos1); pos2=find_non_word_char(usr, pos1);
}
if(pos1!=std::string::npos) {
if(pos2!=std::string::npos) if(pos2!=std::string::npos)
data.emplace_back(usr.substr(pos1, pos2-pos1)); data.emplace_back(usr.substr(pos1, pos2-pos1));
else else

Loading…
Cancel
Save