1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.debug.ui.actions;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.util.List;
17 import net.sourceforge.phpdt.core.Flags;
18 import net.sourceforge.phpdt.core.ICompilationUnit;
19 import net.sourceforge.phpdt.core.IJavaElement;
20 import net.sourceforge.phpdt.core.IMethod;
21 import net.sourceforge.phpdt.core.IType;
22 import net.sourceforge.phpdt.core.JavaModelException;
23 import net.sourceforge.phpdt.core.Signature;
24 import net.sourceforge.phpdt.debug.core.PHPDebugModel;
25 import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
26 import net.sourceforge.phpdt.internal.debug.ui.PHPDebugUiPlugin;
27 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
29 import org.eclipse.core.resources.IResource;
30 import org.eclipse.core.resources.ResourcesPlugin;
31 import org.eclipse.core.runtime.CoreException;
32 import org.eclipse.debug.core.DebugPlugin;
33 import org.eclipse.debug.internal.ui.actions.ActionMessages;
34 import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
35 import org.eclipse.jface.text.IDocument;
36 import org.eclipse.jface.text.ITextSelection;
37 import org.eclipse.jface.viewers.ISelection;
38 import org.eclipse.jface.viewers.IStructuredSelection;
39 import org.eclipse.ui.IEditorInput;
40 import org.eclipse.ui.IEditorPart;
41 import org.eclipse.ui.IFileEditorInput;
42 import org.eclipse.ui.IWorkbenchPart;
43 import org.eclipse.ui.texteditor.IEditorStatusLine;
44 import org.eclipse.ui.texteditor.ITextEditor;
47 * Toggles a line breakpoint in a Java editor.
51 public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
53 protected void report(String message, IWorkbenchPart part) {
54 IEditorStatusLine statusLine= (IEditorStatusLine) part.getAdapter(IEditorStatusLine.class);
55 if (statusLine != null) {
56 if (message != null) {
57 statusLine.setMessage(true, message, null);
59 statusLine.setMessage(true, null, null);
62 if (message != null && PHPDebugUiPlugin.getActiveWorkbenchShell() != null) {
63 PHPDebugUiPlugin.getActiveWorkbenchShell().getDisplay().beep();
67 // protected IType getType(ITextSelection selection) {
68 // IMember member= ActionDelegateHelper.getDefault().getCurrentMember(selection);
70 // if (member instanceof IType) {
71 // type = (IType)member;
72 // } else if (member != null) {
73 // type= member.getDeclaringType();
75 // // bug 52385: we don't want local and anonymous types from compilation unit,
76 // // we are getting 'not-always-correct' names for them.
78 // while (type != null && !type.isBinary() && type.isLocal()) {
79 // type= type.getDeclaringType();
81 // } catch (JavaModelException e) {
82 // PHPDebugUiPlugin.log(e);
88 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(IWorkbenchPart, ISelection)
90 public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
91 if (selection instanceof ITextSelection) {
93 IEditorPart editorPart = (IEditorPart)part;
94 ITextSelection textSelection = (ITextSelection)selection;
95 // IType type = getType(textSelection);
96 IEditorInput editorInput = editorPart.getEditorInput();
97 IDocument document= ((ITextEditor)editorPart).getDocumentProvider().getDocument(editorInput);
98 int lineNumber= textSelection.getStartLine() + 1;
99 int offset= textSelection.getOffset();
101 // if (type == null) {
102 // IClassFile classFile= (IClassFile)editorInput.getAdapter(IClassFile.class);
103 // if (classFile != null) {
104 // type= classFile.getType();
105 // // bug 34856 - if this is an inner type, ensure the breakpoint is not
106 // // being added to the outer type
107 // if (type.getDeclaringType() != null) {
108 // ISourceRange sourceRange= type.getSourceRange();
109 // int start= sourceRange.getOffset();
110 // int end= start + sourceRange.getLength();
111 // if (offset < start || offset > end) {
112 // // not in the inner type
113 // IStatusLineManager statusLine = editorPart.getEditorSite().getActionBars().getStatusLineManager();
114 // statusLine .setErrorMessage(MessageFormat.format(ActionMessages.getString("ManageBreakpointRulerAction.Breakpoints_can_only_be_created_within_the_type_associated_with_the_editor__{0}._1"), new String[] { type.getTypeQualifiedName()})); //$NON-NLS-1$
115 // Display.getCurrent().beep();
122 // String typeName= null;
124 PHPLineBreakpoint breakpoint= null;
125 // if (type == null) {
126 if (editorInput instanceof IFileEditorInput) {
127 resource= ((IFileEditorInput)editorInput).getFile();
129 resource= ResourcesPlugin.getWorkspace().getRoot();
132 // typeName= type.getFullyQualifiedName();
133 // PHPLineBreakpoint breakpoint=PHPDebugModel.lineBreakpointExists(lineNumber);
134 // if (breakpoint==null)
135 // PHPDebugModel.createLineBreakpoint(getFile(), lineNumber, 0, true, null);
137 // DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
139 PHPLineBreakpoint existingBreakpoint= PHPDebugModel.lineBreakpointExists(lineNumber); //typeName, lineNumber);
140 if (existingBreakpoint != null) {
141 DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
144 breakpoint = PHPDebugModel.createLineBreakpoint(resource, lineNumber, 0, true, null);
147 // new BreakpointLocationVerifierJob(document, breakpoint, lineNumber, typeName, type, resource, (IEditorStatusLine) editorPart.getAdapter(IEditorStatusLine.class)).schedule();
148 } catch (CoreException ce) {
149 // TODO: no message in ActionMessages
150 //ExceptionHandler.handle(ce, ActionMessages.getString("ManageBreakpointActionDelegate.error.title1"), ActionMessages.getString("ManageBreakpointActionDelegate.error.message1")); //$NON-NLS-1$ //$NON-NLS-2$
156 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(IWorkbenchPart, ISelection)
158 public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
159 return selection instanceof ITextSelection;
163 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
165 public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
166 // report(null, part);
167 // selection = translateToMembers(part, selection);
168 // if (selection instanceof ITextSelection) {
169 // ITextSelection textSelection = (ITextSelection) selection;
170 // if (selection != null) {
171 // CompilationUnit compilationUnit= parseCompilationUnit((ITextEditor)part);
172 // if (compilationUnit != null) {
173 // BreakpointMethodLocator locator= new BreakpointMethodLocator(textSelection.getOffset());
174 // compilationUnit.accept(locator);
175 // String methodName= locator.getMethodName();
176 // if (methodName == null) {
177 // report(ActionMessages.getString("ManageMethodBreakpointActionDelegate.CantAdd"), part); //$NON-NLS-1$
180 // String typeName= locator.getTypeName();
181 // String methodSignature= locator.getMethodSignature();
182 // if (methodSignature == null) {
183 // report(ActionMessages.getString("ManageMethodBreakpointActionDelegate.methodNonAvailable"), part); //$NON-NLS-1$
186 // // check if this method breakpoint already exist. If yes, remove it.
187 // IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
188 // IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
189 // for (int i= 0; i < breakpoints.length; i++) {
190 // IBreakpoint breakpoint= breakpoints[i];
191 // if (breakpoint instanceof IJavaMethodBreakpoint) {
192 // IJavaMethodBreakpoint methodBreakpoint= (IJavaMethodBreakpoint)breakpoint;
193 // if (typeName.equals(methodBreakpoint.getTypeName())
194 // && methodName.equals(methodBreakpoint.getMethodName())
195 // && methodSignature.equals(methodBreakpoint.getMethodSignature())) {
196 // breakpointManager.removeBreakpoint(methodBreakpoint, true);
201 // // add the breakpoint
202 // JDIDebugModel.createMethodBreakpoint(getResource((IEditorPart)part), typeName, methodName, methodSignature, true, false, false, -1, -1, -1, 0, true, new HashMap(10));
205 // } else if (selection instanceof IStructuredSelection) {
206 // IMethod[] members= getMethods((IStructuredSelection)selection);
207 // if (members.length == 0) {
208 // report(ActionMessages.getString("ToggleBreakpointAdapter.9"), part); //$NON-NLS-1$
211 // // add or remove the breakpoint
212 // IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
213 // for (int i= 0, length= members.length; i < length; i++) {
214 // IMethod method= members[i];
215 // IJavaBreakpoint breakpoint= getBreakpoint(method);
216 // if (breakpoint == null) {
220 // ISourceRange range = method.getNameRange();
221 // if (range != null) {
222 // start = range.getOffset();
223 // end = start + range.getLength();
225 // Map attributes = new HashMap(10);
226 // BreakpointUtils.addJavaBreakpointAttributes(attributes, method);
227 // String methodName = method.getElementName();
228 // if (method.isConstructor()) {
229 // methodName = "<init>"; //$NON-NLS-1$
231 // IType type= method.getDeclaringType();
232 // String methodSignature= method.getSignature();
233 // if (!type.isBinary()) {
234 // //resolve the type names
235 // methodSignature= resolveMethodSignature(type, methodSignature);
236 // if (methodSignature == null) {
237 // IStatus status = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Source method signature could not be resolved", null); //$NON-NLS-1$
238 // throw new CoreException(status);
241 // JDIDebugModel.createMethodBreakpoint(BreakpointUtils.getBreakpointResource(method), type.getFullyQualifiedName(), methodName, methodSignature, true, false, false, -1, start, end, 0, true, attributes);
243 // // remove breakpoint
244 // breakpointManager.removeBreakpoint(breakpoint, true);
251 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
253 public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
254 // if (selection instanceof IStructuredSelection) {
255 // IStructuredSelection ss = (IStructuredSelection) selection;
256 // return getMethods(ss).length > 0;
258 // return selection instanceof ITextSelection;
263 protected IMethod[] getMethods(IStructuredSelection selection) {
264 if (selection.isEmpty()) {
265 return new IMethod[0];
267 List methods = new ArrayList(selection.size());
268 Iterator iterator = selection.iterator();
269 while (iterator.hasNext()) {
270 Object thing = iterator.next();
272 if (thing instanceof IMethod && !Flags.isAbstract(((IMethod)thing).getFlags())) {
275 } catch (JavaModelException e) {
278 return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
282 // protected IField[] getFields(IStructuredSelection selection) {
283 // if (selection.isEmpty()) {
284 // return new IField[0];
286 // List fields = new ArrayList(selection.size());
287 // Iterator iterator = selection.iterator();
288 // while (iterator.hasNext()) {
289 // Object thing = iterator.next();
290 // if (thing instanceof IField) {
291 // fields.add(thing);
292 // } else if (thing instanceof IJavaFieldVariable) {
293 // IField field= getField((IJavaFieldVariable) thing);
294 // if (field != null) {
295 // fields.add(field);
299 // return (IField[]) fields.toArray(new IField[fields.size()]);
304 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
306 public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
307 // report(null, part);
308 // selection = translateToMembers(part, selection);
309 // if (selection instanceof ITextSelection) {
310 // ITextSelection textSelection= (ITextSelection) selection;
311 // CompilationUnit compilationUnit= parseCompilationUnit((ITextEditor)part);
312 // if (compilationUnit != null) {
313 // BreakpointFieldLocator locator= new BreakpointFieldLocator(textSelection.getOffset());
314 // compilationUnit.accept(locator);
315 // String fieldName= locator.getFieldName();
316 // if (fieldName == null) {
317 // report(ActionMessages.getString("ManageWatchpointActionDelegate.CantAdd"), part); //$NON-NLS-1$
320 // String typeName= locator.getTypeName();
321 // // check if the watchpoint already exists. If yes, remove it
322 // IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
323 // IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
324 // for (int i= 0; i < breakpoints.length; i++) {
325 // IBreakpoint breakpoint= breakpoints[i];
326 // if (breakpoint instanceof IJavaWatchpoint) {
327 // IJavaWatchpoint watchpoint= (IJavaWatchpoint)breakpoint;
328 // if (typeName.equals(watchpoint.getTypeName()) && fieldName.equals(watchpoint.getFieldName())) {
329 // breakpointManager.removeBreakpoint(watchpoint, true);
334 // // add the watchpoint
335 // JDIDebugModel.createWatchpoint(getResource((IEditorPart)part), typeName, fieldName, -1, -1, -1, 0, true, new HashMap(10));
337 // } else if (selection instanceof IStructuredSelection) {
338 // IField[] members = getFields((IStructuredSelection)selection);
339 // if (members.length == 0) {
340 // report(ActionMessages.getString("ToggleBreakpointAdapter.10"), part); //$NON-NLS-1$
343 // // add or remove watchpoint
344 // IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
345 // for (int i= 0, length= members.length; i < length; i++) {
346 // IField element= members[i];
347 // IJavaBreakpoint breakpoint= getBreakpoint(element);
348 // if (breakpoint == null) {
349 // IType type = element.getDeclaringType();
352 // ISourceRange range = element.getNameRange();
353 // if (range != null) {
354 // start = range.getOffset();
355 // end = start + range.getLength();
357 // Map attributes = new HashMap(10);
358 // BreakpointUtils.addJavaBreakpointAttributes(attributes, element);
359 // JDIDebugModel.createWatchpoint(BreakpointUtils.getBreakpointResource(type), type.getFullyQualifiedName(), element.getElementName(), -1, start, end, 0, true, attributes);
361 // // remove breakpoint
362 // breakpointManager.removeBreakpoint(breakpoint, true);
368 public static String resolveMethodSignature(IType type, String methodSignature) throws JavaModelException {
369 String[] parameterTypes= Signature.getParameterTypes(methodSignature);
370 int length= length= parameterTypes.length;
371 String[] resolvedParameterTypes= new String[length];
373 for (int i = 0; i < length; i++) {
374 resolvedParameterTypes[i]= resolveType(type, parameterTypes[i]);
375 if (resolvedParameterTypes[i] == null) {
380 String resolvedReturnType= resolveType(type, Signature.getReturnType(methodSignature));
381 if (resolvedReturnType == null) {
385 return Signature.createMethodSignature(resolvedParameterTypes, resolvedReturnType);
388 private static String resolveType(IType type, String typeSignature) throws JavaModelException {
389 // int count= Signature.getArrayCount(typeSignature);
390 // String elementTypeSignature= Signature.getElementType(typeSignature);
391 // if (elementTypeSignature.length() == 1) {
392 // // no need to resolve primitive types
393 // return typeSignature;
395 // String elementTypeName= Signature.toString(elementTypeSignature);
396 // String[][] resolvedElementTypeNames= type.resolveType(elementTypeName);
397 // if (resolvedElementTypeNames == null || resolvedElementTypeNames.length != 1) {
398 // // the type name cannot be resolved
401 // String resolvedElementTypeName= Signature.toQualifiedName(resolvedElementTypeNames[0]);
402 // String resolvedElementTypeSignature= Signature.createTypeSignature(resolvedElementTypeName, true).replace('.', '/');
403 // return Signature.createArraySignature(resolvedElementTypeSignature, count);
407 protected static IResource getResource(IEditorPart editor) {
409 IEditorInput editorInput = editor.getEditorInput();
410 if (editorInput instanceof IFileEditorInput) {
411 resource= ((IFileEditorInput)editorInput).getFile();
413 resource= ResourcesPlugin.getWorkspace().getRoot();
419 * Returns a handle to the specified method or <code>null</code> if none.
421 * @param editorPart the editor containing the method
425 * @return handle or <code>null</code>
427 protected IMethod getMethodHandle(IEditorPart editorPart, String typeName, String methodName, String signature) throws CoreException {
428 IJavaElement element = (IJavaElement) editorPart.getEditorInput().getAdapter(IJavaElement.class);
430 if (element instanceof ICompilationUnit) {
431 IType[] types = ((ICompilationUnit)element).getAllTypes();
432 for (int i = 0; i < types.length; i++) {
433 if (types[i].getFullyQualifiedName().equals(typeName)) {
439 // else if (element instanceof IClassFile) {
440 // type = ((IClassFile)element).getType();
443 String[] sigs = Signature.getParameterTypes(signature);
444 return type.getMethod(methodName, sigs);
449 // protected IJavaBreakpoint getBreakpoint(IMember element) {
450 // IBreakpointManager breakpointManager= DebugPlugin.getDefault().getBreakpointManager();
451 // IBreakpoint[] breakpoints= breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier());
452 // if (element instanceof IMethod) {
453 // IMethod method= (IMethod)element;
454 // for (int i= 0; i < breakpoints.length; i++) {
455 // IBreakpoint breakpoint= breakpoints[i];
456 // if (breakpoint instanceof IJavaMethodBreakpoint) {
457 // IJavaMethodBreakpoint methodBreakpoint= (IJavaMethodBreakpoint)breakpoint;
458 // IMember container = null;
460 // container= BreakpointUtils.getMember(methodBreakpoint);
461 // } catch (CoreException e) {
462 // JDIDebugUIPlugin.log(e);
465 // if (container == null) {
467 // if (method.getDeclaringType().getFullyQualifiedName().equals(methodBreakpoint.getTypeName())
468 // && method.getElementName().equals(methodBreakpoint.getMethodName())
469 // && method.getSignature().equals(methodBreakpoint.getMethodSignature())) {
470 // return methodBreakpoint;
472 // } catch (CoreException e) {
473 // JDIDebugUIPlugin.log(e);
476 // if (container instanceof IMethod) {
477 // if (method.getDeclaringType().getFullyQualifiedName().equals(container.getDeclaringType().getFullyQualifiedName())) {
478 // if (method.isSimilar((IMethod)container)) {
479 // return methodBreakpoint;
486 // } else if (element instanceof IField) {
487 // for (int i= 0; i < breakpoints.length; i++) {
488 // IBreakpoint breakpoint= breakpoints[i];
489 // if (breakpoint instanceof IJavaWatchpoint) {
491 // if (equalFields(element, (IJavaWatchpoint)breakpoint))
492 // return (IJavaBreakpoint)breakpoint;
493 // } catch (CoreException e) {
494 // JDIDebugUIPlugin.log(e);
503 * Compare two fields. The default <code>equals()</code>
504 * method for <code>IField</code> doesn't give the comparison desired.
506 // private boolean equalFields(IMember breakpointField, IJavaWatchpoint watchpoint) throws CoreException {
507 // return (breakpointField.getElementName().equals(watchpoint.getFieldName()) &&
508 // breakpointField.getDeclaringType().getFullyQualifiedName().equals(watchpoint.getTypeName()));
511 // protected CompilationUnit parseCompilationUnit(ITextEditor editor) {
512 // IEditorInput editorInput = editor.getEditorInput();
513 // IDocument document= editor.getDocumentProvider().getDocument(editorInput);
514 // ASTParser parser = ASTParser.newParser(AST.JLS2);
515 // parser.setSource(document.get().toCharArray());
516 // return (CompilationUnit) parser.createAST(null);
520 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
522 public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
523 // if (selection instanceof IStructuredSelection) {
524 // IStructuredSelection ss = (IStructuredSelection) selection;
525 // return getFields(ss).length > 0;
527 // return selection instanceof ITextSelection;
533 * Returns a selection of the member in the given text selection,
534 * or the original selection if none.
538 * @return a structured selection of the member in the given text selection,
539 * or the original selection if none
540 * @exception CoreException if an exceptoin occurrs
542 // protected ISelection translateToMembers(IWorkbenchPart part, ISelection selection) throws CoreException {
543 // if (selection instanceof ITextSelection && part instanceof IEditorPart) {
544 // ITextSelection textSelection = (ITextSelection)selection;
545 // IEditorPart editorPart = (IEditorPart) part;
546 // IEditorInput editorInput = editorPart.getEditorInput();
548 // IClassFile classFile= (IClassFile)editorInput.getAdapter(IClassFile.class);
549 // if (classFile != null) {
550 // IJavaElement e= classFile.getElementAt(textSelection.getOffset());
551 // if (e instanceof IMember) {
555 // IWorkingCopyManager manager= JavaUI.getWorkingCopyManager();
556 // ICompilationUnit unit= manager.getWorkingCopy(editorInput);
557 // if (unit != null) {
558 // synchronized (unit) {
559 // unit.reconcile(ICompilationUnit.NO_AST /*don't create ast*/, false/*don't force problem detection*/, null/*use primary owner*/, null/*no progress monitor*/);
561 // IJavaElement e = unit.getElementAt(textSelection.getOffset());
562 // if (e instanceof IMember) {
568 // return new StructuredSelection(m);
575 * Returns a list of matching types (IType - Java model) that correspond to the
576 * declaring type (ReferenceType - JDI model) of the given variable.
578 // protected static List searchForDeclaringType(IJavaFieldVariable variable) {
579 // List types= new ArrayList();
580 // ILaunch launch = variable.getDebugTarget().getLaunch();
581 // if (launch == null) {
585 // ILaunchConfiguration configuration= launch.getLaunchConfiguration();
586 // IJavaProject[] javaProjects = null;
587 // IWorkspace workspace= ResourcesPlugin.getWorkspace();
588 // if (configuration != null) {
589 // // Launch configuration support
591 // String projectName= configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
592 // if (projectName.length() != 0) {
593 // javaProjects= new IJavaProject[] {JavaCore.create(workspace.getRoot().getProject(projectName))};
595 // IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
597 // List projectList= new ArrayList();
598 // for (int i= 0, numProjects= projects.length; i < numProjects; i++) {
599 // project= projects[i];
600 // if (project.isAccessible() && project.hasNature(JavaCore.NATURE_ID)) {
601 // projectList.add(JavaCore.create(project));
604 // javaProjects= new IJavaProject[projectList.size()];
605 // projectList.toArray(javaProjects);
607 // } catch (CoreException e) {
608 // JDIDebugUIPlugin.log(e);
611 // if (javaProjects == null) {
615 // SearchEngine engine= new SearchEngine();
616 // IJavaSearchScope scope= SearchEngine.createJavaSearchScope(javaProjects, true);
617 // String declaringType= null;
619 // declaringType= variable.getDeclaringType().getName();
620 // } catch (DebugException x) {
621 // JDIDebugUIPlugin.log(x);
624 // ArrayList typeRefsFound= new ArrayList(3);
625 // ITypeNameRequestor requestor= new TypeInfoRequestor(typeRefsFound);
627 // engine.searchAllTypeNames(
628 // getPackage(declaringType),
629 // getTypeName(declaringType),
630 // SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE,
631 // IJavaSearchConstants.CLASS,
634 // IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
636 // } catch (JavaModelException x) {
637 // JDIDebugUIPlugin.log(x);
640 // Iterator iter= typeRefsFound.iterator();
641 // TypeInfo typeInfo= null;
642 // while (iter.hasNext()) {
643 // typeInfo= (TypeInfo)iter.next();
645 // types.add(typeInfo.resolveType(scope));
646 // } catch (JavaModelException jme) {
647 // JDIDebugUIPlugin.log(jme);
654 * Returns the package name of the given fully qualified type name.
655 * The package name is assumed to be the dot-separated prefix of the
658 // protected static char[] getPackage(String fullyQualifiedName) {
659 // int index= fullyQualifiedName.lastIndexOf('.');
660 // if (index == -1) {
661 // return new char[0];
663 // return fullyQualifiedName.substring(0, index).toCharArray();
667 // * Returns a simple type name from the given fully qualified type name.
668 // * The type name is assumed to be the last contiguous segment of the
669 // * fullyQualifiedName not containing a '.' or '$'
671 // protected static char[] getTypeName(String fullyQualifiedName) {
672 // int index= fullyQualifiedName.lastIndexOf('.');
673 // String typeName= fullyQualifiedName.substring(index + 1);
674 // int lastInnerClass= typeName.lastIndexOf('$');
675 // if (lastInnerClass != -1) {
676 // typeName= typeName.substring(lastInnerClass + 1);
678 // return typeName.toCharArray();
682 // * Return the associated IField (Java model) for the given
683 // * IJavaFieldVariable (JDI model)
685 // private IField getField(IJavaFieldVariable variable) {
686 // String varName= null;
688 // varName= variable.getName();
689 // } catch (DebugException x) {
690 // JDIDebugUIPlugin.log(x);
694 // List types= searchForDeclaringType(variable);
695 // Iterator iter= types.iterator();
696 // while (iter.hasNext()) {
697 // IType type= (IType)iter.next();
698 // field= type.getField(varName);
699 // if (field.exists()) {