Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public RegExpAutoCompleteInfo GetAutoCompleteInfo()
 {
     if (this._autoCompleteInfo == null)
     {
         DfaAutoCompleteType none;
         GetAutoCompleteInfoTransitionsProcessingResult autoCompleteInfoTransitionsProcessing = this.GetAutoCompleteInfoTransitionsProcessing();
         if (autoCompleteInfoTransitionsProcessing._NonExactsFound)
         {
             none = DfaAutoCompleteType.None;
         }
         else if (autoCompleteInfoTransitionsProcessing._ExactCharFound)
         {
             if (!this.Contains(this._finalState))
             {
                 none = DfaAutoCompleteType.ExactChar;
             }
             else
             {
                 GetAutoCompleteInfoTransitionsProcessingResult result2 = autoCompleteInfoTransitionsProcessing;
                 RegExpDfaWave nextWave = this;
                 do
                 {
                     nextWave = nextWave.GetNextWave(result2._ExactChar);
                     result2  = nextWave.GetAutoCompleteInfoTransitionsProcessing();
                 }while ((!result2._NonExactsFound && result2._ExactCharFound) && !nextWave.Contains(this._finalState));
                 if (nextWave.Contains(this._finalState))
                 {
                     if (result2._NonExactsFound)
                     {
                         none = DfaAutoCompleteType.FinalOrExactBeforeFinalOrNone;
                     }
                     else
                     {
                         none = DfaAutoCompleteType.FinalOrExactBeforeFinal;
                     }
                 }
                 else
                 {
                     none = DfaAutoCompleteType.FinalOrExactBeforeNone;
                 }
             }
         }
         else
         {
             none = DfaAutoCompleteType.Final;
         }
         this._autoCompleteInfo = new RegExpAutoCompleteInfo(none, autoCompleteInfoTransitionsProcessing._ExactChar);
     }
     return(this._autoCompleteInfo);
 }
Ejemplo n.º 2
0
        string ExactsAppend(string before)
        {
            string text = before;

            while (true)
            {
                RegExpAutoCompleteInfo autoCompleteInfo = this._regExp.GetAutoCompleteInfo(text);
                if (autoCompleteInfo.DfaAutoCompleteType != DfaAutoCompleteType.ExactChar)
                {
                    return(text);
                }
                text = text + autoCompleteInfo.AutoCompleteChar;
            }
        }
Ejemplo n.º 3
0
        string SmartAppend(string before, char input)
        {
            if (!this.IsValidStart(before))
            {
                return(null);
            }
            string text = this.SmartAutoComplete(before);
            RegExpAutoCompleteInfo autoCompleteInfo = this._regExp.GetAutoCompleteInfo(text);

            switch (autoCompleteInfo.DfaAutoCompleteType)
            {
            case DfaAutoCompleteType.None:
                text = text + input;
                break;

            case DfaAutoCompleteType.Final:
                return(null);

            case DfaAutoCompleteType.FinalOrExactBeforeNone:
                text = this.ExactsAppend(text + autoCompleteInfo.AutoCompleteChar) + input;
                break;

            case DfaAutoCompleteType.FinalOrExactBeforeFinal:
                text = text + autoCompleteInfo.AutoCompleteChar;
                break;

            case DfaAutoCompleteType.FinalOrExactBeforeFinalOrNone:
                text = text + autoCompleteInfo.AutoCompleteChar;
                if (input != autoCompleteInfo.AutoCompleteChar)
                {
                    text = this.ExactsAppend(text) + input;
                }
                break;

            default:
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Internal error: non-covered case '{0}'", new object[] { autoCompleteInfo.DfaAutoCompleteType.ToString() }));
            }
            return(this.SmartAutoComplete(text));
        }