diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index c4a366840..93ed5bcf2 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -880,6 +880,12 @@ namespace CodeCompletion ts = (ts as TypeSynonim).actType; this.entry_scope.AddExtensionMethod(meth_name, ps, ts); topScope.AddExtensionMethod(meth_name, ps, ts); + pr = new ProcRealization(ps, cur_scope); + pr.already_defined = true; + ps.proc_realization = pr; + pr.loc = cur_loc; + pr.head_loc = loc; + this.entry_scope.AddName("$method", pr); } ps.head_loc = loc; if (!ps.is_extension) @@ -1154,6 +1160,12 @@ namespace CodeCompletion ts = (ts as TypeSynonim).actType; this.entry_scope.AddExtensionMethod(meth_name, ps, ts); topScope.AddExtensionMethod(meth_name, ps, ts); + pr = new ProcRealization(ps, cur_scope); + pr.already_defined = true; + ps.proc_realization = pr; + pr.loc = cur_loc; + pr.head_loc = loc; + this.entry_scope.AddName("$method",pr); } if (!ps.is_extension) { @@ -1340,78 +1352,78 @@ namespace CodeCompletion private List ref_type_wait_list = new List(); private ident_list template_args = null; - + public override void visit(type_declaration _type_declaration) { //throw new Exception("The method or operation is not implemented."); cur_type_name = _type_declaration.type_name.name; if (_type_declaration.type_name is template_type_name) { - template_args = (_type_declaration.type_name as template_type_name).template_args; + template_args = (_type_declaration.type_name as template_type_name).template_args; } _type_declaration.type_def.visit(this); if (ret_tn != null && ret_tn is PointerScope && (ret_tn as PointerScope).ref_type is UnknownScope) { - ref_type_wait_list.Add(ret_tn as PointerScope); + ref_type_wait_list.Add(ret_tn as PointerScope); } //else if (ret_tn != null && ret_tn is TypeScope) { - //if (ret_tn is TypeScope) - //{ - if (!(_type_declaration.type_def is named_type_reference)) - { - //(ret_tn as TypeScope).name = _type_declaration.type_name.name; - ret_tn.si.name = _type_declaration.type_name.name; - ret_tn.si.describe = ret_tn.GetDescription(); - if (!(_type_declaration.type_def is class_definition)) - ret_tn.MakeSynonimDescription(); - ret_tn.loc = get_location(_type_declaration);//new location(loc.begin_line_num,loc.begin_column_num,ret_tn.loc.end_line_num,ret_tn.loc.end_column_num,ret_tn.loc.doc); - if (_type_declaration.type_def is class_definition) - { - string key = this.converter.controller.Parser.LanguageInformation.GetClassKeyword((_type_declaration.type_def as class_definition).keyword); - if (key != null && ret_tn.body_loc != null) - { - ret_tn.head_loc = new location(ret_tn.body_loc.begin_line_num,ret_tn.body_loc.begin_column_num, ret_tn.body_loc.begin_line_num,ret_tn.body_loc.begin_column_num+key.Length,doc); - } - } - if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_type_declaration)) - ret_tn.AddDocumentation(this.converter.controller.docs[_type_declaration]); - if (!(_type_declaration.type_def is class_definition)) - cur_scope.AddName(_type_declaration.type_name.name,ret_tn); - } - else - { - TypeSynonim ts = new TypeSynonim(new SymInfo(_type_declaration.type_name.name, SymbolKind.Type,_type_declaration.type_name.name),ret_tn); - ts.loc = get_location(_type_declaration); - ts.topScope = cur_scope; - ts.declaringUnit = entry_scope; - //ts.si.describe = "type "+ret_tn.si.name+" = "+ret_tn.si.describe; - cur_scope.AddName(_type_declaration.type_name.name,ts); - if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_type_declaration)) - ts.AddDocumentation(this.converter.controller.docs[_type_declaration]); - } - //} - + //if (ret_tn is TypeScope) + //{ + if (!(_type_declaration.type_def is named_type_reference)) + { + //(ret_tn as TypeScope).name = _type_declaration.type_name.name; + ret_tn.si.name = _type_declaration.type_name.name; + ret_tn.si.describe = ret_tn.GetDescription(); + if (!(_type_declaration.type_def is class_definition)) + ret_tn.MakeSynonimDescription(); + ret_tn.loc = get_location(_type_declaration);//new location(loc.begin_line_num,loc.begin_column_num,ret_tn.loc.end_line_num,ret_tn.loc.end_column_num,ret_tn.loc.doc); + if (_type_declaration.type_def is class_definition) + { + string key = this.converter.controller.Parser.LanguageInformation.GetClassKeyword((_type_declaration.type_def as class_definition).keyword); + if (key != null && ret_tn.body_loc != null) + { + ret_tn.head_loc = new location(ret_tn.body_loc.begin_line_num, ret_tn.body_loc.begin_column_num, ret_tn.body_loc.begin_line_num, ret_tn.body_loc.begin_column_num + key.Length, doc); + } + } + if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_type_declaration)) + ret_tn.AddDocumentation(this.converter.controller.docs[_type_declaration]); + if (!(_type_declaration.type_def is class_definition)) + cur_scope.AddName(_type_declaration.type_name.name, ret_tn); + } + else + { + TypeSynonim ts = new TypeSynonim(new SymInfo(_type_declaration.type_name.name, SymbolKind.Type, _type_declaration.type_name.name), ret_tn); + ts.loc = get_location(_type_declaration); + ts.topScope = cur_scope; + ts.declaringUnit = entry_scope; + //ts.si.describe = "type "+ret_tn.si.name+" = "+ret_tn.si.describe; + cur_scope.AddName(_type_declaration.type_name.name, ts); + if (add_doc_from_text && this.converter.controller.docs != null && this.converter.controller.docs.ContainsKey(_type_declaration)) + ts.AddDocumentation(this.converter.controller.docs[_type_declaration]); + } + //} + } else if (ret_tn != null) { - if (ret_tn is ProcScope) - { - ret_tn = new ProcType(ret_tn as ProcScope); - ret_tn.topScope = cur_scope; - } - cur_scope.AddName(_type_declaration.type_name.name,ret_tn); - if (ret_tn is ProcType) - { - ret_tn.MakeSynonimDescription(); - } - location loc = get_location(_type_declaration); - if (ret_tn.loc == null) - { - ret_tn.loc = loc; - //ret_tn.loc = new location(loc.begin_line_num,loc.begin_column_num,ret_tn.loc.end_line_num,ret_tn.loc.end_column_num,ret_tn.loc.doc); - } + if (ret_tn is ProcScope) + { + ret_tn = new ProcType(ret_tn as ProcScope); + ret_tn.topScope = cur_scope; + } + cur_scope.AddName(_type_declaration.type_name.name, ret_tn); + if (ret_tn is ProcType) + { + ret_tn.MakeSynonimDescription(); + } + location loc = get_location(_type_declaration); + if (ret_tn.loc == null) + { + ret_tn.loc = loc; + //ret_tn.loc = new location(loc.begin_line_num,loc.begin_column_num,ret_tn.loc.end_line_num,ret_tn.loc.end_column_num,ret_tn.loc.doc); + } } ret_tn.declaringUnit = entry_scope; if (ref_type_wait_list.Count == 0) ret_tn = null; @@ -2649,17 +2661,18 @@ namespace CodeCompletion enum_scope.topScope = cur_scope; List elems = new List(); if (_enum_type_definition.enumerators != null) - foreach (enumerator en in _enum_type_definition.enumerators.enumerators) - { - ElementScope ss = new ElementScope(new SymInfo(en.name.name, SymbolKind.Constant, en.name.name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope,cur_scope); - ss.is_static = true; - ss.cnst_val = en.name.name; - elems.Add(ss); - ss.loc = get_location(en); - cur_scope.AddName(en.name.name, ss); - enum_scope.AddName(en.name.name, ss); - enum_scope.AddEnumConstant(en.name.name); - } + foreach (enumerator en in _enum_type_definition.enumerators.enumerators) + { + ElementScope ss = new ElementScope(new SymInfo(en.name.name, SymbolKind.Constant, en.name.name),/*cur_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.integer_type_name)*/enum_scope, cur_scope); + ss.is_static = true; + ss.cnst_val = en.name.name; + elems.Add(ss); + ss.loc = get_location(en); + cur_scope.AddName(en.name.name, ss); + enum_scope.AddName(en.name.name, ss); + enum_scope.AddEnumConstant(en.name.name); + ss.AddDocumentation(this.converter.controller.docs[en]); + } for (int i=0; i to_remove = new List(); for (int i = 0; i < ret_names.Count; i++) { if (ret_names[i] is ElementScope && (ret_names[i] as ElementScope).sc is ProcType) @@ -781,7 +782,13 @@ namespace CodeCompletion //if (ret_names[i] != null) //ret_names[i] = ((ret_names[i] as ElementScope).sc as ProcType).target; } + else if (left_scope is ElementScope && ret_names[i] is ProcScope && (ret_names[i] as ProcScope).IsStatic) + { + ret_names[i] = null; + } } + ret_names.RemoveAll(x => x == null); + if (ret_tn is ElementScope && stv != null) { List procs = stv.entry_scope.GetExtensionMethods((_dot_node.right as ident).name,(ret_tn as ElementScope).sc as TypeScope); @@ -1439,7 +1446,7 @@ namespace CodeCompletion public override void visit(question_colon_expression _question_colon_expression) { - throw new NotImplementedException(); + _question_colon_expression.ret_if_true.visit(this); } public override void visit(expression_as_statement _expression_as_statement) diff --git a/ParserTools/DocumentationConstructor.cs b/ParserTools/DocumentationConstructor.cs index 3301a53e3..3f1423fcd 100644 --- a/ParserTools/DocumentationConstructor.cs +++ b/ParserTools/DocumentationConstructor.cs @@ -166,5 +166,13 @@ namespace PascalABCCompiler { connect(_destructor); } + public override void visit(enum_type_definition _enum_type_definition) + { + visit_collection(_enum_type_definition.enumerators.enumerators); + } + public override void visit(enumerator _enumerator) + { + connect(_enumerator); + } } }