Permalink
Browse files

Добавлено предупреждение: Использование нелокальной переменной в каче…

…стве счетчика цикла
  • Loading branch information...
1 parent 6b52b13 commit 003c3c9983ca096d78799343318e9fdfad9605df @ibond84 ibond84 committed Sep 15, 2016
@@ -68,24 +68,24 @@ public static IParser CurrentParser
}
}
- internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List<Error> ErrorsList)
+ internal compilation_unit ParsersControllerGetCompilationUnit(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings)
{
string ext = Path.GetExtension(FileName);
Parser = ParsersController.selectParser(ext.ToLower());
parsers[ext] = Parser;
compilation_unit cu = null;
- cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList);
+ cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings);
//ParsersController.GetExpression("test.pas", "a+b", new List<PascalABCCompiler.Errors.Error>());
return cu;
}
- internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List<Error> ErrorsList)
+ internal compilation_unit ParsersControllerGetCompilationUnitSpecial(string FileName, string Text, List<Error> ErrorsList, List<CompilerWarning> Warnings)
{
string ext = Path.GetExtension(FileName);
Parser = ParsersController.selectParser(ext.ToLower());
parsers[ext] = Parser;
compilation_unit cu = null;
- cu = ParsersController.GetCompilationUnitSpecial(FileName, Text, ErrorsList);
+ cu = ParsersController.GetCompilationUnitSpecial(FileName, Text, ErrorsList, Warnings);
//ParsersController.GetExpression("test.pas","a+b",new List<PascalABCCompiler.Errors.Error>());
return cu;
}
@@ -95,13 +95,14 @@ 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);
+ cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
ErrorsList.Clear();
- PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text/*+")))));end."*/, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text/*+")))));end."*/, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
if (cu != null)
docs = docconst.Construct(cu, dt);
@@ -120,22 +121,23 @@ public DomConverter Compile(string FileName, string Text)
else
{
ErrorsList.Clear();
+ Warnings.Clear();
try
{
//cu = ParsersController.GetComilationUnit(FileName, Text+")))));end.",comp.CompilerOptions.ParserSearchPatchs,ErrorsList);
//cu = ParsersControllerGetComilationUnit(FileName, get_temp_text(Text), ErrorsList, true);
string tmp = ParsersHelper.GetModifiedProgramm(Text);
if (tmp != null)
{
- cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList);
+ cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
}
if (comp_modules[FileName] == null)
{
if (cu == null)
cu = get_fictive_unit(Text, FileName);
}
ErrorsList.Clear();
- PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
if (cu != null)
docs = docconst.Construct(cu, dt);
@@ -188,7 +190,8 @@ private compilation_unit get_fictive_unit(string s, string FileName)
public PascalABCCompiler.SyntaxTree.compilation_unit ParseOnlySyntaxTree(string FileName, string Text)
{
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
- PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList);
+ List<CompilerWarning> Warnings = new List<CompilerWarning>();
+ PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersControllerGetCompilationUnit(FileName, Text, ErrorsList, Warnings);
return cu;
}
@@ -200,11 +203,11 @@ public DomConverter CompileAllIfNeed(string FileName, string Text)
this.FileName = FileName;
string ext = Path.GetExtension(FileName);
List<PascalABCCompiler.Errors.Error> ErrorsList = new List<PascalABCCompiler.Errors.Error>();
-
- PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList);
+ List<CompilerWarning> Warnings = new List<CompilerWarning>();
+ PascalABCCompiler.SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings);
Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower());
ErrorsList.Clear();
- PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
if (cu != null)
docs = docconst.Construct(cu, dt);
@@ -218,20 +221,22 @@ public DomConverter CompileAllIfNeed(string FileName, string Text)
else
{
ErrorsList.Clear();
+ Warnings.Clear();
//cu = ParsersControllerGetComilationUnit(FileName, Text, ErrorsList, true);
if (comp_modules[FileName] == null)
{
string tmp = ParsersHelper.GetModifiedProgramm(Text);
if (tmp != null)
{
- cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList);
+ cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
ErrorsList.Clear();
}
if (cu == null)
cu = get_fictive_unit(Text, FileName);
}
ErrorsList.Clear();
- dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ Warnings.Clear();
+ dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text + ")))));end.", ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
//PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
if (cu != null)
docs = docconst.Construct(cu, dt);
@@ -258,14 +263,16 @@ public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface=
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;
if (Text != null)
{
- cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList);
+ cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings);
}
Parser = ParsersController.selectParser(Path.GetExtension(FileName).ToLower());
ErrorsList.Clear();
- PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ Warnings.Clear();
+ PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
if (cu != null)
docs = docconst.Construct(cu, dt);
@@ -280,20 +287,22 @@ public DomConverter CompileAllIfNeed(string FileName, bool parse_only_interface=
else
{
ErrorsList.Clear();
+ Warnings.Clear();
//cu = ParsersControllerGetComilationUnit(FileName, Text, ErrorsList, true);
if (comp_modules[FileName] == null)
{
string tmp = ParsersHelper.GetModifiedProgramm(Text);
if (tmp != null)
{
- cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList);
+ cu = ParsersControllerGetCompilationUnitSpecial(FileName, tmp, ErrorsList, Warnings);
ErrorsList.Clear();
}
if (cu == null)
cu = get_fictive_unit(Text, FileName);
}
ErrorsList.Clear();
- dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ Warnings.Clear();
+ dt = ParsersController.Compile(System.IO.Path.ChangeExtension(FileName, get_doctagsParserExtension(ext)), Text, ErrorsList, Warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
if (cu != null)
docs = docconst.Construct(cu, dt);
if (CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(FileName, CodeCompletionController.currentLanguageISO) != null)
@@ -885,7 +885,8 @@ public string GetDescription(expression expr, string FileName, string expr_witho
if (!header && ss.IsInScope(ss.head_loc,line+1,col+1))
{
List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
- expr = parser.GetExpression("test"+Path.GetExtension(FileName), expr_without_brackets, Errors);
+ List<PascalABCCompiler.Errors.CompilerWarning> Warnings = new List<PascalABCCompiler.Errors.CompilerWarning>();
+ expr = parser.GetExpression("test"+Path.GetExtension(FileName), expr_without_brackets, Errors, Warnings);
if (expr == null || Errors.Count > 0)
return null;
}
@@ -106,7 +106,8 @@ public static string GetDescription(int pos, string content, int line, int col,
if (expr == null)
expr = expr_without_brackets;
var errors = new List<PascalABCCompiler.Errors.Error>();
- var tree = controller.GetExpression("test" + Path.GetExtension(FileName), expr, errors);
+ var warnings = new List<CompilerWarning>();
+ var tree = controller.GetExpression("test" + Path.GetExtension(FileName), expr, errors, warnings);
var desc = dc.GetDescription(tree, FileName, expr_without_brackets, controller, line, col, keyw, false);
return desc;
}
@@ -769,7 +770,8 @@ public static void Test()
{
string Text = new StreamReader(s,System.Text.Encoding.GetEncoding(1251)).ReadToEnd();
List<Error> Errors = new List<Error>();
- compilation_unit cu = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(s, Text, Errors);
+ List<CompilerWarning> Warnings = new List<CompilerWarning>();
+ compilation_unit cu = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(s, Text, Errors, Warnings);
if (Errors.Count == 0)
{
CodeFormatters.CodeFormatter cf = new CodeFormatters.CodeFormatter(2);
@@ -778,7 +780,8 @@ public static void Test()
sw.Write(Text);
sw.Close();
Errors.Clear();
- compilation_unit cu2 = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(Path.Combine(test_dir + @"\output", Path.GetFileName(s)), Text, Errors);
+ Warnings.Clear();
+ compilation_unit cu2 = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(Path.Combine(test_dir + @"\output", Path.GetFileName(s)), Text, Errors, Warnings);
if (Errors.Count > 0)
{
for (int i = 0; i < Errors.Count; i++)
@@ -800,7 +803,8 @@ public static void Test()
{
string Text = new StreamReader(s, System.Text.Encoding.GetEncoding(1251)).ReadToEnd();
List<Error> Errors = new List<Error>();
- compilation_unit cu = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(s, Text, Errors);
+ List<CompilerWarning> Warnings = new List<CompilerWarning>();
+ compilation_unit cu = CodeCompletionController.ParsersController.GetCompilationUnitForFormatter(s, Text, Errors, Warnings);
CodeFormatters.CodeFormatter cf = new CodeFormatters.CodeFormatter(2);
string Text2 = cf.FormatTree(Text, cu, 1, 1);
if (Text != Text2)
View
@@ -2751,19 +2751,19 @@ public string GetSourceFileText(string FileName)
}
- public SyntaxTree.compilation_unit ParseText(string FileName, string Text, List<Error> ErrorList)
+ public SyntaxTree.compilation_unit ParseText(string FileName, string Text, List<Error> ErrorList, List<CompilerWarning> Warnings)
{
Reset();
OnChangeCompilerState(this, CompilerState.CompilationStarting, FileName);
- SyntaxTree.compilation_unit cu = InternalParseText(FileName, Text, ErrorsList);
+ SyntaxTree.compilation_unit cu = InternalParseText(FileName, Text, ErrorsList, Warnings);
OnChangeCompilerState(this, CompilerState.Ready, FileName);
return cu;
}
- private SyntaxTree.compilation_unit InternalParseText(string FileName, string Text, List<Error> ErrorList, List<string> DefinesList = null)
+ private SyntaxTree.compilation_unit InternalParseText(string FileName, string Text, List<Error> ErrorList, List<CompilerWarning> Warnings, List<string> DefinesList = null)
{
OnChangeCompilerState(this, CompilerState.BeginParsingFile, FileName);
- SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, DefinesList);
+ SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, DefinesList);
OnChangeCompilerState(this, CompilerState.EndParsingFile, FileName);
//Вычисляем сколько строк скомпилировали
if (ErrorList.Count == 0 && cu != null && cu.source_context!=null)
@@ -2915,7 +2915,7 @@ public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_l
DefinesList.Add("RELEASE");
else
DefinesList.Add("DEBUG");
- CurrentUnit.SyntaxTree = InternalParseText(UnitName, SourceText, errorsList, DefinesList);
+ CurrentUnit.SyntaxTree = InternalParseText(UnitName, SourceText, errorsList, warnings, DefinesList);
if (errorsList.Count == 0) // SSM 2/05/16 - для преобразования синтаксических деревьев извне
{
@@ -3179,8 +3179,9 @@ public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_l
private Dictionary<SyntaxTree.syntax_tree_node,string> AddDocumentationToNodes(SyntaxTree.compilation_unit cu, string Text)
{
List<PascalABCCompiler.Errors.Error> errors = new List<PascalABCCompiler.Errors.Error>();
+ List<PascalABCCompiler.Errors.CompilerWarning> warnings = new List<CompilerWarning>();
string doctagsParserExtension = Path.GetExtension(cu.file_name)+"dt"+PascalABCCompiler.Parsers.Controller.HideParserExtensionPostfixChar;
- PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(cu.file_name, doctagsParserExtension), Text, errors, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
+ PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(cu.file_name, doctagsParserExtension), Text, errors, warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list;
if (errors.Count > 0) return null;
PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor();
return docconst.Construct(cu, dt);
@@ -107,7 +107,7 @@ SourceFilesProviderDelegate SourceFilesProvider
void AddWarnings(List<CompilerWarning> WarningList);
- SyntaxTree.compilation_unit ParseText(string FileName, string Text, List<Error> ErrorList);
+ SyntaxTree.compilation_unit ParseText(string FileName, string Text, List<Error> ErrorList, List<CompilerWarning> Warnings);
string GetSourceFileText(string FileName);
Oops, something went wrong.

0 comments on commit 003c3c9

Please sign in to comment.