- fix: Results of "find symbol usage" in project not correctly set in the search result view
This commit is contained in:
parent
3352d413b3
commit
14254a2f15
1
NEWS.md
1
NEWS.md
|
@ -3,6 +3,7 @@ Version 0.7.9
|
|||
- fix: hit info not correctly displayed in the search result view
|
||||
- fix: If find in files found no hits, search result view will not be shown.
|
||||
- fix: wront indents when paste one line content
|
||||
- fix: Results of "find symbol usage" in project not correctly set in the search result view
|
||||
|
||||
Version 0.7.8
|
||||
- enhancement: In problem view's output control, indicates which line is different with the expected
|
||||
|
|
|
@ -35,23 +35,33 @@ bool CppRefacter::findOccurence(Editor *editor, const BufferCoord &pos)
|
|||
|
||||
std::shared_ptr<Project> project = pMainWindow->project();
|
||||
if (editor->inProject() && project) {
|
||||
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
|
||||
statement->fullName,
|
||||
SearchFileScope::wholeProject
|
||||
);
|
||||
foreach (const PProjectUnit& unit, project->units()) {
|
||||
if (isCfile(unit->fileName()) || isHfile(unit->fileName())) {
|
||||
findOccurenceInFile(
|
||||
phrase,
|
||||
unit->fileName(),
|
||||
statement,
|
||||
pos.Line,
|
||||
editor->parser());
|
||||
PSearchResultTreeItem item = findOccurenceInFile(
|
||||
unit->fileName(),
|
||||
statement,
|
||||
editor->parser());
|
||||
if (item && !(item->results.isEmpty())) {
|
||||
results->results.append(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
findOccurenceInFile(
|
||||
phrase,
|
||||
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
|
||||
statement->fullName,
|
||||
SearchFileScope::currentFile
|
||||
);
|
||||
PSearchResultTreeItem item = findOccurenceInFile(
|
||||
editor->filename(),
|
||||
statement,
|
||||
pos.Line,
|
||||
editor->parser());
|
||||
if (item && !(item->results.isEmpty())) {
|
||||
results->results.append(item);
|
||||
}
|
||||
}
|
||||
pMainWindow->searchResultModel()->notifySearchResultsUpdated();
|
||||
return true;
|
||||
|
@ -241,25 +251,3 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
|||
realEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
void CppRefacter::findOccurenceInFile(
|
||||
const QString& phrase,
|
||||
const QString &filename,
|
||||
const PStatement &statement,
|
||||
int line,
|
||||
const PCppParser &parser)
|
||||
{
|
||||
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
|
||||
phrase,
|
||||
filename,
|
||||
line
|
||||
);
|
||||
|
||||
PSearchResultTreeItem item = findOccurenceInFile(
|
||||
filename,
|
||||
statement,
|
||||
parser);
|
||||
if (item && !(item->results.isEmpty())) {
|
||||
results->results.append(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,6 @@ public:
|
|||
void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& word, const QString& newWord);
|
||||
signals:
|
||||
private:
|
||||
void findOccurenceInFile(
|
||||
const QString& phrase,
|
||||
const QString& filename,
|
||||
const PStatement& statement,
|
||||
int line,
|
||||
const PCppParser& parser);
|
||||
PSearchResultTreeItem findOccurenceInFile(
|
||||
const QString& filename,
|
||||
const PStatement& statement,
|
||||
|
|
|
@ -31,15 +31,17 @@ PSearchResults SearchResultModel::addSearchResults(const QString &keyword, SynSe
|
|||
return results;
|
||||
}
|
||||
|
||||
PSearchResults SearchResultModel::addSearchResults(const QString &keyword, const QString &filename, int symbolLine)
|
||||
PSearchResults SearchResultModel::addSearchResults(
|
||||
const QString& symbolFullname,
|
||||
SearchFileScope scope)
|
||||
{
|
||||
int index=-1;
|
||||
for (int i=0;i<mSearchResults.size();i++) {
|
||||
PSearchResults results = mSearchResults[i];
|
||||
if (results->searchType == SearchType::FindOccurences
|
||||
&& results->keyword == keyword
|
||||
&& results->filename == filename
|
||||
&& results->symbolLine == symbolLine) {
|
||||
&& results->scope == scope
|
||||
&& results->keyword == symbolFullname
|
||||
) {
|
||||
index=i;
|
||||
break;
|
||||
}
|
||||
|
@ -51,10 +53,10 @@ PSearchResults SearchResultModel::addSearchResults(const QString &keyword, const
|
|||
mSearchResults.pop_back();
|
||||
}
|
||||
PSearchResults results = std::make_shared<SearchResults>();
|
||||
results->keyword = keyword;
|
||||
results->filename = filename;
|
||||
results->symbolLine = symbolLine;
|
||||
results->keyword = symbolFullname;
|
||||
results->filename = "";
|
||||
results->searchType = SearchType::FindOccurences;
|
||||
results->scope = scope;
|
||||
mSearchResults.push_front(results);
|
||||
mCurrentIndex = 0;
|
||||
return results;
|
||||
|
@ -367,10 +369,13 @@ QVariant SearchResultListModel::data(const QModelIndex &index, int role) const
|
|||
return tr("Open Files:") + QString(" \"%1\"").arg(results->keyword);
|
||||
}
|
||||
} else if (results->searchType == SearchType::FindOccurences) {
|
||||
return tr("References to symbol \'%1\' at '%2':%3")
|
||||
.arg(results->keyword)
|
||||
.arg(extractFileName(results->filename))
|
||||
.arg(results->symbolLine);
|
||||
if (results->scope == SearchFileScope::currentFile) {
|
||||
return tr("Find Usages in Current File: '%1'")
|
||||
.arg(results->keyword);
|
||||
} else {
|
||||
return tr("Find Usages in Project: '%1'")
|
||||
.arg(results->keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
|
|
@ -35,7 +35,6 @@ struct SearchResults{
|
|||
SearchFileScope scope;
|
||||
SearchType searchType;
|
||||
QString filename;
|
||||
int symbolLine;
|
||||
QList<PSearchResultTreeItem> results;
|
||||
};
|
||||
|
||||
|
@ -48,9 +47,8 @@ public:
|
|||
PSearchResults addSearchResults(const QString& keyword,SynSearchOptions options,
|
||||
SearchFileScope scope);
|
||||
PSearchResults addSearchResults(
|
||||
const QString& keyword,
|
||||
const QString& filename,
|
||||
int symbolLine);
|
||||
const QString& symbolFullname,
|
||||
SearchFileScope scope);
|
||||
PSearchResults results(int index);
|
||||
void notifySearchResultsUpdated();
|
||||
int currentIndex() const;
|
||||
|
|
Loading…
Reference in New Issue