/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="fileId">The id of the file.</param> /// <param name="methods">The methods.</param> private static void SetCodeElements(CodeFile codeFile, string fileId, IEnumerable <XElement> methods) { foreach (var method in methods) { string methodName = ExtractMethodName(method.Parent.Attribute("Name").Value, method.Attribute("Name").Value); if (Regex.IsMatch(methodName, LambdaMethodRegex)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_") || methodName.StartsWith("set_")) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var statement = method .Elements("Statement") .FirstOrDefault(); if (statement != null && statement.Attribute("FileIndex").Value == fileId) { int line = int.Parse(statement.Attribute("Line").Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { string methodName = method.Attribute("name").Value; if (lambdaMethodNameRegex.IsMatch(methodName)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var lineNumbers = method .Elements("statement") .Select(l => int.Parse(l.Attribute("line").Value, CultureInfo.InvariantCulture)) .ToArray(); if (lineNumbers.Length > 0) { codeFile.AddCodeElement(new CodeElement(methodName, type, lineNumbers.Min(), lineNumbers.Max())); } } }
/// <summary> /// Initializes a new instance of the <see cref="CodeElement" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The <see cref="Analysis.CodeElementType"/>.</param> /// <param name="firstLine">The number of the first line.</param> /// <param name="lastLine">The number of the last line.</param> internal CodeElement(string name, CodeElementType type, int firstLine, int lastLine) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.CodeElementType = type; this.FirstLine = firstLine; this.LastLine = lastLine; }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfClass">The methods of the class.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfClass) { foreach (var method in methodsOfClass) { string methodName = method.Attribute("name").Value; if (Regex.IsMatch(methodName, LambdaMethodRegex)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_") || methodName.StartsWith("set_")) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnt = method .Elements("seqpnt") .FirstOrDefault(); if (seqpnt != null && seqpnt.Attribute("document").Value.Equals(codeFile.Path)) { int line = int.Parse(seqpnt.Attribute("line").Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { if (lambdaMethodNameRegex.IsMatch(method.Element("MethodName").Value)) { continue; } string methodName = ExtractMethodName(method.Element("MethodName").Value, method.Element("MethodKeyName").Value); CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnts = method .Elements("Lines") .Select(l => new { LineNumberStart = int.Parse(l.Element("LnStart").Value, CultureInfo.InvariantCulture), LineNumberEnd = int.Parse(l.Element("LnEnd").Value, CultureInfo.InvariantCulture) }) .ToArray(); if (seqpnts.Length > 0) { codeFile.AddCodeElement(new CodeElement(methodName, type, seqpnts.Min(s => s.LineNumberStart), seqpnts.Max(s => s.LineNumberEnd))); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { if (Regex.IsMatch(method.Element("MethodName").Value, LambdaMethodRegex)) { continue; } string methodName = ExtractMethodName(method.Element("MethodName").Value, method.Element("MethodKeyName").Value); CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_") || methodName.StartsWith("set_")) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnt = method .Elements("Lines") .Elements("LnStart") .FirstOrDefault(); if (seqpnt != null) { int line = int.Parse(seqpnt.Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="fileId">The id of the file.</param> /// <param name="methods">The methods.</param> private static void SetCodeElements(CodeFile codeFile, string fileId, IEnumerable <XElement> methods) { foreach (var method in methods) { if (Regex.IsMatch(method.Attribute("name").Value, LambdaMethodRegex)) { continue; } string sig = method.Attribute("sig").Value; string methodName = method.Attribute("name").Value + sig.Substring(sig.LastIndexOf('(')); CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnt = method .Elements("pt") .Where(pt => pt.HasAttributeWithValue("fid", fileId)) .FirstOrDefault(); if (seqpnt != null) { int line = int.Parse(seqpnt.Attribute("sl").Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { string methodName = method.Attribute("name").Value; if (Regex.IsMatch(methodName, LambdaMethodRegex)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var firstLine = method .Elements("statement") .FirstOrDefault(); if (firstLine != null) { int line = int.Parse(firstLine.Attribute("line").Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { if (method.Attribute("skippedDueTo") != null || Regex.IsMatch(method.Element("Name").Value, LambdaMethodRegex)) { continue; } string methodName = ExtractMethodName(method.Element("Name").Value); methodName = methodName.Substring(methodName.LastIndexOf(':') + 1); CodeElementType type = CodeElementType.Method; if (method.HasAttributeWithValue("isGetter", "true") || method.HasAttributeWithValue("isSetter", "true")) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnt = method .Elements("SequencePoints") .Elements("SequencePoint") .FirstOrDefault(); if (seqpnt != null) { int line = int.Parse(seqpnt.Attribute("sl").Value, CultureInfo.InvariantCulture); codeFile.AddCodeElement(new CodeElement(methodName, type, line)); } } }
public void InitializeContent(CodeElementType ElementType) { RefreshModules(); RefreshModuleHosts(); RefreshUProjects(); TaskData = null; AddCodeElement_ViewModel view_model = null; switch (ElementType) { case CodeElementType.Type: TaskData = new AddTypeTask(); view_model = new AddType_ViewModel(TaskData as AddTypeTask); break; case CodeElementType.Source: TaskData = new AddSourceFileTask(); view_model = new AddCodeElement_ViewModel(TaskData); break; case CodeElementType.Module: TaskData = new AddModuleTask(); view_model = new AddModule_ViewModel(TaskData as AddModuleTask); break; case CodeElementType.Plugin: TaskData = new AddPluginTask(); view_model = new AddCodeElement_ViewModel(TaskData); break; } TaskData.ElementType = ElementType; TaskData.PropertyChanged += OnModelChanged; ElementTypeBox.DataContext = view_model; // @NOTE: Setting this also sets the DataContext to the same object AddElementPresenter.Content = view_model; // @TODO: Don't understand why, but if leaving the template selector applied in the xaml to choose the template, // then we can't access the instantiated template here (nor by explicitly calling ApplyTemplate, or delaying until later). var selector = new CodeElementTypeTemplateSelector(); AddElementPresenter.ContentTemplate = selector.SelectTemplate(view_model, AddElementPresenter); AddElementPresenter.ApplyTemplate(); var name_text_box = AddElementPresenter.ContentTemplate.FindName("ElementNameBox", AddElementPresenter) as FrameworkElement; if (name_text_box != null) { name_text_box.Focus(); } // AddBtn.DataContext = TaskData; AddFinishBtn.DataContext = TaskData; this.ContentUpdated?.Invoke(this, new EventArgs()); }
public ReflectionHelper Property(string propertyName) { _propertyInfo = FindProperty(_target.GetType(), propertyName); if (_propertyInfo == null) throw new NullReferenceException(String.Format("Sorry, There is no such property = {0} in class type {1}", propertyName, _target.GetType().FullName)); _lastSelectedElementType = CodeElementType.Property; return this; }
public ReflectionHelper Field(string fieldName) { _fieldInfo = FindField(_target.GetType(), fieldName); if (_fieldInfo == null) throw new NullReferenceException(String.Format("Sorry, There is no such field = {0} in class type {1}", fieldName, _target.GetType().FullName)); _lastSelectedElementType = CodeElementType.Field; return this; }
/// <summary> /// Initializes a new instance of the <see cref="CodeElement" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The <see cref="Analysis.CodeElementType"/>.</param> /// <param name="line">The line number.</param> internal CodeElement(string name, CodeElementType type, int line) { if (name == null) { throw new ArgumentNullException(nameof(name)); } this.Name = name; this.CodeElementType = type; this.Line = line; }
/// <summary> /// Initializes a new instance of the <see cref="CodeElement" /> class. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The <see cref="Analysis.CodeElementType"/>.</param> /// <param name="firstLine">The number of the first line.</param> /// <param name="lastLine">The number of the last line.</param> /// <param name="coverageQuota">The coverage quota.</param> internal CodeElement(string name, CodeElementType type, int firstLine, int lastLine, decimal?coverageQuota) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.CodeElementType = type; this.FirstLine = firstLine; this.LastLine = lastLine; if (coverageQuota.HasValue) { this.CoverageQuota = Math.Min(100, Math.Max(0, coverageQuota.Value)); } }
public ReflectionHelper Property(string propertyName) { _propertyInfo = FindProperty(_target.GetType(), propertyName); if (_propertyInfo == null) { throw new NullReferenceException(String.Format("Sorry, There is no such property = {0} in class type {1}", propertyName, _target.GetType().FullName)); } _lastSelectedElementType = CodeElementType.Property; return(this); }
public ReflectionHelper Field(string fieldName) { _fieldInfo = FindField(_target.GetType(), fieldName); if (_fieldInfo == null) { throw new NullReferenceException(String.Format("Sorry, There is no such field = {0} in class type {1}", fieldName, _target.GetType().FullName)); } _lastSelectedElementType = CodeElementType.Field; return(this); }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { if (method.Attribute("skippedDueTo") != null || lambdaMethodNameRegex.IsMatch(method.Element("Name").Value)) { continue; } string methodName = ExtractMethodName(method.Element("Name").Value); methodName = methodName.Substring(methodName.LastIndexOf(':') + 1); CodeElementType type = CodeElementType.Method; if (method.HasAttributeWithValue("isGetter", "true") || method.HasAttributeWithValue("isSetter", "true")) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnts = method .Elements("SequencePoints") .Elements("SequencePoint") .Select(seqpnt => new { LineNumberStart = int.Parse(seqpnt.Attribute("sl").Value, CultureInfo.InvariantCulture), LineNumberEnd = seqpnt.Attribute("el") != null ? int.Parse(seqpnt.Attribute("el").Value, CultureInfo.InvariantCulture) : int.Parse(seqpnt.Attribute("sl").Value, CultureInfo.InvariantCulture) }) .ToArray(); if (seqpnts.Length > 0) { int firstLine = seqpnts.Min(s => s.LineNumberStart); int lastLine = seqpnts.Max(s => s.LineNumberEnd); codeFile.AddCodeElement(new CodeElement( methodName, type, firstLine, lastLine, codeFile.CoverageQuota(firstLine, lastLine))); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfFile">The methods of the file.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfFile) { foreach (var method in methodsOfFile) { if (lambdaMethodNameRegex.IsMatch(method.Attribute("name").Value)) { continue; } string methodName = ExtractMethodName(method.Attribute("name").Value, method.Attribute("type_name").Value); CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnts = method .Elements("ranges") .Elements("range") .Where(l => l.Attribute("start_line").Value != "15732480") .Select(l => new { LineNumberStart = int.Parse(l.Attribute("start_line").Value, CultureInfo.InvariantCulture), LineNumberEnd = int.Parse(l.Attribute("end_line").Value, CultureInfo.InvariantCulture) }) .ToArray(); if (seqpnts.Length > 0) { int firstLine = seqpnts.Min(s => s.LineNumberStart); int lastLine = seqpnts.Max(s => s.LineNumberEnd); codeFile.AddCodeElement(new CodeElement( methodName, type, firstLine, lastLine, codeFile.CoverageQuota(firstLine, lastLine))); } } }
public string GetCodeElementTypeTemplate(CodeType codeType, CodeElementType codeElementType) { Dictionary <CodeElementType, string> templates; if (!codeTemplates.TryGetValue(codeType, out templates)) { throw new NotSupportedException(messageManager.GetMessage("CurrentCodeTypeIsNotSupported")); } string template; if (!templates.TryGetValue(codeElementType, out template)) { throw new NotSupportedException(messageManager.GetMessage("CurrentCodeElementTypeIsNotSupported")); } return(template); }
public string GetCodeElementTypeTemplate(CodeType codeType, CodeElementType codeElementType) { Dictionary <CodeElementType, string> templates; if (!codeTemplates.TryGetValue(codeType, out templates)) { throw new NotSupportedException("Current code type is not supported"); } string template; if (!templates.TryGetValue(codeElementType, out template)) { throw new NotSupportedException("Current code element type is not supported"); } return(template); }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="methodsOfClass">The methods of the class.</param> private static void SetCodeElements(CodeFile codeFile, IEnumerable <XElement> methodsOfClass) { foreach (var method in methodsOfClass) { string methodName = method.Attribute("name").Value; if (lambdaMethodNameRegex.IsMatch(methodName)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnts = method .Elements("seqpnt") .Where(seqpnt => seqpnt.Attribute("document").Value.Equals(codeFile.Path) && seqpnt.Attribute("line").Value != "16707566") .Select(seqpnt => new { LineNumberStart = int.Parse(seqpnt.Attribute("line").Value, CultureInfo.InvariantCulture), LineNumberEnd = int.Parse(seqpnt.Attribute("endline").Value, CultureInfo.InvariantCulture) }) .ToArray(); if (seqpnts.Length > 0) { int firstLine = seqpnts.Min(s => s.LineNumberStart); int lastLine = seqpnts.Max(s => s.LineNumberEnd); codeFile.AddCodeElement(new CodeElement( methodName, type, firstLine, lastLine, codeFile.CoverageQuota(firstLine, lastLine))); } } }
/// <summary> /// Extracts the methods/properties of the given <see cref="XElement">XElements</see>. /// </summary> /// <param name="codeFile">The code file.</param> /// <param name="fileId">The id of the file.</param> /// <param name="methods">The methods.</param> private static void SetCodeElements(CodeFile codeFile, string fileId, IEnumerable <XElement> methods) { foreach (var method in methods) { string methodName = ExtractMethodName(method.Parent.Attribute("Name").Value, method.Attribute("Name").Value); if (lambdaMethodNameRegex.IsMatch(methodName)) { continue; } CodeElementType type = CodeElementType.Method; if (methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase) || methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase)) { type = CodeElementType.Property; methodName = methodName.Substring(4); } var seqpnts = method .Elements("Statement") .Where(c => c.Attribute("FileIndex").Value == fileId) .Select(c => new { LineNumberStart = int.Parse(c.Attribute("Line").Value, CultureInfo.InvariantCulture), LineNumberEnd = int.Parse(c.Attribute("EndLine").Value, CultureInfo.InvariantCulture) }) .ToArray(); if (seqpnts.Length > 0) { int firstLine = seqpnts.Min(s => s.LineNumberStart); int lastLine = seqpnts.Max(s => s.LineNumberEnd); codeFile.AddCodeElement(new CodeElement( methodName, type, seqpnts.Min(s => s.LineNumberStart), seqpnts.Max(s => s.LineNumberEnd), codeFile.CoverageQuota(firstLine, lastLine))); } } }
protected PerformStatement(CodeElementType codeElementType, StatementType statementType) : base(codeElementType, statementType) { }
public AbstractArithmeticStatement(CodeElementType ce, StatementType statement) : base(ce, statement) { }
public CodeInfo CreateCodeItemInfo(MethodInfo methodInformation, string fileName, CodeType codeType, CodeElementType codeElementType, bool useVSFormatting) { string serverMethodFolderPath = projectManager.ServerMethodFolderPath; string selectedFolderPath = projectManager.SelectedFolderPath; string methodName = projectManager.MethodName; string codeItemPath = selectedFolderPath.Substring(serverMethodFolderPath.IndexOf(serverMethodFolderPath) + serverMethodFolderPath.Length); codeItemPath = Path.Combine(codeItemPath, fileName); string codeItemAttributePath = codeItemPath.Substring(codeItemPath.IndexOf(methodName) + methodName.Length + 1); codeItemAttributePath = codeItemAttributePath.Replace("\\", "/"); var templateLoader = new TemplateLoader(this.dialogFactory); templateLoader.Load(projectManager.MethodConfigPath); TemplateInfo template = null; template = templateLoader.Templates.Where(t => t.TemplateLanguage == methodInformation.MethodLanguage && t.TemplateName == methodInformation.TemplateName).FirstOrDefault(); if (template == null) { template = templateLoader.Templates.Where(t => t.TemplateLanguage == methodInformation.MethodLanguage && t.IsSupported).FirstOrDefault(); } if (template == null) { throw new Exception("Template not found."); } EventSpecificDataType eventData = CommonData.EventSpecificDataTypeList.First(x => x.EventSpecificData == methodInformation.EventData); GeneratedCodeInfo codeInfo = this.CreateWrapper(template, eventData, methodName, useVSFormatting); string methodCode = File.ReadAllText(projectManager.MethodPath, new UTF8Encoding(true)); var tree = CSharpSyntaxTree.ParseText(methodCode); var root = tree.GetRoot(); var referenceUsings = string.Empty; var mainUsingDirectiveSyntaxes = root.DescendantNodes().OfType <UsingDirectiveSyntax>(); referenceUsings = string.Join("\r\n", mainUsingDirectiveSyntaxes); if (!string.IsNullOrEmpty(referenceUsings)) { referenceUsings += "\r\n"; } string codeItemTemplate = this.codeItemProvider.GetCodeElementTypeTemplate(codeType, codeElementType); string code = string.Format(codeItemTemplate, referenceUsings, codeInfo.MethodCodeParentClassName, codeItemAttributePath, codeInfo.Namespace, fileName); var codeItemInfo = new CodeInfo() { Path = codeItemPath, Code = useVSFormatting ? FormattingCode(code) : code }; return(codeItemInfo); }
public CodeInfo CreateExternalCodeItemInfo(MethodInfo methodInformation, string fileName, CodeElementType codeElementType, bool useVSFormatting, string methodFolderPath, string selectedFolderPath, string methodName, TemplateLoader templateLoader, string MethodPath) { throw new NotImplementedException(); }
public StatementElement(CodeElementType codeElementType, StatementType statementType) : base(codeElementType) { StatementType = statementType; }
protected CodeElement(CodeElementType type) { Type = type; ConsumedTokens = new List <Token>(); SymbolInformationForTokens = new Dictionary <Token, SymbolInformation>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="version">The version of this Code article (e.g. "4.3" or "API" or "Latest").</param> /// <param name="fullUniqueName">The full name of the code article (e.g. "Code:FACT_DLL").</param> /// <param name="elementType">The element type of the code article (e.g. Namespace, Class or Member).</param> public BaseCodeArticle(string version, string fullUniqueName, CodeElementType elementType) : base(version + ":" + fullUniqueName, ArticleType.Code) { this.m_Version = version; this.m_ElementType = elementType; this.m_Children = new List<BaseCodeArticle>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="fullUniqueNameWithVersion">The full name of the code article, including version (e.g. "Code:4.5:FACT_DLL").</param> /// <param name="elementType">The element type of the code article (e.g. Namespace, Class or Member).</param> public BaseCodeArticle(string fullUniqueNameWithVersion, CodeElementType elementType) : base(fullUniqueNameWithVersion, ArticleType.Code) { this.m_Version = Tools.GetFirstColonSuffix(fullUniqueNameWithVersion); this.m_ElementType = elementType; this.m_Children = new List<BaseCodeArticle>(); }
/// <summary> /// Gets a list of all the code articles of a given element type (e.g. Namespace, Class or Member). /// Code articles are not fetched from DB but from flat files that must be looked-up via an index file. /// </summary> /// <param name="version">The specific version of the Code articles to get.</param> /// <param name="elementTypeFilter">The specific element type of Code articles to get.</param> /// <returns>A list of all the code articles of a certain element type (e.g. Namespace, Class or Member).</returns> public static List<BaseCodeArticle> GetCodeArticles(string version, CodeElementType elementTypeFilter) { // Get the input directory and the index file used to match the article titles to their file names. string codeArticlesDirectory = Path.Combine(ConfigurationManager.AppSettings["codeArticlesDirectory"].ToString(), version); string indexFilePath = Path.Combine(codeArticlesDirectory, INDEX_FILE_NAME); List<BaseCodeArticle> codeArticles = new List<BaseCodeArticle>(); StreamReader indexFile = new StreamReader(indexFilePath); while (!indexFile.EndOfStream) { // Not EOF => We can read at least once more. string line = indexFile.ReadLine(); // Each line of the index file is composed of 3 parts separated by tabs. string[] lineParts = line.Split(new char[] { '\t' }); // The type of the code element (i.e. Namespace, Class or Member). string elementTypeValue = lineParts[0]; // The full unique name of the code element. This part is used to find the matching article title. string elementFullName = lineParts[1]; // The name of the file where the content of the wiki text lies. string wikiFileName = lineParts[2] + CODE_ARTICLE_FILE_EXTENSION; CodeElementType elementType; if (!string.IsNullOrEmpty(elementTypeValue) && Enum.IsDefined(typeof(CodeElementType), elementTypeValue)) elementType = (CodeElementType)Enum.Parse(typeof(CodeElementType), elementTypeValue); else throw new NotSupportedException("The provided code element type is invalid: " + elementTypeValue); // Note that several Code element types are Members (i.e. Fields, Constructor, Property, Method and Event). if (elementType == elementTypeFilter || (elementTypeFilter == CodeElementType.Member && (elementType == CodeElementType.Field || elementType == CodeElementType.Constructor || elementType == CodeElementType.Property || elementType == CodeElementType.Method || elementType == CodeElementType.Event))) { BaseCodeArticle codeArticle = new BaseCodeArticle(version, elementFullName, elementType); codeArticles.Add(codeArticle); } } return codeArticles; }
protected NamedCodeElement(CodeElementType type) : base(type) { }
protected DataSectionHeader(CodeElementType type) : base(type) { }
public NamedCodeElement(CodeElementType type) : base(type) { }
protected AbstractArithmeticStatement(CodeElementType ce, StatementType statement) : base(ce, statement) { }
public CodeElement(CodeElementType type) { Type = type; SymbolInformationForTokens = new Dictionary<Token, SymbolInformation>(); Diagnostics = new List<Diagnostic>(); }
protected StatementElement(CodeElementType codeElementType, StatementType statementType) : base(codeElementType) { StatementType = statementType; }
private static IToken BuildCodeElementFromType(CodeElementType type, Token lastTokenBeforeError, string informationText) { CodeElement codeElement = null; switch (type) { case CodeElementType.ProgramIdentification: codeElement = new ProgramIdentification(); break; case CodeElementType.ProgramEnd: codeElement = new ProgramEnd(); break; case CodeElementType.ClassIdentification: codeElement = new ClassIdentification(); break; case CodeElementType.ClassEnd: codeElement = new ClassEnd(); break; case CodeElementType.FactoryIdentification: codeElement = new FactoryIdentification(); break; case CodeElementType.FactoryEnd: codeElement = new FactoryEnd(); break; case CodeElementType.ObjectIdentification: codeElement = new ObjectIdentification(); break; case CodeElementType.ObjectEnd: codeElement = new ObjectEnd(); break; case CodeElementType.MethodIdentification: codeElement = new MethodIdentification(); break; case CodeElementType.MethodEnd: codeElement = new MethodEnd(); break; case CodeElementType.EnvironmentDivisionHeader: codeElement = new EnvironmentDivisionHeader(); break; case CodeElementType.DataDivisionHeader: codeElement = new DataDivisionHeader(); break; case CodeElementType.ProcedureDivisionHeader: codeElement = new ProcedureDivisionHeader(); break; case CodeElementType.DeclarativesHeader: codeElement = new DeclarativesHeader(); break; case CodeElementType.DeclarativesEnd: codeElement = new DeclarativesEnd(); break; case CodeElementType.SectionHeader: codeElement = new SectionHeader(); break; case CodeElementType.ConfigurationSectionHeader: codeElement = new ConfigurationSectionHeader(); break; case CodeElementType.InputOutputSectionHeader: codeElement = new InputOutputSectionHeader(); break; case CodeElementType.FileSectionHeader: codeElement = new FileSectionHeader(); break; case CodeElementType.WorkingStorageSectionHeader: codeElement = new WorkingStorageSectionHeader(); break; case CodeElementType.LocalStorageSectionHeader: codeElement = new LocalStorageSectionHeader(); break; case CodeElementType.LinkageSectionHeader: codeElement = new LinkageSectionHeader(); break; case CodeElementType.ParagraphHeader: codeElement = new ParagraphHeader(); break; case CodeElementType.FileControlParagraphHeader: codeElement = new FileControlParagraphHeader(); break; case CodeElementType.IOControlParagraphHeader: codeElement = new IOControlParagraphHeader(); break; case CodeElementType.SentenceEnd: codeElement = new SentenceEnd(); break; case CodeElementType.FileDescriptionEntry: codeElement = new FileDescriptionEntry(); break; case CodeElementType.DataDescriptionEntry: codeElement = new DataDescriptionEntry(); break; case CodeElementType.DataRedefinesEntry: codeElement = new DataRedefinesEntry(); break; case CodeElementType.DataRenamesEntry: codeElement = new DataRenamesEntry(); break; case CodeElementType.DataConditionEntry: codeElement = new DataConditionEntry(); break; case CodeElementType.FileControlEntry: codeElement = new FileControlEntry(); break; case CodeElementType.IOControlEntry: codeElement = new RerunIOControlEntry(); break; case CodeElementType.SourceComputerParagraph: codeElement = new SourceComputerParagraph(); break; case CodeElementType.ObjectComputerParagraph: codeElement = new ObjectComputerParagraph(); break; case CodeElementType.SpecialNamesParagraph: codeElement = new SpecialNamesParagraph(); break; case CodeElementType.RepositoryParagraph: codeElement = new RepositoryParagraph(); break; case CodeElementType.AcceptStatement: codeElement = new AcceptFromInputDeviceStatement(); break; case CodeElementType.AddStatement: codeElement = new AddSimpleStatement(); break; case CodeElementType.AlterStatement: codeElement = new AlterStatement(); break; case CodeElementType.CallStatement: codeElement = new CallStatement(); break; case CodeElementType.CancelStatement: codeElement = new CancelStatement(); break; case CodeElementType.CloseStatement: codeElement = new CloseStatement(); break; case CodeElementType.ComputeStatement: codeElement = new ComputeStatement(); break; case CodeElementType.ContinueStatement: codeElement = new ContinueStatement(); break; case CodeElementType.DeleteStatement: codeElement = new DeleteStatement(); break; case CodeElementType.DisplayStatement: codeElement = new DisplayStatement(); break; case CodeElementType.DivideStatement: codeElement = new DivideSimpleStatement(); break; case CodeElementType.EntryStatement: codeElement = new EntryStatement(); break; case CodeElementType.EvaluateStatement: codeElement = new EvaluateStatement(); break; case CodeElementType.ExecStatement: codeElement = new ExecStatement(); break; case CodeElementType.ExitMethodStatement: codeElement = new ExitMethodStatement(); break; case CodeElementType.ExitProgramStatement: codeElement = new ExitProgramStatement(); break; case CodeElementType.ExitStatement: codeElement = new ExitStatement(); break; case CodeElementType.GobackStatement: codeElement = new GobackStatement(); break; case CodeElementType.GotoStatement: codeElement = new GotoSimpleStatement(); break; case CodeElementType.IfStatement: codeElement = new IfStatement(); break; case CodeElementType.InitializeStatement: codeElement = new InitializeStatement(); break; case CodeElementType.InspectStatement: codeElement = new InspectTallyingStatement(); break; case CodeElementType.InvokeStatement: codeElement = new InvokeStatement(); break; case CodeElementType.MergeStatement: codeElement = new MergeStatement(); break; case CodeElementType.MoveStatement: codeElement = new MoveSimpleStatement(null, null, null); break; case CodeElementType.MultiplyStatement: codeElement = new MultiplySimpleStatement(); break; case CodeElementType.NextSentenceStatement: codeElement = new NextSentenceStatement(); break; case CodeElementType.OpenStatement: codeElement = new OpenStatement(); break; case CodeElementType.PerformProcedureStatement: codeElement = new PerformProcedureStatement(); break; case CodeElementType.PerformStatement: codeElement = new PerformStatement(); break; case CodeElementType.ReadStatement: codeElement = new ReadStatement(); break; case CodeElementType.ReleaseStatement: codeElement = new ReleaseStatement(); break; case CodeElementType.ReturnStatement: codeElement = new ReturnStatement(); break; case CodeElementType.RewriteStatement: codeElement = new RewriteStatement(); break; case CodeElementType.SearchStatement: codeElement = new SearchSerialStatement(); break; case CodeElementType.SetStatement: codeElement = new SetStatementForAssignment(); break; case CodeElementType.SortStatement: codeElement = new SortStatement(); break; case CodeElementType.StartStatement: codeElement = new StartStatement(); break; case CodeElementType.StopStatement: codeElement = new StopStatement(); break; case CodeElementType.StringStatement: codeElement = new StringStatement(); break; case CodeElementType.SubtractStatement: codeElement = new SubtractSimpleStatement(); break; case CodeElementType.UnstringStatement: codeElement = new UnstringStatement(); break; case CodeElementType.UseStatement: codeElement = new UseAfterIOExceptionStatement(); break; case CodeElementType.WriteStatement: codeElement = new WriteStatement(); break; case CodeElementType.XmlGenerateStatement: codeElement = new XmlGenerateStatement(); break; case CodeElementType.XmlParseStatement: codeElement = new XmlParseStatement(); break; case CodeElementType.AtEndCondition: codeElement = new AtEndCondition(); break; case CodeElementType.NotAtEndCondition: codeElement = new NotAtEndCondition(); break; case CodeElementType.AtEndOfPageCondition: codeElement = new AtEndOfPageCondition(); break; case CodeElementType.NotAtEndOfPageCondition: codeElement = new NotAtEndOfPageCondition(); break; case CodeElementType.OnExceptionCondition: codeElement = new OnExceptionCondition(); break; case CodeElementType.NotOnExceptionCondition: codeElement = new NotOnExceptionCondition(); break; case CodeElementType.OnOverflowCondition: codeElement = new OnOverflowCondition(); break; case CodeElementType.NotOnOverflowCondition: codeElement = new NotOnOverflowCondition(); break; case CodeElementType.InvalidKeyCondition: codeElement = new InvalidKeyCondition(); break; case CodeElementType.NotInvalidKeyCondition: codeElement = new NotInvalidKeyCondition(); break; case CodeElementType.OnSizeErrorCondition: codeElement = new OnSizeErrorCondition(); break; case CodeElementType.NotOnSizeErrorCondition: codeElement = new NotOnSizeErrorCondition(); break; case CodeElementType.ElseCondition: codeElement = new ElseCondition(); break; case CodeElementType.WhenCondition: codeElement = new WhenCondition(); break; case CodeElementType.WhenOtherCondition: codeElement = new WhenOtherCondition(); break; case CodeElementType.WhenSearchCondition: codeElement = new WhenSearchCondition(); break; case CodeElementType.AddStatementEnd: codeElement = new AddStatementEnd(); break; case CodeElementType.CallStatementEnd: codeElement = new CallStatementEnd(); break; case CodeElementType.ComputeStatementEnd: codeElement = new ComputeStatementEnd(); break; case CodeElementType.DeleteStatementEnd: codeElement = new DeleteStatementEnd(); break; case CodeElementType.DivideStatementEnd: codeElement = new DivideStatementEnd(); break; case CodeElementType.EvaluateStatementEnd: codeElement = new EvaluateStatementEnd(); break; case CodeElementType.IfStatementEnd: codeElement = new IfStatementEnd(); break; case CodeElementType.InvokeStatementEnd: codeElement = new InvokeStatementEnd(); break; case CodeElementType.MultiplyStatementEnd: codeElement = new MultiplyStatementEnd(); break; case CodeElementType.PerformStatementEnd: codeElement = new PerformStatementEnd(); break; case CodeElementType.ReadStatementEnd: codeElement = new ReadStatementEnd(); break; case CodeElementType.ReturnStatementEnd: codeElement = new ReturnStatementEnd(); break; case CodeElementType.RewriteStatementEnd: codeElement = new RewriteStatementEnd(); break; case CodeElementType.SearchStatementEnd: codeElement = new SearchStatementEnd(); break; case CodeElementType.StartStatementEnd: codeElement = new StartStatementEnd(); break; case CodeElementType.StringStatementEnd: codeElement = new StringStatementEnd(); break; case CodeElementType.SubtractStatementEnd: codeElement = new SubtractStatementEnd(); break; case CodeElementType.UnstringStatementEnd: codeElement = new UnstringStatementEnd(); break; case CodeElementType.WriteStatementEnd: codeElement = new WriteStatementEnd(); break; case CodeElementType.XmlStatementEnd: codeElement = new XmlStatementEnd(); break; case CodeElementType.LibraryCopy: codeElement = new LibraryCopyCodeElement(); break; case CodeElementType.FunctionDeclarationHeader: codeElement = new FunctionDeclarationHeader(null, AccessModifier.Private, FunctionType.Undefined); break; case CodeElementType.FunctionDeclarationEnd: codeElement = new FunctionDeclarationEnd(); break; default: throw new NotImplementedException(); } if (lastTokenBeforeError != null) { var missingToken = new MissingToken(TokenType.InvalidToken, informationText, lastTokenBeforeError.TokensLine, lastTokenBeforeError.StopIndex); codeElement.ConsumedTokens.Add(missingToken); } return(codeElement); }
public DataDefinitionEntry(CodeElementType codeElementType) : base(codeElementType) { }
public CodeInfo CreateCodeItemInfo(MethodInfo methodInfo, string fileName, CodeType codeType, CodeElementType codeElementType, bool isUseVSFormattingCode) { throw new NotImplementedException(); }
public DataSectionHeader(CodeElementType type) : base(type) { }