本文整理汇总了Java中org.netbeans.spi.editor.completion.CompletionProvider.COMPLETION_QUERY_TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java CompletionProvider.COMPLETION_QUERY_TYPE属性的具体用法?Java CompletionProvider.COMPLETION_QUERY_TYPE怎么用?Java CompletionProvider.COMPLETION_QUERY_TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.netbeans.spi.editor.completion.CompletionProvider
的用法示例。
在下文中一共展示了CompletionProvider.COMPLETION_QUERY_TYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryImpl
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);
}
}
示例2: createTask
@Override
public CompletionTask createTask(int queryType, JTextComponent component) {
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
return null;
}
return new AsyncCompletionTask(new AsyncCompletionQuery() {
@Override
protected void query(CompletionResultSet resultSet, Document doc, int caretOffset) {
//Iterate through the available locales
//and assign each country display name
//to a CompletionResultSet:
String text = DocumentHelper.getWordBeforeCaret(doc, caretOffset);
CompletionProposals[] words = CompletionProposals.values();
Arrays.sort(words);
for (CompletionProposals word : words) {
final String name = word.name().toLowerCase();
if (name.startsWith(text)) {
resultSet.addItem(new RTCompletionItem(name, caretOffset));
}
}
resultSet.finish();
}
}, component);
}
示例3: createTask
@Override
public CompletionTask createTask(int queryType, JTextComponent component) {
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE && queryType !=CompletionProvider.COMPLETION_ALL_QUERY_TYPE) {
return null;
}
return new AsyncCompletionTask(new PUCompletionQuery(queryType, component, component.getSelectionStart(), true), component);
}
示例4: complete
@Override
public List<? extends CompletionItem> complete() {
List<CompletionItem> result = new ArrayList<CompletionItem>();
if (ctx.getCompletionType() == CompletionProvider.COMPLETION_QUERY_TYPE) {
completeShallow(result);
} else {
completeAllEvents(result);
}
return result;
}
示例5: setHasAdditionalItems
public synchronized void setHasAdditionalItems(boolean value) {
checkNotFinished();
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
return;
}
this.hasAdditionalItems = value;
}
示例6: setHasAdditionalItemsText
public synchronized void setHasAdditionalItemsText(String text) {
checkNotFinished();
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
return;
}
this.hasAdditionalItemsText = text;
}
示例7: createTask
public CompletionTask createTask(int queryType, JTextComponent component) {
if( queryType != CompletionProvider.COMPLETION_QUERY_TYPE )
return null;
return new AsyncCompletionTask(new HibernateCfgCompletionQuery(queryType,
component.getSelectionStart()), component);
}
示例8: createTask
public CompletionTask createTask(int queryType, JTextComponent component) {
if( queryType != CompletionProvider.COMPLETION_QUERY_TYPE )
return null;
return new AsyncCompletionTask(new HibernateRevengCompletionQuery(queryType,
component.getSelectionStart()), component);
}
示例9: createTask
public CompletionTask createTask(int queryType, JTextComponent component) {
if( queryType != CompletionProvider.COMPLETION_QUERY_TYPE )
return null;
return new AsyncCompletionTask(new HibernateMappingCompletionQuery(queryType,
component.getSelectionStart()), component);
}
示例10: query
private List<HibernateCompletionItem> query(int caretOffset) throws Exception {
List<HibernateCompletionItem> completionItems = new ArrayList<HibernateCompletionItem>();
assert(instanceDocument != null);
HibernateCfgCompletionQuery instance = new HibernateCfgCompletionQuery(CompletionProvider.COMPLETION_QUERY_TYPE,
caretOffset);
instance.getCompletionItems(instanceDocument, caretOffset, completionItems);
return completionItems;
}
示例11: query
private List<HibernateCompletionItem> query(int caretOffset) throws Exception {
List<HibernateCompletionItem> completionItems = new ArrayList<HibernateCompletionItem>();
assert(instanceDocument != null);
HibernateMappingCompletionQuery instance = new HibernateMappingCompletionQuery(CompletionProvider.COMPLETION_QUERY_TYPE,
caretOffset);
instance.getCompletionItems(instanceDocument, caretOffset, completionItems);
return completionItems;
}
示例12: createTask
public CompletionTask createTask(int queryType, JTextComponent component) {
if (queryType == CompletionProvider.COMPLETION_QUERY_TYPE || queryType == CompletionProvider.COMPLETION_ALL_QUERY_TYPE) {
DatabaseConnection dbconn = findDBConn(component);
if (dbconn == null) {
// XXX perhaps should have an item in the completion instead?
Completion.get().hideAll();
SQLExecutionBaseAction.notifyNoDatabaseConnection();
return null;
}
return new AsyncCompletionTask(new SQLCompletionQuery(dbconn), component);
}
return null;
}
示例13: createTask
@Override
public CompletionTask createTask(int queryType, JTextComponent component) {
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
return null;
}
return new AsyncCompletionTask(new AsyncCompletionQuery() {
@Override
protected void query(CompletionResultSet completionResultSet, Document document, int caretOffset) {
String filter;
int startOffset;
try {
final StyledDocument bDoc = (StyledDocument) document;
final int lineStartOffset = getRowFirstNonWhite(bDoc, caretOffset);
final char[] line = bDoc.getText(lineStartOffset, caretOffset - lineStartOffset).toCharArray();
final int whiteOffset = indexOfWhite(line);
filter = new String(line, whiteOffset + 1, line.length - whiteOffset - 1);
filter = filter.toLowerCase();
if (whiteOffset > 0) {
startOffset = lineStartOffset + whiteOffset + 1;
} else {
startOffset = lineStartOffset;
}
String[] keywords = new String[]{"ClassMethod", "Method", "Property", "Parameter", "Index"};
for (String keyword : keywords) {
if (!keyword.equals("") && keyword.toLowerCase().startsWith(filter)) {
completionResultSet.addItem(new clsCompletionItem(keyword, startOffset, caretOffset));
}
}
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
completionResultSet.finish();
}
}, component);
}
示例14: getAutoQueryTypes
public int getAutoQueryTypes(JTextComponent component, String typedText) {
if (typedText.endsWith(".")) return CompletionProvider.COMPLETION_QUERY_TYPE; // NOI18N
return CompletionProvider.COMPLETION_ALL_QUERY_TYPE;
}
示例15: createTask
@Override
public CompletionTask createTask(int queryType, JTextComponent jtc) {
if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
return null;
}
Project prj = Utilities.actionsGlobalContext().lookup(Project.class);
if (prj == null) {
return null;
}
logger.log(FINE, "Completing within context of prj {0}", FileUtil.getFileDisplayName(prj.getProjectDirectory()));
final SpringBootService sbs = prj.getLookup().lookup(SpringBootService.class);
if (sbs == null) {
return null;
}
logger.fine("Creating completion task");
return new AsyncCompletionTask(new AsyncCompletionQuery() {
@Override
protected void query(CompletionResultSet completionResultSet, Document document, int caretOffset) {
final StyledDocument styDoc = (StyledDocument) document;
Element lineElement = styDoc.getParagraphElement(caretOffset);
int lineStartOffset = lineElement.getStartOffset();
try {
String lineToCaret = styDoc.getText(lineStartOffset, caretOffset - lineStartOffset);
logger.log(FINER, "Completion on line to caret: {0}", lineToCaret);
if (!lineToCaret.contains("#")) {
String[] parts = lineToCaret.split("=");
//property name extraction from part before =
Matcher matcher = PATTERN_PROP_NAME.matcher(parts[0]);
String propPrefix = null;
int propPrefixOffset = 0;
while (matcher.find()) {
propPrefix = matcher.group();
propPrefixOffset = matcher.start();
}
// check which kind of completion
final int equalSignOffset = lineToCaret.indexOf('=');
if (parts.length > 1) {
//value completion
String valPrefix = parts[1].trim();
completePropValue(sbs, completionResultSet, propPrefix, valPrefix, lineStartOffset + lineToCaret.indexOf(
valPrefix, equalSignOffset), caretOffset);
} else if (equalSignOffset >= 0) {
//value completion with empty filter
completePropValue(sbs, completionResultSet, propPrefix, null, lineStartOffset + equalSignOffset + 1,
caretOffset);
} else {
// property completion
completePropName(sbs, completionResultSet, propPrefix, lineStartOffset + propPrefixOffset, caretOffset);
}
}
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
completionResultSet.finish();
}
}, jtc);
}