mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-11 04:52:21 +02:00
Fixit for brace-to-paren for object initializers
This commit is contained in:
parent
535045c48a
commit
10421d99ca
4 changed files with 38 additions and 7 deletions
|
@ -318,13 +318,13 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Field | .Method /*2*/)]
|
[AttributeUsage(.Field | .Method | .Property /*2*/)]
|
||||||
public struct NoShowAttribute : Attribute
|
public struct NoShowAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Field | .Method /*2*/)]
|
[AttributeUsage(.Field | .Method | .Property /*2*/)]
|
||||||
public struct HideAttribute : Attribute
|
public struct HideAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -2277,6 +2277,16 @@ namespace IDE.ui
|
||||||
|
|
||||||
void ApplyFixit(String data)
|
void ApplyFixit(String data)
|
||||||
{
|
{
|
||||||
|
int splitIdx = data.IndexOf('\x01');
|
||||||
|
if (splitIdx != -1)
|
||||||
|
{
|
||||||
|
String lhs = scope String(data, 0, splitIdx);
|
||||||
|
String rhs = scope String(data, splitIdx + 1);
|
||||||
|
ApplyFixit(lhs);
|
||||||
|
ApplyFixit(rhs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UndoBatchStart undoBatchStart = null;
|
UndoBatchStart undoBatchStart = null;
|
||||||
|
|
||||||
var parts = String.StackSplit!(data, '|');
|
var parts = String.StackSplit!(data, '|');
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "BfUtil.h"
|
#include "BfUtil.h"
|
||||||
#include "BfDeferEvalChecker.h"
|
#include "BfDeferEvalChecker.h"
|
||||||
#include "BfVarDeclChecker.h"
|
#include "BfVarDeclChecker.h"
|
||||||
|
#include "BfFixits.h"
|
||||||
|
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
@ -7420,7 +7421,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
||||||
paramTypes.Add(resolvedArg.mTypedValue.mType);
|
paramTypes.Add(resolvedArg.mTypedValue.mType);
|
||||||
}
|
}
|
||||||
|
|
||||||
autoComplete->FixitAddMethod(typeInst, methodName, mExpectingType, paramTypes, wantStatic);
|
autoComplete->FixitAddMethod(typeInst, methodName, mExpectingType, paramTypes, wantStatic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11683,8 +11684,20 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
||||||
autoComplete->CheckTypeRef(objCreateExpr->mTypeRef, false, true);
|
autoComplete->CheckTypeRef(objCreateExpr->mTypeRef, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (objCreateExpr->mArraySizeSpecifier == NULL)
|
if ((autoComplete != NULL) && (objCreateExpr->mOpenToken != NULL) && (objCreateExpr->mCloseToken != NULL) &&
|
||||||
CheckObjectCreateTypeRef(mExpectingType, objCreateExpr->mNewNode);
|
(objCreateExpr->mOpenToken->mToken == BfToken_LBrace) && (autoComplete->CheckFixit(objCreateExpr->mOpenToken)))
|
||||||
|
{
|
||||||
|
auto refNode = objCreateExpr->mOpenToken;
|
||||||
|
BfParserData* parser = refNode->GetSourceData()->ToParserData();
|
||||||
|
if (parser != NULL)
|
||||||
|
{
|
||||||
|
autoComplete->AddEntry(AutoCompleteEntry("fixit", StrFormat("Change initializer braces to parentheses\treformat|%s|%d-1|(\x01|%s|%d-1|)",
|
||||||
|
parser->mFileName.c_str(), refNode->mSrcStart,
|
||||||
|
parser->mFileName.c_str(), objCreateExpr->mCloseToken->mSrcStart).c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckObjectCreateTypeRef(mExpectingType, objCreateExpr->mNewNode);
|
||||||
|
|
||||||
BfAttributeState attributeState;
|
BfAttributeState attributeState;
|
||||||
attributeState.mTarget = BfAttributeTargets_Alloc;
|
attributeState.mTarget = BfAttributeTargets_Alloc;
|
||||||
|
|
|
@ -1613,7 +1613,15 @@ void BfPrinter::Visit(BfObjectCreateExpression* newExpr)
|
||||||
ExpectSpace();
|
ExpectSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
VisitChild(newExpr->mOpenToken);
|
auto _WriteToken = [&](BfAstNode* node, BfToken token)
|
||||||
|
{
|
||||||
|
if (node == NULL)
|
||||||
|
return;
|
||||||
|
Visit(node);
|
||||||
|
Write(BfTokenToString(token));
|
||||||
|
};
|
||||||
|
|
||||||
|
_WriteToken(newExpr->mOpenToken, BfToken_LParen);
|
||||||
for (int i = 0; i < (int)newExpr->mArguments.size(); i++)
|
for (int i = 0; i < (int)newExpr->mArguments.size(); i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
@ -1623,7 +1631,7 @@ void BfPrinter::Visit(BfObjectCreateExpression* newExpr)
|
||||||
}
|
}
|
||||||
VisitChild(newExpr->mArguments[i]);
|
VisitChild(newExpr->mArguments[i]);
|
||||||
}
|
}
|
||||||
VisitChild(newExpr->mCloseToken);
|
_WriteToken(newExpr->mCloseToken, BfToken_RParen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfPrinter::Visit(BfBoxExpression* boxExpr)
|
void BfPrinter::Visit(BfBoxExpression* boxExpr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue