Exemple #1
0
        /// <include file='doc\Colorizer.uex' path='docs/doc[@for="Colorizer.GetLineInfo"]/*' />
        public virtual TokenInfo[] GetLineInfo(IVsTextLines buffer, int line, IVsTextColorState colorState)
        {
            int length;

            NativeMethods.ThrowOnFailure(buffer.GetLengthOfLine(line, out length));
            if (length == 0)
            {
                return(null);
            }

            string text;

            NativeMethods.ThrowOnFailure(buffer.GetLineText(line, 0, line, length, out text));

            int state;

            NativeMethods.ThrowOnFailure(colorState.GetColorStateAtStartOfLine(line, out state));

            if (this.cachedLine == line && this.cachedLineText == text &&
                this.cachedLineState == state && this.cachedLineInfo != null)
            {
                return(this.cachedLineInfo);
            }

            // recolorize the line, and cache the results
            this.cachedLineInfo  = null;
            this.cachedLine      = line;
            this.cachedLineText  = text;
            this.cachedLineState = state;

            NativeMethods.ThrowOnFailure(GetColorInfo(text, length, state));

            //now it should be in the cache
            return(this.cachedLineInfo);
        }
Exemple #2
0
        // used by intellisense mechanisms.
        public virtual TokenInfo[] GetLineInfo(int line, IVsTextColorState colorState)
        {
            int length;

            buffer.GetLengthOfLine(line, out length);
            string text;

            buffer.GetLineText(line, 0, line, length, out text);

            int state;

            colorState.GetColorStateAtStartOfLine(line, out state);

            if (this.cachedLine == line && this.cachedLineText == text &&
                this.cachedLineState == state && this.cachedLineInfo != null)
            {
                return(this.cachedLineInfo);
            }

            // recolorize the line, and cache the results
            this.cachedLineInfo  = null;
            this.cachedLine      = line;
            this.cachedLineText  = text;
            this.cachedLineState = state;

            GetColorInfo(text, length, state);

            //now it should be in the cache
            return(this.cachedLineInfo);
        }
Exemple #3
0
        /// <summary>Return colorer lexer state for specified line.</summary>
        private ScanState GetLineState(int line)
        {
            int state;

            ErrorHandler.ThrowOnFailure(
                ColorState.GetColorStateAtStartOfLine(line, out state));
            return((ScanState)state);
        }
Exemple #4
0
        /// <include file='doc\Colorizer.uex' path='docs/doc[@for="Colorizer.GetLineInfo"]/*' />
        public virtual TokenInfo[] GetLineInfo(IVsTextLines buffer, int line, IVsTextColorState colorState)
        {
            int length;

            NativeMethods.ThrowOnFailure(buffer.GetLengthOfLine(line, out length));
            if (length == 0)
            {
                return(null);
            }

            string text;

            NativeMethods.ThrowOnFailure(buffer.GetLineText(line, 0, line, length, out text));

            int state;

            NativeMethods.ThrowOnFailure(colorState.GetColorStateAtStartOfLine(line, out state));

            if (this.cachedLine == line && this.cachedLineText == text &&
                this.cachedLineState == state && this.cachedLineInfo != null)
            {
                return(this.cachedLineInfo);
            }

            // recolorize the line, and cache the results
            this.cachedLineInfo  = null;
            this.cachedLine      = line;
            this.cachedLineText  = text;
            this.cachedLineState = state;

            // GetColorInfo will update the cache. Note that here we don't use NativeMethods.ThrowOnFailure
            // because the return code is the current parsing state, not an HRESULT.
            GetColorInfo(text, length, state);

            //now it should be in the cache
            return(this.cachedLineInfo);
        }
Exemple #5
0
        /// <include file='doc\Colorizer.uex' path='docs/doc[@for="Colorizer.GetLineInfo"]/*' />
        public virtual TokenInfo[] GetLineInfo(IVsTextLines buffer, int line, IVsTextColorState colorState) {

            int length;

            NativeMethods.ThrowOnFailure(buffer.GetLengthOfLine(line, out length));
            if (length == 0)
                return null;

            string text;

            NativeMethods.ThrowOnFailure(buffer.GetLineText(line, 0, line, length, out text));

            int state;

            NativeMethods.ThrowOnFailure(colorState.GetColorStateAtStartOfLine(line, out state));

            if (this.cachedLine == line && this.cachedLineText == text &&
                this.cachedLineState == state && this.cachedLineInfo != null) {
                return this.cachedLineInfo;
            }

            // recolorize the line, and cache the results
            this.cachedLineInfo = null;
            this.cachedLine = line;
            this.cachedLineText = text;
            this.cachedLineState = state;

            NativeMethods.ThrowOnFailure(GetColorInfo(text, length, state));

            //now it should be in the cache
            return this.cachedLineInfo;
        }
        /// <include file='doc\Colorizer.uex' path='docs/doc[@for="Colorizer.GetLineInfo"]/*' />
        public virtual TokenInfo[] GetLineInfo(IVsTextLines buffer, int line, IVsTextColorState colorState)
        {
            int length;

            NativeMethods.ThrowOnFailure(buffer.GetLengthOfLine(line, out length));
            if (length == 0)
                return null;

            string text;

            NativeMethods.ThrowOnFailure(buffer.GetLineText(line, 0, line, length, out text));

            int state;

            NativeMethods.ThrowOnFailure(colorState.GetColorStateAtStartOfLine(line, out state));

            if (this.cachedLine == line && this.cachedLineText == text &&
                this.cachedLineState == state && this.cachedLineInfo != null) {
                return this.cachedLineInfo;
            }

            // recolorize the line, and cache the results
            this.cachedLineInfo = null;
            this.cachedLine = line;
            this.cachedLineText = text;
            this.cachedLineState = state;

            // GetColorInfo will update the cache. Note that here we don't use NativeMethods.ThrowOnFailure
            // because the return code is the current parsing state, not an HRESULT.
            GetColorInfo(text, length, state);

            //now it should be in the cache
            return this.cachedLineInfo;
        }
Exemple #7
0
    // used by intellisense mechanisms.
    public virtual TokenInfo[] GetLineInfo(int line, IVsTextColorState colorState) {
      
      int length;
      buffer.GetLengthOfLine(line, out length);
      string text;
      buffer.GetLineText(line, 0, line, length, out text);
      
      int state;
      colorState.GetColorStateAtStartOfLine(line, out state);

      if (this.cachedLine == line && this.cachedLineText == text && 
          this.cachedLineState == state && this.cachedLineInfo != null) {
        return this.cachedLineInfo;
      }

      // recolorize the line, and cache the results
      this.cachedLineInfo = null;
      this.cachedLine = line;
      this.cachedLineText = text;
      this.cachedLineState = state;

      GetColorInfo(text, length, state);

      //now it should be in the cache
      return this.cachedLineInfo;
    }