Example #1
0
 /// <summary>
 /// Selects the text specified in the action point
 /// </summary>
 public static void ExecuteActionPoint(ActionPoint point, ScintillaNet.ScintillaControl sci)
 {
     if (point.EntryPosition != -1 && point.ExitPosition != -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         Int32 end = sci.MBSafePosition(point.ExitPosition);
         sci.SetSel(start, end);
     }
     else if (point.EntryPosition != -1 && point.ExitPosition == -1)
     {
         Int32 start = sci.MBSafePosition(point.EntryPosition);
         sci.SetSel(start, start);
     }
 }
Example #2
0
 /// <summary>
 /// Processes the snippet and template arguments
 /// </summary>
 public static Int32 PostProcessSnippets(ScintillaNet.ScintillaControl sci, Int32 currentPosition)
 {
     Int32 delta = 0;
     while (sci.SelectText(BOUNDARY, 0) != -1) { sci.ReplaceSel(""); delta -= BOUNDARY.Length; }
     String text = sci.Text; // Store text temporarily
     Int32 entryPosition = sci.MBSafePosition(text.IndexOf(ENTRYPOINT));
     Int32 exitPosition = sci.MBSafePosition(text.IndexOf(EXITPOINT));
     if (entryPosition != -1 && exitPosition != -1)
     {
         sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
         sci.SelectText(EXITPOINT, 0); sci.ReplaceSel(""); delta -= EXITPOINT.Length;
         sci.SetSel(entryPosition, exitPosition - ENTRYPOINT.Length);
     }
     else if (entryPosition != -1 && exitPosition == -1)
     {
         sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
         sci.SetSel(entryPosition, entryPosition);
     }
     else sci.SetSel(currentPosition, currentPosition);
     return delta;
 }
 /// <summary>
 /// Checks if the given match actually is the declaration.
 /// </summary>
 public static bool IsMatchTheTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target)
 {
     if (Sci == null || target == null || target.InFile == null || target.Member == null)
     {
         return false;
     }
     String originalFile = Sci.FileName;
     // get type at match position
     ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
     return (declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)));
 }
        /// <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 bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
        {
            if (Sci == null || target == null) return false;
            FileModel targetInFile = null;

            if (target.InFile != null)
                targetInFile = target.InFile;
            else if (target.Member != null && target.InClass == null)
                targetInFile = target.Member.InFile;

            Boolean matchMember = targetInFile != null && target.Member != null;
            Boolean matchType = target.Member == null && target.IsStatic && target.Type != null;
            if (!matchMember && !matchType) return false;

            ASResult result = null;
            // get type at match position
            if (match.Index < Sci.Text.Length) // TODO: find out rare cases of incorrect index reported
            {
                result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
                if (associatedDocumentHelper != null)
                {
                    // because the declaration lookup opens a document, we should register it with the document helper to be closed later
                    associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
                }
            }
            // check if the result matches the target
            if (result == null || (result.InFile == null && result.Type == null)) return false;
            if (matchMember)
            {
                if (result.Member == null) return false;

                var resultInFile = result.InClass != null ? result.InFile : result.Member.InFile;

                return resultInFile.BasePath == targetInFile.BasePath
                    && resultInFile.FileName == targetInFile.FileName
                    && result.Member.LineFrom == target.Member.LineFrom
                    && result.Member.Name == target.Member.Name;
            }
            else // type
            {
                if (result.Type == null) return false;
                if (result.Type.QualifiedName == target.Type.QualifiedName) return true;
                return false;
            }
        }
Example #5
0
 public void GotoPosAndFocus(ScintillaNet.ScintillaControl sci, int position)
 {
     int pos = sci.MBSafePosition(position);
     int line = sci.LineFromPosition(pos);
     sci.EnsureVisible(line);
     sci.GotoPos(pos);
 }
 /// <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>
 static public bool DoesMatchPointToTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target, DocumentHelper associatedDocumentHelper)
 {
     if (Sci == null || target == null || target.inFile == null || target.Member == null)
     {
         return false;
     }
     // get type at match position
     ASResult result = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
     if (associatedDocumentHelper != null)
     {
         // because the declaration lookup opens a document, we should register it with the document helper to be closed later
         associatedDocumentHelper.RegisterLoadedDocument(PluginBase.MainForm.CurrentDocument);
     }
     // check if the result matches the target
     // TODO: this method of checking their equality seems pretty crude -- is there a better way?
     if (result == null || result.inFile == null || result.Member == null)
     {
         return false;
     }
     Boolean doesMatch = result.inFile.BasePath == target.inFile.BasePath && result.inFile.FileName == target.inFile.FileName && result.Member.LineFrom == target.Member.LineFrom && result.Member.Name == target.Member.Name;
     return (doesMatch);
 }