1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-02 22:36:00 +02:00

Added error/warning panel, region support

This commit is contained in:
Brian Fiete 2020-01-06 13:49:35 -08:00
parent c63edcbf87
commit 8970ebcd93
33 changed files with 454 additions and 130 deletions

View file

@ -51,7 +51,8 @@ namespace IDE.ui
public bool mNeedsResolveAll;
public bool mErrorsDirty;
public Monitor mMonitor = new .() ~ delete _;
public List<BfPassInstance.BfError> mErrorList = new .() ~ DeleteContainerAndItems!(_);
public Dictionary<String, List<BfPassInstance.BfError>> mParseErrors = new .() ~ delete _;
public List<BfPassInstance.BfError> mResolveErrors = new .() ~ DeleteContainerAndItems!(_);
public int mDirtyTicks;
public int mErrorCount;
@ -98,6 +99,11 @@ namespace IDE.ui
AddWidget(mDockingFrame);
}
public ~this()
{
ClearParserErrors(null);
}
public override void Serialize(StructuredData data)
{
base.Serialize(data);
@ -122,12 +128,23 @@ namespace IDE.ui
{
using (mMonitor.Enter())
{
mErrorCount = 0;
mWarningCount = 0;
int32 errorCount = passInstance.GetErrorCount();
ClearAndDeleteItems(mErrorList);
mErrorList.Capacity = mErrorList.Count;
if (passKind != .Parse)
{
if (!mResolveErrors.IsEmpty)
mErrorsDirty = true;
for (let error in mResolveErrors)
{
if (error.mIsWarning)
mWarningCount--;
else
mErrorCount--;
}
ClearAndDeleteItems(mResolveErrors);
mResolveErrors.Capacity = mResolveErrors.Count;
}
for (int32 errorIdx = 0; errorIdx < errorCount; errorIdx++)
{
@ -148,16 +165,61 @@ namespace IDE.ui
bfError.mMoreInfo.Add(moreInfo);
}
mErrorList.Add(bfError);
}
if (passKind == .Parse)
{
bool added = mParseErrors.TryAdd(bfError.mFilePath, var keyPtr, var valuePtr);
if (added)
{
*keyPtr = new .(bfError.mFilePath);
*valuePtr = new .();
}
(*valuePtr).Add(bfError);
}
else
mResolveErrors.Add(bfError);
mErrorsDirty = true;
mErrorsDirty = true;
}
}
}
public void ClearParserErrors(StringView filePath)
public void ClearParserErrors(String filePath)
{
using (mMonitor.Enter())
{
void DeleteErrorList(List<BfPassInstance.BfError> list)
{
for (let error in list)
{
if (error.mIsWarning)
mWarningCount--;
else
mErrorCount--;
delete error;
}
delete list;
}
if (filePath == null)
{
for (var kv in mParseErrors)
{
delete kv.key;
DeleteErrorList(kv.value);
mErrorsDirty = true;
}
mParseErrors.Clear();
}
else
{
if (mParseErrors.GetAndRemove(filePath) case .Ok((let key, let list)))
{
delete key;
DeleteErrorList(list);
mErrorsDirty = true;
}
}
}
}
void ProcessErrors()
@ -168,7 +230,8 @@ namespace IDE.ui
{
let root = mErrorLV.GetRoot();
for (let error in mErrorList)
int idx = 0;
void HandleError(BfPassInstance.BfError error)
{
ErrorsListViewItem item;
@ -181,7 +244,6 @@ namespace IDE.ui
item.Label = str;
}
int idx = @error.Index;
if (idx >= root.GetChildCount())
{
item = (.)root.CreateChildItem();
@ -225,9 +287,28 @@ namespace IDE.ui
if (changed)
item.Focused = false;
idx++;
}
while (root.GetChildCount() > mErrorList.Count)
if (!mParseErrors.IsEmpty)
{
List<String> paths = scope .();
for (var path in mParseErrors.Keys)
paths.Add(path);
paths.Sort();
for (var path in paths)
{
for (var error in mParseErrors[path])
HandleError(error);
}
}
for (let error in mResolveErrors)
HandleError(error);
while (root.GetChildCount() > idx)
root.RemoveChildItemAt(root.GetChildCount() - 1);
mErrorsDirty = false;
@ -277,7 +358,7 @@ namespace IDE.ui
bool foundFocused = false;
let root = mErrorLV.GetRoot();
if (root.mChildItems == null)
if (root.GetChildCount() == 0)
return;
for (let lvItem in root.mChildItems)
{

View file

@ -195,7 +195,7 @@ namespace IDE.ui
if (mShowingDropdown)
return null;
mShowingDropdown = true;
defer(scope) { mShowingDropdown = false; }
defer { mShowingDropdown = false; }
/*var stopWatch = scope Stopwatch();
stopWatch.Start();*/

View file

@ -97,6 +97,10 @@ namespace IDE.ui
{
panel = gApp.mImmediatePanel;
}
else if (type == "ErrorsPanel")
{
panel = gApp.mErrorsPanel;
}
else if (type == "FindResultsPanel")
{
panel = gApp.mFindResultsPanel;

View file

@ -868,7 +868,7 @@ namespace IDE.ui
String dir = scope String(fileDialog.InitialDirectory);
List<String> alreadyHadFileList = scope List<String>();
defer(scope) ClearAndDeleteItems(alreadyHadFileList);
defer ClearAndDeleteItems(alreadyHadFileList);
for (String fileNameIn in fileDialog.FileNames)
{

View file

@ -1653,6 +1653,9 @@ namespace IDE.ui
if (gApp.mDbgDelayedAutocomplete)
Thread.Sleep(250);
if ((resolveType == .Classify) || (resolveType == .ClassifyFullRefresh))
gApp.mErrorsPanel.SetNeedsResolveAll();
/*if (resolveType == .Autocomplete)
{
Thread.Sleep(250);
@ -1818,6 +1821,13 @@ namespace IDE.ui
resolvePassData.SetDocumentationRequest(resolveParams.mDocumentationName);
parser.Parse(passInstance, !mIsBeefSource);
parser.Reduce(passInstance);
if ((mIsBeefSource) &&
((resolveType == .Classify) || (resolveType == .ClassifyFullRefresh)))
{
gApp.mErrorsPanel.ClearParserErrors(mFilePath);
gApp.mErrorsPanel.ProcessPassInstance(passInstance, .Parse);
}
if (isInterrupt)
{
@ -2511,13 +2521,16 @@ namespace IDE.ui
if (trackedElement.mSnapToLineStart)
{
int32 lineLeft = trackedElementView.mTextPosition.mIndex;
repeat
{
if (!((char8)editContent.mData.mText[lineLeft].mChar).IsWhiteSpace)
startContentIdx = lineLeft;
lineLeft--;
}
while ((lineLeft > 0) && (editContent.mData.mText[lineLeft].mChar != '\n'));
if (lineLeft < editContent.mData.mTextLength)
{
repeat
{
if (!((char8)editContent.mData.mText[lineLeft].mChar).IsWhiteSpace)
startContentIdx = lineLeft;
lineLeft--;
}
while ((lineLeft > 0) && (editContent.mData.mText[lineLeft].mChar != '\n'));
}
if (startContentIdx == -1)
{
@ -4926,7 +4939,7 @@ namespace IDE.ui
{
for (var moreInfo in bestError.mMoreInfo)
{
showMouseoverString.AppendF("\n@{0}\t{1}\t{2}", moreInfo.mFileName, moreInfo.mSrcStart, moreInfo.mError);
showMouseoverString.AppendF("\n@{0}\t{1}\t{2}", moreInfo.mFilePath, moreInfo.mSrcStart, moreInfo.mError);
}
}
}

View file

@ -365,9 +365,21 @@ namespace IDE.ui
else
mStatusBoxUpdateCnt = -1;
///
{
if (gApp.mErrorsPanel.mErrorCount > 0)
{
g.Draw(DarkTheme.sDarkTheme.GetImage(.CodeError), GS!(6), 0);
}
else if (gApp.mErrorsPanel.mWarningCount > 0)
{
g.Draw(DarkTheme.sDarkTheme.GetImage(.CodeWarning), GS!(6), 0);
}
}
if (gApp.mSettings.mEnableDevMode)
{
g.DrawString(StackStringFormat!("FPS: {0}", gApp.mLastFPS), GS!(4), 0);
g.DrawString(StackStringFormat!("FPS: {0}", gApp.mLastFPS), GS!(32), 0);
String resolveStr = scope String();
let bfResolveCompiler = gApp.mBfResolveCompiler;
@ -418,5 +430,16 @@ namespace IDE.ui
g.DrawString(resolveStr, GS!(100), 0);
}
}
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
{
base.MouseDown(x, y, btn, btnCount);
if (Rect(GS!(6), 0, GS!(20), mHeight).Contains(x, y))
{
gApp.mErrorsPanel.ShowErrorNext();
return;
}
}
}
}