diff options
author | Dani Megert | 2010-05-02 05:58:03 +0000 |
---|---|---|
committer | Dani Megert | 2010-05-02 05:58:03 +0000 |
commit | 42f587086b31ee2d9d5d1f50fa66f3defbdb4580 (patch) | |
tree | 4ef812e9a20a0cc94ff0bf5fe77b349cd7bfb83a /org.eclipse.search | |
parent | 20849686dbab468a22ae140e35aea00dd7fc9e80 (diff) | |
download | eclipse.platform.text-42f587086b31ee2d9d5d1f50fa66f3defbdb4580.tar.gz eclipse.platform.text-42f587086b31ee2d9d5d1f50fa66f3defbdb4580.tar.xz eclipse.platform.text-42f587086b31ee2d9d5d1f50fa66f3defbdb4580.zip |
Fixed bug 311148: SearchPageDescriptor#computeScore(Object) should test alternatives
Diffstat (limited to 'org.eclipse.search')
-rw-r--r-- | org.eclipse.search/schema/searchPages.exsd | 2 | ||||
-rw-r--r-- | org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/org.eclipse.search/schema/searchPages.exsd b/org.eclipse.search/schema/searchPages.exsd index b6a71aa920d..17c2b2281bf 100644 --- a/org.eclipse.search/schema/searchPages.exsd +++ b/org.eclipse.search/schema/searchPages.exsd @@ -138,7 +138,7 @@ page comes first <annotation> <documentation> a comma separated list with file extensions on which the search page can operate. Each extension must also include a weight (0 meaning lowest weight) which enables the search infrastructure to find the best fitting page. The weight is separated from the extension by a colon. If a search page can search all possible resources then "*" can be used. -<br><b>Note:</b> This only applies if there is no <code>org.eclipse.search.ui.ISearchPageScoreComputer</code> adapter for the selected element. +<br><b>Note:</b> If there is an <code>org.eclipse.search.ui.ISearchPageScoreComputer</code> adapter for the selected element which returns a higher weight, then this higher weight will be used. </documentation> </annotation> </attribute> diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java index 6132437e3a2..28c8b88bf80 100644 --- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java +++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -311,16 +311,20 @@ class SearchPageDescriptor implements IPluginContribution, Comparable { */ public int computeScore(Object element) { if (element instanceof IAdaptable) { + int score= ISearchPageScoreComputer.UNKNOWN; + ISearchPageScoreComputer tester= (ISearchPageScoreComputer)((IAdaptable)element).getAdapter(ISearchPageScoreComputer.class); if (tester != null) - return tester.computeScore(getId(), element); + score= tester.computeScore(getId(), element); IResource resource= (IResource)((IAdaptable)element).getAdapter(IResource.class); if (resource != null && resource.getType() == IResource.FILE) { String extension= ((IFile)resource).getFileExtension(); if (extension != null) - return getScoreForFileExtension(extension); + score= Math.max(score, getScoreForFileExtension(extension)); } + if (score != ISearchPageScoreComputer.UNKNOWN) + return score; } if (fWildcardScore != ISearchPageScoreComputer.UNKNOWN) return fWildcardScore; @@ -338,10 +342,8 @@ class SearchPageDescriptor implements IPluginContribution, Comparable { if (extension.equals(p.extension)) return p.score; } - if (fWildcardScore != ISearchPageScoreComputer.UNKNOWN) - return fWildcardScore; - return ISearchPageScoreComputer.LOWEST; + return ISearchPageScoreComputer.UNKNOWN; } private void readExtensionScorePairs() { |