internal void ParseSection(Lines lines, ObjectType objectType) { var match = lines.FirstLineMustMatch(Patterns.SectionSignature); var sectionType = match.Groups[1].Value.ToSectionType(); Listener.OnBeginSection(sectionType); lines.FirstLineMustMatch(Patterns.BeginSection); lines.LastLineMustMatch(Patterns.EndSection); lines.Unindent(2); switch (sectionType) { case SectionType.ObjectProperties: ParseObjectPropertiesSection(lines); break; case SectionType.Properties: ParsePropertiesSection(lines); break; case SectionType.Fields: switch (objectType) { case ObjectType.Table: ParseTableFieldsSection(lines); break; case ObjectType.Dataport: ParseDataPortFieldsSection(lines); break; } break; case SectionType.Keys: ParseKeysSection(lines); break; case SectionType.FieldGroups: ParseFieldGroupsSection(lines); break; case SectionType.Controls: switch (objectType) { case ObjectType.Page: ParsePageControlsSection(lines); break; case ObjectType.Form: ParseFormControlsSection(lines); break; case ObjectType.Report: ParseReportControlsSection(lines); break; } break; case SectionType.Elements: switch (objectType) { case ObjectType.Query: ParseQueryElementsSection(lines); break; case ObjectType.XmlPort: ParseXmlPortElementsSection(lines); break; } break; case SectionType.Events: break; case SectionType.Dataset: ParseDatasetSection(lines); break; case SectionType.Labels: ParseLabelsSection(lines); break; case SectionType.RdlData: break; case SectionType.WordLayout: ParseWordLayoutSection(lines); break; case SectionType.Code: ParseCodeSection(lines); break; case SectionType.RequestPage: ParseRequestPageSection(lines, objectType); break; case SectionType.MenuNodes: ParseMenuNodesSection(lines); break; case SectionType.RequestForm: ParseRequestFormSection(lines, objectType); break; case SectionType.DataItems: ParseDataItemsSection(lines, objectType); break; case SectionType.Sections: ParseSectionsSection(lines); break; default: Exceptions.ThrowException(Exceptions.UnknownSectionType, sectionType); break; } Listener.OnEndSection(); }
internal bool ParseProcedure(Lines lines) { #if NAV2016 Match tryFunctionMatch = null; Match businessEventPublisherMatch = null; Match integrationEventPublisherMatch = null; Match eventSubscriberMatch = null; #endif Match functionTypeMatch = null; Match handlerFunctionsMatch = null; Match transactionModelMatch = null; Match procedureSignatureMatch = null; #if NAV2017 Match testPermissionsMatch = null; #endif #if NAV2016 lines.FirstLineTryMatch(Patterns.TryFunctionAttribute, out tryFunctionMatch); if (!lines.FirstLineTryMatch(Patterns.BusinessEventPublisherAttribute, out businessEventPublisherMatch)) { if (!lines.FirstLineTryMatch(Patterns.IntegrationEventPublisherAttribute, out integrationEventPublisherMatch)) if (!lines.FirstLineTryMatch(Patterns.EventSubscriberAttribute, out eventSubscriberMatch)) #endif lines.FirstLineTryMatch(Patterns.FunctionTypeAttribute, out functionTypeMatch); lines.FirstLineTryMatch(Patterns.HandlerFunctionsAttribute, out handlerFunctionsMatch); lines.FirstLineTryMatch(Patterns.TransactionModelAttribute, out transactionModelMatch); #if NAV2017 lines.FirstLineTryMatch(Patterns.TestPermissionsAttribute, out testPermissionsMatch); #endif if (!lines.FirstLineTryMatch(Patterns.ProcedureSignature, out procedureSignatureMatch)) { return(false); } var procedureLocal = procedureSignatureMatch.Groups[1].Value == "LOCAL "; var procedureName = procedureSignatureMatch.Groups[2].Value; var procedureID = procedureSignatureMatch.Groups[3].Value.ToInteger(); Listener.OnBeginFunction(procedureID, procedureName, procedureLocal); #if NAV2016 if (businessEventPublisherMatch.Success) { Listener.OnFunctionAttribute("Business", businessEventPublisherMatch.Groups[2].Value); } else if (integrationEventPublisherMatch.Success) { Listener.OnFunctionAttribute("Integration", integrationEventPublisherMatch.Groups[2].Value, integrationEventPublisherMatch.Groups[4].Value); } else if (eventSubscriberMatch.Success) { Listener.OnFunctionAttribute( "EventSubscriber", eventSubscriberMatch.Groups["ObjectType"].Value, eventSubscriberMatch.Groups["ObjectID"].Value, eventSubscriberMatch.Groups["Function"].Value, eventSubscriberMatch.Groups["Element"].Value, eventSubscriberMatch.Groups["OnMissingLicense"].Value, eventSubscriberMatch.Groups["OnMissingPermission"].Value); } else #endif if (functionTypeMatch.Success) { Listener.OnFunctionAttribute(functionTypeMatch.Groups[1].Value); } #if NAV2016 if (tryFunctionMatch.Success) { Listener.OnFunctionAttribute("TryFunction"); } #endif if (handlerFunctionsMatch.Success) { Listener.OnFunctionAttribute("HandlerFunctions", handlerFunctionsMatch.Groups[1].Value); } if (transactionModelMatch.Success) { Listener.OnFunctionAttribute("TransactionModel", transactionModelMatch.Groups[1].Value); } #if NAV2017 if (testPermissionsMatch.Success) { Listener.OnFunctionAttribute("TestPermissions", testPermissionsMatch.Groups[1].Value); } #endif ParseParameters(lines); ParseReturnValue(lines); if (lines.FirstLineTryMatch(Patterns.Variables)) ParseLocals(lines); } else { lines.FirstLineMustMatch(Patterns.BeginCodeBlock); } while (!lines.FirstLineTryMatch(Patterns.EndCodeBlock)) { Listener.OnCodeLine(lines.FirstLineMustMatch(Patterns.Any).Value.UnIndent(2)); } Listener.OnEndFunction(); lines.FirstLineTryMatch(Patterns.BlankLine); return(true); }
internal bool ParseVariable(Lines lines) { var variablePattern = CodeStyle.NoVariableIds ? Patterns.VariableNoId : Patterns.Variable; Match match = null; lines.FirstLineTryMatch(Patterns.BlankLine); if (!lines.FirstLineTryMatch(Patterns.MultiLineTextConst, out match)) { if (!lines.FirstLineTryMatch(variablePattern, out match)) { return(false); } } var variableName = match.Groups[1].Value.TrimEnd(); var variableID = match.Groups[2].Value.ToInteger(); var variableType = match.Groups[3].Value; if (String.IsNullOrEmpty(variableType)) { variableType = "TextConst"; } var variableSuppressDispose = ParseSuppressDispose(ref variableType); var variableRunOnClient = ParseRunOnClient(ref variableType); var variableWithEvents = ParseWithEvents(ref variableType); var variableSecurityFiltering = ParseSecurityFiltering(ref variableType); var variableInDataSet = ParseInDataSet(ref variableType); var variableDimensions = ParseDimensions(ref variableType); var variableTemporary = ParseTemporary(ref variableType); var variableConstValue = ParseTextConstant(ref variableType); //.ToConstValue(); var variableSubType = ParseVariableSubType(ref variableType); var variableLength = ParseVariableLength(ref variableType); var variableOptionString = ParseOptionString(ref variableType); if (variableType == "TextConst") { var stringBuilder = new StringBuilder(); while (lines.FirstLineTryMatch(Patterns.MultiLineTextConstValue, out match)) { var languageCode = match.Groups[1].Value; var languageValue = match.Groups[2].Value; var separator = match.Groups[3].Value; if (String.IsNullOrEmpty(separator)) //TextConst value is multiline { while (!lines.FirstLineTryMatch(Patterns.EndMultiLineTextConstValue, true)) { var valuePart = lines.First(); lines.Consume(0, 0, valuePart.Length); languageValue += valuePart + "\n"; } } stringBuilder.AppendFormat("{0}={1};", languageCode, languageValue); } variableConstValue = stringBuilder.ToString(); if (String.IsNullOrEmpty(variableConstValue)) { lines.FirstLineTryMatch(Patterns.EndOfCodeLine, true); } } Listener.OnVariable( variableID, variableName, variableType.ToEnum <VariableType>(), variableSubType, variableLength, variableOptionString, variableConstValue, variableTemporary, variableDimensions, variableRunOnClient, variableWithEvents, variableSecurityFiltering, variableInDataSet, variableSuppressDispose); return(true); }