本文整理汇总了Java中org.netbeans.spi.editor.completion.CompletionItem类的典型用法代码示例。如果您正苦于以下问题:Java CompletionItem类的具体用法?Java CompletionItem怎么用?Java CompletionItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionItem类属于org.netbeans.spi.editor.completion包,在下文中一共展示了CompletionItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMethodCallTags
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
/**
* Adds completion items obtained by method call to result.
*/
private void addMethodCallTags (
List keys,
Context context,
Result resultSet,
String start
) {
Iterator it = keys.iterator ();
while (it.hasNext ()) {
Object o = it.next ();
if (o instanceof org.netbeans.api.languages.CompletionItem)
o = new CompletionSupport (
(org.netbeans.api.languages.CompletionItem) o,
start
);
CompletionItem item = (CompletionItem) o;
items.add (item);
CharSequence chs = item.getInsertPrefix ();
String s = chs instanceof String ? (String) chs : chs.toString ();
if (ignoreCase)
s = s.toLowerCase ();
if (s.startsWith (start))
resultSet.addItem (item);
}
}
示例2: addTags
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private void addTags (
String text,
Feature feature,
int j,
String start,
Result resultSet
) {
if (ignoreCase)
text = text.toLowerCase ();
String description = (String) feature.getValue ("description" + j);
if (description == null)
description = text;
String icon = (String) feature.getValue ("icon" + j);
CompletionItem item = new CompletionSupport (
text, start, description, null, icon, 2
);
items.add (item);
if (!text.startsWith (start))
return;
resultSet.addItem (item);
}
示例3: createCompletionItem
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private static CompletionSupport createCompletionItem (DatabaseDefinition definition, String fileName,
String start) {
Type type = null;
if ("local".equals (definition.getType ()))
type = Type.LOCAL;
else
if ("parameter".equals (definition.getType ()))
type = Type.PARAMETER;
else
if ("field".equals (definition.getType ()))
type = Type.FIELD;
else
if ("method".equals (definition.getType ()))
type = Type.METHOD;
return new CompletionSupport (new org.netbeans.api.languages.CompletionItem (
definition.getName (),
null,
fileName,
type,
100
), start);
}
示例4: resolveCompletion
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private void resolveCompletion (ParserResult controller)
throws IOException {
Env env = getCompletionEnvironment(controller, true);
int offset = env.getOffset();
String prefix = env.getPrefix();
results = new ArrayList<CompletionItem>();
isTruncated = false;
isFilterable = true;
anchorOffset = env.getOffset() - ((prefix != null) ? prefix.length() : 0);
CodeCompletionHandler completer = env.getCompletable();
if (completer != null) {
addCodeCompletionItems(controller, completer, offset, prefix);
if (isTruncated) {
// Add truncation item
GsfCompletionItem item = GsfCompletionItem.createTruncationItem();
results.add(item);
}
}
}
示例5: getFilteredData
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private Collection getFilteredData(Collection<CompletionItem> data, String prefix) {
if (prefix.length() == 0) {
return data;
}
List ret = new ArrayList();
for (Iterator<CompletionItem> it = data.iterator(); it.hasNext();) {
CompletionItem itm = it.next();
if (startsWith(itm.getInsertPrefix().toString(), prefix)) {
ret.add(itm);
}
// else if (itm instanceof LazyTypeCompletionItem && Utilities.startsWith(((LazyTypeCompletionItem)itm).getItemText(), prefix))
// ret.add(itm);
}
return ret;
}
示例6: complete
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
@Override
public List<? extends CompletionItem> complete() {
List<String> allValues = new ArrayList<String>(instance.getDefinition().getConstants());
Collections.sort(allValues);
String prefix = ctx.getPrefix();
if (prefix != null && prefix.length() > 0) {
for (Iterator<String> it = allValues.iterator(); it.hasNext(); ) {
String s = it.next();
if (!s.startsWith(prefix)) {
it.remove();
}
}
}
if (allValues.isEmpty()) {
return null;
}
List<CompletionItem> items = new ArrayList<CompletionItem>();
for (String v : allValues) {
ValueItem vi = new ValueItem(ctx, v, ICON_CONSTANT_VALUE);
items.add(vi);
}
return items;
}
示例7: convert
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
@Override
public CompletionItem convert(TypeElement elem, CompletionContext ctx, int priorityHint) {
CompilationInfo ci = ctx.getCompilationInfo();
if (!acceptsType(elem, ci)) {
return null;
} else {
String fqn = elem.getQualifiedName().toString();
FxBean bean = ctx.getBeanInfo(fqn);
String n = ctx.getSimpleClassName(fqn);
if (n == null) {
n = fqn;
}
return SimpleClassItem.setup(
new ValueClassItem(
ctx,
n,
bean != null && bean.getPropertyNames().isEmpty()
), elem, ctx, priorityHint);
}
}
示例8: createItem
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private CompletionItem createItem(ElementHandle<TypeElement> handle, int priority) {
TypeElement el = handle.resolve(ctx.getCompilationInfo());
if (el == null) {
// element does not exist etc
return null;
}
if (el.getKind() != ElementKind.CLASS && el.getKind() != ElementKind.ENUM) {
// do not honour interfaces
return null;
}
if (!el.getModifiers().contains(Modifier.PUBLIC)) {
return null;
}
CompletionItem item = null;
Collection<? extends ClassItemFactory> converters = MimeLookup.getLookup(JavaFXEditorUtils.FXML_MIME_TYPE).lookupAll(ClassItemFactory.class);
for (ClassItemFactory converter : converters) {
item = converter.convert(el, ctx, priority);
if (item != null) {
break;
}
}
return item;
}
示例9: complete
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
@NbBundle.Messages({
"FMT_fxReferenceCompletionItem=<fx:reference source=\"\"",
"FMT_fxCopyCompletionItem=<fx:copy source=\"\""
})
@Override
public List<CompletionItem> complete() {
Callable<String> fxNs = CompletionUtils.makeFxNamespaceCreator(context);
List<CompletionItem> items = new ArrayList<CompletionItem>(2);
FxInstructionItem inst = new FxInstructionItem(
"fx:reference", // NOI18N
context,
FMT_fxReferenceCompletionItem(),
fxNs);
items.add(inst);
inst = new FxInstructionItem(
"fx:copy", // NOI18N
context,
FMT_fxCopyCompletionItem(),
fxNs);
items.add(inst);
return items;
}
示例10: toCompletionItems
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private void toCompletionItems(String folderName, Collection<FileObject> files) {
for (FileObject f : files) {
DataObject d;
try {
d = DataObject.find(f);
} catch (DataObjectNotFoundException ex) {
// ???
continue;
}
String value = folderName == null ? f.getNameExt() : folderName + "/" + f.getNameExt();
if (f.isFolder()) {
value = value + "/";
}
if (resourceRef) {
value = "@" + value;
}
if (context.isAttribute()) {
value = "\"" + value + "\"";
}
CompletionItem item = new ResourcePathItem(d, context, value, null);
results.add(item);
}
}
示例11: complete
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
@Override
public List<? extends CompletionItem> complete() {
valPrefix = context.getPrefix();
if (resourceRef && valPrefix.startsWith("@")) {
valPrefix = valPrefix.substring(1);
}
// first try to complete from the nearby files; if empty, try to query all resources with the matching name.
Set<String> names = new HashSet<String>();
List<FileObject> files = new ArrayList<FileObject>();
if (valPrefix.startsWith("/")) {
completeFromRoots();
} else {
completeFromCurrent();
}
return results;
}
示例12: queryImpl
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private void queryImpl(CompletionResultSet resultSet, Document doc, int caretOffset) throws InterruptedException, ExecutionException {
JavadocContext jdctx = new JavadocContext();
items = new ArrayList<CompletionItem>();
this.caretOffset = caretOffset;
runInJavac(JavaSource.forDocument(doc), jdctx);
if (!ignoreCancel && isTaskCancelled()) {
return;
}
if ((queryType & CompletionProvider.COMPLETION_QUERY_TYPE) != 0) {
if (!items.isEmpty()) {
resultSet.addAllItems(items);
}
resultSet.setHasAdditionalItems(hasAdditionalItems);
}
if (jdctx.anchorOffset >= 0) {
resultSet.setAnchorOffset(jdctx.anchorOffset);
}
}
示例13: JavadocExecutableItem
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
public JavadocExecutableItem(CompletionItem jmethod,
ExecutableElement ee, int substitutionOffset) {
this.delegate = jmethod;
this.substitutionOffset = substitutionOffset;
this.name = ee.getKind() == ElementKind.METHOD
? ee.getSimpleName()
: ee.getEnclosingElement().getSimpleName();
List<? extends VariableElement> params = ee.getParameters();
this.paramTypes = new String[params.size()];
int i = 0;
for (VariableElement p : params) {
TypeMirror asType = p.asType();
this.paramTypes[i++] = resolveTypeName(asType, ee.isVarArgs()).toString();
}
}
示例14: performCompletionTest
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
private void performCompletionTest(String code, String... golden) throws Exception {
int caret = code.indexOf('|');
prepareTest(code.replace("|", ""));
List<CompletionItem> resultObj = JavadocCompletionQuery.runCompletionQuery(CompletionProvider.COMPLETION_QUERY_TYPE, doc, caret);
List<String> resultStrings = new ArrayList<String>(resultObj.size());
for (CompletionItem ci : resultObj) {
if (ci instanceof JavadocCompletionItem) {
JavadocCompletionItem jci = (JavadocCompletionItem) ci;
resultStrings.add(stripHTML(jci.getLeftHtmlText() + ":" + (jci.getRightHtmlText() != null ? jci.getRightHtmlText() : "")));
} else {
resultStrings.add(stripHTML(ci.toString()));
}
}
List<String> goldenList = new ArrayList<String>(Arrays.asList(golden));
if (goldenList.contains(null)) {
goldenList.remove(null);
assertTrue(resultStrings.toString(), resultStrings.containsAll(goldenList));
} else {
Collections.sort(goldenList);
Collections.sort(resultStrings);
assertEquals(goldenList, resultStrings);
}
}
示例15: completeOpenTags
import org.netbeans.spi.editor.completion.CompletionItem; //导入依赖的package包/类
@Override
public List<CompletionItem> completeOpenTags(CompletionContext context) {
List<CompletionItem> items = new ArrayList<>();
FileObject file = context.getResult().getSnapshot().getSource().getFileObject();
Configuration conf = Configuration.EMPTY;
if (file != null) {
conf = Configuration.get(file);
}
for (Tag t : conf.getTags()) {
String tagName = t.getName();
if (tagName.startsWith(context.getPrefix())) {
items.add(new CustomTagCompletionItem(t, context.getCCItemStartOffset()));
}
}
return items;
}