use of com.intellij.codeInsight.lookup.LookupElementBuilder in project intellij-community by JetBrains.
the class XmlCompletionContributor method buildEntityLookupItem.
@Nullable
private static LookupElementBuilder buildEntityLookupItem(@NotNull final XmlEntityDecl decl) {
final String name = decl.getName();
if (name == null) {
return null;
}
final LookupElementBuilder result = LookupElementBuilder.create(name).withInsertHandler(ENTITY_INSERT_HANDLER);
final XmlAttributeValue value = decl.getValueElement();
final ASTNode node = value.getNode();
if (node != null) {
final ASTNode[] nodes = node.getChildren(TokenSet.create(XmlTokenType.XML_CHAR_ENTITY_REF));
if (nodes.length == 1) {
final String valueText = nodes[0].getText();
final int i = valueText.indexOf('#');
if (i > 0) {
String s = valueText.substring(i + 1);
s = StringUtil.trimEnd(s, ";");
try {
final int unicodeChar = Integer.valueOf(s).intValue();
return result.withTypeText(String.valueOf((char) unicodeChar));
} catch (NumberFormatException e) {
return result;
}
}
}
}
return result;
}
use of com.intellij.codeInsight.lookup.LookupElementBuilder in project Intellij-Plugin by getgauge.
the class ConceptDynamicArgCompletionProvider method addCompletions.
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
String prefix = getPrefix(parameters);
resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
Collection<ConceptDynamicArg> args = PsiTreeUtil.collectElementsOfType(parameters.getOriginalFile(), ConceptDynamicArg.class);
for (ConceptDynamicArg arg : args) {
LookupElementBuilder item = LookupElementBuilder.create(arg.getText().replaceAll("<|>", ""));
resultSet.addElement(item);
}
}
Aggregations