* 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
193 lines
8.1 KiB
C#
193 lines
8.1 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.Generic;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using ICSharpCode.TextEditor;
|
|
using ICSharpCode.TextEditor.Document;
|
|
using ICSharpCode.TextEditor.Gui.CompletionWindow;
|
|
using PascalABCCompiler.Parsers;
|
|
|
|
namespace VisualPascalABC
|
|
{
|
|
public class TooltipServiceManager
|
|
{
|
|
static DeclarationViewWindow dvw;
|
|
|
|
private static string GetPopupHintText(TextArea textArea, ToolTipRequestEventArgs e)
|
|
{
|
|
TextLocation logicPos = e.LogicalPosition;
|
|
IDocument doc = textArea.Document;
|
|
LineSegment lineSegment = doc.GetLineSegment(logicPos.Y);
|
|
|
|
string fileName = textArea.MotherTextEditorControl.FileName;
|
|
|
|
if (logicPos.X > lineSegment.Length - 1)
|
|
return null;
|
|
|
|
//string expr = FindFullExpression(doc.TextContent, seg.Offset + logicPos.X,e.LogicalPosition.Line,e.LogicalPosition.Column);
|
|
|
|
IParser parser = CodeCompletion.CodeCompletionController.CurrentParser;
|
|
|
|
string expr = parser.LanguageInformation.FindExpressionFromAnyPosition(
|
|
lineSegment.Offset + logicPos.X, doc.TextContent, e.LogicalPosition.Line, e.LogicalPosition.Column, out var keyw, out var exprWithoutBrackets);
|
|
|
|
// пока непонятно, когда такое может быть EVA
|
|
if (expr == null)
|
|
expr = exprWithoutBrackets;
|
|
|
|
if (expr == null)
|
|
return null;
|
|
|
|
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
|
|
List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>();
|
|
|
|
PascalABCCompiler.SyntaxTree.expression expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName),
|
|
expr, Errors, Warnings);
|
|
|
|
// Пока добавили проверку, что анализируем Паскаль EVA
|
|
if (Errors.Count > 0 && parser == Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(PascalABCCompiler.StringConstants.pascalLanguageName).Parser)
|
|
{
|
|
string s = expr.TrimStart();
|
|
if (s.Length > 0 && s[0] == '^')
|
|
{
|
|
Errors.Clear();
|
|
exprWithoutBrackets = exprWithoutBrackets.TrimStart().Substring(1);
|
|
expressionTree = parser.GetExpression("test" + Path.GetExtension(fileName), s.Substring(1), Errors, Warnings);
|
|
}
|
|
}
|
|
|
|
List<PascalABCCompiler.Errors.Error> Errors2 = new List<PascalABCCompiler.Errors.Error>();
|
|
|
|
// проверка для выражения без скобок
|
|
PascalABCCompiler.SyntaxTree.expression expressionTree2 = parser.GetExpression("test" + Path.GetExtension(fileName), exprWithoutBrackets, Errors2, Warnings);
|
|
|
|
// если не получается, то сразу возврат
|
|
if (expressionTree2 == null || Errors2.Count > 0)
|
|
return null;
|
|
|
|
bool header = false;
|
|
if (expressionTree == null || Errors.Count > 0)
|
|
{
|
|
header = true;
|
|
expressionTree = expressionTree2;
|
|
}
|
|
|
|
CodeCompletion.DomConverter domConverter = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[fileName];
|
|
|
|
if (domConverter == null) return null;
|
|
|
|
return domConverter.GetDescription(expressionTree, fileName, exprWithoutBrackets, e.LogicalPosition.Line, e.LogicalPosition.Column, keyw, header);
|
|
}
|
|
|
|
static int _mouse_hint_x = 0, _mouse_hint_y = 0;
|
|
static int _hint_hide_d = 0;
|
|
static bool toolTipVisible = false;
|
|
|
|
public static void ToolTipService_TextAreaMouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
//System.IO.File.AppendAllText("d:\\logP.txt", "TextAreaMouseMove" + $" {toolTipVisible} {DateTime.Now}\n");
|
|
if (toolTipVisible)
|
|
{
|
|
if (Math.Sqrt((_mouse_hint_x - e.X) * (_mouse_hint_x - e.X) + (_mouse_hint_y - e.Y) * (_mouse_hint_y - e.Y)) > _hint_hide_d)
|
|
hideToolTip();
|
|
}
|
|
}
|
|
|
|
public static void ToolTipService_TextAreaKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
VisualPABCSingleton.MainForm.MenuActive = false;
|
|
//VisualPABCSingleton.MainForm.Text = "MenuActive = " + false.ToString();
|
|
hideToolTip();
|
|
}
|
|
|
|
public static void ToolTipService_TextAreaMouseEvent_HideToolTip(object sender, MouseEventArgs e)
|
|
{
|
|
VisualPABCSingleton.MainForm.MenuActive = false;
|
|
//VisualPABCSingleton.MainForm.Text = "MenuActive = " + false.ToString();
|
|
hideToolTip();
|
|
}
|
|
|
|
public static void hideToolTip()
|
|
{
|
|
if (dvw != null)
|
|
{
|
|
dvw.Description = null;
|
|
toolTipVisible = false;
|
|
}
|
|
}
|
|
|
|
public static void ToolTipService_TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e)
|
|
{
|
|
if (!VisualPABCSingleton.MainForm.UserOptions.CodeCompletionHint)
|
|
return;
|
|
if (CodeCompletion.CodeCompletionController.CurrentParser == null)
|
|
return;
|
|
try
|
|
{
|
|
TextArea textArea = sender as TextArea;
|
|
if (dvw != null && dvw.Description != null)
|
|
{
|
|
hideToolTip();
|
|
return;
|
|
}
|
|
if (e.ToolTipShown && dvw != null)
|
|
{
|
|
hideToolTip();
|
|
return;
|
|
}
|
|
if (e.InDocument)
|
|
{
|
|
|
|
if (dvw == null)
|
|
{
|
|
dvw = new DeclarationWindow(VisualPABCSingleton.MainForm);
|
|
dvw.Font = new System.Drawing.Font(Constants.CompletionWindowDeclarationViewWindowFontName, dvw.Font.Size);
|
|
dvw.HideOnClick = true;
|
|
|
|
//dvw.ShowDeclarationViewWindow();
|
|
}
|
|
dvw.TextEditorControl = textArea.MotherTextEditorControl;
|
|
int ypos = (textArea.Document.GetVisibleLine(e.LogicalPosition.Y) + 1) * textArea.TextView.FontHeight - textArea.VirtualTop.Y;
|
|
System.Drawing.Point p = new System.Drawing.Point(0, ypos);
|
|
p = textArea.PointToScreen(p);
|
|
p.X = Control.MousePosition.X + 3;
|
|
p.Y += 5;
|
|
string txt = GetPopupHintText(textArea, e);
|
|
dvw.Location = choose_location(p, txt);
|
|
if (!VisualPABCSingleton.MainForm.MenuActive)
|
|
{
|
|
//dvw.ShowInTaskbar = false;
|
|
dvw.Description = txt;
|
|
}
|
|
_hint_hide_d = dvw.Font.Height / 2;
|
|
_mouse_hint_x = e.MousePosition.X;
|
|
_mouse_hint_y = e.MousePosition.Y;
|
|
toolTipVisible = true;
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
//VisualPABCSingleton.MainForm.WriteToOutputBox(ex.Message);// ICSharpCode.Core.MessageService.ShowError(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
private static System.Drawing.Point choose_location(System.Drawing.Point p, string desc)
|
|
{
|
|
Graphics g = Graphics.FromHwnd(dvw.Handle);
|
|
Size sz = Size.Ceiling(g.MeasureString(desc, dvw.Font, Screen.PrimaryScreen.WorkingArea.Width));
|
|
if (p.X + sz.Width > Screen.PrimaryScreen.WorkingArea.Width)
|
|
{
|
|
p.X -= sz.Width - Screen.PrimaryScreen.WorkingArea.Width + p.X;
|
|
}
|
|
return p;
|
|
}
|
|
}
|
|
}
|