This commit is contained in:
Бондарев Иван 2018-02-19 20:17:00 +01:00
parent bd0531f6e6
commit 51ad71de05
3 changed files with 66 additions and 3 deletions

View file

@ -22,7 +22,7 @@ namespace CodeCompletion
public class DomSyntaxTreeVisitor : AbstractVisitor
{
private SymScope returned_scope;//vozvrashaemyj scope posle vyzova visit
private SymScope saved_returned_scope;//nuzhen dlja lambd
private Stack<SymScope> saved_returned_scopes = new Stack<SymScope>();//nuzhen dlja lambd
private List<SymScope> returned_scopes = new List<SymScope>();//hranit spisok scopov (metodov) posle vyzova visit, esli search_all=true
public SymScope entry_scope;//korenvoj scope unita
public SymScope impl_scope;
@ -86,12 +86,12 @@ namespace CodeCompletion
private void save_return_value()
{
saved_returned_scope = returned_scope;
saved_returned_scopes.Push(returned_scope);
}
private void restore_return_value()
{
returned_scope = saved_returned_scope;
returned_scope = saved_returned_scopes.Pop();
}
public override void visit(syntax_tree_node _syntax_tree_node)
@ -1967,6 +1967,7 @@ namespace CodeCompletion
}
}
}
}
ns_cache = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
@ -2129,6 +2130,7 @@ namespace CodeCompletion
(new PascalABCCompiler.SyntaxTree.compiler_directive(new token_info("reference"), new token_info(ri.FullAssemblyName)));
}
}
List<string> included_files = new List<string>();
if (_program_module.compiler_directives != null)
foreach (PascalABCCompiler.SyntaxTree.compiler_directive dir in _program_module.compiler_directives)
{
@ -2175,6 +2177,19 @@ namespace CodeCompletion
}
}
}
else if (dir.Name.text.ToLower() == "includenamespace")
{
string directive = dir.Directive.text.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
if (directive == "*.pas" || directive.EndsWith(Path.DirectorySeparatorChar + "*.pas"))
{
string udir = Path.Combine(Path.GetDirectoryName(_program_module.file_name), directive.Replace(Path.DirectorySeparatorChar + "*.pas", ""));
foreach (string file in Directory.EnumerateFiles(udir, "*.pas"))
included_files.Add(file);
}
else
included_files.Add(Path.Combine(Path.GetDirectoryName(_program_module.file_name), directive));
}
}
doc = new document(_program_module.file_name);
@ -2186,6 +2201,18 @@ namespace CodeCompletion
Hashtable ns_cache = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
bool has_system_unit = false;
bool has_extensions_unit = false;
foreach (string file in included_files)
{
DomConverter dc = CodeCompletionController.comp_modules[file] as DomConverter;
if (dc == null)
{
dc = new CodeCompletionController().CompileAllIfNeed(file, true);
}
if (dc.visitor != null)
{
}
}
if (_program_module.used_units != null)
{
unit_scope.uses_source_range = get_location(_program_module.used_units);

View file

@ -1010,6 +1010,8 @@ namespace CodeCompletion
}
}
public class InterfaceUnitScope : SymScope, IInterfaceUnitScope
{
public ImplementationUnitScope impl_scope;
@ -1120,6 +1122,27 @@ namespace CodeCompletion
}
}
public class NamespaceUnitScope : SymScope
{
public List<InterfaceUnitScope> units;
public NamespaceUnitScope(SymInfo si, SymScope topScope) : base(si, topScope)
{
units = new List<InterfaceUnitScope>();
}
public override SymScope FindName(string name)
{
foreach (InterfaceUnitScope unit in units)
{
SymScope ss = unit.FindName(name);
if (ss != null)
return ss;
}
return null;
}
}
//interfejsnyj scope
public class ImplementationUnitScope : SymScope, IImplementationUnitScope
{

View file

@ -0,0 +1,13 @@
type
t1=class t1_member:byte end;
t2=class t2_member:byte end;
begin
var thr{@var thr: Thread;@} := new System.Threading.Thread(()->begin
var a1 := new t1;
var a2 := new t2;
end);
end.