public override SyntaxNode VisitInterfaceBlock(InterfaceBlockSyntax originalNode) { var node = (InterfaceBlockSyntax)base.VisitInterfaceBlock(originalNode); var begin = (InterfaceStatementSyntax)EnsureVisibility(node.InterfaceStatement, node.InterfaceStatement.Modifiers, (x, l) => x.WithModifiers(l), () => GetTypeDefaultVisibility(originalNode)); return(node.WithInterfaceStatement(begin)); }
public UserVariableDefinition(StructDeclaratorSyntax declarator, IdentifierSyntax identifier, string documentation, DefinitionKind kind, Scope scope) : base(documentation, kind, scope, identifier.Span) { if (kind == DefinitionKind.LocalVariable) { this.Name = ColoredString.Create(identifier.Identifier, ColorType.LocalVariable); } else { this.Name = ColoredString.Create(identifier.Identifier, ColorType.GlobalVariable); } InterfaceBlockSyntax block = declarator.Parent as InterfaceBlockSyntax; this.TypeQualifiers = block.TypeQualifier?.ToSyntaxTypes() ?? new List <SyntaxType>(); this.Type = new TypeDefinition(SyntaxType.TypeName); List <ColoredString> arraySpecifiers = new List <ColoredString>(); for (int i = 0; i < declarator.ArraySpecifiers.Count; i++) { arraySpecifiers.AddRange(declarator.ArraySpecifiers[i].ToColoredString()); } this.ArraySpecifiers = arraySpecifiers; }
public override void VisitInterfaceBlock(InterfaceBlockSyntax node) { if (TryAddPublicApi(node.InterfaceStatement)) { base.VisitInterfaceBlock(node); } }
internal static CodeStructureItem MapItem(InterfaceBlockSyntax node) { var item = CreateItem <InterfaceNode>(node); item.AccessModifier = node.InterfaceStatement.Modifiers.GetAccessModifier(); item.Name = node.InterfaceStatement.Identifier.Text; return(item); }
public override void VisitInterfaceBlock(InterfaceBlockSyntax node) { AddBlockData(node); base.VisitInterfaceBlock(node); }
public override void VisitInterfaceBlock(InterfaceBlockSyntax node) { var statementNode = node.ChildNodes().OfType <InterfaceStatementSyntax>().FirstOrDefault(); var isPartial = statementNode.ChildTokens().Any(x => x.Kind() == SyntaxKind.PartialKeyword); var defineName = statementNode.ChildTokens().FirstOrDefault(x => x.Kind() == SyntaxKind.IdentifierToken).ToString(); // ジェネリック型を定義している場合 if (statementNode.ChildNodes().OfType <TypeParameterListSyntax>().Any()) { var listNode = statementNode.ChildNodes().OfType <TypeParameterListSyntax>().FirstOrDefault(); var genericTypes = listNode .ChildNodes() .OfType <TypeParameterSyntax>() .Select(x => x.ChildTokens().FirstOrDefault(y => y.Kind() == SyntaxKind.IdentifierToken).ToString()); defineName = $"{defineName}<{string.Join(", ", genericTypes)}>"; } var startLength = node.Span.Start; var endLength = node.Span.End; var parentNamespace = GetNamespace(DefineKinds.Interface, startLength, endLength); var baseTypeInfos = new List <BaseTypeInfo>(); // 継承元クラス、またはインターフェースがある場合 var hasInherits = node.ChildNodes().OfType <InheritsStatementSyntax>().Any(); var hasImplements = node.ChildNodes().OfType <ImplementsStatementSyntax>().Any(); if (hasInherits || hasImplements) { var baseTypes = new List <SyntaxNode>(); if (hasInherits) { var inheritsNode = node.ChildNodes().OfType <InheritsStatementSyntax>().FirstOrDefault(); var childNodes = inheritsNode.ChildNodes(); // Interface の場合、Inherits, IInterface1, IInterface2 などと記述する // Implements ではなく Inherits でインターフェースを継承する foreach (var childNode in childNodes) { baseTypes.Add(childNode); } } if (hasImplements) { // 上記仕様から以下はありえないのだが、将来仕様変更されるか?されないと思う var implementsNode = node.ChildNodes().OfType <ImplementsStatementSyntax>().FirstOrDefault(); var childNodes = implementsNode.ChildNodes(); foreach (var childNode in childNodes) { baseTypes.Add(childNode); } } baseTypeInfos = GetBaseTypeInfos(baseTypes, parentNamespace); } UserDefinitions.Add(new UserDefinition { DefineKinds = DefineKinds.Interface, IsPartial = isPartial, Namespace = parentNamespace, DefineName = defineName, DefineFullName = $"{parentNamespace}.{defineName}", BaseTypeInfos = baseTypeInfos, SourceFile = SourceFile, StartLength = startLength, EndLength = endLength, }); base.VisitInterfaceBlock(node); }
private void UpdateRegions(VSSnapshot snapshot) { SyntaxTree tree = this.source.Tree; if (tree == null || snapshot == null) { return; } List <Region> newRegions = new List <Region>(); foreach (SyntaxNode node in tree.Root.Descendants) { switch (node.SyntaxType) { case SyntaxType.FunctionDefinition: FunctionDefinitionSyntax functionDefinition = node as FunctionDefinitionSyntax; if (functionDefinition.FunctionHeader?.RightParentheses != null && functionDefinition.Block?.RightBrace != null) { this.AddRegion(newRegions, snapshot, tree, 1, functionDefinition.FunctionHeader.RightParentheses, functionDefinition.Block.RightBrace); } break; case SyntaxType.InterfaceBlock: InterfaceBlockSyntax interfaceBlock = node as InterfaceBlockSyntax; if (interfaceBlock.Identifier != null && interfaceBlock.RightBrace != null) { this.AddRegion(newRegions, snapshot, tree, 1, interfaceBlock.Identifier, interfaceBlock.RightBrace); } break; case SyntaxType.StructSpecifier: StructSpecifierSyntax structSpecifier = node as StructSpecifierSyntax; if (structSpecifier.RightBrace != null) { if (structSpecifier.TypeName != null) { this.AddRegion(newRegions, snapshot, tree, 0, structSpecifier.TypeName, structSpecifier.RightBrace); } else if (structSpecifier.StructKeyword != null) { this.AddRegion(newRegions, snapshot, tree, 1, structSpecifier.StructKeyword, structSpecifier.RightBrace); } } break; case SyntaxType.IfDefinedPreprocessor: IfDefinedPreprocessorSyntax ifDefined = node as IfDefinedPreprocessorSyntax; if (ifDefined.EndIfKeyword != null) { this.AddRegion(newRegions, snapshot, tree, 1, ifDefined.IfDefinedKeyword, ifDefined.EndIfKeyword); } break; case SyntaxType.IfPreprocessor: IfPreprocessorSyntax ifPreprocessor = node as IfPreprocessorSyntax; if (ifPreprocessor.EndIfKeyword != null) { this.AddRegion(newRegions, snapshot, tree, 1, ifPreprocessor.IfKeyword, ifPreprocessor.EndIfKeyword); } break; case SyntaxType.IfNotDefinedPreprocessor: IfNotDefinedPreprocessorSyntax ifNotDefined = node as IfNotDefinedPreprocessorSyntax; if (ifNotDefined.EndIfKeyword != null) { this.AddRegion(newRegions, snapshot, tree, 1, ifNotDefined.IfNotDefinedKeyword, ifNotDefined.EndIfKeyword); } break; } } foreach (IfPreprocessor preprocessor in this.source.Settings.Preprocessors) { if (preprocessor.EndIf != null) { this.AddRegion(newRegions, snapshot, tree, 1, preprocessor.Keyword, preprocessor.EndIf.EndIfKeyword); } for (int i = 0; i < preprocessor.ElsePreprocessors.Count; i++) { SyntaxToken next; if (i < preprocessor.ElsePreprocessors.Count - 1) { ElseIfPreprocessorSyntax elseIf = preprocessor.ElsePreprocessors[i].Keyword.Parent as ElseIfPreprocessorSyntax; if (elseIf != null) { next = elseIf.ExcludedCode.Code.Last() as SyntaxToken; } else { next = preprocessor.ElsePreprocessors[i].Keyword; } } else { next = preprocessor.EndIf.EndIfKeyword; } this.AddRegion(newRegions, snapshot, tree, 1, preprocessor.ElsePreprocessors[i].Keyword, next); } } lock (this.lockObject) { this.regions = newRegions; } this.TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot.TextSnapshot, snapshot.Span.ToVSSpan()))); }
public UserInterfaceBlockDefinition(InterfaceBlockSyntax interfaceBlock, IdentifierSyntax identifier, string documentation, Scope scope) : base(interfaceBlock.TypeQualifier?.ToSyntaxTypes(), identifier.Identifier, documentation, scope, identifier.Span) { }
public override void VisitInterfaceBlock(InterfaceBlockSyntax node) { LogicalLineCount++; base.VisitInterfaceBlock(node); }
private Interface TraverseInterface(InterfaceBlockSyntax ibs) { Interface retInterface = new Interface(); /* Encapsulation = new List<Encapsulation>(); Qualifiers = new List<Qualifiers>(); Attributes = new List<Variables>(); Methods = new List<Method>(); InheritsStrings = new List<string>(); InheritsInterfaces = new List<Interface>(); */ InterfaceStatementSyntax iss = ibs.Begin; foreach (SyntaxToken st in iss.Modifiers) { string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText); Encapsulation encap; Qualifiers qual; if (System.Enum.TryParse<Encapsulation>(modifier, out encap)) { retInterface.Encapsulation.Add(encap); } else if (System.Enum.TryParse<Qualifiers>(modifier, out qual)) { retInterface.Qualifiers.Add(qual); } } retInterface.Name = iss.Identifier.ValueText; foreach(InheritsStatementSyntax inherits in ibs.Inherits){ foreach (SyntaxNode sn in inherits.ChildNodes()) { if (sn is IdentifierNameSyntax) { retInterface.InheritsStrings.Add((sn as IdentifierNameSyntax).Identifier.ValueText); } } } List<MethodBlockSyntax> methods = new List<MethodBlockSyntax>(); List<FieldDeclarationSyntax> Fields = new List<FieldDeclarationSyntax>(); List<PropertyBlockSyntax> properties = new List<PropertyBlockSyntax>(); foreach (SyntaxNode sn in ibs.ChildNodes()) { if (sn is MethodBlockSyntax) { methods.Add(sn as MethodBlockSyntax); } else if (sn is FieldDeclarationSyntax) { Fields.Add(sn as FieldDeclarationSyntax); } else if (sn is PropertyBlockSyntax) { properties.Add(sn as PropertyBlockSyntax); } } foreach (MethodBlockSyntax mbs in methods) { bool isConstructor = false; retInterface.Methods.Add(TraverseMethod(mbs, ref isConstructor)); } foreach (FieldDeclarationSyntax fds in Fields) { retInterface.Fields.Add(TraverseField(fds)); } foreach (PropertyBlockSyntax pbs in properties) { retInterface.Properties.Add(TraverseProperties(pbs)); } return retInterface; }