mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Improved autocomplete with string interpolation
This commit is contained in:
parent
e8a8985734
commit
454ed279dc
2 changed files with 64 additions and 17 deletions
|
@ -1444,10 +1444,14 @@ namespace IDE.ui
|
|||
{
|
||||
mInvokeSrcPositions.Clear();
|
||||
int32 openDepth = 0;
|
||||
int32 braceDepth = 0;
|
||||
int32 checkIdx = startIdx;
|
||||
mInvokeSrcPositions.Add(startIdx);
|
||||
int32 argCount = 0;
|
||||
|
||||
bool inInterpolatedString = false;
|
||||
bool inInterpolatedExpr = false;
|
||||
|
||||
void HadContent()
|
||||
{
|
||||
if (argCount == 0)
|
||||
|
@ -1455,31 +1459,55 @@ namespace IDE.ui
|
|||
}
|
||||
|
||||
bool failed = false;
|
||||
while (checkIdx < mTargetEditWidget.Content.mData.mText.Count)
|
||||
while (checkIdx < data.mText.Count)
|
||||
{
|
||||
var char8Data = mTargetEditWidget.Content.mData.mText[checkIdx];
|
||||
if (char8Data.mDisplayTypeId == 0)
|
||||
{
|
||||
if (char8Data.mChar == '{')
|
||||
var charData = data.mText[checkIdx];
|
||||
if (inInterpolatedExpr)
|
||||
{
|
||||
if ((SourceElementType)charData.mDisplayTypeId == .Normal)
|
||||
{
|
||||
openDepth++;
|
||||
failed = true;
|
||||
break;
|
||||
if (charData.mChar == '{')
|
||||
{
|
||||
braceDepth++;
|
||||
}
|
||||
else if (charData.mChar == '}')
|
||||
{
|
||||
braceDepth--;
|
||||
if (braceDepth == 0)
|
||||
inInterpolatedExpr = false;
|
||||
}
|
||||
}
|
||||
else if (char8Data.mChar == '}')
|
||||
openDepth--;
|
||||
else if (char8Data.mChar == '(')
|
||||
|
||||
}
|
||||
else if ((SourceElementType)charData.mDisplayTypeId == .Normal)
|
||||
{
|
||||
if (charData.mChar == '{')
|
||||
{
|
||||
braceDepth++;
|
||||
if (inInterpolatedString)
|
||||
{
|
||||
inInterpolatedExpr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (charData.mChar == '}')
|
||||
braceDepth--;
|
||||
else if (charData.mChar == '(')
|
||||
openDepth++;
|
||||
else if (char8Data.mChar == ')')
|
||||
else if (charData.mChar == ')')
|
||||
{
|
||||
openDepth--;
|
||||
}
|
||||
else if ((char8Data.mChar == ',') && (openDepth == 1))
|
||||
else if ((charData.mChar == ',') && (openDepth == 1))
|
||||
{
|
||||
mInvokeSrcPositions.Add(checkIdx);
|
||||
argCount++;
|
||||
}
|
||||
else if (!((char8)char8Data.mChar).IsWhiteSpace)
|
||||
else if (!((char8)charData.mChar).IsWhiteSpace)
|
||||
HadContent();
|
||||
|
||||
if (openDepth == 0)
|
||||
|
@ -1488,8 +1516,24 @@ namespace IDE.ui
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (char8Data.mDisplayPassId != (.)SourceElementType.Comment)
|
||||
else if ((SourceElementType)charData.mDisplayPassId != .Comment)
|
||||
{
|
||||
if ((SourceElementType)charData.mDisplayTypeId == .Literal)
|
||||
{
|
||||
if ((charData.mChar == '"') &&
|
||||
(checkIdx > 1) && (data.mText[checkIdx - 1].mChar == '$') &&
|
||||
((SourceElementType)data.mText[checkIdx - 1].mDisplayTypeId == .Literal))
|
||||
{
|
||||
inInterpolatedString = true;
|
||||
}
|
||||
else if ((inInterpolatedString) &&
|
||||
(charData.mChar == '"') &&
|
||||
(checkIdx > 1) && (data.mText[checkIdx - 1].mChar != '\\'))
|
||||
{
|
||||
inInterpolatedString = false;
|
||||
}
|
||||
}
|
||||
|
||||
HadContent();
|
||||
}
|
||||
checkIdx++;
|
||||
|
|
|
@ -3895,8 +3895,11 @@ void BfExprEvaluator::Visit(BfStringInterpolationExpression* stringInterpolation
|
|||
BfTokenNode* newToken = NULL;
|
||||
BfAllocTarget allocTarget;
|
||||
ResolveAllocTarget(allocTarget, stringInterpolationExpression->mAllocNode, newToken);
|
||||
|
||||
CreateObject(NULL, stringInterpolationExpression->mAllocNode, stringType);
|
||||
//
|
||||
{
|
||||
SetAndRestoreValue<BfEvalExprFlags> prevFlags(mBfEvalExprFlags, (BfEvalExprFlags)(mBfEvalExprFlags | BfEvalExprFlags_NoAutoComplete));
|
||||
CreateObject(NULL, stringInterpolationExpression->mAllocNode, stringType);
|
||||
}
|
||||
BfTypedValue newString = mResult;
|
||||
BF_ASSERT(newString);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue