Author: dazarov
Date: 2011-08-12 15:13:11 -0400 (Fri, 12 Aug 2011)
New Revision: 33860
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9473
Modified:
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java 2011-08-12
19:04:36 UTC (rev 33859)
+++
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/QueryParticipantTestUtils.java 2011-08-12
19:13:11 UTC (rev 33860)
@@ -32,45 +32,41 @@
public static final int TYPE_SEARCH = 3;
public static final int PARAMETER_SEARCH = 4;
- public static void testSearchParticipant(IProject project, String fileName, int
searchType, String elementName, String parameterName, IQueryParticipant participant,
List<MatchStructure> matches){
+ public static void testSearchParticipant(IProject project, String fileName, int
searchType, String elementName, String parameterName, IQueryParticipant participant,
List<MatchStructure> matches) throws CoreException{
IFile file = project.getFile(fileName);
assertNotNull("File - "+fileName+" not found", file);
- try{
- ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
- IJavaElement element = null;
+ ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
+ IJavaElement element = null;
+
+ IType type = compilationUnit.findPrimaryType();
+
+ if(searchType == FIELD_SEARCH){
+ element = type.getField(elementName);
+ }else if(searchType == METHOD_SEARCH){
+ element = getMethod(type, elementName);
+ }else if(searchType == TYPE_SEARCH){
+ element = type;
+ }else if(searchType == PARAMETER_SEARCH){
+ IMethod method = getMethod(type, elementName);
+ element = getParameter(method, parameterName);
+ }
+
+ if(element != null){
+ SearchRequestor requestor = new SearchRequestor();
- IType type = compilationUnit.findPrimaryType();
+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
+ IJavaSearchScope scope= factory.createWorkspaceScope(true);
+ String description= factory.getWorkspaceScopeDescription(true);
+ QuerySpecification specification = new ElementQuerySpecification(element,
IJavaSearchConstants.REFERENCES, scope, description);
- if(searchType == FIELD_SEARCH){
- element = type.getField(elementName);
- }else if(searchType == METHOD_SEARCH){
- element = getMethod(type, elementName);
- }else if(searchType == TYPE_SEARCH){
- element = type;
- }else if(searchType == PARAMETER_SEARCH){
- IMethod method = getMethod(type, elementName);
- element = getParameter(method, parameterName);
- }
+ participant.search(requestor, specification, new NullProgressMonitor());
- if(element != null){
- SearchRequestor requestor = new SearchRequestor();
-
- JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
- IJavaSearchScope scope= factory.createWorkspaceScope(true);
- String description= factory.getWorkspaceScopeDescription(true);
- QuerySpecification specification = new ElementQuerySpecification(element,
IJavaSearchConstants.REFERENCES, scope, description);
-
- participant.search(requestor, specification, new NullProgressMonitor());
-
- List<Match> matchesForCheck = requestor.getMatches();
-
- checkMatches(matchesForCheck, matches);
- }else
- fail("Java Element not found");
- }catch(CoreException ex){
- fail("Core exception");
- }
+ List<Match> matchesForCheck = requestor.getMatches();
+
+ checkMatches(matchesForCheck, matches);
+ }else
+ fail("Java Element not found");
}
private static IMethod getMethod(IType type, String name) throws JavaModelException{
@@ -106,7 +102,7 @@
protected static MatchStructure findMatch(List<MatchStructure> matchList, Match
match){
IFile file = (IFile)match.getElement();
- String filePath = ((IFile)match.getElement()).getFullPath().toString();
+ String filePath = file.getFullPath().toString();
String text = FileUtil.getContentFromEditorOrFile(file);
String name = text.substring(match.getOffset(), match.getOffset()+match.getLength());
for(MatchStructure ms : matchList){
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java 2011-08-12
19:04:36 UTC (rev 33859)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java 2011-08-12
19:13:11 UTC (rev 33860)
@@ -5,6 +5,7 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.jboss.tools.jst.web.kb.refactoring.ELReferencesQueryParticipant;
import org.jboss.tools.jst.web.kb.test.QueryParticipantTestUtils;
@@ -60,7 +61,7 @@
}
}
- public void testELReferencesQueryParticipantForType(){
+ public void testELReferencesQueryParticipantForType() throws CoreException{
ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
matches.add(new MatchStructure("/numberguess/web/giveup.jspx",
"numberGuess"));
@@ -75,7 +76,7 @@
matches);
}
- public void testELReferencesQueryParticipantForMethod1(){
+ public void testELReferencesQueryParticipantForMethod1() throws CoreException{
ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
matches.add(new MatchStructure("/numberguess/web/giveup.jspx",
"remainingGuesses"));
@@ -89,7 +90,7 @@
matches);
}
- public void testELReferencesQueryParticipantForMethod2(){
+ public void testELReferencesQueryParticipantForMethod2() throws CoreException{
ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
matches.add(new MatchStructure("/numberguess/web/giveup.jspx",
"possibilities"));