private FieldSymbol BuildPropertyAsField(PropertyDeclarationNode propertyNode, TypeSymbol typeSymbol) { AttributeNode intrinsicPropertyAttribute = AttributeNode.FindAttribute(propertyNode.Attributes, "IntrinsicProperty"); if (intrinsicPropertyAttribute == null) { return(null); } TypeSymbol fieldType = typeSymbol.SymbolSet.ResolveType(propertyNode.Type, _symbolTable, typeSymbol); Debug.Assert(fieldType != null); if (fieldType != null) { FieldSymbol symbol = new FieldSymbol(propertyNode.Name, typeSymbol, fieldType); BuildMemberDetails(symbol, typeSymbol, propertyNode, propertyNode.Attributes); string scriptAlias = GetAttributeValue(propertyNode.Attributes, "ScriptAlias"); if (scriptAlias != null) { symbol.SetAlias(scriptAlias); } return(symbol); } return(null); }
private PropertySymbol BuildProperty(PropertyDeclarationNode propertyNode, TypeSymbol typeSymbol) { TypeSymbol propertyType = typeSymbol.SymbolSet.ResolveType(propertyNode.Type, _symbolTable, typeSymbol); Debug.Assert(propertyType != null); if (propertyType != null) { PropertySymbol property = new PropertySymbol(propertyNode.Name, typeSymbol, propertyType); BuildMemberDetails(property, typeSymbol, propertyNode, propertyNode.Attributes); SymbolImplementationFlags implFlags = SymbolImplementationFlags.Regular; if (propertyNode.SetAccessor == null) { implFlags |= SymbolImplementationFlags.ReadOnly; } if ((propertyNode.Modifiers & Modifiers.Abstract) != 0) { implFlags |= SymbolImplementationFlags.Abstract; } else if ((propertyNode.Modifiers & Modifiers.Override) != 0) { implFlags |= SymbolImplementationFlags.Override; } property.SetImplementationState(implFlags); property.AddParameter(new ParameterSymbol("value", property, propertyType, ParameterMode.In)); return(property); } return(null); }
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) { PropertyDeclarationNode propertyNode = (PropertyDeclarationNode)node; if ((propertyNode.Modifiers & Modifiers.Static) == 0 && (propertyNode.Modifiers & Modifiers.New) != 0) { errorHandler.ReportNodeValidationError(DSharpStringResources.STATIC_NEW_KEYWORD_UNSUPPORTED, propertyNode); return(false); } return(true); }
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) { PropertyDeclarationNode propertyNode = (PropertyDeclarationNode)node; if (((propertyNode.Modifiers & Modifiers.Static) == 0) && ((propertyNode.Modifiers & Modifiers.New) != 0)) { errorHandler.ReportError("The new modifier is not supported on instance members.", propertyNode.Token.Location); return(false); } return(true); }
public static string GetName(this PropertyDeclarationNode @this, ITextSnapshot snapshot) { Contract.Requires(@this != null); Contract.Requires(snapshot != null); var nameNode = @this.MemberName; if (nameNode != null) { var nameNodeSpan = nameNode.GetSpan(); return(nameNodeSpan.Convert(snapshot).GetText()); } return(null); }
public override void VisitPropertyDeclarationNode(PropertyDeclarationNode node) { base.VisitPropertyDeclarationNode(node); var keys = GenerateTag(node, _snapshot); if (keys == null) { //We can't get a proper tag from this (likely ill-formed) property, so we'll skip it for now. var name = node.GetName(_snapshot); VSServiceProvider.Current.Logger.WriteToLog("Can't form a proper tag (likely ill-formed), ignoring member '" + name == null ? "" : name + "' for now..."); return; } if (_properties.ContainsKey(keys)) { //For some reason, we have two properties with the same signature. There is //nothing we can do in this case so we just throw out the second property. VSServiceProvider.Current.Logger.WriteToLog("Two properties where found to have the exact same signature, ignoring second property for now..."); return; } _properties.Add(keys, node); }
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) { PropertyDeclarationNode propertyNode = (PropertyDeclarationNode)node; if (((propertyNode.Modifiers & Modifiers.Static) == 0) && ((propertyNode.Modifiers & Modifiers.New) != 0)) { errorHandler.ReportError("The new modifier is not supported on instance members.", propertyNode.Token.Location); return(false); } if (propertyNode.GetAccessor == null) { errorHandler.ReportError("Set-only properties are not supported. Use a set method instead.", propertyNode.Token.Location); return(false); } return(true); }
private PropertyDeclarationNode ParseLet() { SourcePosition startPosition = PeekBack().Position; bool isMutable = MatchToken(SyntaxTokenKind.MutKeyword); if (CurrentToken.Kind != SyntaxTokenKind.Identifier) { // Syntax error Console.WriteLine("error"); } PropertyDeclarationNode node = new PropertyDeclarationNode(CurrentToken.Text, isMutable) { Range = new SourceRange(startPosition, new SourcePosition(CurrentToken.Position.Line, CurrentToken.Position.Column + CurrentToken.Text.Length)) }; Advance(); return(node); }
public void enterPropertySetter(PropertyDeclarationNode declaration) { methodInfos.add(declaration.SetAccessor.getUserData(typeof(MethodInfo))); }
public static Tuple<object, object> GenerateTag(PropertyDeclarationNode property, ITextSnapshot snapshot) { Contract.Requires(property != null); Contract.Requires(snapshot != null); Contract.Ensures((property.GetAccessorDeclaration == null) || (Contract.Result<Tuple<object, object>>().Item1 != null)); Contract.Ensures((property.SetAccessorDeclaration == null) || (Contract.Result<Tuple<object, object>>().Item2 != null)); var sb = new StringBuilder(); //Append our name var name = property.GetName(snapshot); if (name != null) { sb.Append(name); sb.Append('!'); } //Append our return type if (property.Type != null) { var tn = property.Type.GetName(snapshot); if (tn != null) { sb.Append(tn); sb.Append('!'); } } //Append parameters if (property.FormalParameterList != null) { foreach (var param in property.FormalParameterList) { //AppendParamter nameS if (param.Identifier != null && param.Identifier.Name != null) { sb.Append(param.Identifier.Name.Text); sb.Append('!'); } //Append parameter type if (param.Type != null) { var tn = param.Type.GetName(snapshot); if (tn != null) { sb.Append(tn); sb.Append('!'); } } //Append attributes? if (param.Attributes != null && param.Attributes.Count > 0) { } //Append flags? if (param.Flags != default(NodeFlags)) { sb.Append(param.Flags); sb.Append('!'); } } } //Append parent information var containingType = property.Parent; while (containingType != null) { var asClass = containingType.AsClass(); if (asClass != null) { sb.Append(asClass.Identifier.Name.Text); sb.Append('!'); goto EndOfLoop; } var asInterface = containingType.AsInterface(); if (asInterface != null) { sb.Append(asInterface.Identifier.Name.Text); sb.Append('!'); goto EndOfLoop; } /*Note: there is nothing we can do about the namespace, we can't seem to get namespace name info from the syntactic model. */ EndOfLoop: containingType = containingType.Parent; } //Append our flags if (property.Flags != default(NodeFlags)) { sb.Append(property.Flags); sb.Append('!'); } //Append what kind of node we are sb.Append(PropertyTagSuffix); object getterTag = null; object setterTag = null; if (property.GetAccessorDeclaration != null) getterTag = "GETTER!" + sb.ToString(); if (property.SetAccessorDeclaration != null) setterTag = "SETTER!" + sb.ToString(); //return return new Tuple<object, object>(getterTag, setterTag); }
/// <inheritdoc/> public override void VisitPropertyDeclarationNode(PropertyDeclarationNode node) { }
public static Tuple <object, object> GenerateTag(PropertyDeclarationNode property, ITextSnapshot snapshot) { Contract.Requires(property != null); Contract.Requires(snapshot != null); Contract.Ensures((property.GetAccessorDeclaration == null) || (Contract.Result <Tuple <object, object> >().Item1 != null)); Contract.Ensures((property.SetAccessorDeclaration == null) || (Contract.Result <Tuple <object, object> >().Item2 != null)); var sb = new StringBuilder(); //Append our name var name = property.GetName(snapshot); if (name != null) { sb.Append(name); sb.Append('!'); } //Append our return type if (property.Type != null) { var tn = property.Type.GetName(snapshot); if (tn != null) { sb.Append(tn); sb.Append('!'); } } //Append parameters if (property.FormalParameterList != null) { foreach (var param in property.FormalParameterList) { //AppendParamter nameS if (param.Identifier != null && param.Identifier.Name != null) { sb.Append(param.Identifier.Name.Text); sb.Append('!'); } //Append parameter type if (param.Type != null) { var tn = param.Type.GetName(snapshot); if (tn != null) { sb.Append(tn); sb.Append('!'); } } //Append attributes? if (param.Attributes != null && param.Attributes.Count > 0) { } //Append flags? if (param.Flags != default(NodeFlags)) { sb.Append(param.Flags); sb.Append('!'); } } } //Append parent information var containingType = property.Parent; while (containingType != null) { var asClass = containingType.AsClass(); if (asClass != null) { sb.Append(asClass.Identifier.Name.Text); sb.Append('!'); goto EndOfLoop; } var asInterface = containingType.AsInterface(); if (asInterface != null) { sb.Append(asInterface.Identifier.Name.Text); sb.Append('!'); goto EndOfLoop; } /*Note: there is nothing we can do about the namespace, we can't seem to get namespace name info from the syntactic model. */ EndOfLoop: containingType = containingType.Parent; } //Append our flags if (property.Flags != default(NodeFlags)) { sb.Append(property.Flags); sb.Append('!'); } //Append what kind of node we are sb.Append(PropertyTagSuffix); object getterTag = null; object setterTag = null; if (property.GetAccessorDeclaration != null) { getterTag = "GETTER!" + sb.ToString(); } if (property.SetAccessorDeclaration != null) { setterTag = "SETTER!" + sb.ToString(); } //return return(new Tuple <object, object>(getterTag, setterTag)); }