mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +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();
|
mInvokeSrcPositions.Clear();
|
||||||
int32 openDepth = 0;
|
int32 openDepth = 0;
|
||||||
|
int32 braceDepth = 0;
|
||||||
int32 checkIdx = startIdx;
|
int32 checkIdx = startIdx;
|
||||||
mInvokeSrcPositions.Add(startIdx);
|
mInvokeSrcPositions.Add(startIdx);
|
||||||
int32 argCount = 0;
|
int32 argCount = 0;
|
||||||
|
|
||||||
|
bool inInterpolatedString = false;
|
||||||
|
bool inInterpolatedExpr = false;
|
||||||
|
|
||||||
void HadContent()
|
void HadContent()
|
||||||
{
|
{
|
||||||
if (argCount == 0)
|
if (argCount == 0)
|
||||||
|
@ -1455,31 +1459,55 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
while (checkIdx < mTargetEditWidget.Content.mData.mText.Count)
|
while (checkIdx < data.mText.Count)
|
||||||
{
|
{
|
||||||
var char8Data = mTargetEditWidget.Content.mData.mText[checkIdx];
|
var charData = data.mText[checkIdx];
|
||||||
if (char8Data.mDisplayTypeId == 0)
|
if (inInterpolatedExpr)
|
||||||
{
|
{
|
||||||
if (char8Data.mChar == '{')
|
if ((SourceElementType)charData.mDisplayTypeId == .Normal)
|
||||||
{
|
{
|
||||||
openDepth++;
|
if (charData.mChar == '{')
|
||||||
failed = true;
|
{
|
||||||
break;
|
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++;
|
openDepth++;
|
||||||
else if (char8Data.mChar == ')')
|
else if (charData.mChar == ')')
|
||||||
{
|
{
|
||||||
openDepth--;
|
openDepth--;
|
||||||
}
|
}
|
||||||
else if ((char8Data.mChar == ',') && (openDepth == 1))
|
else if ((charData.mChar == ',') && (openDepth == 1))
|
||||||
{
|
{
|
||||||
mInvokeSrcPositions.Add(checkIdx);
|
mInvokeSrcPositions.Add(checkIdx);
|
||||||
argCount++;
|
argCount++;
|
||||||
}
|
}
|
||||||
else if (!((char8)char8Data.mChar).IsWhiteSpace)
|
else if (!((char8)charData.mChar).IsWhiteSpace)
|
||||||
HadContent();
|
HadContent();
|
||||||
|
|
||||||
if (openDepth == 0)
|
if (openDepth == 0)
|
||||||
|
@ -1488,8 +1516,24 @@ namespace IDE.ui
|
||||||
break;
|
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();
|
HadContent();
|
||||||
}
|
}
|
||||||
checkIdx++;
|
checkIdx++;
|
||||||
|
|
|
@ -3895,8 +3895,11 @@ void BfExprEvaluator::Visit(BfStringInterpolationExpression* stringInterpolation
|
||||||
BfTokenNode* newToken = NULL;
|
BfTokenNode* newToken = NULL;
|
||||||
BfAllocTarget allocTarget;
|
BfAllocTarget allocTarget;
|
||||||
ResolveAllocTarget(allocTarget, stringInterpolationExpression->mAllocNode, newToken);
|
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;
|
BfTypedValue newString = mResult;
|
||||||
BF_ASSERT(newString);
|
BF_ASSERT(newString);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue