Убраны лишние пробелы при генерации CodeTemplates

StructuredObjectToString - правильный вывод Dictionary
This commit is contained in:
Mikhalkovich Stanislav 2020-01-03 11:03:46 +03:00
parent 87124bcf59
commit ba6ac20ec9
6 changed files with 48 additions and 14 deletions

View file

@ -1,9 +1,9 @@
//
// This CSharp output file generated by Gardens Point LEX
// Version: 1.1.3.301
// Machine: DESKTOP-P4NLNB1
// DateTime: 12/30/2019 12:27:08 PM
// UserName: fatco
// Machine: DESKTOP-G8V08V4
// DateTime: 01.01.2020 22:55:53
// UserName: ?????????
// GPLEX input file <ABCPascal.lex>
// GPLEX frame file <embedded resource>
//

View file

@ -1,9 +1,9 @@
// (see accompanying GPPGcopyright.rtf)
// GPPG version 1.3.6
// Machine: DESKTOP-P4NLNB1
// DateTime: 12/30/2019 12:27:10 PM
// UserName: fatco
// Machine: DESKTOP-G8V08V4
// DateTime: 01.01.2020 22:55:53
// UserName: ?????????
// Input file <ABCPascal.y>
// options: no-lines gplex

View file

@ -1,16 +1,18 @@
lex=ABCPascal.lex
yacc=ABCPascal.y
lexGen=H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\Gplex.exe
yaccGen=H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gppg.exe
lexGen=D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\Gplex.exe
yaccGen=D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gppg.exe
lexGenOpt=/unicode
yaccGenOpt=/gplex
useCustomScript
script=
"H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gplex.exe" /unicode "H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.lex"
"D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gplex.exe" /unicode "D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.lex"
"D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gppg.exe" /no-lines /gplex "D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y"
"D:\PABC_Git\Parsers\PascalABCParserNewSaushkin\convert4.exe"
"H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\GPLex_GPPG\gppg.exe" /no-lines /gplex "H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\ABCPascal.y"
"H:\PascalABC.NET\!PABC_Git\Parsers\PascalABCParserNewSaushkin\convert4.exe"

View file

@ -356,6 +356,14 @@ namespace VisualPascalABC
StringBuilder sb = new StringBuilder();
IDocument doc = textArea.Document;
if (textArea.SelectionManager.HasSomethingSelected) // удаление выделенного
{
var isel = textArea.SelectionManager.SelectionCollection[0];
textArea.Caret.Line = isel.StartPosition.Line;
textArea.Caret.Column = isel.StartPosition.Column;
textArea.SelectionManager.RemoveSelectedText();
}
int line = textArea.Caret.Line;
int col = textArea.Caret.Column;
string name = templateManager.GetTemplateHeader(pattern);

View file

@ -11,6 +11,7 @@ using System.Windows.Forms;
using VisualPascalABC;
using System.Text.RegularExpressions;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor;
namespace CodeTemplatesPlugin
{
@ -133,13 +134,20 @@ namespace CodeTemplatesPlugin
if (m.Groups[1].Value.Length > 0)
{
var Curr = GetLine(ta.Caret.Line);
if (Curr.Length < m.Groups[1].Index)
if (Curr.Length > m.Groups[1].Index)
{
ta.Caret.Column = Curr.Length;
ta.InsertString(new string(' ', m.Groups[1].Index - Curr.Length));
ta.InsertString(new string(' ', Curr.Length - m.Groups[1].Index));
}
ta.Caret.Column = m.Groups[1].Index;
var doc = ta.Document;
var tl_beg = new TextLocation(ta.Caret.Column, ta.Caret.Line);
int offset = doc.PositionToOffset(tl_beg);
if (Curr.Length > ta.Caret.Column && Curr.Substring(ta.Caret.Column).TrimEnd().Length == 0)
doc.Remove(offset, Curr.Length - ta.Caret.Column);
}
}
var Next = GetNextLine(ta.Caret.Line);

View file

@ -1995,33 +1995,40 @@ function KV<TKey, TVal>(key: TKey; value: TVal): KeyValuePair<TKey, TVal>;
//>> Вспомогательные функции для pattern matching #
// -----------------------------------------------------
///--
function __TypeCheckAndAssignForIsMatch<T>(obj: object; var res: T): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4>(
first: Tuple<T1, T2>;
second: Tuple<T3, T4>;
elemsToCompare: sequence of integer): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6>(
first: Tuple<T1, T2, T3>;
second: Tuple<T4, T5, T6>;
elemsToCompare: sequence of integer): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6, T7, T8>(
first: Tuple<T1, T2, T3, T4>;
second: Tuple<T5, T6, T7, T8>;
elemsToCompare: sequence of integer): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
first: Tuple<T1, T2, T3, T4, T5>;
second: Tuple<T6, T7, T8, T9, T10>;
elemsToCompare: sequence of integer): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
first: Tuple<T1, T2, T3, T4, T5, T6>;
second: Tuple<T7, T8, T9, T10, T11, T12>;
elemsToCompare: sequence of integer): boolean;
///--
function __WildCardsTupleEqual<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
first: Tuple<T1, T2, T3, T4, T5, T6, T7>;
second: Tuple<T8, T9, T10, T11, T12, T13, T14>;
@ -3497,7 +3504,16 @@ begin
var sb := new StringBuilder();
var g := (o as System.Collections.IEnumerable).GetEnumerator();
var isdictorset := o.GetType.Name.Equals('Dictionary`2') or o.GetType.Name.Equals('SortedDictionary`2') or (o.GetType = typeof(TypedSet)) or o.GetType.Name.Equals('HashSet`1') or o.GetType.Name.Equals('SortedSet`1');
var otype := o.GetType;
//var isdictorset := otype.Name.Equals('Dictionary`2') or otype.Name.Equals('SortedDictionary`2') or otype.Name.Equals('HashSet`1') or otype.Name.Equals('SortedSet`1');
var isdictorset := o.GetType.IsGenericType and
((otype.GetGenericTypeDefinition = typeof(Dictionary<,>))
or (otype.GetGenericTypeDefinition = typeof(SortedDictionary<,>))
or (otype.GetGenericTypeDefinition = typeof(HashSet<>))
or (otype.GetGenericTypeDefinition = typeof(SortedSet<>)));
isdictorset := isdictorset or (otype = typeof(TypedSet));
if isdictorset then
sb.Append('{')
else sb.Append('[');