本文整理汇总了C#中CompilationUnit.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# CompilationUnit.Parse方法的具体用法?C# CompilationUnit.Parse怎么用?C# CompilationUnit.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompilationUnit
的用法示例。
在下文中一共展示了CompilationUnit.Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateParser
public void UpdateParser(System.Object obj)
{
string text = editor.doc.GetRawText();
if (!Directory.Exists(Path.GetDirectoryName(tmpFileName))) {
Directory.CreateDirectory(Path.GetDirectoryName(tmpFileName));
}
try {
System.IO.StreamWriter fileStream = new System.IO.StreamWriter(tmpFileName);
fileStream.Write(text);
fileStream.Close();
}
catch (System.Exception) {
}
CompilationUnit project = new CompilationUnit("");
project.AddFile(tmpFileName);
try {
project.Parse();
}
catch (System.Exception) {
}
errors = new List<ErrorDef>();
foreach (Error error in project.Errors) {
if(error.Code != "SYNERR") continue;
ErrorDef def = new ErrorDef();
def.line = error.Line-1;
def.column = error.Column-1;
def.description = error.Description;
def.type = ErrorType.Error;
errors.Add(def);
if (def.description == "scolon expected") {
def.description = "';' expected.";
}
if (def.description == "lbrace expected") {
def.description = "'{' expected.";
}
if (def.description == "rbrace expected") {
def.description = "'}' expected.";
}
}
wantsParserUpdate = false;
}