Index: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileMatch.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileMatch.java (revision 7355) |
+++ editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileMatch.java (working copy) |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (c) 2011, the Dart project authors. |
+ * Copyright (c) 2012, the Dart project authors. |
* |
* Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except |
* in compliance with the License. You may obtain a copy of the License at |
@@ -13,70 +13,62 @@ |
*/ |
package com.google.dart.tools.search.internal.ui.text; |
-import com.google.dart.tools.search.ui.text.Match; |
- |
-import org.eclipse.core.runtime.Assert; |
- |
import org.eclipse.core.resources.IFile; |
- |
import org.eclipse.jface.text.Region; |
+/** |
+ * A {@link FileResourceMatch} backed by an {@link IFile} in the workspace. |
+ */ |
+public class FileMatch extends FileResourceMatch { |
-public class FileMatch extends Match { |
- private LineElement fLineElement; |
- private Region fOriginalLocation; |
+ private Region originalLocation; |
public FileMatch(IFile element) { |
super(element, -1, -1); |
- fLineElement = null; |
- fOriginalLocation = null; |
+ originalLocation = null; |
} |
public FileMatch(IFile element, int offset, int length, LineElement lineEntry) { |
- super(element, offset, length); |
- Assert.isLegal(lineEntry != null); |
- fLineElement = lineEntry; |
+ super(element, offset, length, lineEntry); |
} |
- public void setOffset(int offset) { |
- if (fOriginalLocation == null) { |
- // remember the original location before changing it |
- fOriginalLocation = new Region(getOffset(), getLength()); |
- } |
- super.setOffset(offset); |
+ public IFile getFile() { |
+ return (IFile) getElement(); |
} |
- public void setLength(int length) { |
- if (fOriginalLocation == null) { |
- // remember the original location before changing it |
- fOriginalLocation = new Region(getOffset(), getLength()); |
+ public int getOriginalLength() { |
+ if (originalLocation != null) { |
+ return originalLocation.getLength(); |
} |
- super.setLength(length); |
+ return getLength(); |
} |
public int getOriginalOffset() { |
- if (fOriginalLocation != null) { |
- return fOriginalLocation.getOffset(); |
+ if (originalLocation != null) { |
+ return originalLocation.getOffset(); |
} |
return getOffset(); |
} |
- public int getOriginalLength() { |
- if (fOriginalLocation != null) { |
- return fOriginalLocation.getLength(); |
- } |
- return getLength(); |
+ public boolean isFileSearch() { |
+ return getLineElement() == null; |
} |
- public LineElement getLineElement() { |
- return fLineElement; |
+ @Override |
+ public void setLength(int length) { |
+ if (originalLocation == null) { |
+ // remember the original location before changing it |
+ originalLocation = new Region(getOffset(), getLength()); |
+ } |
+ super.setLength(length); |
} |
- public IFile getFile() { |
- return (IFile) getElement(); |
+ @Override |
+ public void setOffset(int offset) { |
+ if (originalLocation == null) { |
+ // remember the original location before changing it |
+ originalLocation = new Region(getOffset(), getLength()); |
+ } |
+ super.setOffset(offset); |
} |
- |
- public boolean isFileSearch() { |
- return fLineElement == null; |
- } |
} |