KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > parser > RecoveryScannerData


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.compiler.parser;
13
14 public class RecoveryScannerData {
15     public int insertedTokensPtr = -1;
16     public int[][] insertedTokens;
17     public int[] insertedTokensPosition;
18     public boolean[] insertedTokenUsed;
19     
20     public int replacedTokensPtr = -1;
21     public int[][] replacedTokens;
22     public int[] replacedTokensStart;
23     public int[] replacedTokensEnd;
24     public boolean[] replacedTokenUsed;
25         
26     public int removedTokensPtr = -1;
27     public int[] removedTokensStart;
28     public int[] removedTokensEnd;
29     public boolean[] removedTokenUsed;
30     
31     public RecoveryScannerData removeUnused() {
32         if(this.insertedTokens != null) {
33             int newInsertedTokensPtr = -1;
34             for (int i = 0; i <= this.insertedTokensPtr; i++) {
35                 if(this.insertedTokenUsed[i]) {
36                     newInsertedTokensPtr++;
37                     this.insertedTokens[newInsertedTokensPtr] = this.insertedTokens[i];
38                     this.insertedTokensPosition[newInsertedTokensPtr] = this.insertedTokensPosition[i];
39                     this.insertedTokenUsed[newInsertedTokensPtr] = this.insertedTokenUsed[i];
40                 }
41             }
42             this.insertedTokensPtr = newInsertedTokensPtr;
43         }
44
45         if(this.replacedTokens != null) {
46             int newReplacedTokensPtr = -1;
47             for (int i = 0; i <= this.replacedTokensPtr; i++) {
48                 if(this.replacedTokenUsed[i]) {
49                     newReplacedTokensPtr++;
50                     this.replacedTokens[newReplacedTokensPtr] = this.replacedTokens[i];
51                     this.replacedTokensStart[newReplacedTokensPtr] = this.replacedTokensStart[i];
52                     this.replacedTokensEnd[newReplacedTokensPtr] = this.replacedTokensEnd[i];
53                     this.replacedTokenUsed[newReplacedTokensPtr] = this.replacedTokenUsed[i];
54                 }
55             }
56             this.replacedTokensPtr = newReplacedTokensPtr;
57         }
58         if(this.removedTokensStart != null) {
59             int newRemovedTokensPtr = -1;
60             for (int i = 0; i <= this.removedTokensPtr; i++) {
61                 if(this.removedTokenUsed[i]) {
62                     newRemovedTokensPtr++;
63                     this.removedTokensStart[newRemovedTokensPtr] = this.removedTokensStart[i];
64                     this.removedTokensEnd[newRemovedTokensPtr] = this.removedTokensEnd[i];
65                     this.removedTokenUsed[newRemovedTokensPtr] = this.removedTokenUsed[i];
66                 }
67             }
68             this.removedTokensPtr = newRemovedTokensPtr;
69         }
70         
71         return this;
72     }
73 }
74
Popular Tags