This commit is contained in:
Бондарев Иван 2017-11-19 18:59:07 +01:00
parent 76d18019a0
commit b0fe3c29a8
2 changed files with 145 additions and 132 deletions

View file

@ -2192,56 +2192,58 @@ namespace CodeCompletion
NamespaceScope ns_scope = null; NamespaceScope ns_scope = null;
if (i == 0) if (i == 0)
{ {
if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)) string unit_name = null;
string pcu_unit_name = FindPCUFileName(str);
if (s is uses_unit_in)
unit_name = (s as uses_unit_in).in_file.Value;
else
unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_program_module.file_name));
if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
&& string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
unit_name = null;
if (unit_name != null)
{ {
ns_scope = new NamespaceScope(str); DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
ns_cache[str] = str; if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/)
cur_scope.AddName(str, ns_scope); {
if (s.name.idents.Count == 1) dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
cur_scope.AddUsedUnit(ns_scope); }
} if (dc.visitor != null)
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types) {
{ dc.visitor.entry_scope.InitAssemblies();
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str); cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t))); cur_scope.AddName(str, dc.visitor.entry_scope);
}
} }
else else
{ {
string unit_name = null; //unit_name = FindPCUFileName(str);
string pcu_unit_name = FindPCUFileName(str); unit_name = pcu_unit_name;
if (s is uses_unit_in) unit_name = (s as uses_unit_in).in_file.Value;
else unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_program_module.file_name));
if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
&& string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
unit_name = null;
if (unit_name != null) if (unit_name != null)
{ {
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter; IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/) SymScope ss = pcu_rdr.GetUnit(unit_name);
{ UnitDocCache.Load(ss, unit_name);
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true); cur_scope.AddUsedUnit(ss);
} cur_scope.AddName(str, ss);
if (dc.visitor != null)
{
dc.visitor.entry_scope.InitAssemblies();
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddName(str, dc.visitor.entry_scope);
}
} }
else else
{ {
//unit_name = FindPCUFileName(str); if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str))
unit_name = pcu_unit_name;
if (unit_name != null)
{ {
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader(); ns_scope = new NamespaceScope(str);
SymScope ss = pcu_rdr.GetUnit(unit_name); ns_cache[str] = str;
UnitDocCache.Load(ss, unit_name); cur_scope.AddName(str, ns_scope);
cur_scope.AddUsedUnit(ss); if (s.name.idents.Count == 1)
cur_scope.AddName(str, ss); cur_scope.AddUsedUnit(ns_scope);
}
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types)
{
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str);
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t)));
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
} }
if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/) if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/)
@ -3670,65 +3672,65 @@ namespace CodeCompletion
NamespaceScope ns_scope = null; NamespaceScope ns_scope = null;
if (i == 0) if (i == 0)
{ {
if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)) try
{ {
ns_scope = new NamespaceScope(str); string unit_name = null;
ns_cache[str] = str; string pcu_unit_name = FindPCUFileName(str);
cur_scope.AddName(str, ns_scope); if (s is uses_unit_in)
if (s.name.idents.Count == 1) unit_name = (s as uses_unit_in).in_file.Value;
cur_scope.AddUsedUnit(ns_scope); else
} unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name));
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types) if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
{ && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str); unit_name = null;
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t))); if (unit_name != null)
}
else
{
try
{ {
string unit_name = null; DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
string pcu_unit_name = FindPCUFileName(str); if (dc == null)
if (s is uses_unit_in) {
unit_name = (s as uses_unit_in).in_file.Value; dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
else }
unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name)); if (dc.visitor != null)
if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0 {
&& string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0) dc.visitor.entry_scope.InitAssemblies();
unit_name = null; cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddName(str, dc.visitor.entry_scope);
}
}
else
{
//unit_name = FindPCUFileName(str);
unit_name = pcu_unit_name;
if (unit_name != null) if (unit_name != null)
{ {
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter; IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
if (dc == null) SymScope ss = pcu_rdr.GetUnit(unit_name);
{ UnitDocCache.Load(ss, unit_name);
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true); cur_scope.AddUsedUnit(ss);
} cur_scope.AddName(str, ss);
if (dc.visitor != null)
{
dc.visitor.entry_scope.InitAssemblies();
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddName(str, dc.visitor.entry_scope);
}
} }
else else
{ {
//unit_name = FindPCUFileName(str); if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str))
unit_name = pcu_unit_name;
if (unit_name != null)
{ {
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader(); ns_scope = new NamespaceScope(str);
SymScope ss = pcu_rdr.GetUnit(unit_name); ns_cache[str] = str;
UnitDocCache.Load(ss, unit_name); cur_scope.AddName(str, ns_scope);
cur_scope.AddUsedUnit(ss); if (s.name.idents.Count == 1)
cur_scope.AddName(str, ss); cur_scope.AddUsedUnit(ns_scope);
}
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types)
{
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str);
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t)));
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
catch (Exception e) }
{ catch (Exception e)
{
}
} }
} }
if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/) if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/)
@ -3785,66 +3787,66 @@ namespace CodeCompletion
NamespaceScope ns_scope = null; NamespaceScope ns_scope = null;
if (i == 0) if (i == 0)
{ {
if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)) try
{ {
ns_scope = new NamespaceScope(str); string unit_name = null;
cur_scope.AddName(str, ns_scope); string pcu_unit_name = FindPCUFileName(str);
if (s.name.idents.Count == 1) if (s is uses_unit_in)
cur_scope.AddUsedUnit(ns_scope); unit_name = (s as uses_unit_in).in_file.Value;
} else
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types) unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name));
{ if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str); && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0)
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t))); unit_name = null;
} if (unit_name != null)
else
{
try
{ {
string unit_name = null; DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter;
string pcu_unit_name = FindPCUFileName(str); if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/)
if (s is uses_unit_in) {
unit_name = (s as uses_unit_in).in_file.Value; dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true);
else }
unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name)); if (dc.visitor != null)
if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0 {
&& string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0) dc.visitor.entry_scope.InitAssemblies();
unit_name = null; cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddName(str, dc.visitor.entry_scope);
}
}
else
{
//unit_name = FindPCUFileName(str);
unit_name = pcu_unit_name;
if (unit_name != null) if (unit_name != null)
{ {
DomConverter dc = CodeCompletionController.comp_modules[unit_name] as DomConverter; IntellisensePCUReader pcu_rdr = new IntellisensePCUReader();
if (dc == null /*|| CodeCompletionController.recomp_files[unit_name] != null*/) SymScope ss = pcu_rdr.GetUnit(unit_name);
{ UnitDocCache.Load(ss, unit_name);
dc = new CodeCompletionController().CompileAllIfNeed(unit_name, true); cur_scope.AddUsedUnit(ss);
} cur_scope.AddName(str, ss);
if (dc.visitor != null)
{
dc.visitor.entry_scope.InitAssemblies();
cur_scope.AddUsedUnit(dc.visitor.entry_scope);
cur_scope.AddName(str, dc.visitor.entry_scope);
}
} }
else else
{ {
//unit_name = FindPCUFileName(str); if (PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str))
unit_name = pcu_unit_name;
if (unit_name != null)
{ {
IntellisensePCUReader pcu_rdr = new IntellisensePCUReader(); ns_scope = new NamespaceScope(str);
SymScope ss = pcu_rdr.GetUnit(unit_name); cur_scope.AddName(str, ns_scope);
UnitDocCache.Load(ss, unit_name); if (s.name.idents.Count == 1)
cur_scope.AddUsedUnit(ss); cur_scope.AddUsedUnit(ns_scope);
cur_scope.AddName(str, ss); }
else if (PascalABCCompiler.NetHelper.NetHelper.IsType(str) && semantic_options.allow_import_types)
{
Type t = PascalABCCompiler.NetHelper.NetHelper.FindType(str);
cur_scope.AddUsedUnit(new NamespaceTypeScope(TypeTable.get_compiled_type(new SymInfo(t.Name, SymbolKind.Class, t.FullName), t)));
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
//unit_name = System.IO.Path.GetDirectoryName(_program_module.file_name)+"\\"+str+System.IO.Path.GetExtension(_program_module.file_name);
} }
catch (Exception e) }
{ catch (Exception e)
{
#if DEBUG #if DEBUG
File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine); File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
#endif #endif
}
} }
} }
if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/) if (i == s.name.idents.Count - 1 && i > 0 /*&& PascalABCCompiler.NetHelper.NetHelper.IsNetNamespace(str)*/)

View file

@ -0,0 +1,11 @@
uses Timers{@unit Timers@},
GraphABC{@unit GraphABC@},
Graph3D{@unit Graph3D@},
GraphWPF{@unit GraphWPF@},
NumLibABC{@unit NumLibABC@},
PT4{@unit PT4@},
ABCObjects{@unit ABCObjects@},
Drawman{@unit Drawman@};
begin
end.