blob: 4c4bccfeb15d3c40c2ab2be646960294aa2dd44e [file] [log] [blame]
amywu0c7262d2006-09-18 22:20:52 +00001/*******************************************************************************
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 *******************************************************************************/
11package org.eclipse.wst.sse.core.internal.text;
12
13import org.eclipse.jface.text.Position;
14
15class ReadOnlyPosition extends Position {
16 private boolean fIncludeStartOffset = false;
17
nitindc8c1e282007-09-13 02:05:46 +000018 public ReadOnlyPosition(int newOffset, int newLength, boolean includeStart) {
19 super(newOffset, newLength);
amywu0c7262d2006-09-18 22:20:52 +000020 fIncludeStartOffset = includeStart;
21 }
22
nitindc8c1e282007-09-13 02:05:46 +000023 public boolean overlapsWith(int newOffset, int newLength) {
24 boolean overlapsWith = super.overlapsWith(newOffset, newLength);
amywu0c7262d2006-09-18 22:20:52 +000025 if (overlapsWith) {
26 /*
27 * BUG157526 If at the start of the read only region and length =
28 * 0 most likely asking to insert and want to all inserting before
29 * read only region
30 */
nitindc8c1e282007-09-13 02:05:46 +000031 if (fIncludeStartOffset && (newLength == 0) && (this.length != 0) && (newOffset == this.offset)) {
amywu0c7262d2006-09-18 22:20:52 +000032 overlapsWith = false;
33 }
34 }
35 return overlapsWith;
36 }
37}