diff options
Diffstat (limited to 'bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java')
25 files changed, 0 insertions, 2125 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java deleted file mode 100644 index e505f4dd30..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java +++ /dev/null @@ -1,372 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.search.SearchDocument; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jdt.core.search.SearchRequestor; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.jst.jsp.ui.internal.Logger; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.DocumentChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.osgi.util.NLS; -import org.eclipse.text.edits.MalformedTreeException; -import org.eclipse.text.edits.MultiTextEdit; -import org.eclipse.text.edits.ReplaceEdit; -import org.eclipse.text.edits.TextEdit; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.sse.core.internal.document.DocumentReader; -import org.eclipse.wst.sse.core.internal.encoding.CodedStreamCreator; - -/** - * Creates document change(s) for an IJavaElement rename. - * Changes are created for every type "match" in the workspace - * @author pavery - */ -public class BasicRefactorSearchRequestor extends SearchRequestor { - - /** - * Workspace operation to perform save on model for updated documents. - * Should only be done on models not open in an editor. - */ - private class SaveJspFileOp extends WorkspaceModifyOperation { - - private IDocument fJSPDoc = null; - private IFile fJSPFile = null; - - public SaveJspFileOp(IFile jspFile, IDocument jspDoc) { - this.fJSPDoc = jspDoc; - this.fJSPFile = jspFile; - } - - protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { - - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3765 - // save file w/ no intermediate model creation - - CodedStreamCreator codedStreamCreator = new CodedStreamCreator(); - Reader reader = new DocumentReader(this.fJSPDoc); - codedStreamCreator.set(this.fJSPFile, reader); - - ByteArrayOutputStream codedByteStream = null; - InputStream codedStream = null; - try { - codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(); - codedStream = new ByteArrayInputStream(codedByteStream.toByteArray()); - if (this.fJSPFile.exists()) - this.fJSPFile.setContents(codedStream, true, true, null); - else - this.fJSPFile.create(codedStream, false, null); - - } catch (CoreException e) { - Logger.logException(e); - } catch (IOException e) { - Logger.logException(e); - } - finally { - try { - if(codedByteStream != null) - codedByteStream.close(); - if(codedStream != null) - codedStream.close(); - } - catch (IOException e){ - // unlikely - } - } - } - } - // end inner class SaveJspFileOp - - /** - * Change class that wraps a text edit on the jsp document - */ - private class RenameChange extends DocumentChange { - - private TextEdit fEdit = null; - private IFile fJSPFile = null; - private IDocument fJSPDoc = null; - private String fDescription = JSPUIMessages.BasicRefactorSearchRequestor_0; - - public RenameChange(IFile jspFile, IDocument jspDoc, TextEdit edit, String description) { - super(JSPUIMessages.BasicRefactorSearchRequestor_6, jspDoc); - this.fEdit = edit; - this.fJSPFile = jspFile; - this.fJSPDoc = jspDoc; - this.fDescription = description; - } - - public RefactoringStatus isValid(IProgressMonitor pm)throws CoreException { - return new RefactoringStatus(); - } - - public IDocument getPreviewDocument(IProgressMonitor pm) throws CoreException { - IDocument copyDoc = new Document(fJSPDoc.get()); - try { - fEdit.apply(copyDoc); - } - catch (MalformedTreeException e) { - // ignore - } - catch (BadLocationException e) { - // ignore - } - return copyDoc; - } - - public Change perform(IProgressMonitor pm) throws CoreException { - RenameChange undoChange = null; - try { - - if(!isOpenInEditor(this.fJSPDoc)) { - // apply edit to JSP doc AND save model - undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription); - saveFile(this.fJSPFile, this.fJSPDoc); - } - else { - // just apply edit to JSP document - undoChange = new RenameChange(this.fJSPFile, this.fJSPDoc, this.fEdit.apply(fJSPDoc), this.fDescription); - } - - } catch (MalformedTreeException e) { - Logger.logException(e); - } catch (BadLocationException e) { - Logger.logException(e); - } - return undoChange; - } - - /** - * Performed in an operation since it modifies resources in the workspace - * @param jspDoc - * @throws CoreException - */ - private void saveFile(IFile jspFile, IDocument jspDoc) { - - SaveJspFileOp op = new SaveJspFileOp(jspFile, jspDoc); - - try { - op.run(JSPSearchSupport.getInstance().getProgressMonitor()); - } catch (InvocationTargetException e) { - Logger.logException(e); - } catch (InterruptedException e) { - Logger.logException(e); - } - } - - /** - * Checks if a document is open in an editor - * @param jspDoc - * @return - */ - private boolean isOpenInEditor(IDocument jspDoc) { - IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); - IWorkbenchWindow w = null; - for (int i = 0; i < windows.length; i++) { - - w = windows[i]; - IWorkbenchPage page = w.getActivePage(); - if (page != null) { - - IEditorReference[] references = page.getEditorReferences(); - IEditorPart editor = null; - Object o = null; - IDocument doc = null; - for (int j = 0; j < references.length; j++) { - - editor = references[j].getEditor(true); - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3764 - // use adapter to get ITextEditor (for things like - // page designer) - o = editor.getAdapter(ITextEditor.class); - if (o != null && o instanceof ITextEditor) { - - doc = ((ITextEditor) o).getDocumentProvider().getDocument(editor.getEditorInput()); - if (doc != null && doc.equals(jspDoc)) { - return true; - } - } - } - } - } - return false; - } - - public String getName() { - return this.fDescription; - } - - public Object getModifiedElement() { - return getElement(); - } - } - // end inner class RenameChange - - - /** The type being renamed (the old type)*/ - IJavaElement fElement = null; - /** The new name of the type being renamed*/ - private String fNewName = ""; //$NON-NLS-1$ - /** maps a JSPSearchDocument path -> MultiTextEdit for the java file*/ - private HashMap fSearchDocPath2JavaEditMap = null; - - public BasicRefactorSearchRequestor(IJavaElement element, String newName) { - this.fNewName = newName; - this.fElement = element; - this.fSearchDocPath2JavaEditMap = new HashMap(); - } - - public IJavaElement getElement() { - return this.fElement; - } - - /** - * @return the new name for the Type - */ - public String getNewName() { - return this.fNewName; - } - - /** - * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch) - */ - public void acceptSearchMatch(SearchMatch javaMatch) throws CoreException { - - String matchDocumentPath = javaMatch.getResource().getFullPath().toString(); - SearchDocument searchDoc = JSPSearchSupport.getInstance().getSearchDocument(matchDocumentPath); - - if (searchDoc != null && searchDoc instanceof JavaSearchDocumentDelegate) { - - String renameText = getRenameText((JavaSearchDocumentDelegate)searchDoc, javaMatch); - - // add it for the correct document - addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText)); - } - } - - /** - * @param searchDoc - * @return - */ - protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - return getNewName(); - } - - /** - * Adds to the multi edit for a give java document. - * @param javaDocument - * @param javaEdit - */ - private void addJavaEdit(String searchDocPath, ReplaceEdit javaEdit) { - - Object o = this.fSearchDocPath2JavaEditMap.get(searchDocPath); - if(o != null) { - - MultiTextEdit multi = (MultiTextEdit)o; - multi.addChild(javaEdit); - } - else { - // use a multi edit so doc position offsets get updated automatically - // when adding multiple child edits - MultiTextEdit multi = new MultiTextEdit(); - multi.addChild(javaEdit); - this.fSearchDocPath2JavaEditMap.put(searchDocPath, multi); - } - } - - /** - * - * @return all JSP changes for the search matches for the given Type - */ - public Change[] getChanges() { - - JSPSearchSupport support = JSPSearchSupport.getInstance(); - List changes = new ArrayList(); - Iterator keys = fSearchDocPath2JavaEditMap.keySet().iterator(); - String searchDocPath = null; - SearchDocument delegate = null; - - while(keys.hasNext()) { - // create on the fly - searchDocPath = (String)keys.next(); - MultiTextEdit javaEdit = (MultiTextEdit)fSearchDocPath2JavaEditMap.get(searchDocPath); - delegate = support.getSearchDocument(searchDocPath); - - if(delegate != null && delegate instanceof JavaSearchDocumentDelegate) { - JavaSearchDocumentDelegate javaDelegate = (JavaSearchDocumentDelegate)delegate; - changes.add(createChange(javaDelegate, javaDelegate.getJspTranslation().getJspEdit(javaEdit))); - } - } - return (Change[])changes.toArray(new Change[changes.size()]); - } - - private Change createChange(JavaSearchDocumentDelegate searchDoc, TextEdit edit) { - - IDocument doc = searchDoc.getJspTranslation().getJspDocument(); - String file = searchDoc.getFile().getName(); - String description = getDescription(); - try { - // document lines are 0 based - String lineNumber = Integer.toString(doc.getLineOfOffset(edit.getOffset()) + 1); - description += " " + NLS.bind(JSPUIMessages.BasicRefactorSearchRequestor_1, new String[]{file, lineNumber}); //$NON-NLS-1$ - } - catch (BadLocationException e) { - Logger.logException(e); - } - return new RenameChange(searchDoc.getFile(), doc, edit, description); - } - - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3205 - // only relevant for IType refactorings - protected boolean isFullyQualified(String matchText) { - if(getElement() instanceof IType) { - String pkg = ((IType)getElement()).getPackageFragment().getElementName(); - return matchText.startsWith(pkg); - } - return false; - } - - /** - * Subclasses should override to better describe the change. - * @return - */ - protected String getDescription() { - return ""; //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java deleted file mode 100644 index 38f2dac80a..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPJavaSelectionProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -class JSPJavaSelectionProvider { - static IJavaElement[] getSelection(ITextEditor textEditor) { - IJavaElement[] elements = null; - - IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); - ISelection selection = textEditor.getSelectionProvider().getSelection(); - if (selection instanceof ITextSelection) { - ITextSelection textSelection = (ITextSelection) selection; - // get the JSP translation object for this editor's document - IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - try { - if (model instanceof IDOMModel) { - IDOMModel xmlModel = (IDOMModel)model; - IDOMDocument xmlDoc = xmlModel.getDocument(); - - JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); - if (adapter != null) { - JSPTranslation translation = adapter.getJSPTranslation(); - elements = translation.getElementsFromJspRange(textSelection.getOffset(), textSelection.getOffset() + textSelection.getLength()); - } - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - } - if (elements == null) { - elements = new IJavaElement[0]; - } - return elements; - } - -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameChange.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameChange.java deleted file mode 100644 index 485ff11a89..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameChange.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -/** - * @author pavery - */ -public class JSPMethodRenameChange extends Change { - - public static Change[] createChangesFor(IMethod method, String newName) { - JSPSearchSupport support = JSPSearchSupport.getInstance(); - - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - - BasicRefactorSearchRequestor requestor = new JSPMethodRenameRequestor(method, newName); - support.searchRunnable(method, new JSPSearchScope(), requestor); - - return requestor.getChanges(); - } - - public String getName() { - return JSPUIMessages.JSP_changes; //$NON-NLS-1$ - } - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - public Change perform(IProgressMonitor pm) throws CoreException { - // pa_TODO return the "undo" change here - return null; - } - - public Object getModifiedElement() { - // pa_TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameParticipant.java deleted file mode 100644 index edac9c846d..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameParticipant.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * Created on May 6, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.jst.jsp.ui.internal.Logger; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; - -/** - * @author pavery - */ -public class JSPMethodRenameParticipant extends RenameParticipant { - - private IMethod fMethod = null; - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - if(element instanceof IMethod) { - this.fMethod = (IMethod) element; - return true; - } - return false; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - String name = ""; //$NON-NLS-1$ - if(this.fMethod != null) { - try { - name = this.fMethod.getSource(); - } catch (JavaModelException e) { - Logger.logException(e); - } - } - return name; - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPMethodRenameChange.createChangesFor(this.fMethod, getArguments().getNewName()); - CompositeChange multiChange = null; - if(changes.length > 0) - multiChange = new CompositeChange(JSPUIMessages.JSP_changes, changes); //$NON-NLS-1$ - return multiChange; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameRequestor.java deleted file mode 100644 index 6147208de9..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMethodRenameRequestor.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; - -/** - * @author pavery - */ -public class JSPMethodRenameRequestor extends BasicRefactorSearchRequestor { - - public JSPMethodRenameRequestor(IJavaElement element, String newName) { - super(element, newName); - } - - protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - - String javaText = searchDoc.getJspTranslation().getJavaText(); - String methodText = javaText.substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - String methodSuffix = methodText.substring(methodText.indexOf("(")); //$NON-NLS-1$ - return getNewName() + methodSuffix; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - protected String getDescription() { - - String methodName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JSPUIMessages.BasicRefactorSearchRequestor_3, new String[]{methodName, newName}); //$NON-NLS-1$ - return description; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java deleted file mode 100644 index b61d4bdf8d..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPMoveElementActionDelegate.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; - -/** - * An action delegate that launches JDT move element wizard - * - * Still relies heavily on internal API - * will change post 3.0 with public move support - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 - */ -public class JSPMoveElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - //private IEditorPart fEditor; - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - //fEditor = targetEditor; - } - - public void dispose() { - // nulling out just in case - //fEditor = null; - } - - public void init(IAction action) { - if (action != null) { - action.setText(JSPUIMessages.MoveElement_label); - action.setToolTipText(JSPUIMessages.MoveElement_label); - } - } - - public void runWithEvent(IAction action, Event event) { - run(action); - } - - public void run(IAction action) { - - // no-op until we know how we're supposed to use this - // eclipse 3.2M5 - // public move support: https://bugs.eclipse.org/bugs/show_bug.cgi?id=61817 - -// IJavaElement[] elements = getSelectedElements(); -// if (elements.length > 0) { -// -// // need to check if it's movable -// try { -// JavaMoveProcessor processor = JavaMoveProcessor.create(getResources(elements), elements); -// -// Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); -// MoveRefactoring refactoring = new MoveRefactoring(processor); -// -// RefactoringWizard wizard = createWizard(refactoring); -// -// /* -// * We want to get the shell from the refactoring dialog but -// * it's not known at this point, so we pass the wizard and -// * then, once the dialog is open, we will have access to its -// * shell. -// */ -// -// processor.setCreateTargetQueries(new CreateTargetQueries(wizard)); -// processor.setReorgQueries(new ReorgQueries(wizard)); -// // String openRefactoringWizMsg = -// // RefactoringMessages.getString("OpenRefactoringWizardAction.refactoring"); -// // //$NON-NLS-1$ -// String openRefactoringWizMsg = JSPUIMessages.MoveElementWizard; // "Move -// // the -// // selected -// // elements"; -// // //$NON-NLS-1$ -// new RefactoringStarter().activate(refactoring, wizard, parent, openRefactoringWizMsg, true); -// -// PlatformStatusLineUtil.clearStatusLine(); -// -// } -// catch (JavaModelException e) { -// Logger.logException(e); -// } -// } -// else { -// PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPMoveElementAction_0); //$NON-NLS-1$ -// } - - } - - public void selectionChanged(IAction action, ISelection selection) { - PlatformStatusLineUtil.clearStatusLine(); - } - - public void init(IViewPart view) { - // do nothing - } - - - -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameChange.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameChange.java deleted file mode 100644 index d15e089ab0..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameChange.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -/** - * @author pavery - */ -public class JSPPackageRenameChange extends Change { - - public static Change[] createChangesFor(IPackageFragment pkg, String newName) { - JSPSearchSupport support = JSPSearchSupport.getInstance(); - - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - //support.indexWorkspaceAndWait(); - - BasicRefactorSearchRequestor requestor = new JSPPackageRenameRequestor(pkg, newName); - support.searchRunnable(pkg, new JSPSearchScope(), requestor); - - return requestor.getChanges(); - } - - public String getName() { - return JSPUIMessages.JSP_changes; //$NON-NLS-1$ - } - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } - - public Object getModifiedElement() { - - //return this.pkg; - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameParticipant.java deleted file mode 100644 index 3903d39882..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameParticipant.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; - -/** - * Remember to change the plugin.xml file if the name of this class changes. - * - * @author pavery - */ -public class JSPPackageRenameParticipant extends RenameParticipant { - - private IPackageFragment fPkg = null; - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - if(element instanceof IPackageFragment) { - this.fPkg = (IPackageFragment) element; - return true; - } - return false; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - String name = ""; //$NON-NLS-1$ - if(this.fPkg != null) { - name = this.fPkg.getElementName(); - } - return name; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPPackageRenameChange.createChangesFor(this.fPkg, getArguments().getNewName()); - CompositeChange multiChange = null; - if(changes.length > 0) - multiChange = new CompositeChange(JSPUIMessages.JSP_changes, changes); //$NON-NLS-1$ - return multiChange; - } - - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameRequestor.java deleted file mode 100644 index 3cffa0cd11..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPPackageRenameRequestor.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.osgi.util.NLS; - -/** - * Overrides get description - * @author pavery - */ -public class JSPPackageRenameRequestor extends BasicRefactorSearchRequestor { - - /** - * Element is the old package. newName is the new package name. - * @param element - * @param newName - */ - public JSPPackageRenameRequestor(IJavaElement element, String newName) { - super(element, newName); - } - - /* - * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - protected String getDescription() { - String packageName = getElement().getElementName(); - String newName = getNewName(); - String description = NLS.bind(JSPUIMessages.BasicRefactorSearchRequestor_5, (new String[]{packageName, newName})); //$NON-NLS-1$ - return description; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java deleted file mode 100644 index f487fc54a4..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPRenameElementActionDelegate.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.ui.refactoring.RenameSupport; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.jst.jsp.ui.internal.Logger; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IEditorActionDelegate; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; - -/** - * An action delegate that launches JDT rename element wizard - */ -public class JSPRenameElementActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { - private IEditorPart fEditor; - - public void setActiveEditor(IAction action, IEditorPart targetEditor) { - fEditor = targetEditor; - } - - public void dispose() { - // nulling out just in case - fEditor = null; - } - - public void init(IAction action) { - if (action != null) { - action.setText(JSPUIMessages.RenameElement_label); - action.setToolTipText(JSPUIMessages.RenameElement_label); - } - } - - public void runWithEvent(IAction action, Event event) { - run(action); - } - - public void run(IAction action) { - IJavaElement element = getSelectedElement(); - if(element != null) { - RenameSupport renameSupport = null; - try { - switch(element.getElementType()) { - case IJavaElement.TYPE: - renameSupport= RenameSupport.create((IType)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - case IJavaElement.METHOD: - renameSupport= RenameSupport.create((IMethod)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - case IJavaElement.PACKAGE_FRAGMENT: - renameSupport= RenameSupport.create((IPackageFragment)element, element.getElementName(), RenameSupport.UPDATE_REFERENCES); - break; - } - if(renameSupport != null) { - renameSupport.openDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - PlatformStatusLineUtil.clearStatusLine(); - } - } - catch (CoreException e) { - Logger.logException(e); - } - } - else { - PlatformStatusLineUtil.displayErrorMessage(JSPUIMessages.JSPRenameElementAction_0); //$NON-NLS-1$ - PlatformStatusLineUtil.addOneTimeClearListener(); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - PlatformStatusLineUtil.clearStatusLine(); - } - - public void init(IViewPart view) { - // do nothing - } - - private IJavaElement getSelectedElement() { - IJavaElement element = null; - if (fEditor instanceof ITextEditor) { - IJavaElement[] elements = JSPJavaSelectionProvider.getSelection((ITextEditor)fEditor); - if (elements.length == 1) - element = elements[0]; - } - return element; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveChange.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveChange.java deleted file mode 100644 index facd6802fb..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveChange.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IType; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - -/** - * @author pavery - */ -public class JSPTypeMoveChange extends Change { - - public static Change[] createChangesFor(IType type, String newName) { - - JSPSearchSupport support = JSPSearchSupport.getInstance(); - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - - JSPTypeMoveRequestor requestor = new JSPTypeMoveRequestor(type, newName); - support.searchRunnable(type, new JSPSearchScope(), requestor); - - return requestor.getChanges(); - } - - public String getName() { - return JSPUIMessages.JSP_changes; //$NON-NLS-1$ - } - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } - - public Object getModifiedElement() { - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveParticipant.java deleted file mode 100644 index 40c80b17f4..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveParticipant.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.MoveParticipant; - -/** - * @author pavery - */ -public class JSPTypeMoveParticipant extends MoveParticipant { - - IType fType = null; - - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - - if(element instanceof IType) { - this.fType = (IType)element; - return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - - String name = ""; //$NON-NLS-1$ - if(this.fType != null) - name = this.fType.getElementName(); - return name; - } - - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException { - - if(pm != null && pm.isCanceled()) - return null; - - CompositeChange multiChange = null; - Object dest = getArguments().getDestination(); - - if(dest instanceof IPackageFragment) { - Change[] changes = JSPTypeMoveChange.createChangesFor(fType, ((IPackageFragment)dest).getElementName()); - if(changes.length > 0) - multiChange = new CompositeChange(JSPUIMessages.JSP_changes, changes); //$NON-NLS-1$ - } - return multiChange; - } - - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java deleted file mode 100644 index edd02f29de..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; - -/** - * @author pavery - */ -public class JSPTypeMoveRequestor extends BasicRefactorSearchRequestor { - - /** - * @param element - * @param newName - */ - public JSPTypeMoveRequestor(IJavaElement element, String newPackage) { - super(element, newPackage); - } - - protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - - String renameText = getElement().getElementName(); - - JSPTranslation trans = searchDoc.getJspTranslation(); - String matchText = trans.getJavaText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - - // if it's an import or jsp:useBean, we need to add the package name as well - if(trans.isImport(javaMatch.getOffset()) || trans.isUseBean(javaMatch.getOffset()) || isFullyQualified(matchText)) { - if(!getNewName().equals("")) //$NON-NLS-1$ - // getNewName() is the pkg name - renameText = getNewName() + "." + renameText; //$NON-NLS-1$ - } - return renameText; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - protected String getDescription() { - - String typeName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JSPUIMessages.BasicRefactorSearchRequestor_2, new String[]{typeName, newName}); //$NON-NLS-1$ - return description; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameChange.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameChange.java deleted file mode 100644 index 99f1666adf..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameChange.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IType; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; - - -/** - * @author pavery - */ -public class JSPTypeRenameChange extends Change { - - public static Change[] createChangesFor(IType type, String newName) { - JSPSearchSupport support = JSPSearchSupport.getInstance(); - - // should be handled by JSPIndexManager - // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=3036 - // support.indexWorkspaceAndWait(); - - - JSPTypeRenameRequestor requestor = new JSPTypeRenameRequestor(type, newName); - support.searchRunnable(type, new JSPSearchScope(), requestor); - - return requestor.getChanges(); - } - - public String getName() { - return JSPUIMessages.JSP_changes; //$NON-NLS-1$ - } - - public void initializeValidationData(IProgressMonitor pm) { - // pa_TODO implement - // must be implemented to decide correct value of isValid - } - - public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { - // pa_TODO implement - // This method must ensure that the change object is still valid. - // This is in particular interesting when performing an undo change - // since the workspace could have changed since the undo change has - // been created. - return new RefactoringStatus(); - } - - public Change perform(IProgressMonitor pm) throws CoreException { - // TODO return the "undo" change here - return null; - } - - public Object getModifiedElement() { - // TODO Auto-generated method stub - return null; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameParticipant.java deleted file mode 100644 index e6a16de886..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameParticipant.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.jst.jsp.ui.internal.Logger; -import org.eclipse.ltk.core.refactoring.Change; -import org.eclipse.ltk.core.refactoring.CompositeChange; -import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; -import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; - -/** - * Remember to change the plugin.xml file if the name of this class changes. - * - * @author pavery - */ -public class JSPTypeRenameParticipant extends RenameParticipant { - - private IType fType = null; - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#initialize(java.lang.Object) - */ - protected boolean initialize(Object element) { - if(element instanceof IType) { - this.fType = (IType) element; - return true; - } - return false; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#getName() - */ - public String getName() { - String name = ""; //$NON-NLS-1$ - if(this.fType != null) { - try { - name = this.fType.getSource(); - } catch (JavaModelException e) { - Logger.logException(e); - } - } - return name; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#checkConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext) - */ - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) { - // TODO Auto-generated method stub - return null; - } - - /** - * @see org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant#createChange(org.eclipse.core.runtime.IProgressMonitor) - */ - public Change createChange(IProgressMonitor pm) throws CoreException { - Change[] changes = JSPTypeRenameChange.createChangesFor(fType, getArguments().getNewName()); - CompositeChange multiChange = null; - if(changes.length > 0) - multiChange = new CompositeChange(JSPUIMessages.JSP_changes, changes); //$NON-NLS-1$ - return multiChange; - } - - -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameRequestor.java deleted file mode 100644 index d93ccf7e19..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeRenameRequestor.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.refactoring; - -import java.text.MessageFormat; - -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; - -/** - * Creates document change(s) for a type rename. - * Changes are created for every type "match" in the workspace - * @author pavery - */ -public class JSPTypeRenameRequestor extends BasicRefactorSearchRequestor { - - public JSPTypeRenameRequestor(IType type, String newName) { - super(type, newName); - } - - private IType getType() { - return (IType)getElement(); - } - - protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) { - - String renameText = getNewName(); - - String pkg = getType().getPackageFragment().getElementName(); - JSPTranslation trans = searchDoc.getJspTranslation(); - String matchText = trans.getJavaText().substring(javaMatch.getOffset(), javaMatch.getOffset() + javaMatch.getLength()); - - // if it's an import or jsp:useBean or fully qualified type, we need to add the package name as well - if(trans.isImport(javaMatch.getOffset()) || /*trans.isUseBean(javaMatch.getOffset()) ||*/ isFullyQualified(matchText)) { - if(!pkg.equals("")) //$NON-NLS-1$ - renameText = pkg + "." + renameText; //$NON-NLS-1$ - } - return renameText; - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getDescription() - */ - protected String getDescription() { - - String typeName = getElement().getElementName(); - String newName = getNewName(); - String description = MessageFormat.format(JSPUIMessages.BasicRefactorSearchRequestor_4, new String[]{typeName, newName}); //$NON-NLS-1$ - return description; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/BasicJSPSearchRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/BasicJSPSearchRequestor.java deleted file mode 100644 index ae3dbc49c6..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/BasicJSPSearchRequestor.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.search.SearchDocument; -import org.eclipse.jdt.core.search.SearchMatch; -import org.eclipse.jdt.core.search.SearchParticipant; -import org.eclipse.jdt.core.search.SearchRequestor; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate; - -/** - * Accepts matches from JSPSearchSupport.search(...) request. - * Adapts the results from java to JSP and displays in the SearchResultView. - * - * @author pavery - */ -public class BasicJSPSearchRequestor extends SearchRequestor { - - // for debugging - private static final boolean DEBUG; - static { - String value= Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG= value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - - /** - * Maps java search coordinates to corresponding JSP coordinates. - * Adds the matches to the Search Results view. - * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch) - */ - public void acceptSearchMatch(SearchMatch match) throws CoreException { - - if(JSPSearchSupport.getInstance().isCanceled()) - return; - - String matchDocumentPath = match.getResource().getFullPath().toString(); - SearchDocument searchDoc = JSPSearchSupport.getInstance().getSearchDocument(matchDocumentPath); - - if (searchDoc != null && searchDoc instanceof JavaSearchDocumentDelegate) { - JavaSearchDocumentDelegate javaSearchDoc = (JavaSearchDocumentDelegate)searchDoc; - int jspStart = javaSearchDoc.getJspOffset(match.getOffset()); - int jspEnd = javaSearchDoc.getJspOffset(match.getOffset() + match.getLength()); - - JSPTranslation trans = javaSearchDoc.getJspTranslation(); - String jspText = trans.getJspText(); - String javaText = javaSearchDoc.getJavaText(); - - if (DEBUG) - displayDebugInfo(match, jspStart, jspEnd, jspText, javaText); - - if (jspStart > -1 && jspEnd > -1) - addSearchMatch(new Document(trans.getJspText()), javaSearchDoc.getFile(), jspStart, jspEnd, jspText); - } - } - - /** - * @param searchDoc - * @param jspStart - * @param jspEnd - * @param jspTranslation - * @param jspText - * @throws CoreException - */ - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - // implement in subclass - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.search.SearchRequestor#beginReporting() - */ - public void beginReporting() { - - if (DEBUG) - System.out.println("JSP Search requestor: beginReporting()"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jdt.core.search.SearchRequestor#endReporting() - */ - public void endReporting() { - - if (DEBUG) - System.out.println("JSP Search requestor: endReporting()"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jdt.core.search.SearchRequestor#enterParticipant(org.eclipse.jdt.core.search.SearchParticipant) - */ - public void enterParticipant(SearchParticipant participant) { - - if (DEBUG) - System.out.println("JSP Search requestor: enterParticipant()"); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.jdt.core.search.SearchRequestor#exitParticipant(org.eclipse.jdt.core.search.SearchParticipant) - */ - public void exitParticipant(SearchParticipant participant) { - - if (DEBUG) - System.out.println("JSP Search requestor: exitParticipant()"); //$NON-NLS-1$ - } - - /** - * For debug. - * @param origMatch - * @param jspStart - * @param jspEnd - * @param jspText - * @param javaText - */ - private void displayDebugInfo(SearchMatch origMatch, int jspStart, int jspEnd, String jspText, String javaText) { - - if (origMatch == null || jspStart == -1 || jspEnd == -1 || jspEnd < jspStart || jspText == null || javaText == null) - return; - - System.out.println("+-----------------------------------------+"); //$NON-NLS-1$ - System.out.println("accept possible match [jspDoc: " + origMatch.getResource().getFullPath().toOSString() + " " + origMatch.getOffset() + ":" + origMatch.getOffset() + origMatch.getLength() + "]?"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - System.out.println("match info:"); //$NON-NLS-1$ - System.out.println("the java text is:" + javaText.substring(origMatch.getOffset(), origMatch.getOffset() + origMatch.getLength())); //$NON-NLS-1$ - System.out.println("java search match translates to jsp coords [start: " + jspStart + " end:" + jspEnd + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - System.out.println(" the jsp text is:" + jspText.substring(jspStart, jspEnd)); //$NON-NLS-1$ - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesActionDelegate.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesActionDelegate.java deleted file mode 100644 index 2eaeec0af6..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesActionDelegate.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.jst.jsp.ui.internal.java.search; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.html.ui.internal.search.HTMLFindOccurrencesProcessor; -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate; - -/** - * Sets up FindOccurrencesActionDelegate for jsp find occurrences processors - */ -public class JSPFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate { - private List fProcessors; - - protected List getProcessors() { - if (fProcessors == null) { - fProcessors = new ArrayList(); - HTMLFindOccurrencesProcessor htmlProcessor = new HTMLFindOccurrencesProcessor(); - fProcessors.add(htmlProcessor); -// temporary, workaround to disable function, since using the function -// can easily cause deadlock to occur. -// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=103662 -// JSPFindOccurrencesProcessor jspProcessor = new JSPFindOccurrencesProcessor(); -// fProcessors.add(jspProcessor); - } - return fProcessors; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java deleted file mode 100644 index 9ff15c3028..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPFindOccurrencesProcessor.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.jst.jsp.ui.internal.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslation; -import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter; -import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts; -import org.eclipse.jst.jsp.core.text.IJSPPartitions; -import org.eclipse.search.ui.ISearchQuery; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - -/** - * Configures a FindOccurrencesProcessor with JSP partitions and regions - */ -public class JSPFindOccurrencesProcessor extends FindOccurrencesProcessor { - - protected String[] getPartitionTypes() { - return new String[]{IJSPPartitions.JSP_DEFAULT, IJSPPartitions.JSP_CONTENT_JAVA}; - } - - protected String[] getRegionTypes() { - return new String[]{DOMRegionContext.BLOCK_TEXT, DOMJSPRegionContexts.JSP_CONTENT}; - } - - protected ISearchQuery getSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType, ITextSelection textSelection) { - return new JSPSearchQuery(file, getJavaElement(document, textSelection)); - } - - private IJavaElement getJavaElement(IDocument document, ITextSelection textSelection) { - IJavaElement[] elements = getJavaElementsForCurrentSelection(document, textSelection); - return elements.length > 0 ? elements[0] : null; - } - - /** - * uses JSPTranslation to get currently selected Java elements. - * - * @return currently selected IJavaElements - */ - private IJavaElement[] getJavaElementsForCurrentSelection(IDocument document, ITextSelection selection) { - IJavaElement[] elements = new IJavaElement[0]; - // get JSP translation object for this viewer's document - IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document); - try { - if (model != null && model instanceof IDOMModel) { - IDOMDocument xmlDoc = ((IDOMModel) model).getDocument(); - JSPTranslationAdapter adapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class); - if (adapter != null) { - JSPTranslation translation = adapter.getJSPTranslation(); - - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=102211 - elements = translation.getElementsFromJspRange(selection.getOffset(), selection.getOffset() + selection.getLength()); - } - } - } - finally { - if (model != null) - model.releaseFromRead(); - } - return elements; - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPOccurrencesSearchResult.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPOccurrencesSearchResult.java deleted file mode 100644 index f1d4f8e4db..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPOccurrencesSearchResult.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search; - -import org.eclipse.search.ui.ISearchQuery; -import org.eclipse.search.ui.text.Match; -import org.eclipse.wst.sse.ui.internal.search.OccurrencesSearchResult; - -/** - * @author pavery - */ -public class JSPOccurrencesSearchResult extends OccurrencesSearchResult { - - public JSPOccurrencesSearchResult(ISearchQuery query) { - super(query); - } - - public Match[] getMatches() { - return ((JSPSearchQuery)getQuery()).getMatches(); - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchQuery.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchQuery.java deleted file mode 100644 index 5f96141abd..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchQuery.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.search.SearchDocument; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.JSPUIMessages; -import org.eclipse.osgi.util.NLS; -import org.eclipse.search.ui.ISearchResult; -import org.eclipse.wst.sse.ui.internal.search.BasicSearchQuery; - -/** - * Implementation of <code>ISearchQuery</code> for <code>IJavaElement</code>s in JSP files. - * - * @author pavery - */ -public class JSPSearchQuery extends BasicSearchQuery { - - /** the IJavaElement we are searching for in the file **/ - private IJavaElement fElement = null; - - public JSPSearchQuery(IFile file, IJavaElement element) { - super(file); - this.fElement = element; - } - - public IJavaElement getJavaElement() { - return this.fElement; - } - - // for access by inner class - public JSPSearchQuery getInstance() { - return this; - } - - protected IStatus doQuery() { - - clearMatches(); - - IStatus status = Status.OK_STATUS; - try { - JSPSearchSupport support = JSPSearchSupport.getInstance(); - // index the file - SearchDocument delegate = support.addJspFile(getFile()); - - String scopePath = delegate.getPath(); - JSPSearchScope singleFileScope = new JSPSearchScope(new String[]{getFile().getFullPath().toString(), scopePath}); - - // perform a searchs - // by passing in this jsp search query, requstor can add matches - support.searchRunnable(getJavaElement(), singleFileScope, new JSPSingleFileSearchRequestor(getInstance())); - } - catch (Exception e){ - status = new Status(IStatus.ERROR, "org.eclipse.wst.sse.ui", IStatus.OK, "", null); //$NON-NLS-1$ //$NON-NLS-2$ - } - return status; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#getLabel() - */ - public String getLabel() { - String[] args = {getSearchText(), getOccurrencesCountText(), getFilename()}; - return NLS.bind(JSPUIMessages.OccurrencesSearchQuery_0, args); - } - - private String getFilename() { - String filename = JSPUIMessages.OccurrencesSearchQuery_2; - if(getFile() != null) - filename = getFile().getName(); - return filename; - } - - private String getOccurrencesCountText() { - String count = ""; //$NON-NLS-1$ - // pa_TODO make dynamic - return count; - } - - protected String getSearchText() { - return fElement.getElementName(); - } - - public boolean canRerun() { - - return false; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground() - */ - public boolean canRunInBackground() { - return true; - } - - /** - * @see org.eclipse.search.ui.ISearchQuery#getSearchResult() - */ - public ISearchResult getSearchResult() { - - return new JSPOccurrencesSearchResult(this); - } - -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchRequestor.java deleted file mode 100644 index 9dc8275308..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSearchRequestor.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search; - -import java.util.HashMap; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.ui.search.ISearchRequestor; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jst.jsp.ui.internal.Logger; -import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.ui.text.Match; - - -/** - * @author pavery - */ -public class JSPSearchRequestor extends BasicJSPSearchRequestor { - - private ISearchRequestor fJavaRequestor = null; - - public JSPSearchRequestor() { - super(); - } - - public JSPSearchRequestor(ISearchRequestor javaRequestor) { - // need to report matches to javaRequestor - this.fJavaRequestor = javaRequestor; - } - - - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - - if(!jspFile.exists()) - return; - - int lineNumber = -1; - try { - lineNumber = jspDocument.getLineOfOffset(jspStart); - } catch (BadLocationException e) { - Logger.logException(e); - } - createSearchMarker(jspFile, jspStart, jspEnd, lineNumber); - - if(this.fJavaRequestor != null) { - Match match = new Match(jspFile, jspStart, jspEnd - jspStart); - this.fJavaRequestor.reportMatch(match); - } - } - - /** - * @param jspFile - * @param jspStart - * @param jspEnd - */ - private void createSearchMarker(IFile jspFile, int jspStart, int jspEnd, int lineNumber) { - - try { - IMarker marker = jspFile.createMarker(NewSearchUI.SEARCH_MARKER); - HashMap attributes = new HashMap(4); - attributes.put(IMarker.CHAR_START, new Integer(jspStart)); - attributes.put(IMarker.CHAR_END, new Integer(jspEnd)); - attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber)); - marker.setAttributes(attributes); - - } catch (CoreException e) { - Logger.logException(e); - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSingleFileSearchRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSingleFileSearchRequestor.java deleted file mode 100644 index 4e35d83bed..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/JSPSingleFileSearchRequestor.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.text.IDocument; - - -/** - * <p> - * Special requestor that adds search results for single file search - * (Used for JSPFindOccurrences action). - * It groups each match as it's own result. - * </p> - * - * @author pavery - */ -public class JSPSingleFileSearchRequestor extends BasicJSPSearchRequestor { - - private JSPSearchQuery fQuery = null; - - public JSPSingleFileSearchRequestor(JSPSearchQuery query) { - this.fQuery = query; - } - - protected void addSearchMatch(IDocument jspDocument, IFile jspFile, int jspStart, int jspEnd, String jspText) { - // add match to JSP query... - this.fQuery.addMatch(jspDocument, jspStart, jspEnd); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPMatchPresentation.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPMatchPresentation.java deleted file mode 100644 index 74b1a26c91..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPMatchPresentation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search.ui; - -import org.eclipse.jdt.ui.search.IMatchPresentation; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.search.ui.text.Match; -import org.eclipse.ui.PartInitException; -import org.eclipse.wst.sse.ui.internal.search.BasicSearchLabelProvider; - -/** - * @author pavery - */ -public class JSPMatchPresentation implements IMatchPresentation { - - /** - * @see org.eclipse.jdt.ui.search.IMatchPresentation#createLabelProvider() - */ - public ILabelProvider createLabelProvider() { - return new BasicSearchLabelProvider(); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.search.IMatchPresentation#showMatch(org.eclipse.search.ui.text.Match, int, int, boolean) - */ - public void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException { - // pa_TODO implement -// Object obj = match.getElement(); - // show match in JSP editor - if(activate) { - // use show in target? - } - else { - // just select - } - } -} diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPQueryParticipant.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPQueryParticipant.java deleted file mode 100644 index badbf187b6..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/search/ui/JSPQueryParticipant.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsp.ui.internal.java.search.ui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.core.search.SearchRequestor; -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.PatternQuerySpecification; -import org.eclipse.jdt.ui.search.QuerySpecification; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchScope; -import org.eclipse.jst.jsp.core.internal.java.search.JSPSearchSupport; -import org.eclipse.jst.jsp.ui.internal.java.search.JSPSearchRequestor; - -/** - * @author pavery - */ -public class JSPQueryParticipant implements IQueryParticipant { - - // for debugging - private static final boolean DEBUG; - static { - String value= Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jspsearch"); //$NON-NLS-1$ - DEBUG= value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$ - } - /** - * @see org.eclipse.jdt.ui.search.IQueryParticipant#search(org.eclipse.jdt.ui.search.ISearchRequestor, org.eclipse.jdt.ui.search.QuerySpecification, org.eclipse.core.runtime.IProgressMonitor) - */ - public void search(ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor) throws CoreException { - - //indexIfNeeded(); - - // do search based on the particular Java query - if(querySpecification instanceof ElementQuerySpecification) { - // element search (eg. from global find references in Java file) - ElementQuerySpecification elementQuery = (ElementQuerySpecification)querySpecification; - IJavaElement element = elementQuery.getElement(); - - if(DEBUG) - System.out.println("JSP Query Participant searching on ELEMENT: " + element); //$NON-NLS-1$ - - SearchRequestor jspRequestor = new JSPSearchRequestor(requestor); - - // pa_TODO need to adapt JavaSearchScope to a JSPSearchScope - JSPSearchSupport.getInstance().search(element, new JSPSearchScope(), jspRequestor); - - } - else if(querySpecification instanceof PatternQuerySpecification) { - - // pattern search (eg. from Java search page) - PatternQuerySpecification patternQuery = (PatternQuerySpecification)querySpecification; - String pattern = patternQuery.getPattern(); - - if(DEBUG) - System.out.println("JSP Query Participant searching on PATTERN: " + pattern); //$NON-NLS-1$ - - SearchRequestor jspRequestor = new JSPSearchRequestor(requestor); - - JSPSearchSupport.getInstance().search(pattern, - new JSPSearchScope(), - patternQuery.getSearchFor(), - patternQuery.getLimitTo(), - SearchPattern.R_PATTERN_MATCH, - false, - jspRequestor); - } - } - - /** - * @see org.eclipse.jdt.ui.search.IQueryParticipant#estimateTicks(org.eclipse.jdt.ui.search.QuerySpecification) - */ - public int estimateTicks(QuerySpecification data) { - // pa_TODO use project file counter from JSPSearchSupport... - return 0; - } - - /** - * @see org.eclipse.jdt.ui.search.IQueryParticipant#getUIParticipant() - */ - public IMatchPresentation getUIParticipant() { - return new JSPMatchPresentation(); - } - -} |