01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.formatter;
11:
12: /**
13: * A location maintains positional information both in original source and in the output source.
14: * It remembers source offsets, line/column and indentation level.
15: * @since 2.1
16: */
17: public class Location {
18:
19: public int inputOffset;
20: public int outputLine;
21: public int outputColumn;
22: public int outputIndentationLevel;
23: public boolean needSpace;
24: public boolean pendingSpace;
25: public int nlsTagCounter;
26: public int lastLocalDeclarationSourceStart;
27: public int numberOfIndentations;
28:
29: // chunk management
30: public int lastNumberOfNewLines;
31:
32: // edits management
33: int editsIndex;
34: OptimizedReplaceEdit textEdit;
35:
36: public Location(Scribe scribe, int sourceRestart) {
37: update(scribe, sourceRestart);
38: }
39:
40: public void update(Scribe scribe, int sourceRestart) {
41: this.outputColumn = scribe.column;
42: this.outputLine = scribe.line;
43: this.inputOffset = sourceRestart;
44: this.outputIndentationLevel = scribe.indentationLevel;
45: this.lastNumberOfNewLines = scribe.lastNumberOfNewLines;
46: this.needSpace = scribe.needSpace;
47: this.pendingSpace = scribe.pendingSpace;
48: this.editsIndex = scribe.editsIndex;
49: this.nlsTagCounter = scribe.nlsTagCounter;
50: this.numberOfIndentations = scribe.numberOfIndentations;
51: textEdit = scribe.getLastEdit();
52: }
53: }
|