diff --git a/CodeCompletion/CodeCompletion.cs b/CodeCompletion/CodeCompletion.cs index 7cb998949..eddaf7c63 100644 --- a/CodeCompletion/CodeCompletion.cs +++ b/CodeCompletion/CodeCompletion.cs @@ -350,6 +350,15 @@ namespace CodeCompletion return PascalABCCompiler.Parsers.KeywordKind.None; } + public bool IsKeyword(string name) + { + if (CodeCompletionController.CurrentParser != null) + { + return CodeCompletionController.CurrentParser.LanguageInformation.IsKeyword(name); + } + return false; + } + public string[] GetKeywords() { if (CodeCompletionController.CurrentParser != null) diff --git a/ParserTools/ParserTools/DefaultLanguageInformation.cs b/ParserTools/ParserTools/DefaultLanguageInformation.cs index 2a86b3516..7e3bda409 100644 --- a/ParserTools/ParserTools/DefaultLanguageInformation.cs +++ b/ParserTools/ParserTools/DefaultLanguageInformation.cs @@ -137,6 +137,11 @@ namespace PascalABCCompiler.Parsers keywords.Values.CopyTo(keywords_array, 2); type_keywords_array = type_keys.ToArray(); } + + public bool IsKeyword(string value) + { + return keywords.ContainsKey(value.ToLower()); + } public virtual string BodyStartBracket { @@ -3691,7 +3696,7 @@ namespace PascalABCCompiler.Parsers i++; if (i < Text.Length && Text[i] != ' ' && !char.IsControl(Text[i])) { - while (i < Text.Length && (Char.IsLetterOrDigit(Text[i]) || Text[i] == '_')) + while (i < Text.Length && (Char.IsLetterOrDigit(Text[i]) || Text[i] == '_' || Text[i] == '&')) { sb.Append(Text[i]);//.Append(Text[i]); i++; diff --git a/ParserTools/ParserTools/LanguageInformation.cs b/ParserTools/ParserTools/LanguageInformation.cs index 74c4091a6..d3a5c5ad8 100644 --- a/ParserTools/ParserTools/LanguageInformation.cs +++ b/ParserTools/ParserTools/LanguageInformation.cs @@ -130,6 +130,7 @@ namespace PascalABCCompiler.Parsers string SkipNew(int off, string Text, ref KeywordKind keyw); //char GetParameterDelimiter(); string GetCompiledTypeRepresentation(Type t, System.Reflection.MemberInfo mi, ref int line, ref int col); + bool IsKeyword(string value); string[] Keywords { get; diff --git a/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionActions.cs b/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionActions.cs index fce47fa40..64e79aa3f 100644 --- a/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionActions.cs +++ b/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionActions.cs @@ -37,6 +37,8 @@ namespace VisualPascalABC int addit = 0; PascalABCCompiler.SourceLocation tmp = new PascalABCCompiler.SourceLocation(null, 0, 0, 0, 0); string file_name = null; + if (CodeCompletion.CodeCompletionNameHelper.Helper.IsKeyword(new_val)) + new_val = "&" + new_val; foreach (SymbolsViewerSymbol svs in refers) { if (svs.SourceLocation.BeginPosition.Line != tmp.BeginPosition.Line) @@ -54,6 +56,7 @@ namespace VisualPascalABC TextLocation tl_beg = new TextLocation(svs.SourceLocation.BeginPosition.Column - 1 + addit, svs.SourceLocation.BeginPosition.Line - 1); //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column); int offset = doc.PositionToOffset(tl_beg); + addit += new_val.Length - name.Length; doc.Replace(offset, name.Length, new_val); doc.CommitUpdate(); diff --git a/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionProvider.cs b/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionProvider.cs index 0cb280dea..3fec12767 100644 --- a/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionProvider.cs +++ b/VisualPascalABCNET/IB/CodeCompletion/CodeCompletionProvider.cs @@ -211,11 +211,12 @@ namespace VisualPascalABC rf = new RenameForm(); Form1StringResources.SetTextForAllControls(rf); } - rf.EditValue = name.Trim(' '); + rf.EditValue = name.Trim(' ').Replace("&", ""); DialogResult dr = rf.ShowDialog(); if (dr == DialogResult.OK) { new_val = rf.EditValue; + List refers = FindReferences(expr, fileName, line, column, true); if (refers == null) return null; return refers;