Example #1
0
        internal void Compute_Current_Parameter()
        {
            //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource: computeCurrentParameter");

            int nParameters = this.Parameters.Count;

            if (nParameters == 0)
            {
                this.CurrentParameter = null;
                return;
            }

            //the number of commas in the current line is the index of the current parameter
            SnapshotPoint position = this._applicableToSpan.GetStartPoint(this._subjectBuffer.CurrentSnapshot);
            string        lineStr  = this._subjectBuffer.CurrentSnapshot.GetLineFromPosition(position).GetText();
            //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource: computeCurrentParameter. lineStr=" + lineStr);

            int commaCount = AsmSignature.Count_Commas(lineStr);

            //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource: computeCurrentParameter. commaCount="+ commaCount);

            if (commaCount < nParameters)
            {
                this.CurrentParameter = this.Parameters[commaCount];
            }
            else
            {
                this.CurrentParameter = null;
            }
        }
        private AsmSignature Create_Signature(ITextBuffer textBuffer, AsmSignatureElement signatureElement, ITrackingSpan span)
        {
            int nOperands = signatureElement.Operands.Count;

            Span[] locus = new Span[nOperands];

            StringBuilder sb = new StringBuilder();

            sb.Append(signatureElement.Mnemonic.ToString());
            sb.Append(" ");
            //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource: createSignature: sb=" + sb.ToString());

            for (int i = 0; i < nOperands; ++i)
            {
                int locusStart = sb.Length;
                sb.Append(signatureElement.Get_Operand_Doc(i));
                //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource: createSignature: i="+i+"; sb=" + sb.ToString());
                locus[i] = new Span(locusStart, sb.Length - locusStart);
                if (i < nOperands - 1)
                {
                    sb.Append(", ");
                }
            }

            sb.Append(ArchTools.ToString(signatureElement.Arch));
            AsmSignature sig = new AsmSignature(textBuffer, sb.ToString(), signatureElement.Documentation, null);

            textBuffer.Changed += new EventHandler <TextContentChangedEventArgs>(sig.OnSubjectBufferChanged);

            IList <IParameter> paramList = new List <IParameter>();

            for (int i = 0; i < nOperands; ++i)
            {
                string documentation = AsmSignatureElement.Make_Doc(signatureElement.Operands[i]);
                string operandName   = signatureElement.Get_Operand_Str(i);
                paramList.Add(new AsmParameter(documentation, locus[i], operandName, sig));
            }

            sig.Parameters       = new ReadOnlyCollection <IParameter>(paramList);
            sig.ApplicableToSpan = span;
            sig.Compute_Current_Parameter();
            return(sig);
        }