Методы расширения не конфликтуют больше со статическими методами
Добавлен ряд методов в интерфейсы VisualPascalABCPlugins Ряд исправлений в интеллисенсе В контекстное меню с примерами добавлен operator i where
This commit is contained in:
parent
0fed1054f3
commit
e6993b3ef0
|
|
@ -805,6 +805,7 @@ namespace CodeCompletion
|
||||||
else return ss;
|
else return ss;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (members != null)
|
||||||
foreach (SymScope ss in members)
|
foreach (SymScope ss in members)
|
||||||
if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0)
|
if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0)
|
||||||
if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1)
|
if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1)
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,8 @@ namespace VisualPascalABCPlugins
|
||||||
void SetFileAsChanged(string FileName);
|
void SetFileAsChanged(string FileName);
|
||||||
void OpenTabWithText(string tabName, string Text);
|
void OpenTabWithText(string tabName, string Text);
|
||||||
ICodeFileDocument OpenFileForDebug(string FileName);
|
ICodeFileDocument OpenFileForDebug(string FileName);
|
||||||
|
void CloseAllButThis(ICodeFileDocument nonCloseTab);
|
||||||
|
void PrintActiveDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IWorkbenchProjectService
|
public interface IWorkbenchProjectService
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@ procedure Add(self: List<integer>; params arr: array of integer); extensionmetho
|
||||||
begin
|
begin
|
||||||
self.AddRange(arr);
|
self.AddRange(arr);
|
||||||
end;
|
end;
|
||||||
|
function BinarySearch<T>(self: array of T; item: T): integer; extensionmethod;
|
||||||
|
begin
|
||||||
|
Result := System.Array.BinarySearch(self,item);
|
||||||
|
end;
|
||||||
begin
|
begin
|
||||||
var arr := Arr(1,2,3);
|
var arr := Arr(1,2,3);
|
||||||
assert(arr.myfirst=1);
|
assert(arr.myfirst=1);
|
||||||
|
|
@ -55,4 +59,5 @@ begin
|
||||||
var lst4 := new List<integer>;
|
var lst4 := new List<integer>;
|
||||||
lst4.Add(2,3,4,5);
|
lst4.Add(2,3,4,5);
|
||||||
assert(lst4[3]=5);
|
assert(lst4[3]=5);
|
||||||
|
assert(arr.BinarySearch(3)=2);
|
||||||
end.
|
end.
|
||||||
|
|
@ -4921,7 +4921,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
if (_dot_node != null)
|
if (_dot_node != null)
|
||||||
{
|
{
|
||||||
bool skip_first_parameter = false; //lroman//
|
bool skip_first_parameter = false; //lroman//
|
||||||
|
bool has_extension_overload = false;
|
||||||
semantic_node sn = convert_semantic_strong(_dot_node.left);
|
semantic_node sn = convert_semantic_strong(_dot_node.left);
|
||||||
|
|
||||||
//SyntaxTree.ident id_right = ConvertOperatorNameToIdent(_dot_node.right as SyntaxTree.ident);
|
//SyntaxTree.ident id_right = ConvertOperatorNameToIdent(_dot_node.right as SyntaxTree.ident);
|
||||||
|
|
@ -5054,11 +5054,8 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
si = si.Next;
|
si = si.Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*if (has_obj_methods)
|
if (si != null)
|
||||||
{
|
si.Next = null;
|
||||||
exprs.remove_at(0);
|
|
||||||
skip_first_parameter = false;
|
|
||||||
}*/
|
|
||||||
si = new_si;
|
si = new_si;
|
||||||
}
|
}
|
||||||
if (_method_call.parameters != null)
|
if (_method_call.parameters != null)
|
||||||
|
|
@ -5433,6 +5430,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
{
|
{
|
||||||
si = tn.find_in_type(id_right.name, context.CurrentScope);//CurrentScope
|
si = tn.find_in_type(id_right.name, context.CurrentScope);//CurrentScope
|
||||||
delete_inherited_constructors(ref si, tn);
|
delete_inherited_constructors(ref si, tn);
|
||||||
|
delete_extension_methods(ref si);
|
||||||
}
|
}
|
||||||
|
|
||||||
//definition_node ddn2=check_name_node_type(id_right.name,si,get_location(id_right),
|
//definition_node ddn2=check_name_node_type(id_right.name,si,get_location(id_right),
|
||||||
|
|
@ -6460,6 +6458,35 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void delete_extension_methods(ref SymbolInfo si)
|
||||||
|
{
|
||||||
|
List<SymbolInfo> si_list = new List<SymbolInfo>();
|
||||||
|
SymbolInfo tmp_si = si;
|
||||||
|
while (tmp_si != null)
|
||||||
|
{
|
||||||
|
if (!(tmp_si.sym_info is function_node && (tmp_si.sym_info as function_node).is_extension_method))
|
||||||
|
si_list.Add(tmp_si);
|
||||||
|
tmp_si = tmp_si.Next;
|
||||||
|
}
|
||||||
|
SymbolInfo new_si = null;
|
||||||
|
for (int i = 0; i < si_list.Count; i++)
|
||||||
|
{
|
||||||
|
if (new_si == null)
|
||||||
|
{
|
||||||
|
new_si = si_list[i];
|
||||||
|
si = new_si;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
si.Next = si_list[i];
|
||||||
|
si = si.Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (si != null)
|
||||||
|
si.Next = null;
|
||||||
|
si = new_si;
|
||||||
|
}
|
||||||
|
|
||||||
//ssyy
|
//ssyy
|
||||||
//Удаляет конструкторы предков в списке si
|
//Удаляет конструкторы предков в списке si
|
||||||
private void delete_inherited_constructors(ref SymbolInfo si, type_node tn)
|
private void delete_inherited_constructors(ref SymbolInfo si, type_node tn)
|
||||||
|
|
@ -11801,7 +11828,7 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
/*SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(context.converted_namespace.scope, top_function.ConnectedToType.Scope);
|
/*SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(context.converted_namespace.scope, top_function.ConnectedToType.Scope);
|
||||||
top_function.scope = scope;*/
|
top_function.scope = scope;*/
|
||||||
top_function.ConnectedToType.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
top_function.ConnectedToType.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
||||||
if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind)
|
if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind && top_function.ConnectedToType.element_type.is_generic_parameter)
|
||||||
top_function.ConnectedToType.base_type.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
top_function.ConnectedToType.base_type.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1072,6 +1072,14 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
|
|
||||||
public type_node ConnectedToType = null;
|
public type_node ConnectedToType = null;
|
||||||
|
|
||||||
|
public override bool is_extension_method
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ConnectedToType != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SemanticTree.ITypeNode SemanticTree.ICommonNamespaceFunctionNode.ConnectedToType
|
SemanticTree.ITypeNode SemanticTree.ICommonNamespaceFunctionNode.ConnectedToType
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -3104,7 +3104,8 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
si = AddToSymbolInfo(si, scope.SymbolTable.Find(scope,name));
|
si = AddToSymbolInfo(si, scope.SymbolTable.Find(scope,name));
|
||||||
return si;
|
return si;
|
||||||
*/
|
*/
|
||||||
|
if (this.type_special_kind == SemanticTree.type_special_kind.array_kind && scope == null)
|
||||||
|
this.init_scope();
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
{
|
{
|
||||||
SymbolInfo si = compiled_find(name);
|
SymbolInfo si = compiled_find(name);
|
||||||
|
|
@ -3139,6 +3140,15 @@ namespace PascalABCCompiler.TreeRealization
|
||||||
SymbolInfo si = scope.SymbolTable.Find(scope, name);
|
SymbolInfo si = scope.SymbolTable.Find(scope, name);
|
||||||
SymbolInfo si2 = find_in_additional_names(name);
|
SymbolInfo si2 = find_in_additional_names(name);
|
||||||
SymbolInfo si3 = compiled_find(name);
|
SymbolInfo si3 = compiled_find(name);
|
||||||
|
if (this.type_special_kind == SemanticTree.type_special_kind.array_kind && this.base_type.Scope != null)
|
||||||
|
{
|
||||||
|
SymbolInfo tmp_si = this.base_type.Scope.SymbolTable.Find(this.base_type.Scope, name);
|
||||||
|
if (tmp_si != null)
|
||||||
|
{
|
||||||
|
tmp_si.Next = si;
|
||||||
|
si = tmp_si;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (si != null)
|
if (si != null)
|
||||||
{
|
{
|
||||||
SymbolInfo tmp_si = si;
|
SymbolInfo tmp_si = si;
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ namespace VisualPascalABC
|
||||||
|
|
||||||
public CompilerForm CompilerForm1;
|
public CompilerForm CompilerForm1;
|
||||||
|
|
||||||
public VisualStates visualStates;
|
|
||||||
public AboutBox AboutBox1;
|
public AboutBox AboutBox1;
|
||||||
public FindReplaceForm FindForm;
|
public FindReplaceForm FindForm;
|
||||||
public GotoLineForm GotoLineForm;
|
public GotoLineForm GotoLineForm;
|
||||||
|
|
@ -265,9 +265,6 @@ namespace VisualPascalABC
|
||||||
//this.Width = 800;
|
//this.Width = 800;
|
||||||
//this.Height = 600;
|
//this.Height = 600;
|
||||||
UserOptions = new UserOptions();
|
UserOptions = new UserOptions();
|
||||||
|
|
||||||
visualStates = new VisualStates();
|
|
||||||
|
|
||||||
SetFiltersAndHighlighting();
|
SetFiltersAndHighlighting();
|
||||||
|
|
||||||
FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height;
|
FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace VisualPascalABC
|
||||||
{
|
{
|
||||||
List<string> temp_open_files = new List<string>();
|
List<string> temp_open_files = new List<string>();
|
||||||
public List<string> LastOpenFiles;
|
public List<string> LastOpenFiles;
|
||||||
|
private VisualStates visualStates = new VisualStates();
|
||||||
internal Dictionary<string, CodeFileDocumentControl> OpenDocuments = new Dictionary<string, CodeFileDocumentControl>();
|
internal Dictionary<string, CodeFileDocumentControl> OpenDocuments = new Dictionary<string, CodeFileDocumentControl>();
|
||||||
internal Dictionary<string, WebBrowserControl> OpenBrowserDocuments = new Dictionary<string, WebBrowserControl>();
|
internal Dictionary<string, WebBrowserControl> OpenBrowserDocuments = new Dictionary<string, WebBrowserControl>();
|
||||||
private int MaxLastOpenFiles = 10;
|
private int MaxLastOpenFiles = 10;
|
||||||
|
|
@ -423,6 +424,11 @@ namespace VisualPascalABC
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IWorkbenchFileService.CloseAllButThis(ICodeFileDocument nonCloseTab)
|
||||||
|
{
|
||||||
|
this.CloseAllButThis(nonCloseTab as CodeFileDocumentControl);
|
||||||
|
}
|
||||||
|
|
||||||
void CloseAllButThis(CodeFileDocumentControl nonCloseTab)
|
void CloseAllButThis(CodeFileDocumentControl nonCloseTab)
|
||||||
{
|
{
|
||||||
SaveCanceled = false;
|
SaveCanceled = false;
|
||||||
|
|
@ -576,6 +582,11 @@ namespace VisualPascalABC
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IWorkbenchFileService.PrintActiveDocument()
|
||||||
|
{
|
||||||
|
ExecPrint();
|
||||||
|
}
|
||||||
|
|
||||||
public void ExecPrint()
|
public void ExecPrint()
|
||||||
{
|
{
|
||||||
printDialog1.AllowSelection = true;
|
printDialog1.AllowSelection = true;
|
||||||
|
|
|
||||||
|
|
@ -73,3 +73,9 @@ LINQ\Zip2.pas
|
||||||
|
|
||||||
[CRT]
|
[CRT]
|
||||||
StandardUnits\CRT\*.pas
|
StandardUnits\CRT\*.pas
|
||||||
|
|
||||||
|
[operator]
|
||||||
|
!MainFeatures\06_Classes\OperatorOverloading.pas
|
||||||
|
|
||||||
|
[where]
|
||||||
|
!MainFeatures\06_Classes\Where.pas
|
||||||
Loading…
Reference in a new issue