diff --git a/IDE/src/ui/HoverWatch.bf b/IDE/src/ui/HoverWatch.bf index 1d39e54b..65535639 100644 --- a/IDE/src/ui/HoverWatch.bf +++ b/IDE/src/ui/HoverWatch.bf @@ -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 { diff --git a/IDE/src/ui/SourceViewPanel.bf b/IDE/src/ui/SourceViewPanel.bf index e694e9e9..5b048797 100644 --- a/IDE/src/ui/SourceViewPanel.bf +++ b/IDE/src/ui/SourceViewPanel.bf @@ -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) diff --git a/IDEHelper/Compiler/BfAst.h b/IDEHelper/Compiler/BfAst.h index 945df44f..bce93a12 100644 --- a/IDEHelper/Compiler/BfAst.h +++ b/IDEHelper/Compiler/BfAst.h @@ -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 diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index c30d970b..554c21ec 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -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; } diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 9a41a5ed..6ef524ae 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -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); + } } } }