private bool CompareAttributeArguments(AttributeArgumentListSyntax oldAttributeArguments, AttributeArgumentListSyntax newAttributeArguments) { if (oldAttributeArguments == null || newAttributeArguments == null) { return(oldAttributeArguments == newAttributeArguments); } var oldArguments = oldAttributeArguments.Arguments; var newArguments = newAttributeArguments.Arguments; if (oldArguments.Count != newArguments.Count) { return(false); } for (var i = 0; i < oldArguments.Count; i++) { var oldArgument = oldArguments[i]; var newArgument = newArguments[i]; if (!StringComparer.Ordinal.Equals(CodeModelService.GetName(oldArgument), CodeModelService.GetName(newArgument))) { return(false); } if (!CompareExpressions(oldArgument.Expression, newArgument.Expression)) { return(false); } } return(true); }
private bool CompareEnumMemberDeclarations( EnumMemberDeclarationSyntax oldEnumMember, EnumMemberDeclarationSyntax newEnumMember, SyntaxNode newNodeParent, CodeModelEventQueue eventQueue) { Debug.Assert(oldEnumMember != null && newEnumMember != null); bool same = true; if (!StringComparer.Ordinal.Equals(CodeModelService.GetName(oldEnumMember), CodeModelService.GetName(newEnumMember))) { EnqueueChangeEvent(newEnumMember, newNodeParent, CodeModelEventType.Rename, eventQueue); same = false; } same &= CompareChildren( CompareAttributeLists, oldEnumMember.AttributeLists.AsReadOnlyList(), newEnumMember.AttributeLists.AsReadOnlyList(), newEnumMember, CodeModelEventType.Unknown, eventQueue); return(same); }
private bool CompareVariableDeclarators( VariableDeclaratorSyntax oldVariableDeclarator, VariableDeclaratorSyntax newVariableDeclarator, SyntaxNode newNodeParent, CodeModelEventQueue eventQueue ) { Debug.Assert(oldVariableDeclarator != null && newVariableDeclarator != null); if ( !StringComparer.Ordinal.Equals( CodeModelService.GetName(oldVariableDeclarator), CodeModelService.GetName(newVariableDeclarator) ) ) { EnqueueChangeEvent( newVariableDeclarator, newNodeParent, CodeModelEventType.Rename, eventQueue ); return(false); } return(true); }
protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element) { var node = LookupNode(); var parentElement = !IsRootNamespace ? (AbstractCodeElement)Parent : null; // Option statements foreach (var child in CodeModelService.GetOptionNodes(node)) { string childName; int ordinal; CodeModelService.GetOptionNameAndOrdinal(node, child, out childName, out ordinal); if (childName == name) { element = CodeOptionsStatement.Create(State, FileCodeModel, childName, ordinal); return(true); } } // Imports/using statements foreach (var child in CodeModelService.GetImportNodes(node)) { var childName = CodeModelService.GetImportNamespaceOrType(child); if (childName == name) { element = CodeImport.Create(State, FileCodeModel, parentElement, childName); return(true); } } // Attributes foreach (var child in CodeModelService.GetAttributeNodes(node)) { string childName; int ordinal; CodeModelService.GetAttributeNameAndOrdinal(node, child, out childName, out ordinal); if (childName == name) { element = (EnvDTE.CodeElement)CodeAttribute.Create(State, FileCodeModel, parentElement, childName, ordinal); return(true); } } // Members foreach (var child in CodeModelService.GetLogicalSupportedMemberNodes(node)) { var childName = CodeModelService.GetName(child); if (childName == name) { element = FileCodeModel.CreateCodeElement <EnvDTE.CodeElement>(child); return(true); } } element = null; return(false); }
private bool ComparePropertyDeclarations( BasePropertyDeclarationSyntax oldProperty, BasePropertyDeclarationSyntax newProperty, SyntaxNode newNodeParent, CodeModelEventQueue eventQueue) { Debug.Assert(oldProperty != null && newProperty != null); bool same = true; if (!StringComparer.Ordinal.Equals(CodeModelService.GetName(oldProperty), CodeModelService.GetName(newProperty))) { EnqueueChangeEvent(newProperty, newNodeParent, CodeModelEventType.Rename, eventQueue); same = false; } // If modifiers have changed enqueue a element changed (unknown change) node if (!CompareModifiers(oldProperty, newProperty)) { EnqueueChangeEvent(newProperty, newNodeParent, CodeModelEventType.Unknown, eventQueue); same = false; } // If return type had changed enqueue a element changed (typeref changed) node if (!CompareTypes(oldProperty.Type, newProperty.Type)) { EnqueueChangeEvent(newProperty, newNodeParent, CodeModelEventType.TypeRefChange, eventQueue); same = false; } same &= CompareChildren( CompareAttributeLists, oldProperty.AttributeLists.AsReadOnlyList(), newProperty.AttributeLists.AsReadOnlyList(), newProperty, CodeModelEventType.Unknown, eventQueue); if (oldProperty is IndexerDeclarationSyntax) { var oldIndexer = (IndexerDeclarationSyntax)oldProperty; var newIndexer = (IndexerDeclarationSyntax)newProperty; same &= CompareChildren( CompareParameters, oldIndexer.ParameterList.Parameters.AsReadOnlyList(), newIndexer.ParameterList.Parameters.AsReadOnlyList(), newIndexer, CodeModelEventType.SigChange, eventQueue); } return(same); }
protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element) { var node = LookupNode(); foreach (var child in CodeModelService.GetLogicalSupportedMemberNodes(node)) { var childName = CodeModelService.GetName(child); if (childName == name) { element = FileCodeModel.GetOrCreateCodeElement <EnvDTE.CodeElement>(child); return(true); } } element = null; return(false); }
private bool CompareParameters( ParameterSyntax oldParameter, ParameterSyntax newParameter, SyntaxNode newNodeParent, CodeModelEventQueue eventQueue ) { Debug.Assert(oldParameter != null && newParameter != null); var same = true; if ( !StringComparer.Ordinal.Equals( CodeModelService.GetName(oldParameter), CodeModelService.GetName(newParameter) ) ) { EnqueueChangeEvent( newParameter, newNodeParent, CodeModelEventType.Rename, eventQueue ); same = false; } // If modifiers or the type have changed enqueue a element changed (unknown change) node if ( !CompareModifiers(oldParameter, newParameter) || !CompareTypes(oldParameter.Type, newParameter.Type) ) { EnqueueChangeEvent( newParameter, newNodeParent, CodeModelEventType.Unknown, eventQueue ); same = false; } return(same); }
protected override bool TryGetItemByName(string name, out EnvDTE.CodeElement element) { var node = LookupNode(); var currentIndex = 0; foreach (var child in CodeModelService.GetAttributeArgumentNodes(node)) { var childName = CodeModelService.GetName(child); if (childName == name) { element = (EnvDTE.CodeElement)CodeAttributeArgument.Create(this.State, this.ParentAttribute, currentIndex); return(true); } currentIndex++; } element = null; return(false); }
protected override string GetName() { return(CodeModelService.GetName(LookupNode())); }
protected virtual string GetName() { var node = LookupNode(); return(CodeModelService.GetName(node)); }
private bool CompareMethodDeclarations( BaseMethodDeclarationSyntax oldMethod, BaseMethodDeclarationSyntax newMethod, SyntaxNode newNodeParent, CodeModelEventQueue eventQueue) { Debug.Assert(oldMethod != null && newMethod != null); if (!StringComparer.Ordinal.Equals(CodeModelService.GetName(oldMethod), CodeModelService.GetName(newMethod))) { var change = CompareRenamedDeclarations( CompareParameters, oldMethod.ParameterList.Parameters.AsReadOnlyList(), newMethod.ParameterList.Parameters.AsReadOnlyList(), oldMethod, newMethod, newNodeParent, eventQueue); if (change == DeclarationChange.NameOnly) { EnqueueChangeEvent(newMethod, newNodeParent, CodeModelEventType.Rename, eventQueue); } return(false); } else { bool same = true; if (!CompareModifiers(oldMethod, newMethod)) { same = false; EnqueueChangeEvent(newMethod, newNodeParent, CodeModelEventType.Unknown, eventQueue); } if (!CompareTypes(GetReturnType(oldMethod), GetReturnType(newMethod))) { same = false; EnqueueChangeEvent(newMethod, newNodeParent, CodeModelEventType.TypeRefChange, eventQueue); } same &= CompareChildren( CompareAttributeLists, oldMethod.AttributeLists.AsReadOnlyList(), newMethod.AttributeLists.AsReadOnlyList(), newMethod, CodeModelEventType.Unknown, eventQueue); same &= CompareChildren( CompareParameters, oldMethod.ParameterList.Parameters.AsReadOnlyList(), newMethod.ParameterList.Parameters.AsReadOnlyList(), newMethod, CodeModelEventType.SigChange, eventQueue); return(same); } }
protected override string GetName() => CodeModelService.GetName(LookupNode());