Lines 46-54
Link Here
|
46 |
import java.util.logging.Logger; |
46 |
import java.util.logging.Logger; |
47 |
import javax.swing.text.Document; |
47 |
import javax.swing.text.Document; |
48 |
import javax.swing.text.JTextComponent; |
48 |
import javax.swing.text.JTextComponent; |
49 |
import org.netbeans.api.annotations.common.NullAllowed; |
|
|
50 |
import org.netbeans.api.editor.EditorUtilities; |
51 |
import org.netbeans.api.lexer.Language; |
52 |
import org.netbeans.api.lexer.Token; |
49 |
import org.netbeans.api.lexer.Token; |
53 |
import org.netbeans.api.lexer.TokenHierarchy; |
50 |
import org.netbeans.api.lexer.TokenHierarchy; |
54 |
import org.netbeans.api.lexer.TokenId; |
51 |
import org.netbeans.api.lexer.TokenId; |
Lines 89-95
Link Here
|
89 |
* |
86 |
* |
90 |
* @author Petr Pisl |
87 |
* @author Petr Pisl |
91 |
*/ |
88 |
*/ |
92 |
class JsCodeCompletion implements CodeCompletionHandler { |
89 |
class JsCodeCompletion implements CodeCompletionHandler2 { |
93 |
|
90 |
|
94 |
private static final Logger LOGGER = Logger.getLogger(JsCodeCompletion.class.getName()); |
91 |
private static final Logger LOGGER = Logger.getLogger(JsCodeCompletion.class.getName()); |
95 |
|
92 |
|
Lines 233-240
Link Here
|
233 |
|
230 |
|
234 |
@Override |
231 |
@Override |
235 |
public String document(ParserResult info, ElementHandle element) { |
232 |
public String document(ParserResult info, ElementHandle element) { |
236 |
final StringBuilder documentation = new StringBuilder(); |
233 |
Documentation doc = documentElement(info, element); |
237 |
if(element instanceof IndexedElement) { |
234 |
if (doc != null) { |
|
|
235 |
return doc.getContent(); |
236 |
} |
237 |
return null; |
238 |
} |
239 |
|
240 |
@Override |
241 |
public Documentation documentElement(ParserResult info, ElementHandle element) { |
242 |
if (element instanceof IndexedElement) { |
243 |
final Documentation[] result = new Documentation[1]; |
238 |
final IndexedElement indexedElement = (IndexedElement)element; |
244 |
final IndexedElement indexedElement = (IndexedElement)element; |
239 |
FileObject nextFo = indexedElement.getFileObject(); |
245 |
FileObject nextFo = indexedElement.getFileObject(); |
240 |
if (nextFo != null) { |
246 |
if (nextFo != null) { |
Lines 251-260
Link Here
|
251 |
JsObject jsObjectGlobal = jsInfo.getModel().getGlobalObject(); |
257 |
JsObject jsObjectGlobal = jsInfo.getModel().getGlobalObject(); |
252 |
JsObject property = ModelUtils.findJsObjectByName(jsObjectGlobal, fqn); |
258 |
JsObject property = ModelUtils.findJsObjectByName(jsObjectGlobal, fqn); |
253 |
if (property != null) { |
259 |
if (property != null) { |
254 |
String doc = property.getDocumentation(); |
260 |
Documentation doc = property.getDocumentation(); |
255 |
if (doc != null && !doc.isEmpty()) { |
261 |
result[0] = doc; |
256 |
documentation.append(doc); |
|
|
257 |
} |
258 |
} |
262 |
} |
259 |
|
263 |
|
260 |
} else { |
264 |
} else { |
Lines 267-293
Link Here
|
267 |
LOGGER.log(Level.WARNING, null, ex); |
271 |
LOGGER.log(Level.WARNING, null, ex); |
268 |
} |
272 |
} |
269 |
} |
273 |
} |
|
|
274 |
if (result[0] != null) { |
275 |
return result[0]; |
276 |
} |
270 |
} else if (element instanceof JsObject) { |
277 |
} else if (element instanceof JsObject) { |
271 |
JsObject jsObject = (JsObject) element; |
278 |
JsObject jsObject = (JsObject) element; |
272 |
if (jsObject.getDocumentation() != null) { |
279 |
if (jsObject.getDocumentation() != null) { |
273 |
documentation.append(jsObject.getDocumentation()); |
280 |
return jsObject.getDocumentation(); |
274 |
} |
281 |
} |
275 |
} |
282 |
} |
276 |
if (documentation.length() == 0) { |
283 |
|
277 |
for (CompletionProvider interceptor : EditorExtender.getDefault().getCompletionProviders()) { |
284 |
for (CompletionProvider interceptor : EditorExtender.getDefault().getCompletionProviders()) { |
278 |
String doc = interceptor.getHelpDocumentation(info, element); |
285 |
String doc = interceptor.getHelpDocumentation(info, element); |
279 |
if (doc != null && !doc.isEmpty()) { |
286 |
if (doc != null && !doc.isEmpty()) { |
280 |
documentation.append(doc); |
287 |
return Documentation.create(doc); |
281 |
} |
|
|
282 |
} |
288 |
} |
283 |
} |
289 |
} |
|
|
290 |
|
284 |
if (element instanceof JsDocumentationElement) { |
291 |
if (element instanceof JsDocumentationElement) { |
285 |
return ((JsDocumentationElement) element).getDocumentation(); |
292 |
return Documentation.create(((JsDocumentationElement) element).getDocumentation()); |
286 |
} |
293 |
} |
287 |
if (documentation.length() == 0) { |
294 |
|
288 |
documentation.append(NbBundle.getMessage(JsCodeCompletion.class, "MSG_DocNotAvailable")); |
295 |
return Documentation.create(NbBundle.getMessage(JsCodeCompletion.class, "MSG_DocNotAvailable")); |
289 |
} |
|
|
290 |
return documentation.toString(); |
291 |
} |
296 |
} |
292 |
|
297 |
|
293 |
|
298 |
|