public override int Compare(ICodeExplorerNode x, ICodeExplorerNode y) { var node = base.Compare(x, y); if (node != 0) { return(node); } var first = x?.QualifiedSelection?.Selection; if (first is null) { return(-1); } var second = y?.QualifiedSelection?.Selection; if (second is null) { return(1); } return(first.Value.CompareTo(second.Value)); }
public CodeExplorerSubMemberViewModel(ICodeExplorerNode parent, Declaration declaration) : base(parent, declaration) { if (Declaration is ValuedDeclaration value && !string.IsNullOrEmpty(value.Expression)) { _signature = $" = {value.Expression}"; } }
public CodeExplorerComponentViewModel(ICodeExplorerNode parent, Declaration declaration, ref List <Declaration> declarations, IVBE vbe) : base(parent, declaration) { _vbe = vbe; SetName(); AddNewChildren(ref declarations); }
private static List <ReferenceModel> GetReferencesFromProjectViewModel(ICodeExplorerNode viewModel) { return(viewModel.Children .OfType <CodeExplorerReferenceFolderViewModel>() .SelectMany(folder => folder.Children .OfType <CodeExplorerReferenceViewModel>() .Select(vm => vm.Reference)) .ToList()); }
public CodeExplorerReferenceFolderViewModel( ICodeExplorerNode parent, DeclarationFinder finder, List <ReferenceModel> references, ReferenceKind type) : base(parent, parent?.Declaration) { _finder = finder; ReferenceKind = type; Synchronize(Declaration, references); }
protected CodeExplorerItemViewModelBase(ICodeExplorerNode parent, Declaration declaration) { Parent = parent; _declaration = declaration; UnfilteredIsExpanded = IsExpanded; if (parent != null) { Filter = parent.Filter; } }
private IEnumerable <bool> GetNodeExpandedStates(ICodeExplorerNode root) { yield return(root.IsExpanded); foreach (var node in root.Children) { foreach (var state in GetNodeExpandedStates(node)) { yield return(state); } } }
private bool EvaluateCanExecute(ICodeExplorerNode node) { if (!ApplicableNodes.Contains(node.GetType()) || !(node is CodeExplorerItemViewModel) || node.Declaration == null) { return(false); } var project = node.Declaration.Project; return(AllowableProjectTypes.Contains(project.Type)); }
private bool EvaluateCanExecute(ICodeExplorerNode node) { if (node?.Declaration == null || !ApplicableNodes.Contains(node.GetType()) || !(node is CodeExplorerItemViewModel)) { return(false); } var project = _projectsProvider.Project(node.Declaration.ProjectId); return(project != null && AllowableProjectTypes.Contains(project.Type)); }
public CodeExplorerCustomFolderViewModel( ICodeExplorerNode parent, string name, string fullPath, IVBE vbe, ref List <Declaration> declarations) : base(parent, parent?.Declaration) { _vbe = vbe; FolderDepth = parent is CodeExplorerCustomFolderViewModel folder ? folder.FolderDepth + 1 : 1; FullPath = fullPath?.Trim('"') ?? string.Empty; Name = name.Replace("\"", string.Empty); AddNewChildren(ref declarations); }
private static ICollection <ModuleDeclaration> ContainedModules(ICodeExplorerNode itemModel) { if (itemModel is CodeExplorerComponentViewModel componentModel) { var component = componentModel.Declaration; return(component is ModuleDeclaration moduleDeclaration ? new List <ModuleDeclaration> { moduleDeclaration } : new List <ModuleDeclaration>()); } return(itemModel.Children .SelectMany(ContainedModules) .ToList()); }
private bool EvaluateCanExecute(IAnnotation annotation, ICodeExplorerNode node) { var target = node?.Declaration; if (target == null || annotation == null || !CanExecuteForNode(node)) { return(false); } if (!annotation.AllowMultiple && target.Annotations.Any(pta => pta.Annotation.Equals(annotation))) { return(false); } var targetType = target.DeclarationType; switch (annotation.Target) { case AnnotationTarget.Member: return(targetType.HasFlag(DeclarationType.Member) && targetType != DeclarationType.LibraryFunction && targetType != DeclarationType.LibraryProcedure); case AnnotationTarget.Module: return(targetType.HasFlag(DeclarationType.Module)); case AnnotationTarget.Variable: return(targetType.HasFlag(DeclarationType.Variable) || targetType.HasFlag(DeclarationType.Constant)); case AnnotationTarget.General: return(true); case AnnotationTarget.Identifier: return(false); default: return(false); } }
private bool ShouldBeVisible(IAnnotation annotation, ICodeExplorerNode node) { var target = node.Declaration; if (target == null) { return(false); } if (!target.DeclarationType.HasFlag(DeclarationType.Module) && target.AttributesPassContext == null && annotation is IAttributeAnnotation) { return(false); } var targetType = target.DeclarationType; switch (annotation.Target) { case AnnotationTarget.Member: return(targetType.HasFlag(DeclarationType.Member) && targetType != DeclarationType.LibraryFunction && targetType != DeclarationType.LibraryProcedure); case AnnotationTarget.Module: return(targetType.HasFlag(DeclarationType.Module)); case AnnotationTarget.Variable: return(targetType.HasFlag(DeclarationType.Variable) || targetType.HasFlag(DeclarationType.Constant)); case AnnotationTarget.General: return(!targetType.HasFlag(DeclarationType.Module)); case AnnotationTarget.Identifier: return(false); default: return(false); } }
public override int Compare(ICodeExplorerNode x, ICodeExplorerNode y) { var node = base.Compare(x, y); if (node != 0) { return(node); } if (!(x is CodeExplorerReferenceFolderViewModel first)) { return(-1); } if (!(y is CodeExplorerReferenceFolderViewModel second)) { return(1); } // Libraries are first, so reverse the comparison. return(second.ReferenceKind.CompareTo(first.ReferenceKind)); }
public bool CanExecuteForNode(ICodeExplorerNode node) { if (!ApplicableNodes.Contains(node.GetType()) || !(node is CodeExplorerItemViewModel) || node.Declaration == null) { return(false); } var target = node.Declaration; var targetType = target.DeclarationType; if (!targetType.HasFlag(DeclarationType.Module) && !targetType.HasFlag(DeclarationType.Variable) && !targetType.HasFlag(DeclarationType.Constant) && !targetType.HasFlag(DeclarationType.Member) || targetType == DeclarationType.LibraryFunction || targetType == DeclarationType.LibraryProcedure) { return(false); } return(!_state.IsNewOrModified(target.QualifiedModuleName)); }
public CodeExplorerMemberViewModel(ICodeExplorerNode parent, Declaration declaration, ref List <Declaration> declarations) : base(parent, declaration) { AddNewChildren(ref declarations); Name = DetermineMemberName(declaration); }
protected CodeExplorerItemViewModel(ICodeExplorerNode parent, Declaration declaration) : base(parent, declaration) { }
public CodeExplorerReferenceViewModel(ICodeExplorerNode parent, ReferenceModel reference) : base(parent, parent?.Declaration) { Reference = reference; }
public bool CanExecuteForNode(ICodeExplorerNode model) { return(EvaluateCanExecute(model)); }
public override int Compare(ICodeExplorerNode x, ICodeExplorerNode y) { var node = base.Compare(x, y); return(node != 0 ? node : string.Compare(x?.NameWithSignature, y?.NameWithSignature, StringComparison.OrdinalIgnoreCase)); }