Lines 64-91
Link Here
|
64 |
} |
64 |
} |
65 |
|
65 |
|
66 |
/** |
66 |
/** |
67 |
* Opens given {@link Element}. |
67 |
* Opens {@link Element} corresponding to the given {@link ElementHandle}. |
68 |
* |
68 |
* |
69 |
* @param cpInfo ClasspathInfo which should be used for the search |
69 |
* @param cpInfo ClasspathInfo which should be used for the search |
70 |
* @param el declaration to open |
70 |
* @param el declaration to open |
71 |
* @return true if and only if the declaration was correctly opened, |
71 |
* @return true if and only if the declaration was correctly opened, |
72 |
* false otherwise |
72 |
* false otherwise |
|
|
73 |
* @since 1.5 |
73 |
*/ |
74 |
*/ |
74 |
public static boolean open(final ClasspathInfo cpInfo, final Element el) { |
75 |
public static boolean open(final ClasspathInfo cpInfo, final ElementHandle<? extends Element> el) { |
75 |
Object[] openInfo = getOpenInfo (cpInfo, el); |
76 |
FileObject fo = SourceUtils.getFile(el, cpInfo); |
76 |
if (openInfo != null) { |
77 |
Object[] openInfo = fo != null ? getOpenInfo(fo, el) : null; |
77 |
assert openInfo[0] instanceof FileObject; |
78 |
if (openInfo != null) { |
78 |
assert openInfo[1] instanceof Integer; |
79 |
assert openInfo[0] instanceof FileObject; |
79 |
return doOpen((FileObject)openInfo[0],(Integer)openInfo[1]); |
80 |
assert openInfo[1] instanceof Integer; |
80 |
} |
81 |
return doOpen((FileObject) openInfo[0], (Integer) openInfo[1]); |
81 |
|
82 |
} |
|
|
83 |
|
82 |
BinaryElementOpen beo = Lookup.getDefault().lookup(BinaryElementOpen.class); |
84 |
BinaryElementOpen beo = Lookup.getDefault().lookup(BinaryElementOpen.class); |
83 |
|
85 |
|
84 |
if (beo != null) { |
86 |
if (beo != null) { |
85 |
return beo.open(cpInfo, ElementHandle.create(el)); |
87 |
return beo.open(cpInfo, el); |
86 |
} else { |
88 |
} else { |
87 |
return false; |
89 |
return false; |
88 |
} |
90 |
} |
|
|
91 |
} |
92 |
|
93 |
/** |
94 |
* Opens given {@link Element}. |
95 |
* |
96 |
* @param cpInfo ClasspathInfo which should be used for the search |
97 |
* @param el declaration to open |
98 |
* @return true if and only if the declaration was correctly opened, |
99 |
* false otherwise |
100 |
*/ |
101 |
public static boolean open(final ClasspathInfo cpInfo, final Element el) { |
102 |
return open(cpInfo, ElementHandle.create(el)); |
89 |
} |
103 |
} |
90 |
|
104 |
|
91 |
/** |
105 |
/** |
Lines 120-134
Link Here
|
120 |
|
134 |
|
121 |
// Private methods --------------------------------------------------------- |
135 |
// Private methods --------------------------------------------------------- |
122 |
|
136 |
|
123 |
private static Object[] getOpenInfo (final ClasspathInfo cpInfo, final Element el) { |
|
|
124 |
FileObject fo = SourceUtils.getFile(el, cpInfo); |
125 |
if (fo != null) { |
126 |
return getOpenInfo(fo, ElementHandle.create(el)); |
127 |
} else { |
128 |
return null; |
129 |
} |
130 |
} |
131 |
|
132 |
private static Object[] getOpenInfo(final FileObject fo, final ElementHandle<? extends Element> handle) { |
137 |
private static Object[] getOpenInfo(final FileObject fo, final ElementHandle<? extends Element> handle) { |
133 |
assert fo != null; |
138 |
assert fo != null; |
134 |
|
139 |
|