/// <summary> /// Checks if a given search match actually points to the given target source /// </summary> /// <returns>True if the SearchMatch does point to the target source.</returns> public static ASResult DeclarationLookupResult(ScintillaControl Sci, int position) { if (!ASContext.Context.IsFileValid || (Sci == null)) { return(null); } // get type at cursor position ASResult result = ASComplete.GetExpressionType(Sci, position); if (result.IsPackage) { return(result); } // open source and show declaration if (!result.IsNull()) { if (result.Member != null && (result.Member.Flags & FlagType.AutomaticVar) > 0) { return(null); } FileModel model = result.InFile ?? ((result.Member != null && result.Member.InFile != null) ? result.Member.InFile : null) ?? ((result.Type != null) ? result.Type.InFile : null); if (model == null || model.FileName == "") { return(null); } ClassModel inClass = result.InClass ?? result.Type; // for Back command int lookupLine = Sci.CurrentLine; int lookupCol = Sci.CurrentPos - Sci.PositionFromLine(lookupLine); ASContext.Panel.SetLastLookupPosition(ASContext.Context.CurrentFile, lookupLine, lookupCol); // open the file if (model != ASContext.Context.CurrentModel) { if (model.FileName.Length > 0 && File.Exists(model.FileName)) { ASContext.MainForm.OpenEditableDocument(model.FileName, false); } else { ASComplete.OpenVirtualFile(model); result.InFile = ASContext.Context.CurrentModel; if (result.InFile == null) { return(null); } if (inClass != null) { inClass = result.InFile.GetClassByName(inClass.Name); if (result.Member != null) { result.Member = inClass.Members.Search(result.Member.Name, 0, 0); } } else if (result.Member != null) { result.Member = result.InFile.Members.Search(result.Member.Name, 0, 0); } } } if ((inClass == null || inClass.IsVoid()) && result.Member == null) { return(null); } Sci = ASContext.CurSciControl; if (Sci == null) { return(null); } int line = 0; string name = null; bool isClass = false; // member if (result.Member != null && result.Member.LineFrom > 0) { line = result.Member.LineFrom; name = result.Member.Name; } // class declaration else if (inClass.LineFrom > 0) { line = inClass.LineFrom; name = inClass.Name; isClass = true; // constructor foreach (MemberModel member in inClass.Members) { if ((member.Flags & FlagType.Constructor) > 0) { line = member.LineFrom; name = member.Name; isClass = false; break; } } } if (line > 0) // select { if (isClass) { ASComplete.LocateMember("(class|interface)", name, line); } else { ASComplete.LocateMember("(function|var|const|get|set|property|[,(])", name, line); } } return(result); } return(null); }