public override bool DetectAchievement(DetectionSession detectionSession) { var nrefactorySession = detectionSession.GetSessionObjectOfType<NRefactorySession>(); var filename = detectionSession.BuildInformation.ActiveFile; var parser = nrefactorySession.GetParser(filename); var specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); return specials.OfType<Comment>().Any(a => a.CommentType == CommentType.Block); }
public override bool DetectAchievement(DetectionSession detectionSession) { var nrefactorySession = detectionSession.GetSessionObjectOfType <NRefactorySession>(); var filename = detectionSession.BuildInformation.ActiveFile; var parser = nrefactorySession.GetParser(filename); var specials = parser.Lexer.SpecialTracker.RetrieveSpecials(); return(specials.OfType <Comment>().Any(a => a.CommentType == CommentType.Block)); }
public override bool DetectAchievement(DetectionSession detectionSession) { // Return out if there are no files to check achievements in. if (!detectionSession.BuildInformation.ChangedFiles.Any()) { return(false); } // Obtain a session object and the codebase type declarations var nrefactorySession = detectionSession.GetSessionObjectOfType <NRefactorySession>(); CodebaseTypeDeclarations = nrefactorySession.GetCodebaseTypeDeclarations(detectionSession.BuildInformation); // Have the concrete implementation create it's visitor var visitor = CreateVisitor(detectionSession); // Parse all files in the changed files collection for achievements foreach (var filename in detectionSession.BuildInformation.ChangedFiles) { // Obtain a parser from the nrefactorySession. // This parser is shared context between all concrete achievement implementations. var parser = nrefactorySession.GetParser(filename); // Pass concrete visitor into the AST created by the parser parser.CompilationUnit.AcceptVisitor(visitor, null); // Call OnParsingCompleted on the visitor to give it a last chance to unlock achievements. visitor.OnParsingCompleted(); // Check if the visitor declared the concrete achievement as unlocked. if (visitor.IsAchievementUnlocked) { AchievementCodeLocation = visitor.CodeLocation; if (AchievementCodeLocation != null) { AchievementCodeLocation.FileName = filename; } return(true); } } return(false); }
public override bool DetectAchievement(DetectionSession detectionSession) { // Return out if there are no files to check achievements in. if (!detectionSession.BuildInformation.ChangedFiles.Any()) { return false; } // Obtain a session object and the codebase type declarations var nrefactorySession = detectionSession.GetSessionObjectOfType<NRefactorySession>(); CodebaseTypeDeclarations = nrefactorySession.GetCodebaseTypeDeclarations(detectionSession.BuildInformation); // Have the concrete implementation create it's visitor var visitor = CreateVisitor(detectionSession); // Parse all files in the changed files collection for achievements foreach (var filename in detectionSession.BuildInformation.ChangedFiles) { // Obtain a parser from the nrefactorySession. // This parser is shared context between all concrete achievement implementations. var parser = nrefactorySession.GetParser(filename); // Pass concrete visitor into the AST created by the parser parser.CompilationUnit.AcceptVisitor(visitor, null); // Call OnParsingCompleted on the visitor to give it a last chance to unlock achievements. visitor.OnParsingCompleted(); // Check if the visitor declared the concrete achievement as unlocked. if (visitor.IsAchievementUnlocked) { AchievementCodeLocation = visitor.CodeLocation; if (AchievementCodeLocation != null) { AchievementCodeLocation.FileName = filename; } return true; } } return false; }