mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Added support for autocomplete inserting property overrides
This commit is contained in:
parent
ce66b658c4
commit
c931f92632
4 changed files with 148 additions and 28 deletions
|
@ -152,6 +152,33 @@ class Norg
|
||||||
{
|
{
|
||||||
return a + b + c + bl.mA;
|
return a + b + c + bl.mA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual int Zorf
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int GetVal()
|
||||||
|
{
|
||||||
|
return 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Norg2 : Norg
|
||||||
|
{
|
||||||
|
public override void Zorf
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Zorf = 123;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Blurg
|
struct Blurg
|
||||||
|
|
|
@ -2198,7 +2198,7 @@ namespace IDE.ui
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertSelection(char32 keyChar, String insertType = null)
|
public void InsertSelection(char32 keyChar, String insertType = null, String insertStr = null)
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("InsertSelection");
|
//Debug.WriteLine("InsertSelection");
|
||||||
|
|
||||||
|
@ -2223,6 +2223,9 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (insertStr != null)
|
||||||
|
insertStr.Append(entry.mEntryInsert ?? entry.mEntryDisplay);
|
||||||
|
|
||||||
if (entry.mEntryType == "fixit")
|
if (entry.mEntryType == "fixit")
|
||||||
{
|
{
|
||||||
if (insertType != null)
|
if (insertType != null)
|
||||||
|
@ -2240,7 +2243,7 @@ namespace IDE.ui
|
||||||
if (tabIdx != -1)
|
if (tabIdx != -1)
|
||||||
{
|
{
|
||||||
implText = scope:: String();
|
implText = scope:: String();
|
||||||
implText.Append(insertText, tabIdx + 1);
|
implText.Append(insertText, tabIdx);
|
||||||
insertText.RemoveToEnd(tabIdx);
|
insertText.RemoveToEnd(tabIdx);
|
||||||
}
|
}
|
||||||
String prevText = scope String();
|
String prevText = scope String();
|
||||||
|
@ -2294,13 +2297,52 @@ namespace IDE.ui
|
||||||
UpdateAsyncInfo();*/
|
UpdateAsyncInfo();*/
|
||||||
|
|
||||||
if (implText != null)
|
if (implText != null)
|
||||||
{
|
{
|
||||||
sourceEditWidgetContent.InsertAtCursor("\n");
|
String implSect = scope .();
|
||||||
sourceEditWidgetContent.CursorToLineEnd();
|
|
||||||
sourceEditWidgetContent.OpenCodeBlock();
|
int startIdx = 0;
|
||||||
var lineAndColumn = sourceEditWidgetContent.CursorLineAndColumn;
|
for (int i < implText.Length)
|
||||||
sourceEditWidgetContent.InsertAtCursor(implText);
|
{
|
||||||
sourceEditWidgetContent.CursorLineAndColumn = lineAndColumn;
|
char8 c = implText[i];
|
||||||
|
if ((c == '\t') || (c == '\b') || (c == '\r'))
|
||||||
|
{
|
||||||
|
implSect.Clear();
|
||||||
|
implSect.Append(implText, startIdx, i - startIdx);
|
||||||
|
if (!implSect.IsEmpty)
|
||||||
|
{
|
||||||
|
sourceEditWidgetContent.InsertAtCursor(implSect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == '\t')
|
||||||
|
{
|
||||||
|
sourceEditWidgetContent.InsertAtCursor("\n");
|
||||||
|
sourceEditWidgetContent.CursorToLineEnd();
|
||||||
|
sourceEditWidgetContent.OpenCodeBlock();
|
||||||
|
}
|
||||||
|
else if (c == '\r')
|
||||||
|
{
|
||||||
|
sourceEditWidgetContent.InsertAtCursor("\n");
|
||||||
|
sourceEditWidgetContent.CursorToLineEnd();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let lc = sourceEditWidgetContent.CursorLineAndColumn;
|
||||||
|
sourceEditWidgetContent.CursorLineAndColumn = .(lc.mLine + 1, 0);
|
||||||
|
sourceEditWidgetContent.CursorToLineEnd();
|
||||||
|
sourceEditWidgetContent.InsertAtCursor("\n");
|
||||||
|
sourceEditWidgetContent.CursorToLineEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
startIdx = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
implSect.Clear();
|
||||||
|
implSect.Append(implText, startIdx, implText.Length - startIdx);
|
||||||
|
if (!implSect.IsEmpty)
|
||||||
|
{
|
||||||
|
sourceEditWidgetContent.InsertAtCursor(implSect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistentInvokeSrcPositons != null)
|
if (persistentInvokeSrcPositons != null)
|
||||||
|
|
|
@ -2184,12 +2184,14 @@ namespace IDE.ui
|
||||||
bool allowChar = true;
|
bool allowChar = true;
|
||||||
mIsInKeyChar = true;
|
mIsInKeyChar = true;
|
||||||
String insertType = scope String();
|
String insertType = scope String();
|
||||||
mAutoComplete.InsertSelection(theChar, insertType);
|
String insertStr = scope String();
|
||||||
|
mAutoComplete.InsertSelection(theChar, insertType, insertStr);
|
||||||
mIsInKeyChar = false;
|
mIsInKeyChar = false;
|
||||||
if (insertType != null)
|
if (insertType != null)
|
||||||
{
|
{
|
||||||
//mGenerateAutocompleteHandler(false, false);
|
//mGenerateAutocompleteHandler(false, false);
|
||||||
if ((insertType == "method") && (theChar == '('))
|
if (((insertType == "method") && (theChar == '(')) ||
|
||||||
|
((insertType == "token") && (insertStr == "override")))
|
||||||
{
|
{
|
||||||
if (IsCursorVisible(false))
|
if (IsCursorVisible(false))
|
||||||
mOnGenerateAutocomplete('\0', default);
|
mOnGenerateAutocomplete('\0', default);
|
||||||
|
|
|
@ -1862,31 +1862,31 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter)
|
||||||
if (!curType->IsTypeMemberAccessible(methodDef->mDeclaringType, activeTypeDef))
|
if (!curType->IsTypeMemberAccessible(methodDef->mDeclaringType, activeTypeDef))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodDef->mMethodType == BfMethodType_Normal)
|
auto& methodGroup = curType->mMethodInstanceGroups[methodDef->mIdx];
|
||||||
|
if (methodGroup.mDefault == NULL)
|
||||||
{
|
{
|
||||||
auto& methodGroup = curType->mMethodInstanceGroups[methodDef->mIdx];
|
continue;
|
||||||
if (methodGroup.mDefault == NULL)
|
}
|
||||||
{
|
auto methodInst = methodGroup.mDefault;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto methodInst = methodGroup.mDefault;
|
|
||||||
|
|
||||||
if ((methodDef->mIsVirtual) && (!methodDef->mIsOverride))
|
if ((methodDef->mIsVirtual) && (!methodDef->mIsOverride))
|
||||||
|
{
|
||||||
|
if (methodDef->mMethodType == BfMethodType_Normal)
|
||||||
{
|
{
|
||||||
String methodPrefix;
|
String methodPrefix;
|
||||||
String methodName;
|
String methodName;
|
||||||
String impString;
|
String impString;
|
||||||
|
|
||||||
if (!methodInst->mReturnType->IsVoid())
|
|
||||||
impString = "return ";
|
|
||||||
|
|
||||||
bool isAbstract = methodDef->mIsAbstract;
|
bool isAbstract = methodDef->mIsAbstract;
|
||||||
|
|
||||||
if (!isAbstract)
|
if (!isAbstract)
|
||||||
{
|
{
|
||||||
|
if (!methodInst->mReturnType->IsVoid())
|
||||||
|
impString = "return ";
|
||||||
|
|
||||||
impString += "base.";
|
impString += "base.";
|
||||||
impString += methodDef->mName;;
|
impString += methodDef->mName;
|
||||||
impString += "(";
|
impString += "(";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1898,7 +1898,7 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter)
|
||||||
methodPrefix += " ";
|
methodPrefix += " ";
|
||||||
methodName += methodDef->mName;
|
methodName += methodDef->mName;
|
||||||
methodName += "(";
|
methodName += "(";
|
||||||
for (int paramIdx = 0; paramIdx < (int) methodInst->GetParamCount(); paramIdx++)
|
for (int paramIdx = 0; paramIdx < (int)methodInst->GetParamCount(); paramIdx++)
|
||||||
{
|
{
|
||||||
if (paramIdx > 0)
|
if (paramIdx > 0)
|
||||||
{
|
{
|
||||||
|
@ -1918,8 +1918,57 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter)
|
||||||
if (!isAbstract)
|
if (!isAbstract)
|
||||||
impString += ");";
|
impString += ");";
|
||||||
|
|
||||||
AddEntry(AutoCompleteEntry("override", methodName + "\t" + methodPrefix + methodName + "\t" + impString, methodDeclaration->mDocumentation), filter);
|
AddEntry(AutoCompleteEntry("override", methodName + "\t" + methodPrefix + methodName + "\t" + impString, NULL), filter);
|
||||||
}
|
}
|
||||||
|
else if ((methodDef->mMethodType == BfMethodType_PropertyGetter) || (methodDef->mMethodType == BfMethodType_PropertySetter))
|
||||||
|
{
|
||||||
|
auto propDeclaration = methodDef->GetPropertyDeclaration();
|
||||||
|
bool hasGet = propDeclaration->GetMethod("get") != NULL;
|
||||||
|
bool hasSet = propDeclaration->GetMethod("set") != NULL;
|
||||||
|
|
||||||
|
if ((methodDef->mMethodType == BfMethodType_PropertyGetter) || (!hasGet))
|
||||||
|
{
|
||||||
|
String propName;
|
||||||
|
String impl;
|
||||||
|
|
||||||
|
propDeclaration->mNameNode->ToString(propName);
|
||||||
|
|
||||||
|
bool isAbstract = methodDef->mIsAbstract;
|
||||||
|
|
||||||
|
if (propDeclaration->mProtectionSpecifier != NULL)
|
||||||
|
impl += propDeclaration->mProtectionSpecifier->ToString() + " ";
|
||||||
|
impl += "override ";
|
||||||
|
impl += mModule->TypeToString(methodInst->mReturnType, BfTypeNameFlag_ReduceName);
|
||||||
|
impl += " ";
|
||||||
|
impl += propName;
|
||||||
|
impl += "\t";
|
||||||
|
if (hasGet)
|
||||||
|
{
|
||||||
|
impl += "get\t";
|
||||||
|
if (!isAbstract)
|
||||||
|
{
|
||||||
|
impl += "return base.";
|
||||||
|
impl += propName;
|
||||||
|
impl += ";";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasSet)
|
||||||
|
{
|
||||||
|
if (hasGet)
|
||||||
|
impl += "\b\r";
|
||||||
|
|
||||||
|
impl += "set\t";
|
||||||
|
if (!isAbstract)
|
||||||
|
{
|
||||||
|
impl += "base.";
|
||||||
|
impl += propName;
|
||||||
|
impl += " = value;";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AddEntry(AutoCompleteEntry("override", propName + "\t" + impl, NULL), filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue