@Override public IContentProposal[] getProposals(String contents, int position) { if (!server.isStorageUpdated()) { parentPage.setMessage( "Please refresh project list from server first", IMessageProvider.INFORMATION); return new IContentProposal[0]; } List<IContentProposal> list = new ArrayList<>(); try { List<RemoteModule> modules = getModuleIndex().search(contents); for (RemoteModule m : modules) { RemoteSonarProject prj = new RemoteSonarProject(server.getId(), m.getKey(), m.getName()); list.add(new ContentProposal(prj.asString(), m.getName(), prj.getDescription())); } } catch (Exception e) { SonarLintCorePlugin.getDefault() .debug("Unable to search modules from server " + server.getId(), e); } if (!list.isEmpty()) { parentPage.setMessage("", IMessageProvider.NONE); return list.toArray(new IContentProposal[list.size()]); } else { parentPage.setMessage("No results", IMessageProvider.INFORMATION); return new IContentProposal[0]; } }
public TextSearchIndex<RemoteModule> getModuleIndex() { if (moduleIndex == null && server.isStorageUpdated()) { moduleIndex = server.getModuleIndex(); } return moduleIndex; }