本文整理汇总了Java中com.intellij.psi.filters.position.LeftNeighbour类的典型用法代码示例。如果您正苦于以下问题:Java LeftNeighbour类的具体用法?Java LeftNeighbour怎么用?Java LeftNeighbour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeftNeighbour类属于com.intellij.psi.filters.position包,在下文中一共展示了LeftNeighbour类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import com.intellij.psi.filters.position.LeftNeighbour; //导入依赖的package包/类
@NotNull
@Override
protected ElementFilter compute()
{
return new OrFilter(new AndFilter(new LeftNeighbour(new OrFilter(new AndFilter(new TextFilter("{", "}", ";", ":", "else"), new NotFilter(new SuperParentFilter(new ClassFilter
(PsiAnnotation.class)))), new ElementFilter()
{
@Override
public boolean isAcceptable(Object element, @Nullable PsiElement context)
{
return ((PsiElement) element).getText().endsWith("*/");
}
@Override
public boolean isClassAcceptable(Class hintClass)
{
return true;
}
}, new ClassFilter(OuterLanguageElement.class), new AndFilter(new TextFilter(")"), new NotFilter(new OrFilter(new ParentElementFilter(new ClassFilter(PsiExpressionList.class)), new
ParentElementFilter(new ClassFilter(PsiParameterList.class)), new ParentElementFilter(new ClassFilter(PsiTypeCastExpression.class))))))), new NotFilter(new TextFilter("."))),
START_OF_CODE_FRAGMENT);
}
示例2: registerStandardCompletion
import com.intellij.psi.filters.position.LeftNeighbour; //导入依赖的package包/类
/**
* Template to add all standard keywords completions
*
* @param filter - Semantic filter for given keywords
* @param keywords - Keywords to be completed
*/
private void registerStandardCompletion(ElementFilter filter, String... keywords) {
LeftNeighbour afterDotFilter = new LeftNeighbour(new PlainTextFilter("."));
CompletionVariant variant = new CompletionVariant(new AndFilter(new NotFilter(afterDotFilter), filter));
variant.includeScopeClass(LeafPsiElement.class);
variant.addCompletionFilter(TrueFilter.INSTANCE);
addCompletions(variant, keywords);
registerVariant(variant);
}
示例3: findVariants
import com.intellij.psi.filters.position.LeftNeighbour; //导入依赖的package包/类
public CompletionVariant[] findVariants(PsiElement psiElement, PsiFile psiFile) {
XmlTag tag = SqlMapSymbolCompletionData.getXmlTagForSQLCompletion(psiElement, psiFile);
if (tag != null && findPrefix(psiElement,psiElement.getTextOffset()).contains("#")) { //not symbol
LeftNeighbour left = new LeftNeighbour(TrueFilter.INSTANCE);
CompletionVariant variant = new CompletionVariant(left);
String prefix = findPrefix(psiElement, psiElement.getTextOffset());
String previousText = getPreviousText(psiElement);
//table name completion
if (previousText != null && !prefix.contains("(") && (previousText.equalsIgnoreCase("from") || previousText.equalsIgnoreCase("join")
|| previousText.equalsIgnoreCase("into") || previousText.equalsIgnoreCase("update"))) {
DataSource datasource = JavadocTableNameReferenceProvider.getDataSourceForIbatis(psiElement);
if (datasource != null) {
List<DatabaseTableData> tables = datasource.getTables();
for (DatabaseTableData table : tables) {
variant.addCompletion(IbatisUtil.getTableNameWithoutSchema(table.getName()).toLowerCase());
}
}
} else { //selector completion
String tableAlias = prefix.contains(".") ? prefix.substring(0, prefix.indexOf(".")) : null;
List<String> parameterNames = getSelectorSymbolsForXmlTag(tag, tableAlias); //table alias used
String bracket = "";
if (prefix.contains("(")) {
bracket = prefix.substring(0, prefix.indexOf("(") + 1);
}
if (parameterNames.size() > 0) {
for (String parameterName : parameterNames) {
variant.addCompletion(bracket + (tableAlias == null ? "" : tableAlias + ".") + parameterName.toLowerCase());
}
}
}
variant.includeScopeClass(PsiElement.class, true);
variant.addCompletionFilter(TrueFilter.INSTANCE);
variant.setInsertHandler(new SqlMapSymbolnsertHandler());
return new CompletionVariant[]{variant};
}
if (parentCompletionData != null) return parentCompletionData.findVariants(psiElement, psiFile);
return super.findVariants(psiElement, psiFile);
}
示例4: createXmlEntityCompletionFilter
import com.intellij.psi.filters.position.LeftNeighbour; //导入依赖的package包/类
protected ElementFilter createXmlEntityCompletionFilter() {
return new AndFilter(new LeftNeighbour(new XmlTextFilter("&")), new OrFilter(new XmlTokenTypeFilter(XmlTokenType.XML_DATA_CHARACTERS),
new XmlTokenTypeFilter(
XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)));
}
示例5: findVariants
import com.intellij.psi.filters.position.LeftNeighbour; //导入依赖的package包/类
@Override
public CompletionVariant[] findVariants(PsiElement psiElement, PsiFile psiFile) {
XmlTag tag = getXmlTagForSQLCompletion(psiElement, psiFile);
if (tag != null) { //
String prefix = findPrefix(psiElement, psiElement.getTextOffset());
String prefix2 = prefix.substring(0, prefix.indexOf("#") + 1);
if (prefix.contains("#")) { //# is necessary
LeftNeighbour left = new LeftNeighbour(new TextFilter(OPEN_TAG));
CompletionVariant variant = new CompletionVariant(left);
variant.includeScopeClass(PsiElement.class, true);
variant.addCompletionFilter(TrueFilter.INSTANCE);
variant.setInsertHandler(new SqlMapSymbolnsertHandler());
if (!prefix.contains(":")) { //just clear in line parameter name
if (!prefix.contains(".")) { //root field
List<String> parameterNames = getParameterNamesForXmlTag(tag, prefix2);
for (String parameterName : parameterNames) {
variant.addCompletion(parameterName);
}
} else //recursion field
{
String parameterClass = tag.getAttributeValue("parameterClass");
if (IbatisClassShortcutsReferenceProvider.isDomain(parameterClass)) //domain class
{
PsiClass psiClass = IbatisClassShortcutsReferenceProvider.getPsiClass(psiElement, parameterClass);
if (psiClass != null) { //find
Map<String, String> methodMap = FieldAccessMethodReferenceProvider.getAllSetterMethods(psiClass, prefix.replace("#", ""));
for (Map.Entry<String, String> entry : methodMap.entrySet()) {
variant.addCompletion(prefix2 + entry.getKey());
}
}
}
}
} else //jdbc type will be added
{
if ((prefix + " ").split(":").length == 2) { //only one ':' included
prefix = prefix.substring(0, prefix.indexOf(':'));
for (String typeName : JdbcType.TYPES.keySet()) {
variant.addCompletion(prefix + ":" + typeName);
}
} else //two ':' include
{
}
}
return new CompletionVariant[]{variant};
}
}
if (parentCompletionData != null) return parentCompletionData.findVariants(psiElement, psiFile);
return super.findVariants(psiElement, psiFile);
}