Методы расширения не конфликтуют больше со статическими методами

Добавлен ряд методов в интерфейсы VisualPascalABCPlugins
Ряд исправлений в интеллисенсе
В контекстное меню с примерами добавлен operator i where
This commit is contained in:
Бондарев Иван 2015-10-20 21:19:54 +02:00
parent 0fed1054f3
commit e6993b3ef0
9 changed files with 80 additions and 13 deletions

View file

@ -805,6 +805,7 @@ namespace CodeCompletion
else return ss;
}
else
if (members != null)
foreach (SymScope ss in members)
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)

View file

@ -267,6 +267,8 @@ namespace VisualPascalABCPlugins
void SetFileAsChanged(string FileName);
void OpenTabWithText(string tabName, string Text);
ICodeFileDocument OpenFileForDebug(string FileName);
void CloseAllButThis(ICodeFileDocument nonCloseTab);
void PrintActiveDocument();
}
public interface IWorkbenchProjectService

View file

@ -35,6 +35,10 @@ procedure Add(self: List<integer>; params arr: array of integer); extensionmetho
begin
self.AddRange(arr);
end;
function BinarySearch<T>(self: array of T; item: T): integer; extensionmethod;
begin
Result := System.Array.BinarySearch(self,item);
end;
begin
var arr := Arr(1,2,3);
assert(arr.myfirst=1);
@ -55,4 +59,5 @@ begin
var lst4 := new List<integer>;
lst4.Add(2,3,4,5);
assert(lst4[3]=5);
assert(arr.BinarySearch(3)=2);
end.

View file

@ -4921,7 +4921,7 @@ namespace PascalABCCompiler.TreeConverter
if (_dot_node != null)
{
bool skip_first_parameter = false; //lroman//
bool has_extension_overload = false;
semantic_node sn = convert_semantic_strong(_dot_node.left);
//SyntaxTree.ident id_right = ConvertOperatorNameToIdent(_dot_node.right as SyntaxTree.ident);
@ -5054,11 +5054,8 @@ namespace PascalABCCompiler.TreeConverter
si = si.Next;
}
}
/*if (has_obj_methods)
{
exprs.remove_at(0);
skip_first_parameter = false;
}*/
if (si != null)
si.Next = null;
si = new_si;
}
if (_method_call.parameters != null)
@ -5433,6 +5430,7 @@ namespace PascalABCCompiler.TreeConverter
{
si = tn.find_in_type(id_right.name, context.CurrentScope);//CurrentScope
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),
@ -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
//Удаляет конструкторы предков в списке si
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);
top_function.scope = scope;*/
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));
break;

View file

@ -1072,6 +1072,14 @@ namespace PascalABCCompiler.TreeRealization
public type_node ConnectedToType = null;
public override bool is_extension_method
{
get
{
return ConnectedToType != null;
}
}
SemanticTree.ITypeNode SemanticTree.ICommonNamespaceFunctionNode.ConnectedToType
{
get

View file

@ -3104,7 +3104,8 @@ namespace PascalABCCompiler.TreeRealization
si = AddToSymbolInfo(si, scope.SymbolTable.Find(scope,name));
return si;
*/
if (this.type_special_kind == SemanticTree.type_special_kind.array_kind && scope == null)
this.init_scope();
if (scope == null)
{
SymbolInfo si = compiled_find(name);
@ -3139,6 +3140,15 @@ namespace PascalABCCompiler.TreeRealization
SymbolInfo si = scope.SymbolTable.Find(scope, name);
SymbolInfo si2 = find_in_additional_names(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)
{
SymbolInfo tmp_si = si;

View file

@ -189,7 +189,7 @@ namespace VisualPascalABC
public CompilerForm CompilerForm1;
public VisualStates visualStates;
public AboutBox AboutBox1;
public FindReplaceForm FindForm;
public GotoLineForm GotoLineForm;
@ -265,9 +265,6 @@ namespace VisualPascalABC
//this.Width = 800;
//this.Height = 600;
UserOptions = new UserOptions();
visualStates = new VisualStates();
SetFiltersAndHighlighting();
FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height;

View file

@ -16,6 +16,7 @@ namespace VisualPascalABC
{
List<string> temp_open_files = new List<string>();
public List<string> LastOpenFiles;
private VisualStates visualStates = new VisualStates();
internal Dictionary<string, CodeFileDocumentControl> OpenDocuments = new Dictionary<string, CodeFileDocumentControl>();
internal Dictionary<string, WebBrowserControl> OpenBrowserDocuments = new Dictionary<string, WebBrowserControl>();
private int MaxLastOpenFiles = 10;
@ -423,6 +424,11 @@ namespace VisualPascalABC
return true;
}
void IWorkbenchFileService.CloseAllButThis(ICodeFileDocument nonCloseTab)
{
this.CloseAllButThis(nonCloseTab as CodeFileDocumentControl);
}
void CloseAllButThis(CodeFileDocumentControl nonCloseTab)
{
SaveCanceled = false;
@ -576,6 +582,11 @@ namespace VisualPascalABC
return true;
}
void IWorkbenchFileService.PrintActiveDocument()
{
ExecPrint();
}
public void ExecPrint()
{
printDialog1.AllowSelection = true;

View file

@ -73,3 +73,9 @@ LINQ\Zip2.pas
[CRT]
StandardUnits\CRT\*.pas
[operator]
!MainFeatures\06_Classes\OperatorOverloading.pas
[where]
!MainFeatures\06_Classes\Where.pas