diff options
| author | David Salinas | 2012-07-27 14:34:29 +0000 |
|---|---|---|
| committer | Vivian Kong | 2012-07-27 14:34:29 +0000 |
| commit | 1d56bdf3e79b81d489bcf7a5f05914aa5990da9f (patch) | |
| tree | 0fe0fd39f6290827e771a2b6c98b72ee2cdd44f8 | |
| parent | 1d384942263fada4bf4926ee08cb46270a0768e9 (diff) | |
| download | org.eclipse.ptp-1d56bdf3e79b81d489bcf7a5f05914aa5990da9f.tar.gz org.eclipse.ptp-1d56bdf3e79b81d489bcf7a5f05914aa5990da9f.tar.xz org.eclipse.ptp-1d56bdf3e79b81d489bcf7a5f05914aa5990da9f.zip | |
Bug 386079 - Opening function references from context menu doesn't work
2 files changed, 37 insertions, 6 deletions
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 84efb6a32..2aa7ca0ea 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, 2010 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(); |
