public IList <IDeclaration> GetDeclarations() { /*if (this.parent != null) * { * return this.parent.GetDeclarations(); * } */ var declarations = new List <IDeclaration>(); foreach (var sourceFile in this.GetSourceFiles()) { declarations.AddRange(GetDeclarationsIn(sourceFile, this)); } if (this.filterDeclarations) { var actualDeclarations = NTriplesIdentifierFilter.GetTypeDeclarations(declarations).Cast <IDeclaration>().ToArray(); if (!actualDeclarations.Any()) { var subjects = declarations.Where(d => ((IUriIdentifierDeclaredElement)d).GetKind() == IdentifierKind.Subject).ToArray(); if (subjects.Any()) { actualDeclarations = subjects; } else if (declarations.Any()) { actualDeclarations = new[] { declarations.First() }; } } return(actualDeclarations); } return(declarations); }
public IList <IDeclaration> GetDeclarationsIn(IPsiSourceFile sourceFile) { /*if (this.parent != null) * { * return this.parent.GetDeclarationsIn(sourceFile); * } */ var declarations = GetDeclarationsIn(sourceFile, this); if (this.filterDeclarations) { var actualDeclarations = NTriplesIdentifierFilter.GetTypeDeclarations(declarations).Cast <IDeclaration>().ToArray(); if (!actualDeclarations.Any() && (declarations.Any()) && !NTriplesIdentifierFilter.HasTypeDeclaration(declarations.First())) { actualDeclarations = new[] { declarations.First() }; } return(actualDeclarations); } return(declarations); }
public IEnumerable <Pair <IDeclaredElement, Predicate <FindResult> > > GetRelatedDeclaredElements(IDeclaredElement element) { var uriIdentifier = element as IUriIdentifierDeclaredElement; if (uriIdentifier != null) { var declarations = element.GetDeclarations(); var actualDecalrations = NTriplesIdentifierFilter.GetTypeDeclarations(declarations).ToArray(); if (!actualDecalrations.Any()) { var subjects = declarations.OfType <IUriIdentifierDeclaredElement>().Where(d => d.GetKind() == IdentifierKind.Subject).ToArray(); if (subjects.Any()) { actualDecalrations = subjects; } else { actualDecalrations = new[] { (IUriIdentifierDeclaredElement)declarations.First() }; } } Func <IDeclaration, Pair <IDeclaredElement, Predicate <FindResult> > > selector = e => new Pair <IDeclaredElement, Predicate <FindResult> >(e.DeclaredElement, JetPredicate <FindResult> .True); if (actualDecalrations.Any()) { return(actualDecalrations.Cast <IDeclaration>().Select(selector)); } if (declarations.Any()) { return(declarations.Select(selector)); } } return(new[] { new Pair <IDeclaredElement, Predicate <FindResult> >(element, JetPredicate <FindResult> .True) }); }