Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Problem with IJavaSearchScope
Problem with IJavaSearchScope [message #258523] Fri, 06 February 2009 06:54 Go to next message
Eclipse UserFriend
hello,
i am building an application that finds pattern for Integer() wrapper
class, means occurance of Integer() in a java file. for that i find
eclipse.jdt.core.search and with that i build a program but it throws
ExceptionInInitializerError

I am not getting why this error has occured, please help me to solve my
problem.....
thnx in advance...

my source code is as follows:

import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.core.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.lang.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.osgi.*;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
public class test {

IPackageFragment pkg ;
IJavaSearchScope scope;
public void parser() throws IOException {
// TODO Auto-generated method stub
try {
System.out.println("in method..");

SearchPattern pattern = SearchPattern.createPattern(
"Integer*",
IJavaSearchConstants.METHOD,
IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_PATTERN_MATCH);
scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{this.pkg});
SearchRequestor requestor = new SearchRequestor() {
public void acceptSearchMatch(SearchMatch match) {
System.out.println(match.getElement());

}
};
SearchEngine searchEngine= new SearchEngine();
searchEngine.search(pattern, new
SearchParticipant[]{SearchEngine.getDefaultSearchParticipant ()}, scope,
requestor, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
System.out.println(e.getCause());
}
catch(NullPointerException ne){
System.out.println(ne.getCause());
}
catch (ExceptionInInitializerError ee) {
// TODO Auto-generated catch block
System.out.println(ee.getCause());

}


}

}
Re: Problem with IJavaSearchScope [message #258536 is a reply to message #258523] Fri, 06 February 2009 15:01 Go to previous messageGo to next message
Eclipse UserFriend
gunjju wrote:
> hello,
> i am building an application that finds pattern for Integer() wrapper
> class, means occurance of Integer() in a java file. for that i find
> eclipse.jdt.core.search and with that i build a program but it throws
> ExceptionInInitializerError
> I am not getting why this error has occured, please help me to solve my
> problem.....
> thnx in advance...

You might be running into a problem with the signing of the jars in
your Eclipse build, or in plug-ins you've added. Try updating them.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational
Re: Problem with IJavaSearchScope [message #258546 is a reply to message #258536] Mon, 09 February 2009 03:39 Go to previous messageGo to next message
Eclipse UserFriend
Nitin Dahyabhai wrote:

> gunjju wrote:
>> hello,
>> i am building an application that finds pattern for Integer() wrapper
>> class, means occurance of Integer() in a java file. for that i find
>> eclipse.jdt.core.search and with that i build a program but it throws
>> ExceptionInInitializerError
>> I am not getting why this error has occured, please help me to solve my
>> problem.....
>> thnx in advance...

> You might be running into a problem with the signing of the jars in
> your Eclipse build, or in plug-ins you've added. Try updating them.

Hi,
i have updated and tried for same, but still same problem coming, i tried
with debug it is showing some error in IndexManager indexManager =
JavaModelManager.getJavaModelManager().getIndexManager(); in
BasicSearchEngine.class
Re: Problem with IJavaSearchScope [message #258580 is a reply to message #258523] Tue, 10 February 2009 10:42 Go to previous message
Eclipse UserFriend
gunjju wrote:
> hello,
> i am building an application that finds pattern for Integer() wrapper
> class, means occurance of Integer() in a java file. for that i find
> eclipse.jdt.core.search and with that i build a program but it throws
> ExceptionInInitializerError
> I am not getting why this error has occured, please help me to solve my
> problem.....
> thnx in advance...
>
> my source code is as follows:
>
> import org.eclipse.jdt.core.IClassFile;
> import org.eclipse.jdt.core.ICompilationUnit;
> import org.eclipse.jdt.core.IJavaElement;
> import org.eclipse.jdt.core.IJavaProject;
> import org.eclipse.jdt.core.IPackageFragment;
> import org.eclipse.jdt.core.IPackageFragmentRoot;
> import org.eclipse.jdt.core.search.IJavaSearchConstants;
> import org.eclipse.jdt.core.search.IJavaSearchScope;
> import org.eclipse.jdt.core.search.SearchEngine;
> import org.eclipse.jdt.core.search.SearchMatch;
> import org.eclipse.jdt.core.search.SearchParticipant;
> import org.eclipse.jdt.core.search.SearchPattern;
> import org.eclipse.jdt.core.search.SearchRequestor;
> import org.eclipse.core.*;
> import org.eclipse.core.resources.*;
> import org.eclipse.core.runtime.CoreException;
> import org.eclipse.core.runtime.IProgressMonitor;
> import org.eclipse.jdt.core.util.*;
> import java.io.IOException;
> import java.io.InputStream;
> import java.lang.*;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.StringTokenizer;
> import org.osgi.*;
> import org.eclipse.jface.viewers.ISelection;
> import org.eclipse.jface.viewers.IStructuredSelection;
> public class test {
> IPackageFragment pkg ;
> IJavaSearchScope scope;
> public void parser() throws IOException {
> // TODO Auto-generated method stub
> try {
> System.out.println("in method..");
>
> SearchPattern pattern = SearchPattern.createPattern(
> "Integer*", IJavaSearchConstants.METHOD,
> IJavaSearchConstants.DECLARATIONS,
> SearchPattern.R_PATTERN_MATCH);
> scope = SearchEngine.createJavaSearchScope(new IJavaElement[]{this.pkg});
> SearchRequestor requestor = new SearchRequestor() {
> public void acceptSearchMatch(SearchMatch match) {
> System.out.println(match.getElement());
>
> }
> };
> SearchEngine searchEngine= new SearchEngine();
> searchEngine.search(pattern, new
> SearchParticipant[]{SearchEngine.getDefaultSearchParticipant ()}, scope,
> requestor, null);
> } catch (CoreException e) {
> // TODO Auto-generated catch block
> System.out.println(e.getCause());
> }
> catch(NullPointerException ne){
> System.out.println(ne.getCause());
> }
> catch (ExceptionInInitializerError ee) {
> // TODO Auto-generated catch block
> System.out.println(ee.getCause());
>
> }
> }
>
> }
>
>
>

It looks like you're running this snippet as a Java application...
If so, could you try to run it as an Eclipse application?

I also doubt that this snippet will address your search need.
The created pattern is about method declarations although that
reading your first paragraph it sounds to me that you wanted
to search either for Integer constructors or class references.

The former would expect the following pattern:
SearchPattern pattern = SearchPattern.createPattern(
"Integer",
IJavaSearchConstants.CONSTRUCTOR,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);

The latter would expect the following pattern:
SearchPattern pattern = SearchPattern.createPattern(
"Integer",
IJavaSearchConstants.CLASS,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);
Previous Topic:How to add/remove buttons from the Workbench toolbar?
Next Topic:Compiler warnings & "unnecessary suppress warnings"
Goto Forum:
  


Current Time: Sat Apr 19 15:04:15 EDT 2025

Powered by FUDForum. Page generated in 0.03470 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top