本文整理汇总了C#中Microsoft.VisualStudio.Package.ParseRequest类的典型用法代码示例。如果您正苦于以下问题:C# ParseRequest类的具体用法?C# ParseRequest怎么用?C# ParseRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseRequest类属于Microsoft.VisualStudio.Package命名空间,在下文中一共展示了ParseRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSource
}//OnIdle
public override AuthoringScope ParseSource( ParseRequest req )
{
var dirty = (req.DirtySpan.iStartLine != req.DirtySpan.iEndLine) || (req.DirtySpan.iStartIndex != req.DirtySpan.iEndIndex);
BeeSource src = null;
if( (dirty || (req.Reason == ParseReason.None)) || (req.Reason == ParseReason.Check) )
{
src = ((BeeSource)GetSource( req.FileName ));
try
{
}
catch( ParseError err )
{
req.Sink.AddError( req.FileName, err.Message, new TextSpan() {
iStartLine = err.Lnum,
iStartIndex = err.At,
iEndLine = err.Lnum,
iEndIndex = err.End
}, Severity.Fatal );
}
catch
{
}
}
return new BeeScope( src );
}//ParseSource
示例2: ParseSource
public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(ParseRequest req)
{
Babel.Source source = (Babel.Source)this.GetSource(req.FileName);
bool yyparseResult = false;
// req.DirtySpan seems to be set even though no changes have occurred
// source.IsDirty also behaves strangely
// might be possible to use source.ChangeCount to sync instead
if (req.DirtySpan.iStartIndex != req.DirtySpan.iEndIndex
|| req.DirtySpan.iStartLine != req.DirtySpan.iEndLine) {
ErrorHandler handler = new ErrorHandler();
Scanner scanner = new Scanner(); // string interface
Parser parser = new Parser(); // use noarg constructor
parser.scanner = scanner;
scanner.Handler = handler;
parser.SetHandler(handler);
scanner.SetSource(req.Text, 0);
parser.MBWInit(req);
yyparseResult = parser.Parse();
// store the parse results
// source.ParseResult = aast;
source.ParseResult = null;
source.Braces = parser.Braces;
// for the time being, just pull errors back from the error handler
if (handler.ErrNum > 0) {
foreach (Babel.Parser.Error error in handler.SortedErrorList()) {
TextSpan span = new TextSpan();
span.iStartLine = span.iEndLine = error.line - 1;
span.iStartIndex = error.column;
span.iEndIndex = error.column + error.length;
req.Sink.AddError(req.FileName, error.message, span, Severity.Error);
}
}
}
switch (req.Reason) {
case ParseReason.Check:
case ParseReason.HighlightBraces:
case ParseReason.MatchBraces:
case ParseReason.MemberSelectAndHighlightBraces:
// send matches to sink
// this should (probably?) be filtered on req.Line / col
if (source.Braces != null) {
foreach (TextSpan[] brace in source.Braces) {
if (brace.Length == 2)
req.Sink.MatchPair(brace[0], brace[1], 1);
else if (brace.Length >= 3)
req.Sink.MatchTriple(brace[0], brace[1], brace[2], 1);
}
}
break;
default:
break;
}
return new AuthoringScope(req.Text);
}
示例3: ParseRequestWrapper
public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource
(ParseRequest request)
{
var wrapper = new ParseRequestWrapper(request);
wrapper.Scanning();
return new AuthoringScopeWrapper();
}
示例4: BooScope
public BooScope(CompiledProject compiledProject, BooSource source, ParseRequest parseRequest, ParseRequestProcessor parseRequestProcessor)
{
this.source = source;
declarations = new DeclarationFinder(compiledProject, source, parseRequest.FileName);
this.parseRequest = parseRequest;
this.parseRequestProcessor = parseRequestProcessor;
}
示例5: NSAuthoringScope
public NSAuthoringScope(ParseRequest req, string dirtyFile, string project)
: base()
{
m_sink = req.Sink;
m_projectfile = project;
m_dirtyname = dirtyFile;
m_filename = req.FileName;
}
示例6: ParseSource
public override AuthoringScope ParseSource(ParseRequest req)
{
SassParser parser = new SassParser();
Source source = (Source)this.GetSource(req.FileName);
if (req.Sink.BraceMatching)
{
if (req.Reason == ParseReason.MatchBraces)
{
foreach (TextSpan[] brace in parser.Braces)
{
req.Sink.MatchPair(brace[0], brace[1], 1);
}
}
}
return new SassParserAuthoringScope();
}
示例7: ParseSource
public override AuthoringScope ParseSource(ParseRequest req)
{
if (req == null)
{
return null;
}
var scope = new CQLAuthoringScope();
req.Scope = scope;
if (req.Reason == ParseReason.Check)
{
}
if (m_scanner != null && req.Reason == ParseReason.MemberSelect || req.Reason == ParseReason.MemberSelectAndHighlightBraces && req.TokenInfo != null)
{
var token = m_scanner.GetToken(req.TokenInfo.Token);
if (token != null)
{
if (token.Type == 4) // [
{
scope.AddDeclaration(new CQLDeclaration("Encounter", 0, "An encounter with the patient"));
scope.AddDeclaration(new CQLDeclaration("Procedure", 0, "A procedure"));
scope.AddDeclaration(new CQLDeclaration("Medication", 0, "A medication"));
}
if (token.Type == 3) // ,
{
scope.AddDeclaration(new CQLDeclaration("Performed", 0, "An action performed"));
scope.AddDeclaration(new CQLDeclaration("Proposed", 0, "An action performed"));
scope.AddDeclaration(new CQLDeclaration("Ordered", 0, "An action performed"));
}
if (token.Type == 5) // :
{
scope.AddDeclaration(new CQLDeclaration("\"Inpatient\"", 0, "Inpatient encounter"));
scope.AddDeclaration(new CQLDeclaration("\"Outpatient\"", 0, "Outpatient encounter"));
scope.AddDeclaration(new CQLDeclaration("\"Face-to-face Interaction\"", 0, "Face-to-face interaction"));
}
}
}
return scope;
}
示例8: CreateScopeTest
public void CreateScopeTest()
{
Assert.IsNull(ConsoleAuthoringScope.CreateScope(null));
ParseRequest request = new ParseRequest(false);
request.Reason = ParseReason.None;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.MemberSelect;
Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.HighlightBraces;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.MemberSelectAndHighlightBraces;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.MatchBraces;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.Check;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.CompleteWord;
Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.DisplayMemberList;
Assert.IsNotNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.QuickInfo;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.MethodTip;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.Autos;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.CodeSpan;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
request.Reason = ParseReason.Goto;
Assert.IsNull(ConsoleAuthoringScope.CreateScope(request));
}
示例9: ParseSource
public override AuthoringScope ParseSource(ParseRequest req)
{
XSharpAuthoringScope scope = new XSharpAuthoringScope();
if (req.Reason == ParseReason.Check ||
req.Reason == ParseReason.None)
{
// Parse the entire source as given in req.Text. Store results in the XSharpAuthoringScope object.
}
else if (req.Reason == ParseReason.DisplayMemberList)
{
// Parse the line specified in req.Line for the two tokens just before req.Col to get the identifier and the member connector symbol.
// Find members of the identifer in the parse tree and store the list of members in the Declarations class.
}
else if (req.Reason == ParseReason.MethodTip)
{
// Parse the line specified in req.Line for the token just before req.Col to obtain the name of the method.
// Find all method signatures with the same name in the existing parse tree and store the list of signatures in the Methods class.
}
// continue for the rest of the supported ParseReason values.
return scope;
}
示例10: ParseSource
public override AuthoringScope ParseSource(ParseRequest req)
{
Core.FStarParser parser = new Core.FStarParser();
var result = new TestAuthoringScope();
var tokens = new List<TokenInfo>();
if (req.Sink.BraceMatching || ParseReason.MatchBraces == req.Reason || ParseReason.HighlightBraces == req.Reason)
{
var scanner = GetScanner(null);
scanner.SetSource(req.Text, 0);
var line = 0;
var col = 0;
req.View.GetCaretPos(out line, out col);
(scanner as VisualFStar.Core.FStarScanner).MatchPair(req.Sink, req.Text, line, col);
}
else parser.Parse(req);
if (ParseReason.Check == req.Reason)
{
Console.WriteLine("!!!!");
}
return result;
}
示例11: TriggerParse
/// <summary>
/// Triggers the parse.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="yyresult">if set to <c>true</c> [yyresult].</param>
/// <returns></returns>
private static LuaParser TriggerParse(ParseRequest request, out bool yyresult)
{
LuaParser parser = CreateParser(request);
yyresult = parser.Parse();
return parser;
}
示例12: GetLastWord
/// <summary>
/// Gets the last word.
/// </summary>
/// <param name="request">The request.</param>
/// <returns></returns>
private static string GetLastWord(ParseRequest request)
{
string line;
request.View.GetTextStream(request.Line, 0, request.Line, request.TokenInfo.EndIndex, out line);
if (line != null)
{
// Find the delimiter before the last word
int lastDelimiterIndex = line.LastIndexOfAny(lastWordDelimiters);
// Get the last word before the caret
return lastDelimiterIndex != -1 ? line.Substring(lastDelimiterIndex + 1) : line;
}
return String.Empty;
}
示例13: CreateParser
/// <summary>
/// Creates the parser.
/// </summary>
/// <param name="request">The request.</param>
/// <returns></returns>
private static LuaParser CreateParser(ParseRequest request)
{
// Create ErrorHandler for scanner
var handler = new ParaEngine.Tools.Lua.Parser.ErrorHandler();
// Create scanner and parser
LuaScanner scanner = new ParaEngine.Tools.Lua.Lexer.Scanner();
LuaParser parser = new LuaParser();
// Set the error handler for the scanner
scanner.Handler = handler;
// Associate the scanner with the parser
parser.scanner = scanner;
// Initialize with the request (can be null)
parser.Request = request;
// If the parser is created for a request, automatically set the source from the request
if (request != null)
scanner.SetSource(request.Text, 0);
// Return the parser
return parser;
}
示例14: ParseSource
/// <summary>
/// Processes a Parse request.
/// </summary>
/// <param name="request">The request to process.</param>
/// <returns>An AuthoringScope containing the declarations and other information.</returns>
public override Microsoft.VisualStudio.Package.AuthoringScope ParseSource(ParseRequest request)
{
Trace.WriteLine(request.Reason);
authoringScope.Clear();
if (request.ShouldParse())
{
// Make sure we are processing hidden regions
request.Sink.ProcessHiddenRegions = true;
// Create a parser for the request, and execute parsing...
bool successfulParse;
LuaParser parser = TriggerParse(request, out successfulParse);
InitializeFileCodeModel(parser.Chunk);
if (successfulParse)
{
RefreshDeclarationsForRequest(request, parser, true);
}
if (request.NeedsDeclarations())
{
AddDeclarationProvidersToScope(request);
if (request.NeedsQualifiedName())
{
authoringScope.SetQualifiedName(GetLastWord(request));
}
}
}
else
{
if(request.Reason == ParseReason.QuickInfo)
{
// TODO: mouse over a text to display some info.
}
}
// Return authoring scope
return authoringScope;
}
示例15: HandleParseResponse
internal void HandleParseResponse(ParseRequest req) {
try {
ReportErrors(req.Sink.Errors);
} catch (Exception e) {
CCITracing.Trace("HandleParseResponse exception: " + e.Message);
}
}