public override void ExitXppmethod([NotNull] XP.XppmethodContext context) { // should do the same as the 'normal' methods in VO Class // Retrieve visibility from the XppClassInfo, from the list of declared methods // when not declared produce warning (error ?) // When classname clause is missing then assume the last class in the file before this method context.SetSequencePoint(context.M, context.end.Stop); if (context.Info == null) { context.AddError(new ParseErrorData(context, ErrorCode.WRN_XPPMethodNotDeclared, context.ShortName)); // setup dummy declaration context.Info = new XppDeclaredMethodInfo() { Name = context.ShortName, Declaration = context, Entity = context, Visibility = XP.HIDDEN }; } if (context.Data.IsInitAxit) { // method init becomes constructor, method initClass becomes Class constructor implementConstructor(context); return; } SyntaxList <SyntaxToken> modifiers; if (context.Info.IsProperty) { // the backing method becomes private modifiers = decodeXppMemberModifiers(XP.PRIVATE, false, context.Modifiers?._Tokens); } else { modifiers = decodeXppMemberModifiers(context.Info.Visibility, false, context.Modifiers?._Tokens); } TypeSyntax returnType = context.Type?.Get <TypeSyntax>(); if (returnType == null) { returnType = _getMissingType(); } var attributes = context.Attributes?.GetList <AttributeListSyntax>() ?? EmptyList <AttributeListSyntax>(); var parameters = context.ParamList?.Get <ParameterListSyntax>() ?? EmptyParameterList(); var name = context.Id.Get <SyntaxToken>(); if (context.Info.IsProperty && !context.Info.HasVarName) { // rename method because the property has the same name as the method name = SyntaxFactory.MakeIdentifier(context.Id.GetText() + XSharpSpecialNames.PropertySuffix); } var method = XppCreateMethod(context, name, attributes, modifiers, parameters, returnType); context.Put(method); }
public override void EnterXppmethod([NotNull] XP.XppmethodContext context) { Check4ClipperCC(context, context.ParamList?._Params, null, context.Type); CheckInitMethods(context); string name; XppClassInfo current = null; if (context.ClassId == null) { current = _classes.LastOrDefault(); } else { // when context contains a classname, find the right class in the list of classes name = context.ClassId.GetText(); current = FindClassInfo(name); if (current == null) { context.AddError(new ParseErrorData(context, ErrorCode.ERR_XPPClassNotFound, name)); } current = _classes.LastOrDefault(); } current.ExternalMethods.Add(context); if (current != null) { // link to method name = context.Id.GetText(); var decl = current.FindMethod(name); if (decl == null) { decl = current.FindPropertyMethod(name); } if (decl != null) { if (decl.IsProperty) { if (XSharpString.Equals(decl.AccessMethod, name)) { decl.Entity = context; } if (XSharpString.Equals(decl.AssignMethod, name)) { decl.SetEntity = context; } } else { decl.Entity = context; } context.Info = decl; } } }