mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added mouseover docs support
This commit is contained in:
parent
dc2603bc60
commit
e02b42d6f4
5 changed files with 58 additions and 28 deletions
|
@ -724,23 +724,20 @@ namespace IDE.ui
|
|||
if (evalString.StartsWith(":", StringComparison.Ordinal))
|
||||
{
|
||||
var showString = scope String(evalString, 1);
|
||||
int crPos = showString.IndexOf('\n');
|
||||
if (crPos != -1)
|
||||
bool isShowingDoc = showString.Contains('\x01');
|
||||
if (!isShowingDoc)
|
||||
{
|
||||
val.Append("\n\n");
|
||||
val.Append(showString, crPos + 1);
|
||||
showString.RemoveToEnd(crPos);
|
||||
int crPos = showString.IndexOf('\n');
|
||||
if (crPos != -1)
|
||||
{
|
||||
val.Append("\n\n");
|
||||
val.Append(showString, crPos + 1);
|
||||
showString.RemoveToEnd(crPos);
|
||||
}
|
||||
}
|
||||
|
||||
useListViewItem.Label = showString;
|
||||
isStringLiteral = true;
|
||||
|
||||
|
||||
/*int lineCount = 0;
|
||||
for (int i = 0; i < evalString.Length; i++)
|
||||
if (evalString[i] == '\n')
|
||||
lineCount++;
|
||||
listViewItem.mBottomPadding = listView.mFont.GetLineSpacing() * lineCount; */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4852,6 +4852,24 @@ namespace IDE.ui
|
|||
origDebugExpr.Set(debugExpr);
|
||||
|
||||
debugExpr.Set(resolveParams.mResultString);
|
||||
|
||||
if (debugExpr.StartsWith(':'))
|
||||
{
|
||||
int docsPos = debugExpr.IndexOf('\x03');
|
||||
if (docsPos != -1)
|
||||
{
|
||||
String docs = scope String()..Append(debugExpr, docsPos + 1);
|
||||
debugExpr.RemoveToEnd(docsPos);
|
||||
|
||||
DocumentationParser docParser = scope .(docs);
|
||||
var showString = docParser.ShowDocString;
|
||||
if (!String.IsNullOrEmpty(showString))
|
||||
{
|
||||
debugExpr.AppendF("\n{}", Font.EncodeColor(0xFFC0C0C0));
|
||||
debugExpr.Append(showString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!triedShow)
|
||||
|
|
|
@ -1855,6 +1855,17 @@ class BfCommentNode : public BfAstNode
|
|||
public:
|
||||
BF_AST_TYPE(BfCommentNode, BfAstNode);
|
||||
BfCommentKind mCommentKind;
|
||||
|
||||
void GetDocString(StringImpl& docString)
|
||||
{
|
||||
ToString(docString);
|
||||
for (int i = 0; i < (int)docString.length(); i++)
|
||||
{
|
||||
char c = docString[i];
|
||||
if (c == '\n')
|
||||
docString[i] = '\x3';
|
||||
}
|
||||
}
|
||||
}; BF_AST_DECL(BfCommentNode, BfAstNode);
|
||||
|
||||
class BfPreprocesorIgnoredSectionNode : public BfAstNode
|
||||
|
|
|
@ -7287,19 +7287,7 @@ void BfCompiler::GenerateAutocompleteInfo()
|
|||
|
||||
String& autoCompleteResultString = *gTLStrReturn.Get();
|
||||
autoCompleteResultString.Clear();
|
||||
|
||||
auto _GetDocString = [&](BfCommentNode* commentNode, StringImpl& docString)
|
||||
{
|
||||
commentNode->ToString(docString);
|
||||
for (int i = 0; i < (int)docString.length(); i++)
|
||||
{
|
||||
char c = docString[i];
|
||||
if (c == '\n')
|
||||
docString[i] = '\x3';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
auto bfModule = mResolvePassData->mAutoComplete->mModule;
|
||||
if (bfModule != NULL)
|
||||
{
|
||||
|
@ -7653,7 +7641,7 @@ void BfCompiler::GenerateAutocompleteInfo()
|
|||
if ((methodDeclaration != NULL) && (methodDeclaration->mDocumentation != NULL))
|
||||
{
|
||||
String docString;
|
||||
_GetDocString(methodDeclaration->mDocumentation, docString);
|
||||
methodDeclaration->mDocumentation->GetDocString(docString);
|
||||
methodText += "\x03";
|
||||
methodText += docString;
|
||||
}
|
||||
|
@ -7689,7 +7677,7 @@ void BfCompiler::GenerateAutocompleteInfo()
|
|||
if ((entry->mDocumentation != NULL) && (wantsDocEntry != NULL) && (strcmp(wantsDocEntry, entry->mDisplay) == 0))
|
||||
{
|
||||
docString.Clear();
|
||||
_GetDocString(entry->mDocumentation, docString);
|
||||
entry->mDocumentation->GetDocString(docString);
|
||||
autoCompleteResultString += '\x03';
|
||||
autoCompleteResultString += docString;
|
||||
}
|
||||
|
|
|
@ -3850,7 +3850,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
autoComplete->mResultString += field->mName;
|
||||
|
||||
if (fieldInstance->mConstIdx != -1)
|
||||
{
|
||||
{
|
||||
String constStr = autoComplete->ConstantToString(curCheckType->mConstHolder, BfIRValue(BfIRValueFlags_Const, fieldInstance->mConstIdx));
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
|
@ -3861,6 +3861,15 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
autoComplete->mResultString += constStr;
|
||||
}
|
||||
}
|
||||
|
||||
auto fieldDecl = fieldInstance->GetFieldDef()->mFieldDeclaration;
|
||||
if ((fieldDecl != NULL) && (fieldDecl->mDocumentation != NULL))
|
||||
{
|
||||
String docString;
|
||||
fieldDecl->mDocumentation->GetDocString(docString);
|
||||
autoComplete->mResultString += "\x03";
|
||||
autoComplete->mResultString += docString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7872,6 +7881,13 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->MethodToString(moduleMethodInstance.mMethodInstance);
|
||||
|
||||
auto methodDecl = moduleMethodInstance.mMethodInstance->mMethodDef->GetMethodDeclaration();
|
||||
if ((methodDecl != NULL) && (methodDecl->mDocumentation != NULL))
|
||||
{
|
||||
autoComplete->mResultString += "\x03";
|
||||
methodDecl->mDocumentation->GetDocString(autoComplete->mResultString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue