Author: scabanovich
Date: 2010-10-14 10:56:59 -0400 (Thu, 14 Oct 2010)
New Revision: 25830
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
Log:
JBIDE-7265
https://jira.jboss.org/browse/JBIDE-7265
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2010-10-14
13:04:44 UTC (rev 25829)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/refactoring/RefactorSearcher.java 2010-10-14
14:56:59 UTC (rev 25830)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb.refactoring;
+import java.io.InputStream;
import java.util.List;
import java.util.StringTokenizer;
@@ -192,18 +193,35 @@
}
protected void searchInCach(IFile file){
+ if(file == null) return;
+ ELResolver[] resolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ IRelevanceCheck[] checks = getRelevanceChecks(resolvers);
+ String text = null;
+ try {
+ InputStream is = file.getContents();
+ if(is != null) text = FileUtil.readStream(is);
+ } catch (CoreException e) {
+ //ignore
+ }
+ if(text != null) {
+ boolean found = false;
+ for (IRelevanceCheck check: checks) {
+ if(check.isRelevant(text)) {
+ found = true;
+ break;
+ }
+ }
+ if(!found) return;
+ }
+
ELContext context = PageContextFactory.createPageContext(file);
if(context == null)
return;
ELReference[] references = context.getELReferences();
- ELResolver[] resolvers = context.getElResolvers();
-
- IRelevanceCheck[] checks = new IRelevanceCheck[resolvers.length];
- for (int i = 0; i < checks.length; i++) {
- checks[i] = resolvers[i].createRelevanceCheck(javaElement);
- }
+ resolvers = context.getElResolvers();
+ checks = getRelevanceChecks(resolvers);
if(javaElement != null){
for(ELReference reference : references){
@@ -248,6 +266,15 @@
}
}
+
+ private IRelevanceCheck[] getRelevanceChecks(ELResolver[] resolvers) {
+ if(resolvers == null) return new IRelevanceCheck[0];
+ IRelevanceCheck[] checks = new IRelevanceCheck[resolvers.length];
+ for (int i = 0; i < checks.length; i++) {
+ checks[i] = resolvers[i].createRelevanceCheck(javaElement);
+ }
+ return checks;
+ }
// looking for component references in EL