* Refactor keywords managing to avoid repeating them twice * Fix build error * Fix string comparisons and null reference exception * Manage references in PascalABCLanguageInfo project * Fix inaccuracy in BaseKeywords.cs * Move ValidDirectives field to ILanguageInformation * Basic refactoring of GetPopupHintText + delete ampersend inserting * Delete other cases of ampersend inserting * Add check that we parsing PascalABC.NET in GetPopupHintText Временное решение, нужно будет вынести вторую попытку в интерфейс парсера. * Refactor CodeCompletionProvider (first iteration) * Extract shift space actions in separate class * Replace dollar service character in CodeCompletion by separate boolean (ctrlSpaceAfterDot)) * Refactor GetCompletionDataByFirst method * Fix GetCompletionDataByFirst behaviour when getting symInfos after uses keyword * Another iteration of refactoring in CodeCompletionProvider + comments * Update intellisense documentation * Fix build error * Fix encoding * Squashed commit of the following: commit7751fe7e75Author: samuraiGH <87191377+samuraiGH@users.noreply.github.com> Date: Sun Mar 16 13:28:03 2025 +0300 generating language res file at build time (#3252) commitd1fce63d69Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Mar 4 08:38:09 2025 +0300 Сборка после pr SDK commitd491e88aa7Author: samuraiGH <87191377+samuraiGH@users.noreply.github.com> Date: Mon Mar 3 20:34:51 2025 +0300 migration to new build system (#3241) * converting project files into sdk style * new build commands * adding new dll into nsis * removing unused .cs files commit1fd348ec3cAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sun Feb 23 20:49:26 2025 +0300 NSIS New 3.10 Ярлык в меню Пуск у всех пользователей commit80b7182dc1Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Feb 19 11:50:00 2025 +0300 _ in names commita2b078960bAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Feb 19 10:52:25 2025 +0300 cnfc2 commit58f26d469dAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Feb 18 22:28:13 2025 +0300 перекомпиляция 3.10.3.3611 commitb78a72977fAuthor: nevermind322 <81963698+nevermind322@users.noreply.github.com> Date: Tue Feb 18 22:02:19 2025 +0300 fix build on mono (#3249) * fix build on mono * remove local func * fix again commitc3557e388cAuthor: Nikolay Kuznetsov <adasoft@gmail.com> Date: Sat Feb 15 20:32:46 2025 +0300 Update GraphABC.pas (#3244) 1. Быстрая реализация функции FloodFill Для этого добавлена процедура BitmapFloodFill, которая вызывается из метода Picture.FloodFill и процедуры FloodFill 2.Добавлена поддержка LockDrawing/UnlockDrawing в процедуру FloodFill commit9dbac389e1Author: AlexanderZemlyak <92867056+AlexanderZemlyak@users.noreply.github.com> Date: Wed Feb 12 13:57:14 2025 +0300 Add missing projects to pabcnetc.sln (#3247) commit41dfb6f187Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Fri Feb 7 21:41:01 2025 +0300 [] - преобразование во все контейнеры GraphABCHelper - теперь ABCObjects работает под Линукс School исправлен согласно последним веяниям [] commit79bbbd10ffAuthor: samuraiGH <87191377+samuraiGH@users.noreply.github.com> Date: Wed Jan 29 20:18:37 2025 +0300 removing files for support fx4.0 (#3240) commit88d5c409ebAuthor: samuraiGH <87191377+samuraiGH@users.noreply.github.com> Date: Tue Jan 28 20:41:55 2025 +0300 Рефакторинг PascalABCNET.xshd (#3237) * refactoring PascalABCNET.xshd * removing extra characters commit8fbd7fdfc3Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sun Jan 26 23:42:48 2025 +0300 3.10.3 faststrings EmptyCollection и преобразование ее в List, Dictionary t: (real,real) := (1,2) commitbba132bd5dAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Jan 22 09:14:44 2025 +0300 Поправил справку по функции commit1bd21857ccAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Jan 8 18:46:51 2025 +0300 Teacher Control Plugin - возможность задать server.dat commit0848a1b796Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Jan 4 22:54:38 2025 +0300 Исправление автоформатирования [] commitd45b782a7bAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Jan 4 18:45:07 2025 +0300 Rename PABCSistem in test suite commitc2347e604bAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Jan 4 14:44:51 2025 +0300 Примеры - устранил неточности LightPT - имя сервера вынес в публичную секцию commitb68b8da970Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Dec 17 15:52:18 2024 +0300 Примеры Coords1.pas Coords2.pas.pas commit8a9788e6f9Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Dec 17 15:06:57 2024 +0300 Перенес проверку set array на уровень парсера Немного поправил Intellisense по наведению для NewSet По точке там что то другое работает commit874ddebad3Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Dec 14 21:00:38 2024 +0300 Поправил грамматику [] Теперь нельзя в режиме ## использовать атрибуты Зато можно [1,2,3].Print commit080fb487e1Merge:a53dcd9eda484b0e82Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Dec 14 15:25:24 2024 +0300 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet commita53dcd9ed2Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Dec 14 15:25:16 2024 +0300 SF Prm Cmb для строк commita484b0e82dAuthor: Sun Serega <sunserega2@gmail.com> Date: Thu Dec 12 13:49:17 2024 +0200 fix (#3231) commit6ef11f249cAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Dec 10 11:05:45 2024 +0300 3.10.2 commitdb9679d89fAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Dec 10 10:59:20 2024 +0300 Закончил превращение синтаксиса [] по умолчанию в массивы commit45fdde24b4Author: Ivan Bondarev <ibond84@googlemail.com> Date: Sun Dec 8 18:08:00 2024 +0100 #3229 commit494b47624dMerge:5875b99297906d73daAuthor: Ivan Bondarev <ibond84@googlemail.com> Date: Sun Dec 8 10:42:07 2024 +0100 Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet commit5875b99296Author: Ivan Bondarev <ibond84@googlemail.com> Date: Sun Dec 8 10:41:53 2024 +0100 platformtarget native - .NET 9.0 commit7906d73da3Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Dec 3 14:25:37 2024 +0300 Небольшие изменения в реализации операций с множествами commit087591c7b6Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Nov 27 11:37:07 2024 +0300 3.10.1 Coords - доработки Distance, Middle, DrawText с фоном и рамкой. Глобальные переменные настройки commitd268d4f83bAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Thu Nov 21 22:24:07 2024 +0300 NSToBytes переделал с исключением commit2bacdc8c28Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Nov 20 13:20:33 2024 +0300 Комментарии к NewSet commite917ac8ecaAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Nov 20 12:42:15 2024 +0300 TypeName для set commit206289c6a7Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Nov 19 20:23:03 2024 +0300 Везде заменил _hs на hs в NewSet Убрал вызовы методов расширений NewSet в PABCSystem.pas Убрал var в operator + commitd8262078f6Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Tue Nov 19 13:56:47 2024 +0300 Исправление мелких ошибок NewSet Все тесты проходят. Проблема, которая остаётся - в режиме ускорения такие программы падают: begin var s: set of byte; Print(s = [1]); end. Причина - из dll не вызывается конструктор записи без параметров, хотя он определён. В C# вообще у записей не может быть конструктора по умолчанию - наверное потому. Но для NewSet надо бы сделать исключение commitf8819665baAuthor: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Nov 16 10:56:11 2024 +0300 NS2 commit591d9ebe60Author: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Nov 13 21:34:10 2024 +0100 fix commitc6505634f4Author: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Nov 13 21:12:33 2024 +0100 fix commita6564df23cAuthor: Ivan Bondarev <ibond84@googlemail.com> Date: Wed Nov 13 20:52:29 2024 +0100 fix in new sets commit03be5bd931Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Wed Nov 13 22:13:41 2024 +0300 Переставил operator:= в NewSet commit96c68f1666Author: Ivan Bondarev <ibond84@googlemail.com> Date: Tue Nov 12 21:38:07 2024 +0100 #3223 commit82776f3c77Author: Mikhalkovich Stanislav <miks@math.sfedu.ru> Date: Sat Nov 9 12:18:19 2024 +0300 NewSet - много мелких исправлений. Все тесты проходят кроме Tests 5 - видимо с pabcrtl.dll * Update comments in PascalABCLanguageInformation
431 lines
18 KiB
C#
431 lines
18 KiB
C#
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using PascalABCCompiler.SyntaxTree;
|
|
using PascalABCCompiler.Parsers;
|
|
using PascalABCCompiler.Errors;
|
|
using System.IO;
|
|
using PascalABCCompiler;
|
|
using Languages.Facade;
|
|
//using ICSharpCode.SharpDevelop.Dom;
|
|
|
|
namespace CodeCompletion
|
|
{
|
|
public class CodeCompletionController
|
|
{
|
|
public static LanguageProvider LanguageProvider = LanguageProvider.Instance;
|
|
string FileName;
|
|
string Text;
|
|
public Dictionary<PascalABCCompiler.SyntaxTree.syntax_tree_node, string> docs = new Dictionary<PascalABCCompiler.SyntaxTree.syntax_tree_node, string>();
|
|
static bool parsers_loaded=false;
|
|
public IParser Parser;
|
|
|
|
static CodeCompletionController()
|
|
{
|
|
//ParsersController.Reload();
|
|
}
|
|
|
|
|
|
public CodeCompletionController()
|
|
{
|
|
if (!parsers_loaded)
|
|
{
|
|
//ParsersController.Reload();
|
|
parsers_loaded = true;
|
|
}
|
|
//dconv = new DomConverter(this);
|
|
}
|
|
|
|
public static PascalABCCompiler.Compiler comp;// = new PascalABCCompiler.Compiler();
|
|
public static Hashtable StandartDirectories = new Hashtable();
|
|
public static Hashtable comp_modules = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
|
public static Hashtable parsers = new Hashtable(StringComparer.OrdinalIgnoreCase);
|
|
public static Dictionary<string, InterfaceUnitScope> pabcNamespaces = new Dictionary<string, InterfaceUnitScope>();
|
|
|
|
public static string currentLanguageISO;
|
|
//public static PascalABCCompiler.Parsers.IParser currentParser;
|
|
static string cur_ext = ".pas";
|
|
private static IParser currentParser;
|
|
|
|
public static void SetParser(string ext)
|
|
{
|
|
cur_ext = ext;
|
|
currentParser = null;
|
|
}
|
|
|
|
public void ResetNamespaces()
|
|
{
|
|
pabcNamespaces.Clear();
|
|
}
|
|
|
|
// нужно переделать на использование ILanguage EVA
|
|
public static IParser CurrentParser
|
|
{
|
|
get
|
|
{
|
|
if (currentParser == null)
|
|
currentParser = parsers[cur_ext] as IParser;
|
|
return currentParser;
|
|
}
|
|
}
|
|
|
|
internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings)
|
|
{
|
|
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
|
if (language == null)
|
|
return null;
|
|
Parser = language.Parser;
|
|
parsers[Path.GetExtension(FileName)] = Parser;
|
|
compilation_unit cu = null;
|
|
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal);
|
|
//ParsersController.GetExpression("test.pas", "a+b", new List<PascalABCCompiler.Errors.Error>());
|
|
return cu;
|
|
}
|
|
|
|
internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings)
|
|
{
|
|
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
|
if (language == null)
|
|
return null;
|
|
parsers[Path.GetExtension(FileName)] = Parser;
|
|
compilation_unit cu = null;
|
|
cu = Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Special);
|
|
//ParsersController.GetExpression("test.pas","a+b",new List<PascalABCCompiler.Errors.Error>());
|
|
return cu;
|
|
}
|
|
|
|
public DomConverter Compile(string FileName, string Text)
|
|
{
|
|
this.Text = Text;
|
|
this.FileName = FileName;
|
|
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
|
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
|
PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
|
|
string ext = Path.GetExtension(FileName);
|
|
try
|
|
{
|
|
cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
|
|
ErrorsList.Clear();
|
|
documentation_comment_list dt = LanguageProvider.SelectLanguageByExtension(FileName).DocParser.BuildTree(Text);
|
|
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#if DEBUG
|
|
File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
|
|
#endif
|
|
}
|
|
|
|
// очистка кэша и данных от старых компиляций, чтобы при новой компиляции не появились ссылки на старые данные
|
|
TypeTable.Clear();
|
|
|
|
DomConverter dconv = new DomConverter(this);
|
|
if (cu != null)
|
|
{
|
|
PascalABCCompiler.NetHelper.NetHelper.reset();
|
|
|
|
dconv.ConvertToDom(cu);
|
|
}
|
|
else
|
|
{
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
try
|
|
{
|
|
//cu = ParsersController.GetComilationUnit(file_name, Text+")))));end.",comp.CompilerOptions.ParserSearchPatchs,ErrorsList);
|
|
//cu = ParsersControllerGetComilationUnit(file_name, get_temp_text(Text), ErrorsList, true);
|
|
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
|
if (tmp != null)
|
|
{
|
|
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
|
|
}
|
|
if (comp_modules[FileName] == null)
|
|
{
|
|
if (cu == null)
|
|
cu = get_fictive_unit(Text, FileName);
|
|
}
|
|
ErrorsList.Clear();
|
|
documentation_comment_list dt = LanguageProvider.SelectLanguageByExtension(FileName).DocParser.BuildTree(Text);
|
|
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#if DEBUG
|
|
File.AppendAllText("log.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
|
|
#endif
|
|
}
|
|
if (cu != null)
|
|
{
|
|
PascalABCCompiler.NetHelper.NetHelper.reset();
|
|
dconv.ConvertToDom(cu);
|
|
}
|
|
}
|
|
if (docs != null) docs.Clear();
|
|
//if (dconv.is_compiled) comp_modules[file_name]=dconv;
|
|
return dconv;
|
|
//ConvertToDom(cu);
|
|
}
|
|
|
|
//vremenno, potom ubrat
|
|
private compilation_unit get_fictive_unit(string s, string FileName)
|
|
{
|
|
program_module prog = new program_module();
|
|
int line = 1;
|
|
int col = 1;
|
|
for (int i = 0; i < s.Length; i++)
|
|
if (s[i] == '\n')
|
|
{
|
|
line++;
|
|
col = 1;
|
|
}
|
|
else
|
|
{
|
|
col++;
|
|
}
|
|
prog.source_context = new SourceContext(1, 1, line + 3, 3);
|
|
prog.program_block = new block();
|
|
prog.file_name = FileName;
|
|
statement_list sl = new statement_list();
|
|
prog.program_block.program_code = sl;
|
|
prog.program_block.program_code.left_logical_bracket = new token_info("begin");
|
|
prog.program_block.program_code.left_logical_bracket.source_context = new SourceContext(1, 1, 1, 5);
|
|
prog.program_block.program_code.right_logical_bracket = new token_info("end");
|
|
prog.program_block.program_code.right_logical_bracket.source_context = new SourceContext(line + 3, 1, line + 3, 3);
|
|
sl.subnodes.Add(new empty_statement());
|
|
return prog;
|
|
}
|
|
|
|
public PascalABCCompiler.SyntaxTree.compilation_unit ParseOnlySyntaxTree(string FileName, string Text)
|
|
{
|
|
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
|
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
|
PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
|
|
return cu;
|
|
}
|
|
|
|
public DomConverter CompileAllIfNeed(string FileName, string Text)
|
|
{
|
|
DomConverter dconv = (DomConverter)comp_modules[FileName];
|
|
if (dconv != null) return dconv;
|
|
this.Text = Text;
|
|
this.FileName = FileName;
|
|
string ext = Path.GetExtension(FileName);
|
|
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
|
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
|
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
|
if (language == null)
|
|
return dconv;
|
|
Parser = language.Parser;
|
|
compilation_unit cu = language.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal);
|
|
ErrorsList.Clear();
|
|
documentation_comment_list dt = language.DocParser.BuildTree(Text);
|
|
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
dconv = new DomConverter(this);
|
|
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
|
{
|
|
dconv.visitor.add_doc_from_text = false;
|
|
}
|
|
if (cu != null)
|
|
dconv.ConvertToDom(cu);
|
|
else
|
|
{
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
//cu = ParsersControllerGetComilationUnit(file_name, Text, ErrorsList, true);
|
|
if (comp_modules[FileName] == null)
|
|
{
|
|
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
|
if (tmp != null)
|
|
{
|
|
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
|
|
ErrorsList.Clear();
|
|
}
|
|
if (cu == null)
|
|
cu = get_fictive_unit(Text, FileName);
|
|
}
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
dt = language.DocParser.BuildTree(Text);
|
|
//PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
|
{
|
|
dconv.visitor.add_doc_from_text = false;
|
|
}
|
|
if (cu != null)
|
|
{
|
|
dconv.ConvertToDom(cu);
|
|
}
|
|
}
|
|
//comp_modules[file_name] = dconv;
|
|
if (dconv.is_compiled) comp_modules[FileName] = dconv;
|
|
|
|
if (docs != null) docs.Clear();
|
|
//GC.Collect();
|
|
return dconv;
|
|
}
|
|
|
|
public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface=false)
|
|
{
|
|
this.FileName = FileName;
|
|
this.Text = comp.GetSourceFileText(FileName);
|
|
string ext = Path.GetExtension(FileName);
|
|
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
|
|
List<CompilerWarning> Warnings = new List<CompilerWarning>();
|
|
PascalABCCompiler.SyntaxTree.compilation_unit cu = null;
|
|
|
|
DomConverter dconv = new DomConverter(this);
|
|
|
|
ILanguage language = LanguageProvider.SelectLanguageByExtensionSafe(FileName);
|
|
if (language == null)
|
|
return dconv;
|
|
Parser = language.Parser;
|
|
if (Text != null)
|
|
{
|
|
cu = language.Parser.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, ParseMode.Normal);
|
|
}
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
documentation_comment_list dt = language.DocParser.BuildTree(Text);
|
|
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
|
|
dconv.visitor.parse_only_interface = parse_only_interface;
|
|
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
|
{
|
|
dconv.visitor.add_doc_from_text = false;
|
|
}
|
|
if (cu != null)
|
|
dconv.ConvertToDom(cu);
|
|
else
|
|
{
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
//cu = ParsersControllerGetComilationUnit(file_name, Text, ErrorsList, true);
|
|
if (comp_modules[FileName] == null)
|
|
{
|
|
string tmp = ParsersHelper.GetModifiedProgramm(Text);
|
|
if (tmp != null)
|
|
{
|
|
cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
|
|
ErrorsList.Clear();
|
|
}
|
|
if (cu == null)
|
|
cu = get_fictive_unit(Text, FileName);
|
|
}
|
|
ErrorsList.Clear();
|
|
Warnings.Clear();
|
|
dt = language.DocParser.BuildTree(Text);
|
|
if (cu != null)
|
|
docs = docconst.Construct(cu, dt);
|
|
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
|
|
{
|
|
dconv.visitor.add_doc_from_text = false;
|
|
}
|
|
if (cu != null)
|
|
{
|
|
dconv.ConvertToDom(cu);
|
|
}
|
|
}
|
|
if (dconv.is_compiled) comp_modules[FileName] = dconv;
|
|
if (docs != null) docs.Clear();
|
|
//comp_modules[file_name] = dconv;
|
|
// GC.Collect();
|
|
return dconv;
|
|
}
|
|
}
|
|
|
|
public class CodeCompletionNameHelper
|
|
{
|
|
public static readonly string system_unit_file_name = PascalABCCompiler.StringConstants.pascalSystemUnitName;
|
|
public static string system_unit_file_full_name;
|
|
private static CodeCompletionNameHelper helper;
|
|
|
|
private CodeCompletionNameHelper()
|
|
{
|
|
}
|
|
|
|
public PascalABCCompiler.Parsers.KeywordKind GetKeywordKind(string name)
|
|
{
|
|
if (CodeCompletionController.CurrentParser != null)
|
|
return CodeCompletionController.CurrentParser.LanguageInformation.GetKeywordKind(name);
|
|
return PascalABCCompiler.Parsers.KeywordKind.None;
|
|
}
|
|
|
|
public bool IsKeyword(string name)
|
|
{
|
|
if (CodeCompletionController.CurrentParser != null)
|
|
{
|
|
return CodeCompletionController.CurrentParser.LanguageInformation.IsKeyword(name);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public List<string> GetKeywords()
|
|
{
|
|
if (CodeCompletionController.CurrentParser != null)
|
|
return CodeCompletionController.CurrentParser.LanguageInformation.KeywordsStorage.Keywords;
|
|
return new List<string>();
|
|
}
|
|
|
|
public List<string> GetTypeKeywords()
|
|
{
|
|
if (CodeCompletionController.CurrentParser != null)
|
|
return CodeCompletionController.CurrentParser.LanguageInformation.KeywordsStorage.TypeKeywords;
|
|
return new List<string>();
|
|
}
|
|
|
|
const string LibSourceDirectoryIdent = "%LIBSOURCEDIRECTORY%";
|
|
public static string FindSourceFileName(string unit_name, out int found_dir_ind, params string[] ddirs)
|
|
{
|
|
// TODO: check error in older version
|
|
List<string> Dirs = new List<string>();
|
|
Dirs.AddRange(ddirs);
|
|
if (CodeCompletionController.comp != null)
|
|
Dirs.AddRange(CodeCompletionController.comp.CompilerOptions.SearchDirectories);
|
|
if (CodeCompletionController.StandartDirectories.ContainsKey(LibSourceDirectoryIdent))
|
|
Dirs.Add((string)CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]);
|
|
return CodeCompletionController.comp.FindSourceFileNameInDirs(unit_name, out found_dir_ind, Dirs.ToArray());
|
|
}
|
|
|
|
public static CodeCompletionNameHelper Helper
|
|
{
|
|
get
|
|
{
|
|
if (helper == null) helper = new CodeCompletionNameHelper();
|
|
return helper;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ParsersHelper
|
|
{
|
|
string src;
|
|
static StringBuilder sb = new StringBuilder();
|
|
|
|
public static string GetModifiedProgramm(string src)
|
|
{
|
|
sb.Remove(0,sb.Length);
|
|
if (!src.TrimEnd().EndsWith("end."))
|
|
{
|
|
sb.AppendLine(src);
|
|
sb.AppendLine();
|
|
sb.Append("end.");
|
|
return sb.ToString();
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|