3
* Created on Apr 14, 2004
4
* License: Common Public License v1.0
6
package org.python.pydev.editor.model;
10
import org.python.pydev.editor.codecompletion.revisited.visitors.Definition;
11
import org.python.pydev.parser.jython.SimpleNode;
14
* Pointer points to a python resource inside a file system.
16
* You can create one of these, and use PyOpenAction to open the
19
public class ItemPointer {
21
public Object file; // IFile or File object
22
public Location start; // (first character)
23
public Location end; // (last character)
24
public Definition definition; //the definition that originated this ItemPointer (it might be null).
26
public ItemPointer(Object file) {
27
this(file, new Location(), new Location());
30
public ItemPointer(File file, SimpleNode n) {
31
int line = n.beginLine;
32
int col = n.beginColumn;
35
this.start = new Location(line-1, col-1);
36
this.end = new Location(line-1, col-1);
39
public ItemPointer(Object file, Location start, Location end) {
45
public ItemPointer(File file2, Location location, Location location2, Definition definition) {
46
this(file2, location, location2);
47
this.definition = definition;
51
public String toString() {
52
StringBuffer buffer = new StringBuffer("ItemPointer [");
59
return buffer.toString();
63
public boolean equals(Object obj) {
64
if(!(obj instanceof ItemPointer)){
68
ItemPointer i = (ItemPointer) obj;
69
if(!i.file.equals(file)){
72
if(!i.start.equals(start)){
75
if(!i.end.equals(end)){
83
public int hashCode() {
84
if(this.file != null){
85
return this.file.hashCode() * 17;
87
return (this.end.column+1) * (this.start.line+2) * 9;