~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/ScannerContext.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2004, 2008, 2013 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 implementation
 
10
 *     Anton Leherbauer - adding tokens for preprocessing directives
 
11
 *     Markus Schorn - classification of preprocessing directives.
 
12
 *     Red Hat Inc. - modified for use in SystemTap
 
13
 *******************************************************************************/
 
14
package org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp;
 
15
 
 
16
import java.io.IOException;
 
17
import java.io.Reader;
 
18
import java.util.Stack;
 
19
 
 
20
public class ScannerContext {
 
21
        private Reader fReader;
 
22
        private int fOffset;
 
23
        private Stack<Integer> fUndo = new Stack<Integer>();
 
24
 
 
25
        public ScannerContext() {
 
26
        }
 
27
 
 
28
        public ScannerContext initialize(Reader r) {
 
29
                fReader = r;
 
30
                fOffset = 0;
 
31
                return this;
 
32
        }
 
33
 
 
34
        public ScannerContext initialize(Reader r, int offset) {
 
35
                try {
 
36
                        r.skip(offset);
 
37
                } catch (IOException exc) {
 
38
                        throw new RuntimeException(exc);
 
39
                }
 
40
                fReader = r;
 
41
                fOffset = offset;
 
42
                return this;
 
43
        }
 
44
 
 
45
        public int read() throws IOException {
 
46
                ++fOffset;
 
47
                return fReader.read();
 
48
        }
 
49
 
 
50
        /**
 
51
         * Returns the offset.
 
52
         * @return int
 
53
         */
 
54
        public final int getOffset() {
 
55
                return fOffset;
 
56
        }
 
57
 
 
58
        /**
 
59
         * Returns the reader.
 
60
         * @return Reader
 
61
         */
 
62
        public final Reader getReader() {
 
63
                return fReader;
 
64
        }
 
65
 
 
66
        public final int undoStackSize() {
 
67
                return fUndo.size();
 
68
        }
 
69
 
 
70
        /**
 
71
         * Returns the undo.
 
72
         * @return int
 
73
         */
 
74
        public final int popUndo() {
 
75
                return fUndo.pop().intValue();
 
76
        }
 
77
 
 
78
        /**
 
79
         * Sets the undo.
 
80
         * @param undo The undo to set
 
81
         */
 
82
        public void pushUndo(int undo) {
 
83
                this.fUndo.push(new Integer(undo));
 
84
        }
 
85
}