1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-27 03:58:01 +02:00

Improvements to emit markers on emits only in specialized types

This commit is contained in:
Brian Fiete 2022-05-02 07:48:29 -07:00
parent 01112c54fe
commit 5271f5e2fd
14 changed files with 342 additions and 68 deletions

View file

@ -203,7 +203,7 @@ namespace IDE.ui
public SourceViewPanel mSourceViewPanel;
public DarkComboBox mGenericTypeCombo;
public DarkComboBox mGenericMethodCombo;
public String mGenericTypeFilter;
public String mGenericTypeFilter ~ delete _;
public float mWantHeight;
public float? mMouseDownY;
public float? mDownWantHeight;
@ -268,14 +268,15 @@ namespace IDE.ui
if (mIgnoreChange)
return;
var editWidget = (EditWidget)theEvent.mSender;
var searchText = scope String();
editWidget.GetText(searchText);
searchText.Trim();
if (mGenericTypeFilter == null)
mGenericTypeFilter = new .();
else
mGenericTypeFilter.Clear();
mGenericTypeFilter = searchText;
var editWidget = (EditWidget)theEvent.mSender;
editWidget.GetText(mGenericTypeFilter);
mGenericTypeFilter.Trim();
mGenericTypeCombo.ShowDropdown();
mGenericTypeFilter = null;
}
void EditKeyDownHandler(KeyDownEvent evt)
@ -293,6 +294,7 @@ namespace IDE.ui
typeName = explicitTypeName;
}
DeleteAndNullify!(mGenericTypeFilter);
mIgnoreChange = true;
int colonPos = typeName.IndexOf(':');
if (colonPos != -1)
@ -305,7 +307,7 @@ namespace IDE.ui
void PopulateTypeData(Menu menu)
{
List<StringView> findStrs = null;
if (mGenericTypeFilter != null)
if ((mGenericTypeFilter != null) && (!mGenericTypeFilter.IsWhiteSpace))
findStrs = scope:: List<StringView>(mGenericTypeFilter.Split(' '));
using (mMonitor.Enter())
@ -561,6 +563,7 @@ namespace IDE.ui
case Type = 'T';
case UsingNamespaces = 'U';
case Unknown = '?';
case HasUncertainEmits = '~';
case Emit = 'e';
case EmitAddType = '+';
@ -597,6 +600,9 @@ namespace IDE.ui
public int32 mAnchorIdx;
public int32 mStartLine;
public int32 mEndLine;
public bool mOnlyInResolveAll;
public bool mIncludedInClassify;
public bool mIncludedInResolveAll;
public int32 mAnchorId;
}
@ -613,7 +619,18 @@ namespace IDE.ui
public void Clear()
{
ClearCollapse();
ClearEmit();
}
public void ClearCollapse()
{
mCollapseData.Clear();
}
public void ClearEmit()
{
mEmitData.Clear();
ClearAndDeleteItems(mTypeNames);
}
@ -6264,22 +6281,76 @@ namespace IDE.ui
RehupLineCoords();
}
public void ParseCollapseRegions(String collapseText, int32 textVersion, ref IdSpan idSpan)
public void ParseCollapseRegions(String collapseText, int32 textVersion, ref IdSpan idSpan, ResolveType resolveType)
{
/*if (resolveType == .None)
return;*/
IdSpan.LookupContext lookupCtx = scope .(idSpan);
var data = PreparedData;
data.Clear();
if (resolveType != .None)
{
data.ClearCollapse();
}
List<int32> typeNameIdxMap = scope .();
Dictionary<StringView, int32> typeNameMap = scope .();
Dictionary<int32, int32> emitAnchorIds = scope .();
bool hasUncertainEmits = false;
bool emitInitialized = false;
void CheckInitEmit()
{
if (emitInitialized)
return;
emitInitialized = true;
if ((hasUncertainEmits) || (resolveType == .None))
{
// Leave emits alone
for (var typeName in data.mTypeNames)
typeNameMap[typeName] = (.)@typeName.Index;
for (var emitData in ref data.mEmitData)
{
emitAnchorIds[emitData.mAnchorId] = (.)@emitData.Index;
if (resolveType == .None)
emitData.mIncludedInResolveAll = false;
else
emitData.mIncludedInClassify = false;
}
return;
}
hasUncertainEmits = false;
data.ClearEmit();
}
for (var line in collapseText.Split('\n', .RemoveEmptyEntries))
{
SourceEditWidgetContent.CollapseEntry.Kind kind = (.)line[0];
line.RemoveFromStart(1);
if (kind == .HasUncertainEmits)
{
hasUncertainEmits = true;
continue;
}
if ((kind == .EmitAddType) || (kind.IsEmit))
{
CheckInitEmit();
}
if (kind == .EmitAddType)
{
data.mTypeNames.Add(new String(line));
if (typeNameMap.TryAdd(line, var keyPtr, var valuePtr))
{
data.mTypeNames.Add(new String(line));
*valuePtr = (.)data.mTypeNames.Count - 1;
}
typeNameIdxMap.Add(*valuePtr);
continue;
}
@ -6288,15 +6359,40 @@ namespace IDE.ui
{
EmitData emitData;
emitData.mKind = kind;
emitData.mTypeNameIdx = int32.Parse(itr.GetNext().Value);
int typeNameIdx = int32.Parse(itr.GetNext().Value);
emitData.mTypeNameIdx = typeNameIdxMap[typeNameIdx];
emitData.mAnchorIdx = int32.Parse(itr.GetNext().Value);
emitData.mStartLine = int32.Parse(itr.GetNext().Value);
emitData.mEndLine = int32.Parse(itr.GetNext().Value);
emitData.mAnchorId = lookupCtx.GetIdAtIndex(emitData.mAnchorIdx);
emitData.mOnlyInResolveAll = resolveType == .None;
emitData.mIncludedInClassify = resolveType != .None;
emitData.mIncludedInResolveAll = resolveType == .None;
if (emitAnchorIds.TryGetValue(emitData.mAnchorId, var idx))
{
var curEmitData = ref data.mEmitData[idx];
if (resolveType == .None)
{
curEmitData.mIncludedInResolveAll = true;
}
else
{
emitData.mIncludedInClassify |= curEmitData.mIncludedInClassify;
curEmitData = emitData;
}
continue;
}
data.mEmitData.Add(emitData);
continue;
}
if (resolveType == .None)
continue;
CollapseData collapseData;
collapseData.mAnchorIdx = int32.Parse(itr.GetNext().Value);
@ -6322,6 +6418,23 @@ namespace IDE.ui
data.mCollapseData.Add(collapseData);
}
CheckInitEmit();
for (var emitData in ref data.mEmitData)
{
if (((emitData.mOnlyInResolveAll) && (!emitData.mIncludedInResolveAll)) ||
((!emitData.mOnlyInResolveAll) && (!emitData.mIncludedInClassify)))
{
@emitData.RemoveFast();
continue;
}
if ((emitData.mOnlyInResolveAll) && (!emitData.mIncludedInClassify))
{
gApp.mBfResolveCompiler.mWantsResolveAllCollapseRefresh = true;
}
}
data.mCollapseParseRevision++;
data.mCollapseTextVersionId = textVersion;
}

View file

@ -369,6 +369,7 @@ namespace IDE.ui
public String mData = new .() ~ delete _;
public int32 mTextVersion;
public IdSpan mCharIdSpan ~ _.Dispose();
public ResolveType mResolveType;
}
class QueuedEmitShowData
@ -424,6 +425,7 @@ namespace IDE.ui
bool mWantsFastClassify;
bool mWantsFullClassify; // This triggers a classify
bool mWantsFullRefresh; // If mWantsFullClassify is set, mWantsFullRefresh makes the whole thing refresh
bool mWantsCollapseRefresh;
bool mRefireMouseOverAfterRefresh;
bool mWantsBackgroundAutocomplete;
QueuedAutoComplete mQueuedAutoComplete ~ delete _;
@ -636,7 +638,6 @@ namespace IDE.ui
AddWidget(mNavigationBar);
}
}
public ~this()
{
if (mInPostRemoveUpdatePanels)
@ -889,6 +890,11 @@ namespace IDE.ui
//mDidClangSource = false;
}
public void QueueCollapseRefresh()
{
mWantsCollapseRefresh = true;
}
public override bool EscapeHandler()
{
if (IDEApp.sApp.mSymbolReferenceHelper != null)
@ -1174,7 +1180,7 @@ namespace IDE.ui
useResolveType = ResolveType.Autocomplete;
}
bool doBackground = (useResolveType == ResolveType.Classify) || (useResolveType == ResolveType.ClassifyFullRefresh);
bool doBackground = (useResolveType == .Classify) || (useResolveType == .ClassifyFullRefresh);
if (mAsyncAutocomplete)
{
if ((useResolveType == .Autocomplete) || (useResolveType == .GetCurrentLocation) || (useResolveType == .GetSymbolInfo) ||
@ -1438,6 +1444,31 @@ namespace IDE.ui
bfSystem.Unlock();
}
public void DoRefreshCollapse(BfParser parser, int32 textVersion, IdSpan charIdSpan)
{
var bfCompiler = BfResolveCompiler;
String explicitEmitTypeNames = scope .();
for (var explicitType in mExplicitEmitTypes)
{
explicitEmitTypeNames.Append(explicitType);
explicitEmitTypeNames.Append("\n");
}
var resolvePassData = parser.CreateResolvePassData(.None);
defer delete resolvePassData;
var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .());
using (mMonitor.Enter())
{
DeleteAndNullify!(mQueuedCollapseData);
mQueuedCollapseData = new .();
mQueuedCollapseData.mData.Set(collapseData);
mQueuedCollapseData.mTextVersion = textVersion;
mQueuedCollapseData.mCharIdSpan = charIdSpan;
}
}
public void DoFullClassify(ResolveParams resolveParams)
{
var bfCompiler = BfResolveCompiler;
@ -1457,7 +1488,7 @@ namespace IDE.ui
public void DoFastClassify()
{
if (!mIsSourceCode)
if ((!mIsSourceCode) || (mEmbedKind != .None))
return;
//Debug.WriteLine("DoFastClassify");
@ -1911,7 +1942,8 @@ namespace IDE.ui
var bfCompiler = BfResolveCompiler;
//var compiler = ResolveCompiler;
bool isBackground = (resolveType == .Classify) || (resolveType == .ClassifyFullRefresh) || (resolveType == .GetResultString) || (resolveType == .GoToDefinition);
bool isBackground = (resolveType == .Classify) || (resolveType == .ClassifyFullRefresh) ||
(resolveType == .GetResultString) || (resolveType == .GoToDefinition);
bool fullRefresh = resolveType == ResolveType.ClassifyFullRefresh;
if (!isBackground)
@ -2112,7 +2144,7 @@ namespace IDE.ui
bfSystem.Lock(0);
}
if (!isFastClassify)
if (!isFastClassify)
parser.BuildDefs(passInstance, resolvePassData, fullRefresh);
// For Fixits we do want to parse the whole file but we need the cursorIdx bound still to
@ -2142,11 +2174,6 @@ namespace IDE.ui
{
parser.CreateClassifier(passInstance, resolvePassData, charData);
if (resolveType == .ClassifyFullRefresh)
{
NOP!();
}
if (resolveParams != null)
{
for (var emitEmbedData in resolveParams.mEmitEmbeds)
@ -2157,7 +2184,7 @@ namespace IDE.ui
if (bfCompiler.ClassifySource(passInstance, resolvePassData))
{
if ((resolveType == ResolveType.Classify) || (resolveType == ResolveType.ClassifyFullRefresh))
if ((resolveType == .Classify) || (resolveType == .ClassifyFullRefresh))
{
String explicitEmitTypeNames = scope .();
for (var explicitType in mExplicitEmitTypes)
@ -2166,14 +2193,23 @@ namespace IDE.ui
explicitEmitTypeNames.Append("\n");
}
var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .());
using (mMonitor.Enter())
bool allowCollapseData = resolveType == .ClassifyFullRefresh;
if (allowCollapseData)
{
DeleteAndNullify!(mQueuedCollapseData);
mQueuedCollapseData = new .();
mQueuedCollapseData.mData.Set(collapseData);
mQueuedCollapseData.mTextVersion = resolveParams.mTextVersion;
mQueuedCollapseData.mCharIdSpan = resolveParams.mCharIdSpan.Duplicate();
var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .());
using (mMonitor.Enter())
{
DeleteAndNullify!(mQueuedCollapseData);
mQueuedCollapseData = new .();
mQueuedCollapseData.mData.Set(collapseData);
mQueuedCollapseData.mTextVersion = resolveParams.mTextVersion;
mQueuedCollapseData.mCharIdSpan = resolveParams.mCharIdSpan.Duplicate();
mQueuedCollapseData.mResolveType = resolveType;
}
}
else
{
QueueFullRefresh(false);
}
}
@ -6445,11 +6481,39 @@ namespace IDE.ui
if (Classify(mWantsFullRefresh ? ResolveType.ClassifyFullRefresh : ResolveType.Classify))
{
mWantsFullClassify = false;
mWantsFullRefresh = false;
mWantsFullRefresh = false;
mWantsCollapseRefresh = false;
}
canDoBackground = false;
}
}
else if (mWantsCollapseRefresh)
{
if (!compiler.IsPerformingBackgroundOperation())
{
bfSystem?.Log("SourceViewPanel handling mWantsCollapseRefresh");
mWantsCollapseRefresh = false;
/*Classify(.GetCollapse);*/
if ((projectSource != null) && (mIsBeefSource))
do
{
var bfProject = bfSystem.GetBfProject(projectSource.mProject);
if (bfProject.mDisabled)
break;
var bfParser = bfSystem.FindParser(projectSource);
if (bfParser == null)
break;
var data = mEditWidget.mEditWidgetContent.mData;
compiler.DoBackground(new () =>
{
DoRefreshCollapse(bfParser, data.mCurTextVersionId, data.mTextIdData.Duplicate());
});
}
}
}
else if (mWantsParserCleanup)
{
if (!compiler.IsPerformingBackgroundOperation())
@ -6734,7 +6798,7 @@ namespace IDE.ui
using (mMonitor.Enter())
{
if (mQueuedCollapseData != null)
ewc.ParseCollapseRegions(mQueuedCollapseData.mData, mQueuedCollapseData.mTextVersion, ref mQueuedCollapseData.mCharIdSpan);
ewc.ParseCollapseRegions(mQueuedCollapseData.mData, mQueuedCollapseData.mTextVersion, ref mQueuedCollapseData.mCharIdSpan, mQueuedCollapseData.mResolveType);
DeleteAndNullify!(mQueuedCollapseData);
}
@ -6967,7 +7031,7 @@ namespace IDE.ui
}
else
{
mNavigationBar.mVisible = false;
mNavigationBar?.mVisible = false;
}
// Always leave enough to read the first 3 lines