public static async Task <Document> RefactorAsync( Document document, RegionDirectiveTriviaSyntax regionDirective, CancellationToken cancellationToken = default(CancellationToken)) { return(await Remover.RemoveRegionAsync(document, regionDirective, cancellationToken).ConfigureAwait(false)); }
public static void ComputeRefactorings(RefactoringContext context, DirectiveTriviaSyntax directiveTrivia) { if (context.IsRefactoringEnabled(RefactoringIdentifiers.RemoveDirectiveAndRelatedDirectives) && directiveTrivia.IsKind( SyntaxKind.IfDirectiveTrivia, SyntaxKind.ElseDirectiveTrivia, SyntaxKind.ElifDirectiveTrivia, SyntaxKind.EndIfDirectiveTrivia, SyntaxKind.RegionDirectiveTrivia, SyntaxKind.EndRegionDirectiveTrivia)) { List <DirectiveTriviaSyntax> directives = directiveTrivia.GetRelatedDirectives(); if (directives.Count > 1) { string title = "Remove directive and related directive"; if (directives.Count > 2) { title += "s"; } context.RegisterRefactoring( title, cancellationToken => { return(Remover.RemoveDirectivesAsync( context.Document, directives.ToImmutableArray(), cancellationToken)); }); } } }
public void RemoverRemoveLesson_ValidParameters_LessonRemoved() { // Arrange Creator.CreateCourse(Instances.Name, Instances.Description); Course course = Course.GetByID(1); Creator.CreateStudent(Instances.Name, Instances.Username, Instances.Password); Student student = Student.GetByID(2); course.AddStudent(student); Creator.CreateRoom(Instances.Name); List <Room> rooms = new List <Room> { Room.GetByID(1) }; Creator.CreateLesson(course, Instances.Description, Instances.Online, Instances.Date, rooms, Instances.Filepaths); Lesson lesson = Lesson.GetByID(1); lesson.GiveAbsence(student); // Act Remover.RemoveLesson(lesson); // Assert Assert.AreEqual(0, Lesson.GetAll().Count); Assert.AreEqual(0, course.Lessons.Count); Assert.AreEqual(0, student.Absences.Count); Assert.AreEqual(0, rooms[0].Reservations.Count); }
public void RemoverRemoveCourse_ValidParameters_CourseRemoved() { // Arrange Creator.CreateCourse(Instances.Name, Instances.Description); Course course = Course.GetByID(1); Creator.CreateStudent(Instances.Name, Instances.Username, Instances.Password); Student student = Student.GetByID(2); course.AddStudent(student); Creator.CreateTeacher(Instances.Name, Instances.Username, Instances.Password); Teacher teacher = Teacher.GetByID(3); course.AddTeacher(teacher); Creator.CreateLesson(course, Instances.Description, Instances.Online, Instances.Date, Instances.Rooms, Instances.Filepaths); Creator.CreateAssignmentDescription(course, Instances.Description, Instances.Date, Instances.Filepaths); Creator.CreateCourseGrade(course, student, Instances.Grade, Instances.Comment); // Act Remover.RemoveCourse(course); // Assert Assert.AreEqual(0, Course.GetAll().Count); Assert.AreEqual(0, student.Courses.Count); Assert.AreEqual(0, teacher.Courses.Count); Assert.AreEqual(0, Lesson.GetAll().Count); Assert.AreEqual(0, AssignmentDescription.GetAll().Count); Assert.AreEqual(0, CourseGrade.GetAll().Count); }
private static void EmptyExtractLocation() { if (ExtractLocationIsAvailable()) { Remover.Delete(new DirectoryInfo(ExtractLocation)); } }
/// <inheritdoc/> public override void Process(BatchState batchState) { Remover remover = new Remover(); remover.PopulateExclusionsFromList(Arguments); remover.ApplyRemovals(batchState.DatFile); }
public static TNode ToSingleLine <TNode>( TNode condition, CancellationToken cancellationToken = default(CancellationToken)) where TNode : SyntaxNode { return(Remover.RemoveWhitespaceOrEndOfLine(condition) .WithFormatterAnnotation()); }
static void Main(string[] args) { // Create Bytescout.PDFExtractor.Remover instance Remover remover = new Remover("demo", "demo"); // Load sample PDF document remover.LoadDocumentFromFile(@"sample1.pdf"); // Search Keyword string SearchKeyword = "Martian dichotomy"; // Prepare TextExtractor using (TextExtractor textExtractor = new TextExtractor("demo", "demo")) { // Load document into TextExtractor textExtractor.LoadDocumentFromFile(@"sample1.pdf"); // Set word matching options textExtractor.WordMatchingMode = WordMatchingMode.None; ISearchResult[] searchResults = textExtractor.FindAll(0, SearchKeyword, caseSensitive: false); // Remove text objects find by SearchResults. // NOTE: The removed text might be larger than the specified rectangle. Currently the Remover is unable // to split PDF text objects. remover.RemoveText(searchResults, @"result1.pdf"); } // Open output file in default application System.Diagnostics.Process.Start("result1.pdf"); // Clean up. remover.Dispose(); }
public static async Task <Document> RefactorAsync( Document document, AccessorListSyntax accessorList, CancellationToken cancellationToken) { if (accessorList.Accessors.All(f => f.Body == null)) { var propertyDeclaration = (PropertyDeclarationSyntax)accessorList.Parent; TextSpan span = TextSpan.FromBounds( propertyDeclaration.Identifier.Span.End, accessorList.CloseBraceToken.Span.Start); PropertyDeclarationSyntax newPropertyDeclaration = Remover.RemoveWhitespaceOrEndOfLine(propertyDeclaration, span); newPropertyDeclaration = newPropertyDeclaration .WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(propertyDeclaration, newPropertyDeclaration, cancellationToken).ConfigureAwait(false)); } else { AccessorListSyntax newAccessorList = GetNewAccessorList(accessorList) .WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(accessorList, newAccessorList, cancellationToken).ConfigureAwait(false)); } }
private static AccessorListSyntax GetNewAccessorList(AccessorListSyntax accessorList) { if (accessorList.IsSingleLine(includeExteriorTrivia: false)) { SyntaxTriviaList triviaList = accessorList .CloseBraceToken .LeadingTrivia .Add(NewLineTrivia()); return(Remover.RemoveWhitespaceOrEndOfLine(accessorList) .WithCloseBraceToken(accessorList.CloseBraceToken.WithLeadingTrivia(triviaList))); } else { return(accessorList.ReplaceNodes(accessorList.Accessors, (f, g) => { if (ShouldBeFormatted(f)) { return Remover.RemoveWhitespaceOrEndOfLine(f, f.Span); } else { return g; } })); } }
/// <summary> /// Has to be edited once we have animations /// </summary> private void Death() { //Play death animation //StartCoroutine(Remover.DelayAndRemove(this.transform.gameobject, 200)) isDead = true; Remover.CheckAndRemove(this.transform.gameObject); }
public static Task <Document> RefactorAsync( Document document, RegionDirectiveTriviaSyntax regionDirective, CancellationToken cancellationToken = default(CancellationToken)) { return(Remover.RemoveRegionAsync(document, regionDirective, cancellationToken)); }
public void RemoveWithLimit1() { List <int> list = new List <int>() { 1, 2, 0, 1, 0, 0, 1 }; Remover <int> remover = new Remover <int>(list, 5); int i = 0; while (i < remover.Limit) { if (list[i] == 0) { remover.Remove(ref i); } else { remover.Skip(ref i); } } remover.Finish(remover.Limit); Assert.AreEqual(remover.RemovedCount, 2); CollectionAssert.AreEqual(new int[] { 1, 2, 1, 0, 1 }, list); }
private static PropertyDeclarationSyntax CreateAutoProperty(PropertyDeclarationSyntax property, EqualsValueClauseSyntax initializer) { AccessorListSyntax accessorList = CreateAccessorList(property); if (accessorList .DescendantTrivia() .All(f => f.IsWhitespaceOrEndOfLineTrivia())) { accessorList = Remover.RemoveWhitespaceOrEndOfLine(accessorList); } PropertyDeclarationSyntax newProperty = property .WithIdentifier(property.Identifier.WithTrailingSpace()) .WithExpressionBody(null) .WithAccessorList(accessorList); if (initializer != null) { newProperty = newProperty .WithInitializer(initializer) .WithSemicolonToken(SemicolonToken()); } else { newProperty = newProperty.WithoutSemicolonToken(); } return(newProperty .WithTriviaFrom(property) .WithFormatterAnnotation()); }
public static Task <Document> RefactorAsync( Document document, DestructorDeclarationSyntax destructorDeclaration, CancellationToken cancellationToken) { return(Remover.RemoveMemberAsync(document, destructorDeclaration, cancellationToken)); }
static void Main(string[] args) { // Create Bytescout.PDFExtractor.Remover instance Remover remover = new Remover("demo", "demo"); // Load sample PDF document remover.LoadDocumentFromFile(@"sample1.pdf"); // Remove text "LOREM IPSUM" and save edited document as "result1.pdf". // NOTE: The removed text might be larger than the search string. Currently the Remover deletes // the whole PDF text object containing the search string. remover.RemoveText(0, "LOREM IPSUM", true, @"result1.pdf"); // Remove text objects contained in the specified rectangle or intersecting with it. // NOTE: The removed text might be larger than the specified rectangle. Currently the Remover is unable // to split PDF text objects. remover.RemoveText(0, new RectangleF(74f, 550f, 489f, 67f), @"result2.pdf"); // Remove text object contained in the specified point. // NOTE: The removed text might be larger than a word in the specified point. Currently the Remover is able // to remove only the whole PDF text object containing the word. remover.RemoveText(0, new PointF(121f, 230f), @"result3.pdf"); // Clean up. remover.Dispose(); }
public static async Task <Document> RefactorAsync( Document document, ConstructorDeclarationSyntax constructorDeclaration, CancellationToken cancellationToken) { return(await Remover.RemoveMemberAsync(document, constructorDeclaration, cancellationToken).ConfigureAwait(false)); }
public async Task <Solution> InlineAndRemoveMethodAsync(InvocationExpressionSyntax invocation, ExpressionSyntax expression) { if (invocation.SyntaxTree == MethodDeclaration.SyntaxTree) { DocumentEditor editor = await DocumentEditor.CreateAsync(Document, CancellationToken).ConfigureAwait(false); ExpressionSyntax newExpression = RewriteExpression(invocation, expression); editor.ReplaceNode(invocation, newExpression); editor.RemoveNode(MethodDeclaration); return(editor.GetChangedDocument().Solution()); } else { Document newDocument = await InlineMethodAsync(invocation, expression).ConfigureAwait(false); DocumentId documentId = Document.Solution().GetDocumentId(MethodDeclaration.SyntaxTree); newDocument = await Remover.RemoveMemberAsync(newDocument.Solution().GetDocument(documentId), MethodDeclaration, CancellationToken).ConfigureAwait(false); return(newDocument.Solution()); } }
public void CutToEnd(TimeSpan end) { logger.Log("Removing video and audio packets later than {0}...", (int)end.TotalSeconds); int i = 0; Remover <BasePacket> remover = new Remover <BasePacket>(Packets); while (i < Packets.Count) { BasePacket packet = Packets[i]; if ((packet.PacketType == PacketType.VideoPayload || packet.PacketType == PacketType.AudioPayload) && packet.TimeStamp > end) { remover.Remove(ref i); } else { remover.Skip(ref i); } } remover.Finish(Packets.Count); logger.Log("Removed {0} packets", remover.RemovedCount); }
public void RemoverRemovePerson_StudentAsParameter_PersonRemoved() { //ARRANGE Creator.CreateStudent(Instances.Name, Instances.Username, Instances.Password); Student student = Student.GetLatest(1).Single(); Creator.CreateCourse(Instances.Name, Instances.Description); Course course = Course.GetLatest(1).Single(); Creator.CreateLesson(course, Instances.Description, Instances.Online, Instances.Date, Instances.Rooms, Instances.Filepaths); Lesson lesson = Lesson.GetLatest(1).Single(); List <Person> recipients = new List <Person>(); recipients.Add(Person.GetByID(1)); Creator.CreateMessage(student, Instances.Title, Instances.Text, recipients, Instances.Filepaths); recipients.Clear(); recipients.Add(student); Creator.CreateMessage(Person.GetByID(1), Instances.Title, Instances.Text, recipients, Instances.Filepaths); course.AddStudent(student); lesson.GiveAbsence(student); List <Student> absentStudents = lesson.Absences; List <Student> courseStudents = course.Students; List <Message> allMessages = Message.GetAll(); List <Person> allUsers = Person.GetAll(); //ACT Remover.RemovePerson(student); //ASSERT foreach (Message item in Message.GetAll()) { List <Person> items = item.Recipients; foreach (Person recipient in items) { if (student.ID == recipient.ID) { Assert.Fail("deleted person still in recipients"); } } } List <Message> allMessagesTest = Message.GetAll(); Assert.AreEqual(allMessagesTest.Count, allMessages.Count - 1); List <Student> courseStudentsTest = course.Students; Assert.AreEqual(courseStudentsTest.Count, courseStudents.Count - 1); List <Person> allUsersTest = Person.GetAll(); Assert.AreEqual(allUsersTest.Count, allUsers.Count - 1); List <Student> absentStudentsTest = lesson.Absences; Assert.AreEqual(absentStudentsTest.Count, absentStudents.Count - 1); }
public static async Task <Document> RefactorAsync( Document document, AccessorListSyntax accessorList, CancellationToken cancellationToken) { if (accessorList.Accessors.All(f => f.BodyOrExpressionBody() == null)) { SyntaxNode parent = accessorList.Parent; switch (parent.Kind()) { case SyntaxKind.PropertyDeclaration: { var propertyDeclaration = (PropertyDeclarationSyntax)parent; TextSpan span = TextSpan.FromBounds( propertyDeclaration.Identifier.Span.End, accessorList.CloseBraceToken.Span.Start); PropertyDeclarationSyntax newNode = Remover.RemoveWhitespaceOrEndOfLine(propertyDeclaration, span); newNode = newNode.WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(propertyDeclaration, newNode, cancellationToken).ConfigureAwait(false)); } case SyntaxKind.IndexerDeclaration: { var indexerDeclaration = (IndexerDeclarationSyntax)parent; TextSpan span = TextSpan.FromBounds( indexerDeclaration.ParameterList.CloseBracketToken.Span.End, accessorList.CloseBraceToken.Span.Start); IndexerDeclarationSyntax newNode = Remover.RemoveWhitespaceOrEndOfLine(indexerDeclaration, span); newNode = newNode.WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(indexerDeclaration, newNode, cancellationToken).ConfigureAwait(false)); } default: { Debug.Assert(false, parent.Kind().ToString()); return(document); } } } else { AccessorListSyntax newAccessorList = GetNewAccessorList(accessorList); newAccessorList = AddNewLineAfterFirstAccessorIfNecessary(accessorList, newAccessorList, cancellationToken); newAccessorList = newAccessorList.WithFormatterAnnotation(); return(await document.ReplaceNodeAsync(accessorList, newAccessorList, cancellationToken).ConfigureAwait(false)); } }
private static Task <Document> RefactorAsync(Document document, LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, CancellationToken cancellationToken) { LocalFunctionStatementSyntax newNode = AwaitRemover.Visit(localFunction, semanticModel, cancellationToken); newNode = Remover.RemoveModifier(newNode, SyntaxKind.AsyncKeyword); return(document.ReplaceNodeAsync(localFunction, newNode, cancellationToken)); }
private static Task <Document> RefactorAsync(Document document, MethodDeclarationSyntax methodDeclaration, SemanticModel semanticModel, CancellationToken cancellationToken) { MethodDeclarationSyntax newNode = AwaitRemover.Visit(methodDeclaration, semanticModel, cancellationToken); newNode = Remover.RemoveModifier(newNode, SyntaxKind.AsyncKeyword); return(document.ReplaceNodeAsync(methodDeclaration, newNode, cancellationToken)); }
private static XYPoint MovePoint <L>( IDictionary <XYPoint, SupportRectangleWithId> points, L quadTree, Random random, SupportQuadTreeConfig config, AdderUnique <L> adder, Remover <L> remover) { var coordinates = points.Keys.ToArray(); XYPoint oldCoordinate; XYPoint newCoordinate; while (true) { oldCoordinate = coordinates[random.Next(coordinates.Length)]; var direction = random.Next(4); var newX = oldCoordinate.X; var newY = oldCoordinate.Y; if (direction == 0 && newX > config.X) { newX--; } if (direction == 1 && newY > config.Y) { newY--; } if (direction == 2 && newX < config.X + config.Width - 1) { newX++; } if (direction == 3 && newY < config.Y + config.Height - 1) { newY++; } newCoordinate = new XYPoint(newX, newY); if (!points.ContainsKey(newCoordinate)) { break; } } var moved = points.Delete(oldCoordinate); remover.Invoke(quadTree, moved); moved.X = newCoordinate.X; moved.Y = newCoordinate.Y; adder.Invoke(quadTree, moved); points.Put(newCoordinate, moved); // Comment-me-in: // log.info("Moving " + moved.getId() + " from " + printPoint(oldCoordinate.getX(), oldCoordinate.getY()) + " to " + printPoint(newCoordinate.getX(), newCoordinate.getY())); return(newCoordinate); }
public override SyntaxNode VisitAccessorDeclaration(AccessorDeclarationSyntax node) { if (ShouldBeFormatted(node)) { return(Remover.RemoveWhitespaceOrEndOfLine(node, node.Span)); } return(base.VisitAccessorDeclaration(node)); }
public static async Task <Document> RefactorAsync( Document document, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken) { SyntaxNode newNode = Remover.RemoveModifier(typeDeclaration, SyntaxKind.PartialKeyword); return(await document.ReplaceNodeAsync(typeDeclaration, newNode, cancellationToken).ConfigureAwait(false)); }
public void Remove(ReputationDto item) { var remover = new Remover(this.Session); if (remover.CanRemove(item)) { remover.Remove <Reputation>(item); } }
public static async Task <Document> RefactorAsync( Document document, MemberDeclarationSyntax memberDeclaration, CancellationToken cancellationToken = default(CancellationToken)) { SyntaxNode newNode = Remover.RemoveModifier(memberDeclaration, SyntaxKind.SealedKeyword); return(await document.ReplaceNodeAsync(memberDeclaration, newNode, cancellationToken).ConfigureAwait(false)); }
public void RemoveDiacriticsTest() { // Arrange // Act var actual = Remover.RemoveDiacritics(DATA); // Assert Assert.Equal(EXPECTED, actual); }
public static void ComputeRefactorings(RefactoringContext context, EndRegionDirectiveTriviaSyntax endRegionDirective) { if (context.IsRefactoringEnabled(RefactoringIdentifiers.RemoveRegion) && context.IsRootCompilationUnit) { context.RegisterRefactoring( "Remove region", cancellationToken => Remover.RemoveRegionAsync(context.Document, endRegionDirective, cancellationToken)); } }
// ----- Конструктор ----- public Main() { InitializeComponent(); mutex = new Mutex(false); timer = new System.Threading.Timer(new TimerCallback(SendPacketToServer), null, Timeout.Infinite, 50); share = new List<Packet>(); working = new List<Packet>(); remover = new Remover(Deleter); setter = new Setter(SetterFunction); }
void Awake() { controller=GetComponent<Controller2D>(); camera=GameObject.Find("MainCamera").GetComponent<CameraFollow>(); health=maxHealth; //enemy=GameObject.Find ("enemy01(Clone)").GetComponent<Enemy>(); gravity= -(2*jumpHeight)/Mathf.Pow(timeToJumpApex,2); // jumpVelocity=Mathf.Abs(gravity)*timeToJumpApex; re=GameObject.Find ("Reloader").GetComponent<Remover>(); score=GameObject.Find("Canvas").GetComponent<GameManager>(); etape=GameObject.Find ("Canvas").GetComponent<GameManager>(); bar=GameObject.Find("Canvas").transform.FindChild("UIHealthBar").transform.FindChild("HealthBar").GetComponent<HealthBar>(); }
public void Remove(ReputationDto item) { var remover = new Remover(this.Session); if (remover.CanRemove(item)) { remover.Remove<Reputation>(item); } }