mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed fixit location for usings when file has scoped usings
This commit is contained in:
parent
c523a73860
commit
1cb91c304b
3 changed files with 19 additions and 0 deletions
|
@ -3671,6 +3671,7 @@ void BfAutoComplete::FixitAddNamespace(BfAstNode* refNode, const StringImpl& nam
|
|||
auto parserData = refNode->GetParserData();
|
||||
|
||||
BfUsingFinder usingFinder;
|
||||
usingFinder.mFromIdx = refNode->mSrcStart;
|
||||
usingFinder.VisitMembers(refNode->GetSourceData()->mRootNode);
|
||||
AddEntry(AutoCompleteEntry("fixit", StrFormat("using %s;\t.using|%s|%d||using %s;", namespaceStr.c_str(), parserData->mFileName.c_str(),
|
||||
usingFinder.mLastIdx, namespaceStr.c_str()).c_str()));
|
||||
|
|
|
@ -55,17 +55,34 @@ public:
|
|||
class BfUsingFinder : public BfFixitFinder
|
||||
{
|
||||
public:
|
||||
int mFromIdx;
|
||||
int mLastIdx;
|
||||
|
||||
public:
|
||||
BfUsingFinder()
|
||||
{
|
||||
mLastIdx = 0;
|
||||
mFromIdx = -1;
|
||||
}
|
||||
|
||||
virtual void Visit(BfUsingDirective* usingDirective) override
|
||||
{
|
||||
mLastIdx = FindLineStartAfter(usingDirective->GetSourceData(), usingDirective->GetSrcEnd());
|
||||
}
|
||||
|
||||
virtual void Visit(BfNamespaceDeclaration* namespaceDecl) override
|
||||
{
|
||||
if (mFromIdx != -1)
|
||||
{
|
||||
if ((mFromIdx < namespaceDecl->mSrcStart) || (mFromIdx >= namespaceDecl->mSrcEnd))
|
||||
{
|
||||
// Not inside
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BfFixitFinder::Visit(namespaceDecl);
|
||||
}
|
||||
};
|
||||
|
||||
NS_BF_END
|
|
@ -9931,6 +9931,7 @@ void BfModule::CheckTypeRefFixit(BfAstNode* typeRef, const char* appendName)
|
|||
int insertLoc = 0;
|
||||
|
||||
BfUsingFinder usingFinder;
|
||||
usingFinder.mFromIdx = typeRef->mSrcStart;
|
||||
usingFinder.VisitMembers(typeRef->GetSourceData()->mRootNode);
|
||||
|
||||
for (auto& namespaceStr : fixitNamespaces)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue