mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Improved emit marker resolve/build selection, emitted Go To Definition
This commit is contained in:
parent
faca458283
commit
6ded6a37cc
14 changed files with 216 additions and 44 deletions
|
@ -1504,6 +1504,11 @@ namespace IDE
|
|||
useFileName = scope:: $"$Emit${useFileName.Substring("$Emit$Build$".Length)}";
|
||||
compiler = mBfBuildCompiler;
|
||||
}
|
||||
else if (useFileName.StartsWith("$Emit$Resolve$"))
|
||||
{
|
||||
useFileName = scope:: $"$Emit${useFileName.Substring("$Emit$Resolve$".Length)}";
|
||||
compiler = mBfResolveCompiler;
|
||||
}
|
||||
|
||||
if (!compiler.IsPerformingBackgroundOperation())
|
||||
compiler.GetEmitSource(useFileName, outBuffer);
|
||||
|
@ -7153,31 +7158,76 @@ namespace IDE
|
|||
return null;
|
||||
}
|
||||
|
||||
var itr = filePath.Split('$');
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
var typeName = itr.GetNext().Value;
|
||||
|
||||
mBfBuildCompiler.mBfSystem.Lock(0);
|
||||
var embedFilePath = mBfBuildCompiler.GetEmitLocation(typeName, line, .. scope .(), var embedLine, var embedLineChar, var embedHash);
|
||||
mBfBuildCompiler.mBfSystem.Unlock();
|
||||
|
||||
String embedFilePath;
|
||||
bool isViewValid = true;
|
||||
StringView typeName;
|
||||
int embedLine;
|
||||
int embedLineChar;
|
||||
|
||||
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||
if (filePath.StartsWith("$Emit$Resolve$"))
|
||||
{
|
||||
mBfResolveCompiler.mBfSystem.Lock(0);
|
||||
mBfResolveCompiler.GetEmitLocation(typeName, line, .. scope .(), var resolveLine, var resolveLineChar, var resolveHash);
|
||||
mBfResolveCompiler.mBfSystem.Unlock();
|
||||
|
||||
if ((resolveLine != embedLine) || (resolveLineChar != embedLineChar) || (embedHash != resolveHash))
|
||||
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||
{
|
||||
var itr = filePath.Split('$');
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
typeName = itr.GetNext().Value;
|
||||
|
||||
mBfResolveCompiler.mBfSystem.Lock(0);
|
||||
embedFilePath = mBfResolveCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||
mBfResolveCompiler.mBfSystem.Unlock();
|
||||
|
||||
useFilePath = scope:: $"$Emit${useFilePath.Substring("$Emit$Resolve$".Length)}";
|
||||
}
|
||||
else
|
||||
isViewValid = false;
|
||||
useFilePath = scope:: $"$Emit$Build${useFilePath.Substring("$Emit$".Length)}";
|
||||
}
|
||||
else if (filePath.StartsWith("$Emit$Build$"))
|
||||
{
|
||||
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Build)
|
||||
{
|
||||
var itr = filePath.Split('$');
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
typeName = itr.GetNext().Value;
|
||||
|
||||
mBfBuildCompiler.mBfSystem.Lock(0);
|
||||
embedFilePath = mBfBuildCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||
mBfBuildCompiler.mBfSystem.Unlock();
|
||||
|
||||
useFilePath = scope:: $"$Emit${useFilePath.Substring("$Emit$Build$".Length)}";
|
||||
}
|
||||
else
|
||||
isViewValid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var itr = filePath.Split('$');
|
||||
itr.GetNext();
|
||||
itr.GetNext();
|
||||
typeName = itr.GetNext().Value;
|
||||
|
||||
mBfBuildCompiler.mBfSystem.Lock(0);
|
||||
embedFilePath = mBfBuildCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||
mBfBuildCompiler.mBfSystem.Unlock();
|
||||
|
||||
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||
{
|
||||
mBfResolveCompiler.mBfSystem.Lock(0);
|
||||
mBfResolveCompiler.GetEmitLocation(typeName, line, scope .(), var resolveLine, var resolveLineChar, var resolveHash);
|
||||
mBfResolveCompiler.mBfSystem.Unlock();
|
||||
|
||||
if ((resolveLine != embedLine) || (resolveLineChar != embedLineChar) || (embedHash != resolveHash))
|
||||
{
|
||||
isViewValid = false;
|
||||
useFilePath = scope:: $"$Emit$Build${useFilePath.Substring("$Emit$".Length)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((!embedFilePath.IsEmpty) && (isViewValid))
|
||||
if ((isViewValid) && (!embedFilePath.IsEmpty))
|
||||
{
|
||||
var sourceViewPanel = ShowSourceFile(scope .(embedFilePath), null, showTemp ? SourceShowType.Temp : SourceShowType.ShowExisting).panel;
|
||||
if (sourceViewPanel == null)
|
||||
|
|
|
@ -244,7 +244,12 @@ namespace IDE.ui
|
|||
if (mKind == .GoToDefinition)
|
||||
{
|
||||
mSourceViewPanel.RecordHistoryLocation();
|
||||
var sourceViewPanel = gApp.ShowSourceFileLocation(scope .(filePath), -1, -1, line, lineChar, LocatorType.Smart, true);
|
||||
|
||||
var usePath = scope String(filePath);
|
||||
if (usePath.StartsWith("$Emit$"))
|
||||
usePath.Insert("$Emit$".Length, "Resolve$");
|
||||
|
||||
var sourceViewPanel = gApp.ShowSourceFileLocation(usePath, -1, -1, line, lineChar, LocatorType.Smart, true);
|
||||
sourceViewPanel.RecordHistoryLocation(true);
|
||||
Close();
|
||||
return;
|
||||
|
|
|
@ -1839,7 +1839,19 @@ namespace IDE.ui
|
|||
int line;
|
||||
int lineChar;
|
||||
GetCursorLineChar(out line, out lineChar);
|
||||
return IDEApp.sApp.mHistoryManager.CreateHistory(mSourceViewPanel, mSourceViewPanel.mFilePath, line, lineChar, ignoreIfClose);
|
||||
|
||||
String useFilePath = mSourceViewPanel.mFilePath;
|
||||
if ((mSourceViewPanel.mFilePath.StartsWith("$Emit$")) &&
|
||||
(!mSourceViewPanel.mFilePath.StartsWith("$Emit$Build$")) &&
|
||||
(!mSourceViewPanel.mFilePath.StartsWith("$Emit$Resolve$")))
|
||||
{
|
||||
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||
useFilePath = scope:: String("$Emit$Resolve$")..Append(mSourceViewPanel.mFilePath.Substring("$Emit$".Length));
|
||||
else
|
||||
useFilePath = scope:: String("$Emit$Build$")..Append(mSourceViewPanel.mFilePath.Substring("$Emit$".Length));
|
||||
}
|
||||
|
||||
return IDEApp.sApp.mHistoryManager.CreateHistory(mSourceViewPanel, useFilePath, line, lineChar, ignoreIfClose);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -6505,7 +6517,7 @@ namespace IDE.ui
|
|||
|
||||
var data = PreparedData;
|
||||
|
||||
if (resolveType != .None)
|
||||
if ((resolveType != null) && (resolveType != .None))
|
||||
{
|
||||
data.ClearCollapse();
|
||||
}
|
||||
|
|
|
@ -1493,6 +1493,10 @@ namespace IDE.ui
|
|||
defer delete buildResolvePassData;
|
||||
buildCollapseData = gApp.mBfBuildCompiler.GetCollapseRegions(buildParser, buildResolvePassData, explicitEmitTypeNames, .. scope:: .());
|
||||
}
|
||||
else
|
||||
{
|
||||
buildCollapseData = "";
|
||||
}
|
||||
gApp.mBfBuildSystem.Unlock();
|
||||
}
|
||||
|
||||
|
@ -2504,7 +2508,10 @@ namespace IDE.ui
|
|||
int32 prevLine = mEditWidget.Content.CursorLineAndColumn.mLine;
|
||||
|
||||
mEditWidget.Content.mSelection = null;
|
||||
mEditWidget.Content.CursorTextPos = cursorIdx;
|
||||
|
||||
int wantCursorPos = Math.Min(mEditWidget.Content.mData.mTextLength - 1, cursorIdx);
|
||||
if (wantCursorPos >= 0)
|
||||
mEditWidget.Content.CursorTextPos = wantCursorPos;
|
||||
mEditWidget.Content.CursorMoved();
|
||||
mEditWidget.Content.EnsureCursorVisible(true, true);
|
||||
mEditWidget.Content.mCursorImplicitlyMoved = true;
|
||||
|
@ -6288,15 +6295,15 @@ namespace IDE.ui
|
|||
emitEmbedView.mGenericMethodCombo?.mEditWidget.SetFocus();
|
||||
}
|
||||
|
||||
var sourceViewPanel = emitEmbedView.mSourceViewPanel;
|
||||
var firstSourceViewPanel = emitEmbedView.mSourceViewPanel;
|
||||
|
||||
var embedEWC = sourceViewPanel.mEditWidget.mEditWidgetContent;
|
||||
var firstEmbedEWC = firstSourceViewPanel.mEditWidget.mEditWidgetContent;
|
||||
|
||||
var prevCursorLineAndColumn = embedEWC.CursorLineAndColumn;
|
||||
var prevCursorLineAndColumn = firstEmbedEWC.CursorLineAndColumn;
|
||||
|
||||
var editData = sourceViewPanel.mEditWidget.mEditWidgetContent.mData;
|
||||
var editData = firstSourceViewPanel.mEditWidget.mEditWidgetContent.mData;
|
||||
if (editData.mTextLength == 0)
|
||||
DeleteAndNullify!(sourceViewPanel.mTrackedTextElementViewList);
|
||||
DeleteAndNullify!(firstSourceViewPanel.mTrackedTextElementViewList);
|
||||
|
||||
delete editData.mText;
|
||||
editData.mText = embed.mCharData;
|
||||
|
@ -6307,15 +6314,23 @@ namespace IDE.ui
|
|||
editData.mNextCharId = 0;
|
||||
editData.mTextIdData.Insert(0, editData.mTextLength, ref editData.mNextCharId);
|
||||
|
||||
sourceViewPanel.mEditWidget.mEditWidgetContent.ContentChanged();
|
||||
// We have a full classify now, FastClassify will just mess it up
|
||||
sourceViewPanel.mSkipFastClassify = true;
|
||||
firstSourceViewPanel.mEmitRevision = embed.mRevision;
|
||||
firstSourceViewPanel.InjectErrors(resolveResult.mPassInstance, editData.mText, editData.mTextIdData, false, true);
|
||||
|
||||
if (prevCursorLineAndColumn.mLine >= embedEWC.GetLineCount())
|
||||
embedEWC.CursorLineAndColumn = .(embedEWC.GetLineCount() - 1, prevCursorLineAndColumn.mColumn);
|
||||
|
||||
sourceViewPanel.mEmitRevision = embed.mRevision;
|
||||
sourceViewPanel.InjectErrors(resolveResult.mPassInstance, editData.mText, editData.mTextIdData, false, true);
|
||||
for (var user in editData.mUsers)
|
||||
{
|
||||
if (var embedEWC = user as SourceEditWidgetContent)
|
||||
{
|
||||
var sourceViewPanel = embedEWC.mSourceViewPanel;
|
||||
|
||||
sourceViewPanel.mEditWidget.mEditWidgetContent.ContentChanged();
|
||||
// We have a full classify now, FastClassify will just mess it up
|
||||
sourceViewPanel.mSkipFastClassify = true;
|
||||
|
||||
if (prevCursorLineAndColumn.mLine >= firstEmbedEWC.GetLineCount())
|
||||
embedEWC.CursorLineAndColumn = .(firstEmbedEWC.GetLineCount() - 1, prevCursorLineAndColumn.mColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6868,11 +6883,14 @@ namespace IDE.ui
|
|||
{
|
||||
if (mQueuedCollapseData.mBuildData != null)
|
||||
{
|
||||
bool foundData = false;
|
||||
|
||||
using (gApp.mMonitor.Enter())
|
||||
{
|
||||
var projectSourceCompileInstance = gApp.mWorkspace.GetProjectSourceCompileInstance(projectSource, gApp.mWorkspace.HotCompileIdx);
|
||||
if (projectSourceCompileInstance != null)
|
||||
{
|
||||
foundData = true;
|
||||
ewc.ParseCollapseRegions(mQueuedCollapseData.mBuildData, mQueuedCollapseData.mTextVersion, ref projectSourceCompileInstance.mSourceCharIdData, null);
|
||||
|
||||
HashSet<EditWidgetContent.Data> dataLoaded = scope .();
|
||||
|
@ -6894,6 +6912,20 @@ namespace IDE.ui
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundData)
|
||||
{
|
||||
for (var embed in ewc.mEmbeds.Values)
|
||||
{
|
||||
if (var emitEmbed = embed as SourceEditWidgetContent.EmitEmbed)
|
||||
{
|
||||
if (emitEmbed.mView != null)
|
||||
{
|
||||
emitEmbed.mView.mSourceViewPanel.mEditWidget.mEditWidgetContent.ClearText();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue