Author: dazarov
Date: 2009-09-10 11:44:50 -0400 (Thu, 10 Sep 2009)
New Revision: 17513
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4771
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-10
13:55:53 UTC (rev 17512)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-10
15:44:50 UTC (rev 17513)
@@ -57,6 +57,11 @@
protected static final String JSP_EXT = "jsp"; //$NON-NLS-1$
protected static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
+ private static final String GET = "get"; //$NON-NLS-1$
+ private static final String SET = "set"; //$NON-NLS-1$
+ private static final String IS = "is"; //$NON-NLS-1$
+
+
protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
protected IFile baseFile;
@@ -318,4 +323,14 @@
protected abstract boolean isFileCorrect(IFile file);
protected abstract void match(IFile file, int offset, int length);
+
+ public static String getPropertyName(String methodName){
+ if(methodName.startsWith(GET) || methodName.startsWith(SET))
+ return methodName.substring(3).toLowerCase();
+
+ if(methodName.startsWith(IS))
+ return methodName.substring(2).toLowerCase();
+
+ return methodName.toLowerCase();
+ }
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-09-10 13:55:53 UTC (rev
17512)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-09-10 15:44:50 UTC (rev
17513)
@@ -662,5 +662,13 @@
<xclass
id="org.jboss.tools.seam.ui.views.actions.RenameComponentAction"
class="org.jboss.tools.seam.ui.views.actions.RenameComponentAction"/>
</extension>
-
+ <extension
+ point="org.eclipse.jdt.ui.queryParticipants">
+ <queryParticipant
+
class="org.jboss.tools.seam.ui.search.SeamELReferencesQueryParticipant"
+
id="org.jboss.tools.seam.ui.search.SeamELReferencesQueryParticipant"
+ name="seam-SearchELReferencesParticipant"
+ nature="org.jboss.tools.seam.core.seamnature">
+ </queryParticipant>
+ </extension>
</plugin>
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-09-10
15:44:50 UTC (rev 17513)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.ui.search.ElementQuerySpecification;
+import org.eclipse.jdt.ui.search.IMatchPresentation;
+import org.eclipse.jdt.ui.search.IQueryParticipant;
+import org.eclipse.jdt.ui.search.ISearchRequestor;
+import org.eclipse.jdt.ui.search.QuerySpecification;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.ui.PartInitException;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.seam.internal.core.refactoring.SeamRefactorSearcher;
+
+public class SeamELReferencesQueryParticipant implements IQueryParticipant,
IMatchPresentation{
+ SeamSearchViewLabelProvider labelProvider = new SeamSearchViewLabelProvider(null, 0);
+ private ELSearcher searcher;
+
+ public int estimateTicks(QuerySpecification specification) {
+ return 10;
+ }
+
+ public IMatchPresentation getUIParticipant() {
+ return this;
+ }
+
+ public void search(ISearchRequestor requestor,
+ QuerySpecification querySpecification, IProgressMonitor monitor)
+ throws CoreException {
+ if(querySpecification instanceof ElementQuerySpecification){
+ ElementQuerySpecification qs = (ElementQuerySpecification)querySpecification;
+ IFile file = (IFile)qs.getElement().getResource();
+ String name = ELSearcher.getPropertyName(qs.getElement().getElementName());
+
+ searcher = new ELSearcher(requestor, file, name);
+
+ searcher.findELReferences();
+ }
+ }
+
+ public ILabelProvider createLabelProvider() {
+ return labelProvider;
+ }
+
+ public void showMatch(Match match, int currentOffset,
+ int currentLength, boolean activate) throws PartInitException {
+ }
+
+ class ELSearcher extends SeamRefactorSearcher{
+ ISearchRequestor requestor;
+ public ELSearcher(ISearchRequestor requestor, IFile file, String name){
+ super(file, name);
+ this.requestor = requestor;
+ }
+
+ @Override
+ protected boolean isFileCorrect(IFile file){
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+ return false;
+ }else if(file.isPhantom()){
+ return false;
+ }else if(file.isReadOnly()){
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected void match(IFile file, int offset, int length) {
+ Match match = new Match(file, offset, length);
+ requestor.reportMatch(match);
+ }
+
+ protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+ ELInvocationExpression invExp = invocationExpression;
+ while(invExp != null){
+ if(invExp instanceof ELMethodInvocation || invExp instanceof ELPropertyInvocation){
+ if(invExp.getMemberName() != null &&
invExp.getMemberName().equalsIgnoreCase(propertyName))
+ return invExp;
+ else
+ invExp = invExp.getLeft();
+ }else{
+ invExp = invExp.getLeft();
+ }
+ }
+ return null;
+ }
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain