public static void SortImports(Document doc = null) { doc = doc ?? IdeApp.Workbench.ActiveDocument; if (doc == null) { return; } var ddoc = doc.ParsedDocument as ParsedDModule; if (ddoc == null || ddoc.DDom == null) { return; } var scope = DResolver.SearchBlockAt(ddoc.DDom, new CodeLocation(doc.Editor.Caret.Column, doc.Editor.Caret.Line)) as DBlockNode; if (scope == null) { return; } var editor = doc.Editor; using (editor.Document.OpenUndoGroup(Mono.TextEditor.OperationType.Undefined)) { SortImportsRefactoring.SortImports(scope, new TextDocumentAdapter(editor), SortImportsSeparatePackagesFromEachOther); } editor.Parent.TextViewMargin.PurgeLayoutCache(); editor.Parent.QueueDraw(); }
public IEnumerable <DModule> GetImportableModulesForLastResults() { var nodesToChooseFrom = new List <DModule> (); if (lastResults == null || lastResults.Length < 1) { return(nodesToChooseFrom); } foreach (var res in lastResults) { var n = DResolver.GetResultMember(res, true); if (n != null) { var mod = n.NodeRoot as DModule; if (mod != null && !nodesToChooseFrom.Contains(mod)) { var i = Math.Max(0, nodesToChooseFrom.Count - 1); foreach (var packageMod in TryGetGenericImportingPackageForSymbol(n)) { if (!nodesToChooseFrom.Contains(packageMod)) { nodesToChooseFrom.Insert(i, packageMod); } } nodesToChooseFrom.Add(mod); } } } return(nodesToChooseFrom); }
public static AbstractTooltipContent[] BuildToolTip(IEditorData Editor) { try { var ctxt = ResolverContextStack.Create(Editor); // In the case we've got a method or something, don't return its base type, only the reference to it ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly; var rr = DResolver.ResolveType(Editor, ctxt, DResolver.AstReparseOptions.AlsoParseBeyondCaret); if (rr.Length < 1) { return(null); } var l = new List <AbstractTooltipContent>(rr.Length); foreach (var res in rr) { l.Add(BuildTooltipContent(res)); } return(l.ToArray()); } catch { } return(null); }
ISemantic E(TemplateInstanceExpression tix, bool ImplicitlyExecute = true) { var o = DResolver.StripAliasSymbols(GetOverloads(tix, ctxt)); if (eval) { return(TryDoCTFEOrGetValueRefs(o, tix, ImplicitlyExecute)); } else { ctxt.CheckForSingleResult(o, tix); if (o != null) { if (o.Length == 1) { return(o[0]); } else if (o.Length > 1) { return(new InternalOverloadValue(o, tix)); } } return(null); } }
public void IncrementalParsing_LambdaParameters() { var code = @"module A; int foo; void main() { }"; var m = DParser.ParseString(code); var main = m ["main"].First() as DMethod; var foo = m ["foo"].First() as DVariable; var b = DResolver.SearchBlockAt(m, new CodeLocation(1, 4)); Assert.That(b, Is.SameAs(main)); code = @"module A; int foo; void main() { int a; (string ; }"; var caret = new CodeLocation(9, 5); bool _u; var newMod = IncrementalParsing.UpdateBlockPartly(main.Body, code, DocumentHelper.LocationToOffset(code, caret), caret, out _u) as DMethod; var lambda = newMod.Children [0] as DMethod; Assert.That(lambda, Is.Not.Null); Assert.That(lambda.Parameters.Count, Is.EqualTo(1)); Assert.That(lambda.Parameters [0].Type, Is.Not.Null); Assert.That(lambda.Parameters [0].NameHash, Is.EqualTo(DTokens.IncompleteIdHash)); }
public static IEnumerable <TemplateIntermediateType> SearchForClassDerivatives(TemplateIntermediateType t, ResolutionContext ctxt) { if (!(t is ClassType || t is InterfaceType)) { throw new ArgumentException("t должно быть классом или интерфейсом, но не " + (t != null ? t.ToString() : "null")); } var f = new ClassInterfaceDerivativeFinder(ctxt); f.typeNodeToFind = t.Definition; var bt = t; while (bt != null) { f.alreadyResolvedClasses.Add(bt.Definition); bt = DResolver.StripMemberSymbols(bt.Base) as TemplateIntermediateType; } var filter = MemberFilter.Classes; if (t is InterfaceType) // -> Only interfaces can inherit interfaces. Interfaces cannot be subclasses of classes. { filter |= MemberFilter.Interfaces; } f.IterateThroughScopeLayers(t.Definition.Location, filter); return(f.results); // return them. }
public static TooltipInformation Generate(AbstractType t, int currentParameter = -1, bool isInTemplateArgInsight = false) { var ms = t as MemberSymbol; if (ms != null) { if (ms.Definition is DVariable) { var bt = DResolver.StripAliasSymbol(ms.Base); if (bt is DelegateType) { return(TooltipInfoGenerator.Generate(bt as DelegateType, currentParameter)); } } else if (ms.Definition is DMethod) { return(TooltipInfoGenerator.Generate(ms.Definition as DMethod, isInTemplateArgInsight, currentParameter)); } } else if (t is TemplateIntermediateType) { return(Generate(t as TemplateIntermediateType, currentParameter)); } return(new TooltipInformation()); }
public static string GeneratePrototype(AbstractType t, int currentParameter = -1, bool isInTemplateArgInsight = false) { var ms = t as MemberSymbol; if (ms != null) { if (ms.Definition is DVariable) { var bt = DResolver.StripAliasSymbol(ms.Base); if (bt is DelegateType) { return(VDServerCompletionDataGenerator.GeneratePrototype(bt as DelegateType, currentParameter)); } } else if (ms.Definition is DMethod) { return(VDServerCompletionDataGenerator.GeneratePrototype(ms.Definition as DMethod, isInTemplateArgInsight, currentParameter)); } } else if (t is TemplateIntermediateType) { return(VDServerCompletionDataGenerator.GeneratePrototype(t as TemplateIntermediateType, currentParameter)); } return(null); }
/// <summary> /// http://dlang.org/expression.html#IsExpression /// </summary> public ISemantic E(IsExpression isExpression) { if (!eval) { return(new PrimitiveType(DTokens.Bool)); } bool retTrue = false; if (isExpression.TestedType != null) { var typeToCheck = DResolver.StripMemberSymbols(TypeDeclarationResolver.ResolveSingle(isExpression.TestedType, ctxt)); if (typeToCheck != null) { // case 1, 4 if (isExpression.TypeSpecialization == null && isExpression.TypeSpecializationToken == 0) { retTrue = true; } // The probably most frequented usage of this expression else if (isExpression.TypeAliasIdentifierHash == 0) { retTrue = evalIsExpression_NoAlias(isExpression, typeToCheck); } else { retTrue = evalIsExpression_WithAliases(isExpression, typeToCheck); } } } return(new PrimitiveValue(DTokens.Bool, retTrue?1:0, isExpression)); }
public void GetTip(string filename, int startLine, int startIndex, int endLine, int endIndex) { var ast = GetModule(filename); if (ast == null) { throw new COMException("module not found", 1); } _tipStart = new CodeLocation(startIndex + 1, startLine); _tipEnd = new CodeLocation(startIndex + 2, startLine); _tipText.Clear(); _setupEditorData(); _editorData.CaretLocation = _tipStart; _editorData.SyntaxTree = ast as DModule; _editorData.ModuleCode = _sources[filename]; // codeOffset+1 because otherwise it does not work on the first character _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, _tipStart) + 1; DResolver.NodeResolutionAttempt attempt; var types = DResolver.ResolveTypeLoosely(_editorData, out attempt); _tipText.Clear(); if (types != null) { if (types.DeclarationOrExpressionBase != null) { _tipStart = types.DeclarationOrExpressionBase.Location; _tipEnd = types.DeclarationOrExpressionBase.EndLocation; } DNode dn = null; foreach (var t in AmbiguousType.TryDissolve(types)) { _tipText.Append(NodeToolTipContentGen.Instance.GenTooltipSignature(t)).Append("\a"); if (t is DSymbol) { dn = (t as DSymbol).Definition; } } while (_tipText.Length > 0 && _tipText[_tipText.Length - 1] == '\a') { _tipText.Length--; } if (dn != null) { VDServerCompletionDataGenerator.GenerateNodeTooltipBody(dn, _tipText); } while (_tipText.Length > 0 && _tipText[_tipText.Length - 1] == '\a') { _tipText.Length--; } } }
protected override void BuildCompletionDataInternal(IEditorData Editor, char enteredChar) { var dc = begunNode.Parent as DClassLike; if (dc == null || dc.ClassType != DTokens.Class) { return; } var classType = DResolver.ResolveClassOrInterface(dc, ResolutionContext.Create(Editor), null) as TemplateIntermediateType; if (classType == null) { return; } var typesToScan = new List <TemplateIntermediateType>(); IterateThroughBaseClassesInterfaces(typesToScan, classType); foreach (var t in typesToScan) { foreach (var n in t.Definition) { var dm = n as DMethod; if (dm == null || dm.ContainsAttribute(DTokens.Final, DTokens.Private, DTokens.Static)) { continue; //TODO: Other attributes? } CompletionDataGenerator.AddCodeGeneratingNodeItem(dm, GenerateOverridingMethodStub(dm, begunNode, !(t is InterfaceType))); } } }
public AbstractType TryDeduce(DSymbol ds, IEnumerable <ISemantic> templateArguments, ref INode returnedNode) { var cls = ds as ClassType; if (cls == null || templateArguments == null) { return(null); } var en = templateArguments.GetEnumerator(); if (!en.MoveNext()) { return(null); } returnedNode = cls.Definition; var baseClass = DResolver.StripMemberSymbols(AbstractType.Get(en.Current)) as TemplateIntermediateType; if (baseClass == null) { return(ds); } return(new ClassType(cls.Definition, ds.DeclarationOrExpressionBase, baseClass as ClassType, baseClass is InterfaceType ? new[] { baseClass as InterfaceType } : null, ds.DeducedTypes)); }
public static StaticProperty TryEvalPropertyType(ResolutionContext ctxt, AbstractType t, int propName, bool staticOnly = false) { if (t is PointerType) { t = (t as PointerType).Base; } t = DResolver.StripMemberSymbols(t); if (t is PointerType) { t = (t as PointerType).Base; } if (t == null) { return(null); } var props = Properties[PropOwnerType.Generic]; StaticPropertyInfo prop; if (props.TryGetValue(propName, out prop) || (Properties.TryGetValue(GetOwnerType(t), out props) && props.TryGetValue(propName, out prop))) { var n = prop.GenerateRepresentativeNode(t); return(new StaticProperty(n, n.Type != null ? TypeDeclarationResolver.ResolveSingle(n.Type, ctxt) : null, prop.ValueGetter)); } return(null); }
public static AbstractType[] GetOverloads(IdentifierExpression id, ResolverContextStack ctxt) { var raw = TypeDeclarationResolver.ResolveIdentifier(id.Value as string, ctxt, id, id.ModuleScoped); var f = DResolver.FilterOutByResultPriority(ctxt, raw); return(f == null ? null : f.ToArray()); }
public void GetDefinition(string filename, int startLine, int startIndex, int endLine, int endIndex) { filename = normalizePath(filename); var ast = GetModule(filename); if (ast == null) { throw new COMException("module not found", 1); } _tipStart = new CodeLocation(startIndex + 1, startLine); _tipEnd = new CodeLocation(endIndex + 1, endLine); _tipText.Clear(); _setupEditorData(); _editorData.CaretLocation = _tipEnd; _editorData.SyntaxTree = ast as DModule; _editorData.ModuleCode = _sources[filename]; // codeOffset+1 because otherwise it does not work on the first character _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, _tipStart) + 2; ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData); LooseResolution.NodeResolutionAttempt attempt; var rr = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt, true) : null; _tipText.Clear(); if (rr != null) { var n = DResolver.GetResultMember(rr, true); if (n == null) { return; } bool decl = false; var mthd = n as DMethod; if (mthd != null) { decl = mthd.Body == null; } else if (n.ContainsAttribute(DTokens.Extern)) { decl = true; } if (decl) { _tipText.Append("EXTERN:"); } _tipStart = n.Location; _tipEnd = n.EndLocation; INode node = n.NodeRoot; if (node is DModule) { _tipText.Append((node as DModule).FileName); } } }
public static AbstractType[] ResolveHoveredCode(out ResolutionContext ResolverContext, IEditorData edData) { ResolverContext = ResolutionContext.Create(edData, false); // Resolve the hovered piece of code return(AmbiguousType.TryDissolve(DResolver.ResolveType(edData, ctxt: ResolverContext)).ToArray()); }
void FindDerivedClassesThread(object s) { var monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true); monitor.BeginStepTask(GettextCatalog.GetString("Find Derived Classes"), lastResults.Length, 1); foreach (var t in lastResults) { var t_ = DResolver.StripMemberSymbols(t); if (!(t_ is ClassType || t_ is InterfaceType)) { monitor.Step(1); continue; } foreach (var res in ClassInterfaceDerivativeFinder.SearchForClassDerivatives(t_ as TemplateIntermediateType, ctxt)) { var dc = res.Definition; var file = (dc.NodeRoot as DModule).FileName; var targetDoc = TextFileProvider.Instance.GetTextEditorData(new FilePath(file)); monitor.ReportResult(new SearchResult(new FileProvider(file, IdeApp.Workspace.GetProjectContainingFile(file)), targetDoc.LocationToOffset(dc.NameLocation.Line, dc.NameLocation.Column), dc.Name.Length)); } monitor.Step(1); } monitor.EndTask(); monitor.Dispose(); }
protected override string Process(EditorData editorData, bool moduleOnly) { var sr = DResolver.GetScopedCodeObject(editorData); var rr = sr != null?LooseResolution.ResolveTypeLoosely(editorData, sr, out _, true) : null; var refs = new StringBuilder(); if (rr != null) { var n = ExpressionTypeEvaluation.GetResultMember(rr); if (n != null) { var ctxt = ResolutionContext.Create(editorData, true); if (moduleOnly || n.ContainsAnyAttribute(DTokens.Private) || (n is DVariable variable && variable.IsLocal)) { GetReferencesInModule(editorData.SyntaxTree, refs, n, ctxt); } else { foreach (var rootPackage in editorData.ParseCache.EnumRootPackagesSurroundingModule(editorData.SyntaxTree)) { foreach (var module in rootPackage) { GetReferencesInModule(module, refs, n, ctxt); } } } } //var res = TypeReferenceFinder.Scan(_editorData, System.Threading.CancellationToken.None, null); }
AbstractType HandleAccessExpressions(PostfixExpression_Access acc, ResolutionContext ctxt) { AbstractType pfType = null; if (acc.PostfixForeExpression is PostfixExpression_Access) { pfType = HandleAccessExpressions((PostfixExpression_Access)acc.PostfixForeExpression, ctxt); } else { pfType = DResolver.StripAliasSymbol(Evaluation.EvaluateType(acc.PostfixForeExpression, ctxt)); if (acc.PostfixForeExpression is IdentifierExpression || acc.PostfixForeExpression is TemplateInstanceExpression || acc.PostfixForeExpression is PostfixExpression_Access) { HandleResult(acc.PostfixForeExpression, pfType); } } var accessedMembers = Evaluation.GetAccessedOverloads(acc, ctxt, pfType); ctxt.CheckForSingleResult(accessedMembers, acc); if (accessedMembers != null && accessedMembers.Length != 0) { HandleResult(acc, accessedMembers[0]); return(accessedMembers[0]); } return(null); }
public static AbstractType[] GetOverloads(IdentifierExpression id, ResolutionContext ctxt, IEnumerable <AbstractType> resultBases = null, bool deduceParameters = true) { AbstractType[] res; if (resultBases == null) { res = TypeDeclarationResolver.ResolveIdentifier(id.ValueStringHash, ctxt, id, id.ModuleScoped); } else { res = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(id.ValueStringHash, resultBases, ctxt, id); } if (res == null) { return(null); } var f = DResolver.FilterOutByResultPriority(ctxt, res); if (f.Count == 0) { return(null); } return((ctxt.Options & ResolutionOptions.NoTemplateParameterDeduction) == 0 && deduceParameters? TemplateInstanceHandler.DeduceParamsAndFilterOverloads(f, null, false, ctxt) : f.ToArray()); }
bool HandleDecl(TemplateTypeParameter p, IdentifierDeclaration id, ISemantic r) { // Bottom-level reached if (id.InnerDeclaration == null && Contains(id.IdHash) && !id.ModuleScoped) { // Associate template param with r return(Set((p != null && id.IdHash == p.NameHash) ? p : null, r, id.IdHash)); } var deducee = DResolver.StripMemberSymbols(AbstractType.Get(r)) as DSymbol; if (id.InnerDeclaration != null && deducee != null && deducee.Definition.NameHash == id.IdHash) { var physicalParentType = TypeDeclarationResolver.HandleNodeMatch(deducee.Definition.Parent, ctxt, null, id.InnerDeclaration); if (HandleDecl(p, id.InnerDeclaration, physicalParentType)) { if (Contains(id.IdHash)) { Set((p != null && id.IdHash == p.NameHash) ? p : null, deducee, id.IdHash); } return(true); } } /* * If not stand-alone identifier or is not required as template param, resolve the id and compare it against r */ var _r = TypeDeclarationResolver.ResolveSingle(id, ctxt); return(_r != null && (EnforceTypeEqualityWhenDeducing ? ResultComparer.IsEqual(r, _r) : ResultComparer.IsImplicitlyConvertible(r, _r))); }
public string ResolveExpression(TextEditorData ed, Document doc, int offset, out int startOffset) { startOffset = offset; var editorData = DResolverWrapper.CreateEditorData(doc); if (editorData == null) { return(null); } editorData.CaretOffset = offset; var edLoc = ed.OffsetToLocation(offset); editorData.CaretLocation = new CodeLocation(edLoc.Column, edLoc.Line); var o = DResolver.GetScopedCodeObject(editorData); if (o != null) { startOffset = ed.LocationToOffset(o.Location.Line, o.Location.Column); if (o is INode) { return((o as INode).Name); } return(o.ToString()); } return(null); }
ISemantic E(PostfixExpression ex) { if (ex is PostfixExpression_MethodCall) { return(E((PostfixExpression_MethodCall)ex, !ctxt.Options.HasFlag(ResolutionOptions.ReturnMethodReferencesOnly))); } var foreExpr = E(ex.PostfixForeExpression); if (foreExpr is AliasedType) { foreExpr = DResolver.StripAliasSymbol((AbstractType)foreExpr); } if (foreExpr == null) { if (eval) { return(null); } else { ctxt.LogError(new NothingFoundError(ex.PostfixForeExpression)); return(null); } } if (ex is PostfixExpression_Access) { var r = E((PostfixExpression_Access)ex, foreExpr, true); ctxt.CheckForSingleResult(r, ex); return(r != null && r.Length != 0 ? r[0] : null); } else if (ex is PostfixExpression_Increment) { return(E((PostfixExpression_Increment)ex, foreExpr)); } else if (ex is PostfixExpression_Decrement) { return(E((PostfixExpression_Decrement)foreExpr)); } // myArray[0]; myArray[0..5]; // opIndex/opSlice ? if (foreExpr is MemberSymbol) { foreExpr = DResolver.StripMemberSymbols((AbstractType)foreExpr); } if (ex is PostfixExpression_Slice) { return(E((PostfixExpression_Slice)ex, foreExpr)); } else if (ex is PostfixExpression_Index) { return(E((PostfixExpression_Index)ex, foreExpr)); } return(null); }
protected override void Update(CommandArrayInfo info) { ResolverContextStack ctxt; var rr = Resolver.DResolverWrapper.ResolveHoveredCode(out ctxt); bool noRes = true; if (rr != null && rr.Length > 0) { res = rr[rr.Length - 1]; n = DResolver.GetResultMember(res); if (n != null) { noRes = false; info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.GotoDeclaration), new Action(GotoDeclaration)); info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.FindReferences), new Action(FindReferences)); if (RenamingRefactoring.CanRename(n)) { info.AddSeparator(); info.Add(IdeApp.CommandService.GetCommandInfo(EditCommands.Rename), new Action(RenameSymbol)); } } } if (noRes) { info.Add(IdeApp.CommandService.GetCommandInfo(RefactoryCommands.ImportSymbol), new Action(ImportSymbol)); } info.Add(IdeApp.CommandService.GetCommandInfo(Commands.OpenDDocumentation), new Action(OpenDDoc)); }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength) { if (!(triggerChar == ' ' || char.IsLetter(triggerChar) || triggerChar == '_' || triggerChar == '.' || triggerChar == '\0')) { return(null); } else if ((char.IsLetter(triggerChar) && !DResolver.IsTypeIdentifier(Document.Editor.Text, Document.Editor.Caret.Offset))) { return(null); } triggerWordLength = DCodeCompletionSupport.IsIdentifierChar(triggerChar) ? 1 : 0; // Require a parsed D source var dom = base.Document.ParsedDocument as ParsedDModule; if (dom == null) { return(null); } // Check if in comment or string literal if (DResolver.CommentSearching.IsInCommentAreaOrString(Document.Editor.Text, completionContext.TriggerOffset)) { return(null); } var l = new CompletionDataList(); DCodeCompletionSupport.BuildCompletionData(Document, dom.DDom, completionContext, l, triggerChar == '\0'?"":triggerChar.ToString()); return(l); }
public bool HandleDecl(TemplateTypeParameter p, ITypeDeclaration td, ISemantic rr) { if (td is IdentifierDeclaration) { return(HandleDecl(p, (IdentifierDeclaration)td, rr)); } if (TemplateInstanceHandler.IsNonFinalArgument(rr)) { foreach (var tp in this.TargetDictionary.Keys.ToList()) { if (TargetDictionary[tp] == null) { TargetDictionary[tp] = new TemplateParameterSymbol(tp, null); } } return(true); } //HACK Ensure that no information gets lost by using this function // -- getting a value but requiring an abstract type and just extract it from the value - is this correct behaviour? var at = AbstractType.Get(rr); if (td is ArrayDecl) { return(HandleDecl(p, (ArrayDecl)td, DResolver.StripMemberSymbols(at) as AssocArrayType)); } else if (td is DTokenDeclaration) { return(HandleDecl((DTokenDeclaration)td, at)); } else if (td is DelegateDeclaration) { return(HandleDecl(p, (DelegateDeclaration)td, DResolver.StripMemberSymbols(at) as DelegateType)); } else if (td is PointerDecl) { return(HandleDecl(p, (PointerDecl)td, DResolver.StripMemberSymbols(at) as PointerType)); } else if (td is MemberFunctionAttributeDecl) { return(HandleDecl(p, (MemberFunctionAttributeDecl)td, at)); } else if (td is TypeOfDeclaration) { return(HandleDecl((TypeOfDeclaration)td, at)); } else if (td is VectorDeclaration) { return(HandleDecl((VectorDeclaration)td, at)); } else if (td is TemplateInstanceExpression) { return(HandleDecl(p, (TemplateInstanceExpression)td, at)); } return(false); }
public static ResolutionContext Create(IEditorData editor, ConditionalCompilationFlags globalConditions = null) { IStatement stmt; return(new ResolutionContext(editor.ParseCache, globalConditions ?? new ConditionalCompilationFlags(editor), DResolver.SearchBlockAt(editor.SyntaxTree, editor.CaretLocation, out stmt) ?? editor.SyntaxTree, stmt)); }
bool IterateThrough(DClassLike cls, MemberFilter VisibleMembers, ref bool breakOnNextScope) { var curWatchedClass = cls; // MyClass > BaseA > BaseB > Object while (curWatchedClass != null) { if (curWatchedClass.TemplateParameters != null && (breakOnNextScope = HandleItems(curWatchedClass.TemplateParameterNodes as IEnumerable <INode>)) && breakImmediately) { return(true); } var ch = PrefilterSubnodes(curWatchedClass); if (ch != null) { foreach (var m in ch) { var dm2 = m as DNode; var dm3 = m as DMethod; // Only show normal & delegate methods if (!CanAddMemberOfType(VisibleMembers, m) || dm2 == null || (dm3 != null && !(dm3.SpecialType == DMethod.MethodType.Normal || dm3.SpecialType == DMethod.MethodType.Delegate))) { continue; } // Add static and non-private members of all base classes; // Add everything if we're still handling the currently scoped class if ((curWatchedClass == cls || dm2.IsStatic || (!(m is DVariable) || ((DVariable)dm2).IsConst) || !dm2.ContainsAttribute(DTokens.Private)) && (breakOnNextScope = HandleItem(m)) && breakImmediately) { return(true); } } } // 3) if (cls.ClassType == DTokens.Class) { var tr = DResolver.ResolveBaseClasses(new ClassType(curWatchedClass, curWatchedClass, null), ctxt, true); if (tr.Base is TemplateIntermediateType) { curWatchedClass = ((TemplateIntermediateType)tr.Base).Definition; } else { break; } } else { break; } } return(false); }
public void GetReferences(string filename, string tok, uint line, uint idx, string expr) { filename = normalizePath(filename); var ast = GetModule(filename); if (ast == null) { throw new COMException("module not found", 1); } _request = Request.References; _result = "__pending__"; Action dg = () => { _setupEditorData(); CodeLocation loc = new CodeLocation((int)idx + 1, (int)line); _editorData.CaretLocation = loc; _editorData.SyntaxTree = ast as DModule; _editorData.ModuleCode = _sources[filename]; _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, loc); ISyntaxRegion sr = DResolver.GetScopedCodeObject(_editorData); LooseResolution.NodeResolutionAttempt attempt; var rr = sr != null?LooseResolution.ResolveTypeLoosely(_editorData, sr, out attempt, true) : null; StringBuilder refs = new StringBuilder(); if (rr != null) { var n = DResolver.GetResultMember(rr, true); if (n != null) { var ctxt = ResolutionContext.Create(_editorData, true); if (n.ContainsAttribute(DTokens.Private) || ((n is DVariable) && (n as DVariable).IsLocal)) { GetReferencesInModule(ast, refs, n, ctxt); } else { foreach (var basePath in _imports.Split(nlSeparator, StringSplitOptions.RemoveEmptyEntries)) { foreach (var mod in GlobalParseCache.EnumModulesRecursively(basePath)) { GetReferencesInModule(mod, refs, n, ctxt); } } } } //var res = TypeReferenceFinder.Scan(_editorData, System.Threading.CancellationToken.None, null); } if (!_editorData.CancelToken.IsCancellationRequested && _request == Request.References) { _result = refs.ToString(); } }; }
public override void VisitChildren(IBlockNode block) { var ch = DResolver.SearchRegionAt <INode>(block.Children, caret); if (ch != null && ch != block) { ch.Accept(this); } }