diff --git a/IDE/src/ui/SourceViewPanel.bf b/IDE/src/ui/SourceViewPanel.bf index 3ed4c6b7..6ad130e3 100644 --- a/IDE/src/ui/SourceViewPanel.bf +++ b/IDE/src/ui/SourceViewPanel.bf @@ -4767,7 +4767,8 @@ namespace IDE.ui { let resolveParams = scope ResolveParams(); resolveParams.mOverrideCursorPos = (int32)textIdx; - Classify(ResolveType.GetResultString, resolveParams); + if (!gApp.mDebugger.IsPaused()) + Classify(ResolveType.GetResultString, resolveParams); if (!String.IsNullOrEmpty(resolveParams.mResultString)) { origDebugExpr = scope:: String(); diff --git a/IDEHelper/Compiler/BfAutoComplete.cpp b/IDEHelper/Compiler/BfAutoComplete.cpp index 4344bc45..01a15952 100644 --- a/IDEHelper/Compiler/BfAutoComplete.cpp +++ b/IDEHelper/Compiler/BfAutoComplete.cpp @@ -672,8 +672,11 @@ 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)) - SetDefinitionLocation(propDef->mFieldDeclaration->mNameNode); + if (AddEntry(entry, filter)) + { + if ((mIsGetDefinition) && (propDef->mFieldDeclaration != NULL)) + SetDefinitionLocation(propDef->mFieldDeclaration->mNameNode); + } } } @@ -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)) diff --git a/IDEHelper/Compiler/BfAutoComplete.h b/IDEHelper/Compiler/BfAutoComplete.h index c8d1a423..ec2134e9 100644 --- a/IDEHelper/Compiler/BfAutoComplete.h +++ b/IDEHelper/Compiler/BfAutoComplete.h @@ -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); diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index a061c753..32026a21 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -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); diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 81fb2d48..6d2226d5 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -3414,7 +3414,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar auto fieldInstance = &curCheckType->mFieldInstances[field->mIdx]; bool isResolvingFields = curCheckType->mResolvingConstField || curCheckType->mResolvingVarField; - + if (field->mIsVolatile) mIsVolatileReference = true; @@ -3473,7 +3473,31 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar auto autoComplete = GetAutoComplete(); if (autoComplete != NULL) + { autoComplete->CheckFieldRef(BfNodeDynCast(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) { @@ -5781,15 +5822,15 @@ BfTypedValue BfExprEvaluator::MatchConstructor(BfAstNode* targetSrc, BfMethodBou else if (resolvedTypeInstance->mTypeDef->mTypeDeclaration != NULL) 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) { diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 02f7af63..8318a1b4 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -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 += ")"; diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index a715ac44..3ee2308d 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -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); + } } } }