当前位置: 首页>>代码示例>>Java>>正文


Java CompletionProvider.COMPLETION_QUERY_TYPE属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavadocCompletionQuery.java

示例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);
}
 
开发者ID:iti-luebeck,项目名称:RTeasy2,代码行数:25,代码来源:RTCompletionProvider.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:PUCompletionProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:EventCompleter.java

示例5: setHasAdditionalItems

public synchronized void setHasAdditionalItems(boolean value) {
    checkNotFinished();
    if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
        return;
    }
    this.hasAdditionalItems = value;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:CompletionResultSetImpl.java

示例6: setHasAdditionalItemsText

public synchronized void setHasAdditionalItemsText(String text) {
    checkNotFinished();
    if (queryType != CompletionProvider.COMPLETION_QUERY_TYPE) {
        return;
    }
    this.hasAdditionalItemsText = text;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:CompletionResultSetImpl.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:HibernateCfgCompletionProvider.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:HibernateRevengCompletionProvider.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:HibernateMappingCompletionProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:HibernateCfgCompletionManagerTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:HibernateMappingCompletionManagerTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SQLCompletionProvider.java

示例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);
}
 
开发者ID:daimor,项目名称:NBStudio,代码行数:40,代码来源:clsCodeCompletion.java

示例14: getAutoQueryTypes

public int getAutoQueryTypes(JTextComponent component, String typedText) {
    if (typedText.endsWith(".")) return CompletionProvider.COMPLETION_QUERY_TYPE;  // NOI18N
    return CompletionProvider.COMPLETION_ALL_QUERY_TYPE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:OQLCompletionProvider.java

示例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);
}
 
开发者ID:AlexFalappa,项目名称:nb-springboot,代码行数:57,代码来源:CfgPropsCompletionProvider.java


注:本文中的org.netbeans.spi.editor.completion.CompletionProvider.COMPLETION_QUERY_TYPE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。