mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added more informational mouseovers
This commit is contained in:
parent
9499c727ab
commit
d11c79e43e
7 changed files with 183 additions and 13 deletions
|
@ -4767,6 +4767,7 @@ namespace IDE.ui
|
|||
{
|
||||
let resolveParams = scope ResolveParams();
|
||||
resolveParams.mOverrideCursorPos = (int32)textIdx;
|
||||
if (!gApp.mDebugger.IsPaused())
|
||||
Classify(ResolveType.GetResultString, resolveParams);
|
||||
if (!String.IsNullOrEmpty(resolveParams.mResultString))
|
||||
{
|
||||
|
|
|
@ -672,10 +672,13 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
|||
if (propDef->mFieldDeclaration != NULL)
|
||||
documentation = propDef->mFieldDeclaration->mDocumentation;
|
||||
AutoCompleteEntry entry("property", propDef->mName, documentation);
|
||||
if ((AddEntry(entry, filter)) && (mIsGetDefinition) && (propDef->mFieldDeclaration != NULL))
|
||||
if (AddEntry(entry, filter))
|
||||
{
|
||||
if ((mIsGetDefinition) && (propDef->mFieldDeclaration != NULL))
|
||||
SetDefinitionLocation(propDef->mFieldDeclaration->mNameNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allowInterfaces)
|
||||
{
|
||||
|
@ -2383,6 +2386,24 @@ void BfAutoComplete::CheckLocalRef(BfIdentifierNode* identifierNode, BfLocalVari
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (mResolveType == BfResolveType_GetResultString)
|
||||
{
|
||||
if (IsAutocompleteNode(identifierNode))
|
||||
{
|
||||
String constStr;
|
||||
if (varDecl->mConstValue)
|
||||
constStr = ConstantToString(mModule->mBfIRBuilder, varDecl->mConstValue);
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
mResultString = constStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
mResultString = ":";
|
||||
mResultString += mModule->TypeToString(varDecl->mResolvedType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BfAutoComplete::CheckFieldRef(BfIdentifierNode* identifierNode, BfFieldInstance* fieldInst)
|
||||
|
@ -2942,6 +2963,64 @@ String BfAutoComplete::FixitGetLocation(BfParserData* parser, int insertPos)
|
|||
return StrFormat("%s|%d:%d", parser->mFileName.c_str(), line, lineChar);
|
||||
}
|
||||
|
||||
String BfAutoComplete::ConstantToString(BfIRConstHolder* constHolder, BfIRValue id)
|
||||
{
|
||||
char str[32];
|
||||
|
||||
int stringId = mModule->GetStringPoolIdx(id, constHolder);
|
||||
if (stringId != -1)
|
||||
{
|
||||
BfStringPoolEntry* entry;
|
||||
if (mModule->mContext->mStringObjectIdMap.TryGetValue(stringId, &entry))
|
||||
{
|
||||
String result = "\"";
|
||||
result += SlashString(entry->mString, true, true, true);
|
||||
result += "\"";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
auto constant = constHolder->GetConstant(id);
|
||||
switch (constant->mTypeCode)
|
||||
{
|
||||
case BfTypeCode_UInt8:
|
||||
return StrFormat(":(uint8) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt16:
|
||||
return StrFormat(":(uint16) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt32:
|
||||
return StrFormat(":(uint32) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt64:
|
||||
return StrFormat(":(uint64) %llu", constant->mUInt64);
|
||||
|
||||
case BfTypeCode_Int8:
|
||||
return StrFormat(":(int8) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int16:
|
||||
return StrFormat(":(int16) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int32:
|
||||
return StrFormat(":(int32) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int64:
|
||||
return StrFormat(":(int64) %lld", constant->mInt64);
|
||||
|
||||
case BfTypeCode_Single:
|
||||
{
|
||||
ExactMinimalFloatToStr((float)constant->mDouble, str);
|
||||
String result;
|
||||
result += str;
|
||||
result += "f";
|
||||
return result;
|
||||
}
|
||||
case BfTypeCode_Double:
|
||||
{
|
||||
ExactMinimalDoubleToStr(constant->mDouble, str);
|
||||
String result;
|
||||
result += str;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void BfAutoComplete::FixitAddMethod(BfTypeInstance* typeInst, const StringImpl& methodName, BfType* returnType, const BfTypeVector& paramTypes, bool wantStatic)
|
||||
{
|
||||
if ((typeInst->IsEnum()) && (returnType == typeInst) && (wantStatic))
|
||||
|
|
|
@ -222,6 +222,7 @@ public:
|
|||
void FixitGetParamString(const BfTypeVector& paramTypes, StringImpl& outStr);
|
||||
int FixitGetMemberInsertPos(BfTypeDef* typeDef);
|
||||
String FixitGetLocation(BfParserData* parserData, int insertPos);
|
||||
String ConstantToString(BfIRConstHolder* constHolder, BfIRValue id);
|
||||
|
||||
public:
|
||||
BfAutoComplete(BfResolveType resolveType = BfResolveType_Autocomplete);
|
||||
|
|
|
@ -3839,6 +3839,12 @@ void BfCompiler::ProcessAutocompleteTempType()
|
|||
autoComplete->mDefType = actualTypeDef;
|
||||
autoComplete->mInsertStartIdx = nameNode->GetSrcStart();
|
||||
autoComplete->mInsertEndIdx = nameNode->GetSrcEnd();
|
||||
|
||||
if (autoComplete->mResolveType == BfResolveType_GetResultString)
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += module->TypeToString(typeInst);
|
||||
}
|
||||
}
|
||||
}
|
||||
autoComplete->CheckInterfaceFixit(typeInst, tempTypeDef->mTypeDeclaration->mNameNode);
|
||||
|
|
|
@ -3473,7 +3473,31 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
|
||||
auto autoComplete = GetAutoComplete();
|
||||
if (autoComplete != NULL)
|
||||
{
|
||||
autoComplete->CheckFieldRef(BfNodeDynCast<BfIdentifierNode>(targetSrc), fieldInstance);
|
||||
if ((autoComplete->mResolveType == BfResolveType_GetResultString) && (autoComplete->IsAutocompleteNode(targetSrc)))
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->TypeToString(fieldInstance->mResolvedType);
|
||||
autoComplete->mResultString += " ";
|
||||
autoComplete->mResultString += mModule->TypeToString(curCheckType);
|
||||
autoComplete->mResultString += ".";
|
||||
autoComplete->mResultString += field->mName;
|
||||
|
||||
if (fieldInstance->mConstIdx != -1)
|
||||
{
|
||||
String constStr = autoComplete->ConstantToString(curCheckType->mConstHolder, BfIRValue(BfIRValueFlags_Const, fieldInstance->mConstIdx));
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
autoComplete->mResultString += " = ";
|
||||
if (constStr.StartsWith(':'))
|
||||
autoComplete->mResultString.Append(StringView(constStr, 1, constStr.mLength - 1));
|
||||
else
|
||||
autoComplete->mResultString += constStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (field->mIsStatic)
|
||||
{
|
||||
|
@ -3879,6 +3903,18 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
}
|
||||
}
|
||||
|
||||
if ((autoComplete != NULL) && (autoComplete->mResolveType == BfResolveType_GetResultString) && (autoComplete->IsAutocompleteNode(targetSrc)))
|
||||
{
|
||||
BfPropertyDef* basePropDef = mPropDef;
|
||||
BfTypeInstance* baseTypeInst = curCheckType;
|
||||
mModule->GetBasePropertyDef(basePropDef, baseTypeInst);
|
||||
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->TypeToString(baseTypeInst);
|
||||
autoComplete->mResultString += ".";
|
||||
autoComplete->mResultString += basePropDef->mName;
|
||||
}
|
||||
|
||||
// Check for direct auto-property access
|
||||
if (startCheckType == mModule->mCurTypeInstance)
|
||||
{
|
||||
|
@ -5763,6 +5799,11 @@ BfTypedValue BfExprEvaluator::MatchConstructor(BfAstNode* targetSrc, BfMethodBou
|
|||
if (mModule->mCompiler->mResolvePassData != NULL)
|
||||
mModule->mCompiler->mResolvePassData->HandleMethodReference(targetSrc, curTypeInst->mTypeDef, methodDef);
|
||||
|
||||
// There should always be a constructor
|
||||
BF_ASSERT(methodMatcher.mBestMethodDef != NULL);
|
||||
|
||||
auto moduleMethodInstance = mModule->GetMethodInstance(methodMatcher.mBestMethodTypeInstance, methodMatcher.mBestMethodDef, methodMatcher.mBestMethodGenericArguments);
|
||||
|
||||
BfAutoComplete* autoComplete = GetAutoComplete();
|
||||
if (autoComplete != NULL)
|
||||
{
|
||||
|
@ -5782,13 +5823,13 @@ BfTypedValue BfExprEvaluator::MatchConstructor(BfAstNode* targetSrc, BfMethodBou
|
|||
autoComplete->SetDefinitionLocation(resolvedTypeInstance->mTypeDef->mTypeDeclaration->mNameNode, true);
|
||||
}
|
||||
}
|
||||
else if ((autoComplete->mResolveType == BfResolveType_GetResultString) && (autoComplete->IsAutocompleteNode(targetSrc)) &&
|
||||
(moduleMethodInstance.mMethodInstance != NULL))
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->MethodToString(moduleMethodInstance.mMethodInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// There should always be a constructor
|
||||
BF_ASSERT(methodMatcher.mBestMethodDef != NULL);
|
||||
|
||||
auto moduleMethodInstance = mModule->GetMethodInstance(methodMatcher.mBestMethodTypeInstance, methodMatcher.mBestMethodDef, methodMatcher.mBestMethodGenericArguments);
|
||||
|
||||
BfConstructorDeclaration* ctorDecl = (BfConstructorDeclaration*)methodMatcher.mBestMethodDef->mMethodDeclaration;
|
||||
if ((methodMatcher.mBestMethodDef->mHasAppend) && (targetType->IsObject()))
|
||||
|
@ -7114,6 +7155,12 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
autoComplete->mDefMethod = methodDef;
|
||||
autoComplete->mDefType = curTypeInst->mTypeDef;
|
||||
}
|
||||
|
||||
if (autoComplete->mResolveType == BfResolveType_GetResultString)
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->MethodToString(moduleMethodInstance.mMethodInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14228,6 +14275,17 @@ BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericTyp
|
|||
if (mPropSrc != NULL)
|
||||
mModule->UpdateExprSrcPos(mPropSrc);
|
||||
|
||||
auto autoComplete = GetAutoComplete();
|
||||
if ((autoComplete != NULL) && (autoComplete->IsAutocompleteNode(mPropSrc)) && (autoComplete->mResolveType == BfResolveType_GetResultString))
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->TypeToString(methodInstance.mMethodInstance->mReturnType);
|
||||
autoComplete->mResultString += " ";
|
||||
autoComplete->mResultString += mModule->TypeToString(methodInstance.mMethodInstance->GetOwner());
|
||||
autoComplete->mResultString += ".";
|
||||
autoComplete->mResultString += mPropDef->mName;
|
||||
}
|
||||
|
||||
CheckPropFail(matchedMethod, methodInstance.mMethodInstance, (mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0);
|
||||
PerformCallChecks(methodInstance.mMethodInstance, mPropSrc);
|
||||
|
||||
|
@ -15078,6 +15136,17 @@ void BfExprEvaluator::PerformAssignment(BfAssignmentExpression* assignExpr, bool
|
|||
BF_ASSERT(methodInstance.mMethodInstance->mMethodDef == setMethod);
|
||||
CheckPropFail(setMethod, methodInstance.mMethodInstance, (mPropGetMethodFlags & BfGetMethodInstanceFlag_Friend) == 0);
|
||||
|
||||
auto autoComplete = GetAutoComplete();
|
||||
if ((autoComplete != NULL) && (autoComplete->IsAutocompleteNode(mPropSrc)) && (autoComplete->mResolveType == BfResolveType_GetResultString))
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += mModule->TypeToString(methodInstance.mMethodInstance->GetParamType(0));
|
||||
autoComplete->mResultString += " ";
|
||||
autoComplete->mResultString += mModule->TypeToString(methodInstance.mMethodInstance->GetOwner());
|
||||
autoComplete->mResultString += ".";
|
||||
autoComplete->mResultString += mPropDef->mName;
|
||||
}
|
||||
|
||||
BfTypedValue convVal;
|
||||
if (binaryOp != BfBinaryOp_None)
|
||||
{
|
||||
|
|
|
@ -9446,6 +9446,14 @@ String BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodNameFlags
|
|||
|
||||
methodName += " ";
|
||||
methodName += methodInst->GetParamName(paramIdx);
|
||||
|
||||
auto paramInitializer = methodInst->GetParamInitializer(paramIdx);
|
||||
if (paramInitializer != NULL)
|
||||
{
|
||||
methodName += " = ";
|
||||
methodName += paramInitializer->ToString();
|
||||
}
|
||||
|
||||
dispParamIdx++;
|
||||
}
|
||||
methodName += ")";
|
||||
|
|
|
@ -6002,7 +6002,7 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
|
||||
if (autoComplete != NULL)
|
||||
{
|
||||
isGetDefinition = autoComplete->mIsGetDefinition;
|
||||
isGetDefinition = autoComplete->mIsGetDefinition || (autoComplete->mResolveType == BfResolveType_GetResultString);
|
||||
}
|
||||
|
||||
if (((mCompiler->mResolvePassData->mGetSymbolReferenceKind == BfGetSymbolReferenceKind_Type) || (isGetDefinition)) &&
|
||||
|
@ -6021,7 +6021,7 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
if (mCompiler->IsAutocomplete())
|
||||
{
|
||||
BfAutoComplete* autoComplete = mCompiler->mResolvePassData->mAutoComplete;
|
||||
if ((autoComplete->mIsGetDefinition) && (autoComplete->IsAutocompleteNode(elementTypeRef)))
|
||||
if ((isGetDefinition) && (autoComplete->IsAutocompleteNode(elementTypeRef)))
|
||||
{
|
||||
BfAstNode* baseNode = elementTypeRef;
|
||||
while (true)
|
||||
|
@ -6061,6 +6061,12 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
autoComplete->mDefType = elementTypeInst->mTypeDef;
|
||||
autoComplete->SetDefinitionLocation(elementTypeInst->mTypeDef->mTypeDeclaration->mNameNode);
|
||||
}
|
||||
|
||||
if ((autoComplete->mResolveType == BfResolveType_GetResultString) && (resolvedTypeRef != NULL))
|
||||
{
|
||||
autoComplete->mResultString = ":";
|
||||
autoComplete->mResultString += TypeToString(resolvedTypeRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue