Created
June 19, 2017 22:58
-
-
Save controlflow/ec9c89bea6ffdd371343172b55f3e872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Run(ITreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) | |
{ | |
var warningDirective = element as IWarningDirective; | |
if (warningDirective != null) | |
{ | |
var messageToken = "#warning directive"; | |
var tokenNode = warningDirective.Message; | |
if (tokenNode != null) messageToken = tokenNode.GetText(); | |
consumer.AddHighlighting(new WarningPPDirectiveWarning(warningDirective, messageToken)); | |
return; | |
} | |
var errorDirective = element as IErrorDirective; | |
if (errorDirective != null) | |
{ | |
var message = "#error directive"; | |
var messageToken = errorDirective.Message; | |
if (messageToken != null) message = messageToken.GetText(); | |
consumer.AddHighlighting(new ErrorPPDirectiveError(errorDirective, message)); | |
return; | |
} | |
var invalidDirective = element as IPreprocessorErrorDirective; | |
if (invalidDirective != null) | |
{ | |
consumer.AddHighlighting(new InvalidPPDirectiveError(invalidDirective)); | |
return; | |
} | |
var startRegion = element as IStartRegion; | |
if (startRegion != null) | |
{ | |
var daemonStageProcess = (CSharpDaemonStageProcessBase) consumer.Process; | |
var fileStructure = daemonStageProcess.FileStructure.NotNull(); | |
if (fileStructure[startRegion] == null) | |
{ | |
consumer.AddHighlighting(new UnmatchedRegionPPDirectiveError(startRegion)); | |
return; | |
} | |
} | |
var endRegion = element as IEndRegion; | |
if (endRegion != null) | |
{ | |
var daemonStageProcess = (CSharpDaemonStageProcessBase) consumer.Process; | |
var fileStructure = daemonStageProcess.FileStructure.NotNull(); | |
if (fileStructure[endRegion] == null) | |
{ | |
consumer.AddHighlighting(new UnmatchedRegionPPDirectiveError(endRegion)); | |
return; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Run(ITreeNode element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) | |
{ | |
switch (element) | |
{ | |
case IWarningDirective warningDirective: | |
{ | |
var messageToken = "#warning directive"; | |
var tokenNode = warningDirective.Message; | |
if (tokenNode != null) messageToken = tokenNode.GetText(); | |
consumer.AddHighlighting(new WarningPPDirectiveWarning(warningDirective, messageToken)); | |
return; | |
} | |
case IErrorDirective errorDirective: | |
{ | |
var message = "#error directive"; | |
var messageToken = errorDirective.Message; | |
if (messageToken != null) message = messageToken.GetText(); | |
consumer.AddHighlighting(new ErrorPPDirectiveError(errorDirective, message)); | |
return; | |
} | |
case IPreprocessorErrorDirective invalidDirective: | |
{ | |
consumer.AddHighlighting(new InvalidPPDirectiveError(invalidDirective)); | |
return; | |
} | |
case IStartRegion startRegion: | |
{ | |
var daemonStageProcess = (CSharpDaemonStageProcessBase) consumer.Process; | |
var fileStructure = daemonStageProcess.FileStructure.NotNull(); | |
if (fileStructure[startRegion] == null) | |
consumer.AddHighlighting(new UnmatchedRegionPPDirectiveError(startRegion)); | |
return; | |
} | |
case IEndRegion endRegion: | |
{ | |
var daemonStageProcess = (CSharpDaemonStageProcessBase) consumer.Process; | |
var fileStructure = daemonStageProcess.FileStructure.NotNull(); | |
if (fileStructure[endRegion] == null) | |
consumer.AddHighlighting(new UnmatchedRegionPPDirectiveError(endRegion)); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment