use of org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager in project eclipse.jdt.ls by eclipse.
the class JavaLanguageServerPlugin method start.
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext bundleContext) throws BackingStoreException {
try {
Platform.getBundle(ResourcesPlugin.PI_RESOURCES).start(Bundle.START_TRANSIENT);
} catch (BundleException e) {
logException(e.getMessage(), e);
}
try {
redirectStandardStreams();
} catch (FileNotFoundException e) {
logException(e.getMessage(), e);
}
JavaLanguageServerPlugin.context = bundleContext;
JavaLanguageServerPlugin.pluginInstance = this;
// Set the ID to use for preference lookups
JavaManipulation.setPreferenceNodeId(PLUGIN_ID);
preferenceManager = new PreferenceManager();
initializeJDTOptions();
projectsManager = new ProjectsManager(preferenceManager);
try {
ResourcesPlugin.getWorkspace().addSaveParticipant(PLUGIN_ID, projectsManager);
} catch (CoreException e) {
logException(e.getMessage(), e);
}
contentProviderManager = new ContentProviderManager(preferenceManager);
logInfo(getClass() + " is started");
configureProxy();
}
use of org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager in project eclipse.jdt.ls by eclipse.
the class JDTUtils method findElementsAtSelection.
public static IJavaElement[] findElementsAtSelection(ITypeRoot unit, int line, int column, PreferenceManager preferenceManager, IProgressMonitor monitor) throws JavaModelException {
if (unit == null) {
return null;
}
int offset = JsonRpcHelpers.toOffset(unit.getBuffer(), line, column);
if (offset > -1) {
return unit.codeSelect(offset, 0);
}
if (unit instanceof IClassFile) {
IClassFile classFile = (IClassFile) unit;
ContentProviderManager contentProvider = JavaLanguageServerPlugin.getContentProviderManager();
String contents = contentProvider.getSource(classFile, monitor);
if (contents != null) {
IDocument document = new Document(contents);
try {
offset = document.getLineOffset(line) + column;
if (offset > -1) {
String name = parse(contents, offset);
if (name == null) {
return null;
}
SearchPattern pattern = SearchPattern.createPattern(name, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_FULL_MATCH);
IJavaSearchScope scope = createSearchScope(unit.getJavaProject());
List<IJavaElement> elements = new ArrayList<>();
SearchRequestor requestor = new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) {
if (match.getElement() instanceof IJavaElement) {
elements.add((IJavaElement) match.getElement());
}
}
};
SearchEngine searchEngine = new SearchEngine();
searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, requestor, null);
return elements.toArray(new IJavaElement[0]);
}
} catch (BadLocationException | CoreException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
}
}
return null;
}
use of org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager in project eclipse.jdt.ls by eclipse.
the class JDTLanguageServer method classFileContents.
/* (non-Javadoc)
* @see org.eclipse.jdt.ls.core.internal.JavaProtocolExtensions#ClassFileContents(org.eclipse.lsp4j.TextDocumentIdentifier)
*/
@Override
public CompletableFuture<String> classFileContents(TextDocumentIdentifier param) {
logInfo(">> java/classFileContents");
ContentProviderManager handler = JavaLanguageServerPlugin.getContentProviderManager();
URI uri = JDTUtils.toURI(param.getUri());
return computeAsync((monitor) -> handler.getContent(uri, monitor));
}
Aggregations