diff options
| author | David Salinas | 2012-07-27 15:18:46 +0000 |
|---|---|---|
| committer | Vivian Kong | 2012-07-27 15:18:46 +0000 |
| commit | a63965e61a72a68c9e5132a8cc0e3f18565a5697 (patch) | |
| tree | 080a4b5e6a8cea76342896020ca3b7684d3d8bef | |
| parent | 98d72faae750ada1e0e343935359d08fe032e712 (diff) | |
| download | org.eclipse.ptp-a63965e61a72a68c9e5132a8cc0e3f18565a5697.tar.gz org.eclipse.ptp-a63965e61a72a68c9e5132a8cc0e3f18565a5697.tar.xz org.eclipse.ptp-a63965e61a72a68c9e5132a8cc0e3f18565a5697.zip | |
Bug 386079 - Opening function references from context menu doesn't work
3 files changed, 38 insertions, 7 deletions
diff --git a/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF b/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF index c04d921bf..fe0dc93c9 100755 --- a/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF +++ b/rdt/org.eclipse.ptp.rdt.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.ptp.rdt.ui;singleton:=true -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.1.1.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.cdt.core;bundle-version="5.0.2", org.eclipse.cdt.ui;bundle-version="5.0.2", diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/RemoteSearchService.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/RemoteSearchService.java index b8079145a..6cd75745a 100755 --- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/RemoteSearchService.java +++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/RemoteSearchService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,12 +10,16 @@ *******************************************************************************/ package org.eclipse.ptp.internal.rdt.ui.search; +import java.util.Map; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.utils.EFSExtensionManager; +import org.eclipse.core.resources.IProject; import org.eclipse.jface.text.ITextSelection; +import org.eclipse.ptp.internal.rdt.core.RemoteIndexerInfoProviderFactory; import org.eclipse.ptp.internal.rdt.core.RemoteScannerInfo; import org.eclipse.ptp.internal.rdt.core.model.ModelAdapter; import org.eclipse.ptp.internal.rdt.core.model.Scope; @@ -81,13 +85,21 @@ public class RemoteSearchService extends AbstractRemoteService implements ISearc return new RemoteSearchElementQueryAdapter(getSubSystem(), indexScope, query); } - public ISearchQuery createSearchTextSelectionQuery(Scope indexScope, ICElement[] searchScope, ITranslationUnit element, ITextSelection selNode, int limitTo) { + public ISearchQuery createSearchTextSelectionQuery(Scope indexScope, ICElement[] searchScope, ITranslationUnit element, ITextSelection selNode, int limitTo, IProject project) { try { ITranslationUnit unit = ModelAdapter.adaptElement(null, element, 0, false); if (unit instanceof TranslationUnit) { TranslationUnit tu = (TranslationUnit) unit; // TODO is it ok to use an empty scanner info? - tu.setASTContext(new RemoteScannerInfo(), null); + // SALINAS: No, it's not OK. + Map<String,String> langaugeProperties = null; + try { + String languageId = unit.getLanguage().getId(); + langaugeProperties = RemoteIndexerInfoProviderFactory.getLanguageProperties(languageId, project); + } catch(Exception e) { + RDTLog.logError(e); + } + tu.setASTContext(new RemoteScannerInfo(), langaugeProperties); } RemoteSearchTextSelectionQuery query = new RemoteSearchTextSelectionQuery(convertScope(searchScope), unit, selNode.getText(), selNode.getOffset(), selNode.getLength(), limitTo); return new RemoteSearchTextSelectionQueryAdapter(getSubSystem(), indexScope, query); @@ -95,4 +107,19 @@ public class RemoteSearchService extends AbstractRemoteService implements ISearc throw new IllegalArgumentException(e); } } + + public ISearchQuery createSearchTextSelectionQuery(Scope indexScope, ICElement[] searchScope, ITranslationUnit element, ITextSelection selNode, int limitTo) { + try { + ITranslationUnit unit = ModelAdapter.adaptElement(null, element, 0, false); + if (unit instanceof TranslationUnit) { + TranslationUnit tu = (TranslationUnit) unit; + // TODO is it ok to use an empty scanner info? + tu.setASTContext(new RemoteScannerInfo(), null); + } + RemoteSearchTextSelectionQuery query = new RemoteSearchTextSelectionQuery(convertScope(searchScope), unit, selNode.getText(), selNode.getOffset(), selNode.getLength(), limitTo); + return new RemoteSearchTextSelectionQueryAdapter(getSubSystem(), indexScope, query); + } catch (CModelException e) { + throw new IllegalArgumentException(e); + } + } } diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/actions/FindAction.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/actions/FindAction.java index e736f867a..6bc9e7741 100755 --- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/actions/FindAction.java +++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/internal/rdt/ui/search/actions/FindAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ptp.internal.rdt.core.model.Scope; import org.eclipse.ptp.internal.rdt.ui.search.ISearchService; +import org.eclipse.ptp.internal.rdt.ui.search.RemoteSearchService; import org.eclipse.ptp.rdt.core.services.IRDTServiceConstants; import org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2; import org.eclipse.ptp.services.core.IService; @@ -112,8 +113,11 @@ public abstract class FindAction extends SelectionParseAction { IProject project = element.getCProject().getProject(); ISearchService service = getSearchService(project); Scope scope = new Scope(project); - return service.createSearchTextSelectionQuery(scope, getScope(), - (ITranslationUnit)element, selNode, getLimitTo()); + if (service instanceof RemoteSearchService) { + RemoteSearchService rss = (RemoteSearchService)service; + return rss.createSearchTextSelectionQuery(scope, getScope(), (ITranslationUnit)element, selNode, getLimitTo(), project); + } else + return service.createSearchTextSelectionQuery(scope, getScope(), (ITranslationUnit)element, selNode, getLimitTo()); } abstract protected String getScopeDescription(); |
