Collection<LookupElement> (XPathElement reference) { final ContextProvider contextProvider = ContextProvider.getContextProvider(reference); final VariableContext resolver = contextProvider.getVariableContext(); if (resolver != null) { final Object[] variablesInScope = resolver.getVariablesInScope(reference); final List<LookupElement> lookups = new ArrayList<>(variablesInScope.length); for (final Object o : variablesInScope) { if (o instanceof PsiNamedElement) { final String type; if (o instanceof XPathVariable) { final XPathType t = ((XPathVariable)o).getType(); if (t != XPathType.UNKNOWN) { type = t.getName(); } else { type = ""; } } else { type = ""; } final String name = ((PsiNamedElement)o).getName(); lookups.add(new VariableLookup("$" + name, type, ((PsiNamedElement)o).getIcon(0), (PsiElement)o)); } else { lookups.add(new VariableLookup("$" + o, IconManager.getInstance().getPlatformIcon(com.intellij.ui.PlatformIcons.Variable))); } } return lookups; } else { return Collections.emptySet(); } }