issue_id
int64 2.03k
426k
| title
stringlengths 9
251
| body
stringlengths 1
32.8k
⌀ | status
stringclasses 6
values | after_fix_sha
stringlengths 7
7
| project_name
stringclasses 6
values | repo_url
stringclasses 6
values | repo_name
stringclasses 6
values | language
stringclasses 1
value | issue_url
null | before_fix_sha
null | pull_url
null | commit_datetime
timestamp[us, tz=UTC] | report_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 2
187
| file_content
stringlengths 0
368k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchUtil.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
* This class contains some utility methods for J Search.
*/
public class SearchUtil {
// LRU working sets
public static int LRU_WORKINGSET_LIST_SIZE= 3;
private static LRUWorkingSetsList fgLRUWorkingSets;
// Settings store
private static final String DIALOG_SETTINGS_KEY= "JavaElementSearchActions"; //$NON-NLS-1$
private static final String STORE_LRU_WORKING_SET_NAMES= "lastUsedWorkingSetNames"; //$NON-NLS-1$
private static IDialogSettings fgSettingsStore;
private static final String BIN_PRIM_CONST_WARN_DIALOG_ID= "BinaryPrimitiveConstantWarningDialog"; //$NON-NLS-1$
public static IJavaElement getJavaElement(IMarker marker) {
if (marker == null || !marker.exists())
return null;
try {
String handleId= (String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID);
IJavaElement je= JavaCore.create(handleId);
if (je == null)
return null;
if (!marker.getAttribute(IJavaSearchUIConstants.ATT_IS_WORKING_COPY, false)) {
if (je.exists())
return je;
}
ICompilationUnit cu= (ICompilationUnit) je.getAncestor(IJavaElement.COMPILATION_UNIT);
if (cu == null) {
return je;
}
if (!cu.exists()) {
IResource res= marker.getResource();
if (res instanceof IFile) {
cu= JavaCore.createCompilationUnitFrom((IFile) res);
if (cu == null) {
return je;
}
}
}
if (!je.exists()) {
IJavaElement[] jElements= cu.findElements(je);
if (jElements == null || jElements.length == 0)
je= cu.getElementAt(marker.getAttribute(IMarker.CHAR_START, 0));
else
je= jElements[0];
}
return je;
} catch (JavaModelException ex) {
if (!ex.isDoesNotExist())
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
} catch (CoreException ex) {
ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createJavaElement.title"), SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-2$ //$NON-NLS-1$
return null;
}
}
public static IJavaElement getJavaElement(Object entry) {
if (entry != null && isISearchResultViewEntry(entry))
return getJavaElement((ISearchResultViewEntry)entry);
return null;
}
public static IResource getResource(Object entry) {
if (entry != null && isISearchResultViewEntry(entry))
return ((ISearchResultViewEntry)entry).getResource();
return null;
}
public static IJavaElement getJavaElement(ISearchResultViewEntry entry) {
if (entry != null)
return getJavaElement(entry.getSelectedMarker());
return null;
}
public static boolean isSearchPlugInActivated() {
return Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.search").isPluginActivated(); //$NON-NLS-1$
}
public static boolean isISearchResultViewEntry(Object object) {
return object != null && isSearchPlugInActivated() && (object instanceof ISearchResultViewEntry);
}
/**
* Returns the compilation unit for the given java element.
*
* @param element the java element whose compilation unit is searched for
* @return the compilation unit of the given java element
*/
static ICompilationUnit findCompilationUnit(IJavaElement element) {
if (element == null)
return null;
return (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
}
/*
* Copied from JavaModelUtil and patched to allow members which do not exist.
* The only case where this is a problem is for methods which have same name and
* paramters as a constructor. The constructor will win in such a situation.
*
* @see JavaModelUtil#findMemberInCompilationUnit(ICompilationUnit, IMember)
*/
public static IMember findInCompilationUnit(ICompilationUnit cu, IMember member) throws JavaModelException {
if (member.getElementType() == IJavaElement.TYPE) {
return JavaModelUtil.findTypeInCompilationUnit(cu, JavaModelUtil.getTypeQualifiedName((IType)member));
} else {
IType declaringType= JavaModelUtil.findTypeInCompilationUnit(cu, JavaModelUtil.getTypeQualifiedName(member.getDeclaringType()));
if (declaringType != null) {
IMember result= null;
switch (member.getElementType()) {
case IJavaElement.FIELD:
result= declaringType.getField(member.getElementName());
break;
case IJavaElement.METHOD:
IMethod meth= (IMethod) member;
// XXX: Begin patch ---------------------
boolean isConstructor;
if (meth.exists())
isConstructor= meth.isConstructor();
else
isConstructor= declaringType.getElementName().equals(meth.getElementName());
// XXX: End patch -----------------------
result= JavaModelUtil.findMethod(meth.getElementName(), meth.getParameterTypes(), isConstructor, declaringType);
break;
case IJavaElement.INITIALIZER:
result= declaringType.getInitializer(1);
break;
}
if (result != null && result.exists()) {
return result;
}
}
}
return null;
}
/*
* XXX: Unchanged copy from JavaModelUtil
*/
public static IJavaElement findInCompilationUnit(ICompilationUnit cu, IJavaElement element) throws JavaModelException {
if (element instanceof IMember)
return findInCompilationUnit(cu, (IMember)element);
int type= element.getElementType();
switch (type) {
case IJavaElement.IMPORT_CONTAINER:
return cu.getImportContainer();
case IJavaElement.PACKAGE_DECLARATION:
return find(cu.getPackageDeclarations(), element.getElementName());
case IJavaElement.IMPORT_DECLARATION:
return find(cu.getImports(), element.getElementName());
case IJavaElement.COMPILATION_UNIT:
return cu;
}
return null;
}
/*
* XXX: Unchanged copy from JavaModelUtil
*/
private static IJavaElement find(IJavaElement[] elements, String name) {
if (elements == null || name == null)
return null;
for (int i= 0; i < elements.length; i++) {
if (name.equals(elements[i].getElementName()))
return elements[i];
}
return null;
}
public static String toString(IWorkingSet[] workingSets) {
Arrays.sort(workingSets, new WorkingSetComparator());
String result= ""; //$NON-NLS-1$
if (workingSets != null && workingSets.length > 0) {
boolean firstFound= false;
for (int i= 0; i < workingSets.length; i++) {
String workingSetName= workingSets[i].getName();
if (firstFound)
result= SearchMessages.getFormattedString("SearchUtil.workingSetConcatenation", new String[] {result, workingSetName}); //$NON-NLS-1$
else {
result= workingSetName;
firstFound= true;
}
}
}
return result;
}
// ---------- LRU working set handling ----------
/**
* Updates the LRU list of working sets.
*
* @param workingSets the workings sets to be added to the LRU list
*/
public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
if (workingSets == null || workingSets.length < 1)
return;
getLRUWorkingSets().add(workingSets);
saveState();
}
private static void saveState() {
IWorkingSet[] workingSets;
Iterator iter= fgLRUWorkingSets.iterator();
int i= 0;
while (iter.hasNext()) {
workingSets= (IWorkingSet[])iter.next();
String[] names= new String[workingSets.length];
for (int j= 0; j < workingSets.length; j++)
names[j]= workingSets[j].getName();
fgSettingsStore.put(STORE_LRU_WORKING_SET_NAMES + i, names);
i++;
}
}
public static LRUWorkingSetsList getLRUWorkingSets() {
if (fgLRUWorkingSets == null) {
restoreState();
}
return fgLRUWorkingSets;
}
static void restoreState() {
fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
if (fgSettingsStore == null)
fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
boolean foundLRU= false;
for (int i= LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) {
String[] lruWorkingSetNames= fgSettingsStore.getArray(STORE_LRU_WORKING_SET_NAMES + i);
if (lruWorkingSetNames != null) {
Set workingSets= new HashSet(2);
for (int j= 0; j < lruWorkingSetNames.length; j++) {
IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[j]);
if (workingSet != null) {
workingSets.add(workingSet);
}
}
foundLRU= true;
if (!workingSets.isEmpty())
fgLRUWorkingSets.add((IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]));
}
}
if (!foundLRU)
// try old preference format
restoreFromOldFormat();
}
private static void restoreFromOldFormat() {
fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
if (fgSettingsStore == null)
fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
boolean foundLRU= false;
String[] lruWorkingSetNames= fgSettingsStore.getArray(STORE_LRU_WORKING_SET_NAMES);
if (lruWorkingSetNames != null) {
for (int i= lruWorkingSetNames.length - 1; i >= 0; i--) {
IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[i]);
if (workingSet != null) {
foundLRU= true;
fgLRUWorkingSets.add(new IWorkingSet[]{workingSet});
}
}
}
if (foundLRU)
// save in new format
saveState();
}
public static void warnIfBinaryConstant(IJavaElement element, Shell shell) {
if (isBinaryPrimitveConstantOrString(element))
OptionalMessageDialog.open(
BIN_PRIM_CONST_WARN_DIALOG_ID,
shell,
SearchMessages.getString("Search.FindReferencesAction.BinPrimConstWarnDialog.title"), //$NON-NLS-1$
null,
SearchMessages.getString("Search.FindReferencesAction.BinPrimConstWarnDialog.message"), //$NON-NLS-1$
MessageDialog.INFORMATION,
new String[] { IDialogConstants.OK_LABEL },
0);
}
private static boolean isBinaryPrimitveConstantOrString(IJavaElement element) {
if (element != null && element.getElementType() == IJavaElement.FIELD) {
IField field= (IField)element;
int flags;
try {
flags= field.getFlags();
} catch (JavaModelException ex) {
return false;
}
return field.isBinary() && Flags.isStatic(flags) && Flags.isFinal(flags) && isPrimitiveOrString(field);
}
return false;
}
private static boolean isPrimitiveOrString(IField field) {
String fieldType;
try {
fieldType= field.getTypeSignature();
} catch (JavaModelException ex) {
return false;
}
char first= fieldType.charAt(0);
return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED && first != Signature.C_ARRAY)
|| (first == Signature.C_RESOLVED && fieldType.substring(1, fieldType.length() - 1).equals(String.class.getName()));
}
public static String getProjectScopeDescription(IJavaElement element) {
IJavaProject project= element.getJavaProject();
if (project != null)
return SearchMessages.getFormattedString("ProjectScope", project.getElementName()); //$NON-NLS-1$
else
return SearchMessages.getFormattedString("ProjectScope", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/JavaCorrectionProcessor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMarkerHelpRegistry;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.ui.text.java.IQuickAssistProcessor;
import org.eclipse.jdt.ui.text.java.IQuickFixProcessor;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation;
public class JavaCorrectionProcessor implements IContentAssistProcessor {
private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID= "quickFixProcessors"; //$NON-NLS-1$
private static final String QUICKASSIST_PROCESSOR_CONTRIBUTION_ID= "quickAssistProcessors"; //$NON-NLS-1$
private static class CorrectionsComparator implements Comparator {
private static Collator fgCollator= Collator.getInstance();
public int compare(Object o1, Object o2) {
if ((o1 instanceof IJavaCompletionProposal) && (o2 instanceof IJavaCompletionProposal)) {
IJavaCompletionProposal e1= (IJavaCompletionProposal) o1;
IJavaCompletionProposal e2= (IJavaCompletionProposal) o2;
int del= e2.getRelevance() - e1.getRelevance();
if (del != 0) {
return del;
}
return fgCollator.compare(e1.getDisplayString(), e2.getDisplayString());
}
return fgCollator.compare(((ICompletionProposal) o1).getDisplayString(), ((ICompletionProposal) o2).getDisplayString());
}
}
private static ContributedProcessorDescriptor[] fContributedAssistProcessors= null;
private static ContributedProcessorDescriptor[] fContributedCorrectionProcessors= null;
private static String fErrorMessage;
private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId) {
IConfigurationElement[] elements= Platform.getPluginRegistry().getConfigurationElementsFor(JavaUI.ID_PLUGIN, contributionId);
ArrayList res= new ArrayList(elements.length);
for (int i= 0; i < elements.length; i++) {
ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i]);
IStatus status= desc.checkSyntax();
if (status.isOK()) {
res.add(desc);
} else {
JavaPlugin.log(status);
}
}
return (ContributedProcessorDescriptor[]) res.toArray(new ContributedProcessorDescriptor[res.size()]);
}
private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
if (fContributedCorrectionProcessors == null) {
fContributedCorrectionProcessors= getProcessorDescriptors(QUICKFIX_PROCESSOR_CONTRIBUTION_ID);
}
return fContributedCorrectionProcessors;
}
private static ContributedProcessorDescriptor[] getAssistProcessors() {
if (fContributedAssistProcessors == null) {
fContributedAssistProcessors= getProcessorDescriptors(QUICKASSIST_PROCESSOR_CONTRIBUTION_ID);
}
return fContributedAssistProcessors;
}
public static boolean hasCorrections(ICompilationUnit cu, int problemId) {
ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
for (int i= 0; i < processors.length; i++) {
try {
IQuickFixProcessor processor= (IQuickFixProcessor) processors[i].getProcessor(cu);
if (processor != null && processor.hasCorrections(cu, problemId)) {
return true;
}
} catch (CoreException e) {
//JavaPlugin.log(e);
}
}
return false;
}
public static boolean isQuickFixableType(Annotation annotation) {
return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}
public static boolean hasCorrections(Annotation annotation) {
if (annotation instanceof IJavaAnnotation) {
IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation;
int problemId= javaAnnotation.getId();
if (problemId != -1) {
ICompilationUnit cu= javaAnnotation.getCompilationUnit();
if (cu != null) {
return hasCorrections(cu, problemId);
}
}
}
if (annotation instanceof SimpleMarkerAnnotation) {
return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
}
return false;
}
private static boolean hasCorrections(IMarker marker) {
if (marker == null || !marker.exists())
return false;
IMarkerHelpRegistry registry= IDE.getMarkerHelpRegistry();
return registry != null && registry.hasResolutions(marker);
}
public static boolean hasAssists(IInvocationContext context) {
ContributedProcessorDescriptor[] processors= getAssistProcessors();
for (int i= 0; i < processors.length; i++) {
try {
IQuickAssistProcessor processor= (IQuickAssistProcessor) processors[i].getProcessor(context.getCompilationUnit());
if (processor != null && processor.hasAssists(context)) {
return true;
}
} catch (Exception e) {
JavaPlugin.log(e);
}
}
return false;
}
private JavaCorrectionAssistant fAssistant;
/**
* Constructor for JavaCorrectionProcessor.
*/
public JavaCorrectionProcessor(JavaCorrectionAssistant assistant) {
fAssistant= assistant;
}
/*
* @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
IEditorPart part= fAssistant.getEditor();
ICompilationUnit cu= JavaUI.getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(part.getEditorInput());
int length= viewer != null ? viewer.getSelectedRange().y : 0;
AssistContext context= new AssistContext(cu, documentOffset, length);
fErrorMessage= null;
ArrayList proposals= new ArrayList();
if (model != null) {
processAnnotations(context, model, proposals);
}
if (proposals.isEmpty()) {
proposals.add(new ChangeCorrectionProposal(CorrectionMessages.getString("NoCorrectionProposal.description"), null, 0, null)); //$NON-NLS-1$
}
ICompletionProposal[] res= (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
Arrays.sort(res, new CorrectionsComparator());
return res;
}
private boolean isAtPosition(int offset, Position pos) {
return (pos != null) && (offset >= pos.getOffset() && offset <= (pos.getOffset() + pos.getLength()));
}
private void processAnnotations(IInvocationContext context, IAnnotationModel model, ArrayList proposals) {
int offset= context.getSelectionOffset();
ArrayList problems= new ArrayList();
Iterator iter= model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation= (Annotation) iter.next();
if (isQuickFixableType(annotation)) {
Position pos= model.getPosition(annotation);
if (isAtPosition(offset, pos)) {
processAnnotation(annotation, pos, problems, proposals);
}
}
}
IProblemLocation[] problemLocations= (IProblemLocation[]) problems.toArray(new IProblemLocation[problems.size()]);
collectCorrections(context, problemLocations, proposals);
if (!fAssistant.isUpdatedOffset()) {
collectAssists(context, problemLocations, proposals);
}
}
private void processAnnotation(Annotation curr, Position pos, List problems, List proposals) {
if (curr instanceof IJavaAnnotation) {
IJavaAnnotation javaAnnotation= (IJavaAnnotation) curr;
int problemId= javaAnnotation.getId();
if (problemId != -1) {
problems.add(new ProblemLocation(pos.getOffset(), pos.getLength(), javaAnnotation));
return; // java problems all handled by the quick assist processors
}
}
if (curr instanceof SimpleMarkerAnnotation) {
IMarker marker= ((SimpleMarkerAnnotation) curr).getMarker();
IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
if (res.length > 0) {
for (int i= 0; i < res.length; i++) {
proposals.add(new MarkerResolutionProposal(res[i], marker));
}
}
}
}
public static void collectCorrections(IInvocationContext context, IProblemLocation[] locations, ArrayList proposals) {
ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
for (int i= 0; i < processors.length; i++) {
try {
IQuickFixProcessor curr= (IQuickFixProcessor) processors[i].getProcessor(context.getCompilationUnit());
if (curr != null) {
IJavaCompletionProposal[] res= curr.getCorrections(context, locations);
if (res != null) {
for (int k= 0; k < res.length; k++) {
proposals.add(res[k]);
}
}
}
} catch (Exception e) {
fErrorMessage= CorrectionMessages.getString("JavaCorrectionProcessor.error.quickfix.message"); //$NON-NLS-1$
JavaPlugin.log(e);
}
}
}
public static void collectAssists(IInvocationContext context, IProblemLocation[] locations, ArrayList proposals) {
ContributedProcessorDescriptor[] processors= getAssistProcessors();
for (int i= 0; i < processors.length; i++) {
try {
IQuickAssistProcessor curr= (IQuickAssistProcessor) processors[i].getProcessor(context.getCompilationUnit());
if (curr != null) {
IJavaCompletionProposal[] res= curr.getAssists(context, locations);
if (res != null) {
for (int k= 0; k < res.length; k++) {
proposals.add(res[k]);
}
}
}
} catch (Exception e) {
fErrorMessage= CorrectionMessages.getString("JavaCorrectionProcessor.error.quickassist.message"); //$NON-NLS-1$
JavaPlugin.log(e);
}
}
}
/*
* @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
*/
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
return null;
}
/*
* @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
*/
public char[] getCompletionProposalAutoActivationCharacters() {
return null;
}
/*
* @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
*/
public char[] getContextInformationAutoActivationCharacters() {
return null;
}
/*
* @see IContentAssistProcessor#getContextInformationValidator()
*/
public IContextInformationValidator getContextInformationValidator() {
return null;
}
/*
* @see IContentAssistProcessor#getErrorMessage()
*/
public String getErrorMessage() {
return fErrorMessage;
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.java.hover;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPluginRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.jface.text.Assert;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.java.hover.IJavaEditorTextHover;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
/**
* Describes a Java editor text hover.
*
* @since 2.1
*/
public class JavaEditorTextHoverDescriptor implements Comparable {
private static final String JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.jdt.ui.javaEditorTextHovers"; //$NON-NLS-1$
private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
private static final String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
private static final String ACTIVATE_PLUG_IN_ATTRIBUTE= "activate"; //$NON-NLS-1$
private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
public static final String NO_MODIFIER= "0"; //$NON-NLS-1$
public static final String DISABLED_TAG= "!"; //$NON-NLS-1$
public static final String VALUE_SEPARATOR= ";"; //$NON-NLS-1$
private int fStateMask;
private String fModifierString;
private boolean fIsEnabled;
private IConfigurationElement fElement;
/**
* Returns all Java editor text hovers contributed to the workbench.
*/
public static JavaEditorTextHoverDescriptor[] getContributedHovers() {
IPluginRegistry registry= Platform.getPluginRegistry();
IConfigurationElement[] elements= registry.getConfigurationElementsFor(JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT);
JavaEditorTextHoverDescriptor[] hoverDescs= createDescriptors(elements);
initializeFromPreferences(hoverDescs);
return hoverDescs;
}
/**
* Computes the state mask for the given modifier string.
*
* @param modifiers the string with the modifiers, separated by '+', '-', ';', ',' or '.'
* @return the state mask or -1 if the input is invalid
*/
public static int computeStateMask(String modifiers) {
if (modifiers == null)
return -1;
if (modifiers.length() == 0)
return SWT.NONE;
int stateMask= 0;
StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
while (modifierTokenizer.hasMoreTokens()) {
int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
if (modifier == 0 || (stateMask & modifier) == modifier)
return -1;
stateMask= stateMask | modifier;
}
return stateMask;
}
/**
* Creates a new Java Editor text hover descriptor from the given configuration element.
*/
private JavaEditorTextHoverDescriptor(IConfigurationElement element) {
Assert.isNotNull(element);
fElement= element;
}
/**
* Creates the Java editor text hover.
*/
public IJavaEditorTextHover createTextHover() {
boolean isHoversPlugInActivated= fElement.getDeclaringExtension().getDeclaringPluginDescriptor().isPluginActivated();
if (isHoversPlugInActivated || canActivatePlugIn()) {
try {
return (IJavaEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
} catch (CoreException x) {
JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, JavaHoverMessages.getString("JavaTextHover.createTextHover"), null)); //$NON-NLS-1$
}
}
return null;
}
//---- XML Attribute accessors ---------------------------------------------
/**
* Returns the hover's id.
*/
public String getId() {
return fElement.getAttribute(ID_ATTRIBUTE);
}
/**
* Returns the hover's class name.
*/
public String getHoverClassName() {
return fElement.getAttribute(CLASS_ATTRIBUTE);
}
/**
* Returns the hover's label.
*/
public String getLabel() {
String label= fElement.getAttribute(LABEL_ATTRIBUTE);
if (label != null)
return label;
// Return simple class name
label= getHoverClassName();
int lastDot= label.lastIndexOf('.');
if (lastDot >= 0 && lastDot < label.length() - 1)
return label.substring(lastDot + 1);
else
return label;
}
/**
* Returns the hover's description.
*
* @return the hover's description or <code>null</code> if not provided
*/
public String getDescription() {
return fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
}
public boolean canActivatePlugIn() {
return Boolean.valueOf(fElement.getAttribute(ACTIVATE_PLUG_IN_ATTRIBUTE)).booleanValue();
}
public boolean equals(Object obj) {
if (obj == null || !obj.getClass().equals(this.getClass()) || getId() == null)
return false;
return getId().equals(((JavaEditorTextHoverDescriptor)obj).getId());
}
public int hashCode() {
return getId().hashCode();
}
/**
* {@inheritDoc}
*/
public int compareTo(Object o) {
return Collator.getInstance().compare(getLabel(), ((JavaEditorTextHoverDescriptor)o).getLabel());
}
private static JavaEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
List result= new ArrayList(elements.length);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (HOVER_TAG.equals(element.getName())) {
JavaEditorTextHoverDescriptor desc= new JavaEditorTextHoverDescriptor(element);
result.add(desc);
}
}
Collections.sort(result);
return (JavaEditorTextHoverDescriptor[])result.toArray(new JavaEditorTextHoverDescriptor[result.size()]);
}
private static void initializeFromPreferences(JavaEditorTextHoverDescriptor[] hovers) {
String compiledTextHoverModifiers= JavaPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
String id= tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifier.put(id, tokenizer.nextToken());
}
String compiledTextHoverModifierMasks= JavaPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
String id= tokenizer.nextToken();
if (tokenizer.hasMoreTokens())
idToModifierMask.put(id, tokenizer.nextToken());
}
for (int i= 0; i < hovers.length; i++) {
String modifierString= (String)idToModifier.get(hovers[i].getId());
boolean enabled= true;
if (modifierString == null)
modifierString= DISABLED_TAG;
if (modifierString.startsWith(DISABLED_TAG)) {
enabled= false;
modifierString= modifierString.substring(1);
}
if (modifierString.equals(NO_MODIFIER))
modifierString= ""; //$NON-NLS-1$
hovers[i].fModifierString= modifierString;
hovers[i].fIsEnabled= enabled;
hovers[i].fStateMask= computeStateMask(modifierString);
if (hovers[i].fStateMask == -1) {
// Fallback: use stored modifier masks
try {
hovers[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(hovers[i].getId()));
} catch (NumberFormatException ex) {
hovers[i].fStateMask= -1;
}
// Fix modifier string
int stateMask= hovers[i].fStateMask;
if (stateMask == -1)
hovers[i].fModifierString= ""; //$NON-NLS-1$
else
hovers[i].fModifierString= EditorUtility.getModifierString(stateMask);
}
}
}
/**
* Returns the configured modifier getStateMask for this hover.
*
* @return the hover modifier stateMask or -1 if no hover is configured
*/
public int getStateMask() {
return fStateMask;
}
/**
* Returns the modifier String as set in the preference store.
*
* @return the modifier string
*/
public String getModifierString() {
return fModifierString;
}
/**
* Returns whether this hover is enabled or not.
*
* @return <code>true</code> if enabled
*/
public boolean isEnabled() {
return fIsEnabled;
}
/**
* Returns this hover descriptors configuration element.
*
* @return the configuration element
* @since 3.0
*/
public IConfigurationElement getConfigurationElement() {
return fElement;
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocCompletionProcessor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.javadoc;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPluginRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.templates.TemplateContextType;
import org.eclipse.ui.IEditorPart;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.ui.text.java.IJavadocCompletionProcessor;
import org.eclipse.jdt.internal.corext.template.java.JavaDocContextType;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComparator;
import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine;
/**
* Java doc completion processor using contributed IJavaDocCompletionProcessor's
* to evaluate proposals.
*/
public class JavaDocCompletionProcessor implements IContentAssistProcessor {
private static final String PROCESSOR_CONTRIBUTION_ID= "javadocCompletionProcessor"; //$NON-NLS-1$
private IEditorPart fEditor;
private char[] fProposalAutoActivationSet;
private JavaCompletionProposalComparator fComparator;
private TemplateEngine fTemplateEngine;
private int fSubProcessorFlags;
private String fErrorMessage;
private IJavadocCompletionProcessor[] fSubProcessors;
public JavaDocCompletionProcessor(IEditorPart editor) {
fEditor= editor;
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType("javadoc"); //$NON-NLS-1$
if (contextType == null) {
contextType= new JavaDocContextType();
JavaPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
if (contextType != null)
fTemplateEngine= new TemplateEngine(contextType);
fSubProcessorFlags= 0;
fComparator= new JavaCompletionProposalComparator();
fSubProcessors= null;
fErrorMessage= null;
}
private IJavadocCompletionProcessor[] getContributedProcessors() {
if (fSubProcessors == null) {
try {
IPluginRegistry registry= Platform.getPluginRegistry();
IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, PROCESSOR_CONTRIBUTION_ID);
IJavadocCompletionProcessor[] result= new IJavadocCompletionProcessor[elements.length];
for (int i= 0; i < elements.length; i++) {
result[i]= (IJavadocCompletionProcessor) elements[i].createExecutableExtension("class"); //$NON-NLS-1$
}
fSubProcessors= result;
} catch (CoreException e) {
JavaPlugin.log(e);
fSubProcessors= new IJavadocCompletionProcessor[] { new JavaDocCompletionEvaluator() };
}
}
return fSubProcessors;
}
/**
* Tells this processor to order the proposals alphabetically.
*
* @param order <code>true</code> if proposals should be ordered.
*/
public void orderProposalsAlphabetically(boolean order) {
fComparator.setOrderAlphabetically(order);
}
/**
* Tells this processor to restrict is proposals to those
* starting with matching cases.
*
* @param restrict <code>true</code> if proposals should be restricted
*/
public void restrictProposalsToMatchingCases(boolean restrict) {
fSubProcessorFlags= restrict ? IJavadocCompletionProcessor.RESTRICT_TO_MATCHING_CASE : 0;
}
/**
* @see IContentAssistProcessor#getErrorMessage()
*/
public String getErrorMessage() {
return fErrorMessage;
}
/**
* @see IContentAssistProcessor#getContextInformationValidator()
*/
public IContextInformationValidator getContextInformationValidator() {
return null;
}
/**
* @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
*/
public char[] getContextInformationAutoActivationCharacters() {
return null;
}
/**
* @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
*/
public char[] getCompletionProposalAutoActivationCharacters() {
return fProposalAutoActivationSet;
}
/**
* Sets this processor's set of characters triggering the activation of the
* completion proposal computation.
*
* @param activationSet the activation set
*/
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
fProposalAutoActivationSet= activationSet;
}
/**
* @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
*/
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
ICompilationUnit cu= JavaUI.getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
ArrayList result= new ArrayList();
String errorMessage= null;
IJavadocCompletionProcessor[] processors= getContributedProcessors();
for (int i= 0; i < processors.length; i++) {
IJavadocCompletionProcessor curr= processors[i];
IContextInformation[] contextInfos= curr.computeContextInformation(cu, offset);
if (contextInfos != null) {
for (int k= 0; k < contextInfos.length; k++) {
result.add(contextInfos[k]);
}
}
if (curr.getErrorMessage() != null) {
errorMessage= curr.getErrorMessage();
}
}
fErrorMessage= result.isEmpty() ? errorMessage : null;
return (IContextInformation[]) result.toArray(new IContextInformation[result.size()]);
}
/**
* @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
ICompilationUnit cu= JavaUI.getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
int offset= documentOffset;
int length= 0;
Point selection= viewer.getSelectedRange();
if (selection.y > 0) {
offset= selection.x;
length= selection.y;
}
ArrayList result= new ArrayList();
String errorMessage= null;
IJavadocCompletionProcessor[] processors= getContributedProcessors();
for (int i= 0; i < processors.length; i++) {
IJavadocCompletionProcessor curr= processors[i];
IJavaCompletionProposal[] proposals= curr.computeCompletionProposals(cu, offset, length, fSubProcessorFlags);
if (proposals != null) {
for (int k= 0; k < proposals.length; k++) {
result.add(proposals[k]);
}
}
if (curr.getErrorMessage() != null) {
errorMessage= curr.getErrorMessage();
}
}
if (fTemplateEngine != null) {
fTemplateEngine.reset();
fTemplateEngine.complete(viewer, offset, cu);
ICompletionProposal[] templateResults= fTemplateEngine.getResults();
for (int k= 0; k < templateResults.length; k++) {
result.add(templateResults[k]);
}
}
fErrorMessage= result.isEmpty() ? errorMessage : null;
IJavaCompletionProposal[] total= (IJavaCompletionProposal[]) result.toArray(new IJavaCompletionProposal[result.size()]);
return order(total);
}
/**
* Order the given proposals.
*/
private IJavaCompletionProposal[] order(IJavaCompletionProposal[] proposals) {
Arrays.sort(proposals, fComparator);
return proposals;
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/SpellCheckEngine.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.spelling;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jdt.internal.ui.text.spelling.engine.DefaultSpellChecker;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary;
import org.eclipse.jdt.internal.ui.text.spelling.engine.PersistentSpellDictionary;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* Spell check engine for Java source spell checking.
*
* @since 3.0
*/
public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListener {
/** The dictionary location */
public static final String DICTIONARY_LOCATION= "dictionaries/"; //$NON-NLS-1$
/** The singleton spell checker instance */
private static ISpellChecker fChecker= null;
/** The singleton engine instance */
private static ISpellCheckEngine fEngine= null;
/**
* Returns the available locales for this spell check engine.
*
* @return The available locales for this engine
*/
public static Set getAvailableLocales() {
URL url= null;
Locale locale= null;
InputStream stream= null;
final Set result= new HashSet();
try {
final URL location= getDictionaryLocation();
final Locale[] locales= Locale.getAvailableLocales();
for (int index= 0; index < locales.length; index++) {
locale= locales[index];
url= new URL(location, locale.toString().toLowerCase() + "." + JavaUIMessages.getString("Spelling.dictionary.file.extension")); //$NON-NLS-1$ //$NON-NLS-2$
try {
stream= url.openStream();
if (stream != null) {
try {
result.add(locale);
} finally {
stream.close();
}
}
} catch (IOException exception) {
// Do nothing
}
}
} catch (MalformedURLException exception) {
// Do nothing
}
result.add(getDefaultLocale());
return result;
}
/**
* Returns the default locale for this engine.
*
* @return The default locale
*/
public static Locale getDefaultLocale() {
return Locale.US;
}
/**
* Returns the dictionary location.
*
* @throws MalformedURLException
* if the URL could not be created
* @return The dictionary location, or <code>null</code> iff the location
* is not known
*/
public static URL getDictionaryLocation() throws MalformedURLException {
final JavaPlugin plugin= JavaPlugin.getDefault();
if (plugin != null)
return new URL(plugin.getDescriptor().getInstallURL(), DICTIONARY_LOCATION);
return null;
}
/**
* Returns the singleton instance of the spell check engine.
*
* @return The singleton instance of the spell check engine
*/
public static final synchronized ISpellCheckEngine getInstance() {
if (fEngine == null)
fEngine= new SpellCheckEngine();
return fEngine;
}
/** The registered locale insenitive dictionaries */
private final Set fGlobalDictionaries= new HashSet();
/** The current locale */
private Locale fLocale= null;
/** The registered locale sensitive dictionaries */
private final Map fLocaleDictionaries= new HashMap();
/** The preference store where to listen */
private IPreferenceStore fPreferences= null;
/** The user dictionary */
private ISpellDictionary fUserDictionary= null;
/**
* Creates a new spell check manager.
*/
private SpellCheckEngine() {
fGlobalDictionaries.add(new TaskTagDictionary());
fGlobalDictionaries.add(new HtmlTagDictionary());
fGlobalDictionaries.add(new JavaDocTagDictionary());
try {
Locale locale= null;
final URL location= getDictionaryLocation();
for (final Iterator iterator= getAvailableLocales().iterator(); iterator.hasNext();) {
locale= (Locale)iterator.next();
fLocaleDictionaries.put(locale, new SpellReconcileDictionary(locale, location));
}
} catch (MalformedURLException exception) {
// Do nothing
}
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#createSpellChecker(java.util.Locale,org.eclipse.jface.preference.IPreferenceStore)
*/
public final synchronized ISpellChecker createSpellChecker(final Locale locale, final IPreferenceStore store) {
if (fLocale != null && fLocale.equals(locale))
return fChecker;
if (fChecker == null) {
fChecker= new DefaultSpellChecker(store);
store.addPropertyChangeListener(this);
fPreferences= store;
ISpellDictionary dictionary= null;
for (Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
fChecker.addDictionary(dictionary);
}
}
ISpellDictionary dictionary= null;
if (fLocale != null) {
dictionary= (ISpellDictionary)fLocaleDictionaries.get(fLocale);
if (dictionary != null) {
fChecker.removeDictionary(dictionary);
dictionary.unload();
}
}
fLocale= locale;
dictionary= (ISpellDictionary)fLocaleDictionaries.get(locale);
if (dictionary == null) {
if (!getDefaultLocale().equals(locale)) {
if (fPreferences != null)
fPreferences.removePropertyChangeListener(this);
fChecker= null;
fLocale= null;
}
} else
fChecker.addDictionary(dictionary);
if (fPreferences != null)
propertyChange(new PropertyChangeEvent(this, ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY, null, fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY)));
return fChecker;
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#getLocale()
*/
public final Locale getLocale() {
return fLocale;
}
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public final void propertyChange(final PropertyChangeEvent event) {
if (fChecker != null && event.getProperty().equals(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY)) {
if (fUserDictionary != null) {
fChecker.removeDictionary(fUserDictionary);
fUserDictionary= null;
}
final String file= (String)event.getNewValue();
if (file.length() > 0) {
try {
final URL url= new URL("file", null, file); //$NON-NLS-1$
InputStream stream= url.openStream();
if (stream != null) {
try {
fUserDictionary= new PersistentSpellDictionary(url);
fChecker.addDictionary(fUserDictionary);
} finally {
stream.close();
}
}
} catch (MalformedURLException exception) {
// Do nothing
} catch (IOException exception) {
// Do nothing
}
}
}
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void registerDictionary(final ISpellDictionary dictionary) {
fGlobalDictionaries.add(dictionary);
if (fChecker != null)
fChecker.addDictionary(dictionary);
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(java.util.Locale,org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void registerDictionary(final Locale locale, final ISpellDictionary dictionary) {
fLocaleDictionaries.put(locale, dictionary);
if (fChecker != null && fLocale != null && fLocale.equals(locale))
fChecker.addDictionary(dictionary);
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unload()
*/
public synchronized final void unload() {
ISpellDictionary dictionary= null;
for (final Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
dictionary.unload();
}
for (final Iterator iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
dictionary.unload();
}
if (fPreferences != null)
fPreferences.removePropertyChangeListener(this);
fUserDictionary= null;
fChecker= null;
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unregisterDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void unregisterDictionary(final ISpellDictionary dictionary) {
fGlobalDictionaries.remove(dictionary);
fLocaleDictionaries.values().remove(dictionary);
if (fChecker != null)
fChecker.removeDictionary(dictionary);
dictionary.unload();
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/CoreUtility.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.util;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.custom.BusyIndicator;
public class CoreUtility {
/**
* Creates a folder and all parent folders if not existing.
* Project must exist.
* <code> org.eclipse.ui.dialogs.ContainerGenerator</code> is too heavy
* (creates a runnable)
*/
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
if (!folder.exists()) {
IContainer parent= folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder)parent, force, local, null);
}
folder.create(force, local, monitor);
}
}
/**
* Creates an extension. If the extension plugin has not
* been loaded a busy cursor will be activated during the duration of
* the load.
*
* @param element the config element defining the extension
* @param classAttribute the name of the attribute carrying the class
* @return the extension object
*/
public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
// If plugin has been loaded create extension.
// Otherwise, show busy cursor then create extension.
IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
if (plugin.isPluginActivated()) {
return element.createExecutableExtension(classAttribute);
} else {
final Object[] ret = new Object[1];
final CoreException[] exc = new CoreException[1];
BusyIndicator.showWhile(null, new Runnable() {
public void run() {
try {
ret[0] = element.createExecutableExtension(classAttribute);
} catch (CoreException e) {
exc[0] = e;
}
}
});
if (exc[0] != null)
throw exc[0];
else
return ret[0];
}
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewTypeDropDownAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards;
import java.util.ArrayList;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.internal.IWorkbenchConstants;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
/**
* A type wizard is added to the type drop down if it has a paramater 'javatype':
* <wizard
* name="My Type Wizard"
* icon="icons/wiz.gif"
* category="mycategory"
* id="xx.MyWizard">
* <class class="org.xx.MyWizard">
* <parameter name="javatype" value="true"/>
* </class>
* <description>
* My Type Wizard
* </description>
* </wizard>
*/
public class NewTypeDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
private final static String TAG_WIZARD = "wizard";//$NON-NLS-1$
private final static String ATT_JAVATYPE = "javatype";//$NON-NLS-1$
private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$
private final static String TAG_NAME = "name";//$NON-NLS-1$
private final static String TAG_VALUE = "value";//$NON-NLS-1$
private Menu fMenu;
public NewTypeDropDownAction() {
fMenu= null;
setMenuCreator(this);
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
}
public void dispose() {
if (fMenu != null) {
fMenu.dispose();
fMenu= null;
}
}
public Menu getMenu(Menu parent) {
return null;
}
public Menu getMenu(Control parent) {
if (fMenu == null) {
fMenu= new Menu(parent);
Action[] actions= getActionFromDescriptors();
for (int i= 0; i < actions.length; i++) {
ActionContributionItem item= new ActionContributionItem(actions[i]);
item.fill(fMenu, -1);
}
}
return fMenu;
}
public void run() {
(new OpenClassWizardAction()).run();
}
public static Action[] getActionFromDescriptors() {
ArrayList containers= new ArrayList();
IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_NEW);
if (extensionPoint != null) {
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (element.getName().equals(TAG_WIZARD) && isJavaTypeWizard(element)) {
containers.add(new OpenTypeWizardAction(element));
}
}
}
return (Action[]) containers.toArray(new Action[containers.size()]);
}
private static boolean isJavaTypeWizard(IConfigurationElement element) {
IConfigurationElement[] classElements= element.getChildren(IWorkbenchConstants.TAG_CLASS);
if (classElements.length > 0) {
for (int i= 0; i < classElements.length; i++) {
IConfigurationElement[] paramElements= classElements[i].getChildren(TAG_PARAMETER);
for (int k = 0; k < paramElements.length; k++) {
IConfigurationElement curr= paramElements[k];
if (ATT_JAVATYPE.equals(curr.getAttribute(TAG_NAME))) {
return Boolean.valueOf(curr.getAttribute(TAG_VALUE)).booleanValue();
}
}
}
}
// old way, deprecated
if (Boolean.valueOf(element.getAttribute(ATT_JAVATYPE)).booleanValue()) {
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
run();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/OpenTypeWizardAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
public class OpenTypeWizardAction extends AbstractOpenWizardAction {
private final static String ATT_NAME = "name";//$NON-NLS-1$
private final static String ATT_CLASS = "class";//$NON-NLS-1$
private final static String ATT_ICON = "icon";//$NON-NLS-1$
private static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
private IConfigurationElement fConfigurationElement;
public OpenTypeWizardAction(IConfigurationElement element) {
fConfigurationElement= element;
setText(element.getAttribute(ATT_NAME));
String description= getDescriptionFromConfig(fConfigurationElement);
setDescription(description);
setToolTipText(description);
setImageDescriptor(getIconFromConfig(fConfigurationElement));
}
private String getDescriptionFromConfig(IConfigurationElement config) {
IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
if (children.length>=1) {
return children[0].getValue();
}
return ""; //$NON-NLS-1$
}
private ImageDescriptor getIconFromConfig(IConfigurationElement config) {
try {
String iconName = config.getAttribute(ATT_ICON);
if (iconName != null) {
URL pluginInstallUrl = config.getDeclaringExtension().getDeclaringPluginDescriptor().getInstallURL();
return ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
}
return null;
} catch (MalformedURLException exception) {
JavaPlugin.logErrorMessage("Unable to load wizard icon"); //$NON-NLS-1$
}
return ImageDescriptor.getMissingImageDescriptor();
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction#createWizard()
*/
protected Wizard createWizard() throws CoreException {
return (Wizard) CoreUtility.createExtension(fConfigurationElement, ATT_CLASS);
}
}
|
60,349
|
Bug 60349 [implementation] reduce warnings due to core.runtime deprecations
| null |
resolved fixed
|
67b26cf
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T10:56:06Z
| 2004-04-28T22:06:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ClasspathContainerDescriptor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
/**
*/
public class ClasspathContainerDescriptor {
private IConfigurationElement fConfigElement;
private IClasspathContainerPage fPage;
private static final String ATT_EXTENSION = "classpathContainerPage"; //$NON-NLS-1$
private static final String ATT_ID = "id"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$NON-NLS-1$
private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
public ClasspathContainerDescriptor(IConfigurationElement configElement) throws CoreException {
super();
fConfigElement = configElement;
fPage= null;
String id = fConfigElement.getAttribute(ATT_ID);
String name = configElement.getAttribute(ATT_NAME);
String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
if (name == null) {
throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, 0, "Invalid extension (missing name): " + id, null)); //$NON-NLS-1$
}
if (pageClassName == null) {
throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, 0, "Invalid extension (missing page class name): " + id, null)); //$NON-NLS-1$
}
}
public IClasspathContainerPage createPage() throws CoreException {
if (fPage == null) {
Object elem= CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
if (elem instanceof IClasspathContainerPage) {
fPage= (IClasspathContainerPage) elem;
} else {
String id= fConfigElement.getAttribute(ATT_ID);
throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, 0, "Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
}
}
return fPage;
}
public IClasspathContainerPage getPage() {
return fPage;
}
public void setPage(IClasspathContainerPage page) {
fPage= page;
}
public void dispose() {
if (fPage != null) {
fPage.dispose();
fPage= null;
}
}
public String getName() {
return fConfigElement.getAttribute(ATT_NAME);
}
public String getPageClass() {
return fConfigElement.getAttribute(ATT_PAGE_CLASS);
}
public boolean canEdit(IClasspathEntry entry) {
String id = fConfigElement.getAttribute(ATT_ID);
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
String type = entry.getPath().segment(0);
return id.equals(type);
}
return false;
}
public static ClasspathContainerDescriptor[] getDescriptors() {
ArrayList containers= new ArrayList();
IExtensionPoint extensionPoint = Platform.getPluginRegistry().getExtensionPoint(JavaUI.ID_PLUGIN, ATT_EXTENSION);
if (extensionPoint != null) {
ClasspathContainerDescriptor defaultPage= null;
String defaultPageName= ClasspathContainerDefaultPage.class.getName();
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
try {
ClasspathContainerDescriptor curr= new ClasspathContainerDescriptor(elements[i]);
if (defaultPageName.equals(curr.getPageClass())) {
defaultPage= curr;
} else {
containers.add(curr);
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
if (defaultPageName != null && containers.isEmpty()) {
// default page only added of no other extensions found
containers.add(defaultPage);
}
}
return (ClasspathContainerDescriptor[]) containers.toArray(new ClasspathContainerDescriptor[containers.size()]);
}
}
|
42,328
|
Bug 42328 assign parameter to new field should declare field final [quick assist]
|
When using the quick assist to assign to a new field from a constructor parameter it would be nice if the field created was final. The fields can be safely declared final around 99% of the time.
|
resolved fixed
|
8c5649a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T15:09:56Z
| 2003-09-01T12:40:00Z
|
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/AssistQuickFixTest.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids <sdavids@gmx.de> - testInvertEquals1-23
*******************************************************************************/
package org.eclipse.jdt.ui.tests.quickfix;
import java.util.Hashtable;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.jdt.testplugin.JavaProjectHelper;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.tests.core.ProjectTestSetup;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.correction.AssignToVariableAssistProposal;
import org.eclipse.jdt.internal.ui.text.correction.AssistContext;
import org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal;
import org.eclipse.jdt.internal.ui.text.correction.LinkedNamesAssistProposal;
public class AssistQuickFixTest extends QuickFixTest {
private static final Class THIS= AssistQuickFixTest.class;
private IJavaProject fJProject1;
private IPackageFragmentRoot fSourceFolder;
public AssistQuickFixTest(String name) {
super(name);
}
public static Test allTests() {
return new ProjectTestSetup(new TestSuite(THIS));
}
public static Test suite() {
if (true) {
return allTests();
} else {
TestSuite suite= new TestSuite();
suite.addTest(new AssistQuickFixTest("testUnwrapMethodInvocation"));
return new ProjectTestSetup(suite);
}
}
protected void setUp() throws Exception {
Hashtable options= JavaCore.getDefaultOptions();
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");
JavaCore.setOptions(options);
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);
Preferences corePrefs= JavaCore.getPlugin().getPluginPreferences();
corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");
fJProject1= ProjectTestSetup.getProject();
fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src");
}
protected void tearDown() throws Exception {
JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath());
}
public void testAssignToLocal() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" getClass();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("getClass()");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private Class class1;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" class1 = getClass();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" Class class1 = getClass();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignToLocal2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" goo().iterator();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("goo().iterator()");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Iterator;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" private Iterator iterator;\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" iterator = goo().iterator();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Iterator;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" Iterator iterator = goo().iterator();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignToLocal3() throws Exception {
// test prefixes and this qualification
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true);
Preferences corePrefs= JavaCore.getPlugin().getPluginPreferences();
corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f");
corePrefs.setValue(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_");
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("System");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append(" private SecurityManager fManager;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" this.fManager = System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" SecurityManager _manager = System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignToLocal4() throws Exception {
// test name conflict
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int f;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" Math.min(1.0f, 2.0f);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("Math");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int f;\n");
buf.append(" private float g;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" g = Math.min(1.0f, 2.0f);\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int f;\n");
buf.append("\n");
buf.append(" public void foo() {\n");
buf.append(" float g = Math.min(1.0f, 2.0f);\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignToLocal5() throws Exception {
// test prefixes and this qualification on static method
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true);
Preferences corePrefs= JavaCore.getPlugin().getPluginPreferences();
corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f");
corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg");
corePrefs.setValue(JavaCore.CODEASSIST_LOCAL_PREFIXES, "_");
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append("\n");
buf.append(" public static void foo() {\n");
buf.append(" System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("System");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append(" private static SecurityManager fgManager;\n");
buf.append("\n");
buf.append(" public static void foo() {\n");
buf.append(" E.fgManager = System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append("\n");
buf.append(" private int fCount;\n");
buf.append("\n");
buf.append(" public static void foo() {\n");
buf.append(" SecurityManager _manager = System.getSecurityManager();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignToLocal6() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" static {\n");
buf.append(" getClass(); // comment\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("getClass()");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private static Class class1;\n");
buf.append("\n");
buf.append(" static {\n");
buf.append(" class1 = getClass(); // comment\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" static {\n");
buf.append(" Class class1 = getClass(); // comment\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testAssignParamToField() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public E(int count) {\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("count");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private int count;\n");
buf.append("\n");
buf.append(" public E(int count) {\n");
buf.append(" this.count = count;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testAssignParamToField2() throws Exception {
Preferences corePrefs= JavaCore.getPlugin().getPluginPreferences();
corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "f");
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" public E(int count, Vector vec[]) {\n");
buf.append(" super();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("vec");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" private Vector[] fVec;\n");
buf.append("\n");
buf.append(" public E(int count, Vector vec[]) {\n");
buf.append(" super();\n");
buf.append(" fVec = vec;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testAssignParamToField3() throws Exception {
Preferences corePrefs= JavaCore.getPlugin().getPluginPreferences();
corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "fg");
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true);
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" private int fgVec;\n");
buf.append("\n");
buf.append(" public static void foo(int count, Vector vec[]) {\n");
buf.append(" count++;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("vec[]");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" private int fgVec;\n");
buf.append(" private static Vector[] fgVec2;\n");
buf.append("\n");
buf.append(" public static void foo(int count, Vector vec[]) {\n");
buf.append(" E.fgVec2 = vec;\n");
buf.append(" count++;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testAssignParamToField4() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true);
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private long count;\n");
buf.append("\n");
buf.append(" public void foo(int count) {\n");
buf.append(" count++;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("int count");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private long count;\n");
buf.append(" private int count2;\n");
buf.append("\n");
buf.append(" public void foo(int count) {\n");
buf.append(" this.count2 = count;\n");
buf.append(" count++;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testAssignParamToField5() throws Exception {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, true);
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private int p1;\n");
buf.append("\n");
buf.append(" public void foo(int p1, int p2) {\n");
buf.append(" this.p1 = p1;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
int offset= buf.toString().indexOf("int p2");
AssistContext context= getCorrectionContext(cu, offset, 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private int p1;\n");
buf.append(" private int p2;\n");
buf.append("\n");
buf.append(" public void foo(int p1, int p2) {\n");
buf.append(" this.p1 = p1;\n");
buf.append(" this.p2 = p2;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testAssignToLocal2CursorAtEnd() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" goo().toArray();\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "goo().toArray();";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" private Object[] objects;\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" objects = goo().toArray();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Vector;\n");
buf.append("public class E {\n");
buf.append(" public Vector goo() {\n");
buf.append(" return null;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" Object[] objects = goo().toArray();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testReplaceCatchClauseWithThrowsWithFinally() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" try {\n");
buf.append(" goo();\n");
buf.append(" } catch (IOException e) {\n");
buf.append(" } finally {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "(IOException e)";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() throws IOException {\n");
buf.append(" try {\n");
buf.append(" goo();\n");
buf.append(" } finally {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" try {\n");
buf.append(" goo();\n");
buf.append(" } finally {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testReplaceSingleCatchClauseWithThrows() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" try {\n");
buf.append(" goo();\n");
buf.append(" } catch (IOException e) {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "(IOException e)";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 3);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() throws IOException {\n");
buf.append(" goo();\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" goo();\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(2);
String preview3= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.io.IOException;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" try {\n");
buf.append(" goo();\n");
buf.append(" } catch (IOException e) {\n");
buf.append(" } finally {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
String expected3= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 });
}
public void testUnwrapForLoop() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" for (int i= 0; i < 3; i++) {\n");
buf.append(" goo();\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "for";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" goo();\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapDoStatement() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" do {\n");
buf.append(" goo();\n");
buf.append(" goo();\n");
buf.append(" goo();\n");
buf.append(" } while (true);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "do";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" goo();\n");
buf.append(" goo();\n");
buf.append(" goo();\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapWhileLoop2Statements() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" while (true) {\n");
buf.append(" goo();\n");
buf.append(" System.out.println();\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "while";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" goo();\n");
buf.append(" System.out.println();\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapIfStatement() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" if (1+ 3 == 6) {\n");
buf.append(" StringBuffer buf= new StringBuffer();\n");
buf.append(" buf.append(1);\n");
buf.append(" buf.append(2);\n");
buf.append(" buf.append(3);\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "if";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 2);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview1= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" StringBuffer buf= new StringBuffer();\n");
buf.append(" buf.append(1);\n");
buf.append(" buf.append(2);\n");
buf.append(" buf.append(3);\n");
buf.append(" }\n");
buf.append("}\n");
String expected1= buf.toString();
proposal= (CUCorrectionProposal) proposals.get(1);
String preview2= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" if (1+ 3 == 6) {\n");
buf.append(" StringBuffer buf= new StringBuffer();\n");
buf.append(" buf.append(1);\n");
buf.append(" buf.append(2);\n");
buf.append(" buf.append(3);\n");
buf.append(" } else {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
String expected2= buf.toString();
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });
}
public void testUnwrapTryStatement() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" try {\n");
buf.append(" StringBuffer buf= new StringBuffer();\n");
buf.append(" buf.append(1);\n");
buf.append(" buf.append(2);\n");
buf.append(" buf.append(3);\n");
buf.append(" } finally {\n");
buf.append(" return;\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "try";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" StringBuffer buf= new StringBuffer();\n");
buf.append(" buf.append(1);\n");
buf.append(" buf.append(2);\n");
buf.append(" buf.append(3);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapAnonymous() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" Runnable run= new Runnable() {\n");
buf.append(" public void run() { \n");
buf.append(" throw new NullPointerException();\n");
buf.append(" }\n");
buf.append(" };\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "};";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" throw new NullPointerException();\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapBlock() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" {\n");
buf.append(" { \n");
buf.append(" throw new NullPointerException();\n");
buf.append(" }//comment\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "}//comment";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" {\n");
buf.append(" throw new NullPointerException();\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapParanthesis() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo() {\n");
buf.append(" return (9+ 8);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "(9+ 8)";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo() {\n");
buf.append(" return 9+ 8;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testUnwrapMethodInvocation() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo() {\n");
buf.append(" return Math.abs(9+ 8);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "Math.abs(9+ 8)";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public int foo() {\n");
buf.append(" return 9+ 8;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testSplitDeclaration1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int i = 9;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "9";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int i;\n");
buf.append(" i = 9;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testSplitDeclaration2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" for (int i = 0; i < 9; i++) {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "0";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int i;\n");
buf.append(" for (i = 0; i < 9; i++) {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testSplitDeclaration3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" final int i[] = null;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "i[]";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int i[];\n");
buf.append(" i = null;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testJoinDeclaration1() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int var[];\n");
buf.append(" var = null;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "var";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int var[] = null;\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testJoinDeclaration2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int var;\n");
buf.append(" for (var = 0; var < 9; var++) {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "var";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, false);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" int var = 0;\n");
buf.append(" for (; var < 9; var++) {\n");
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
private static final Class[] FILTER_EQ= { LinkedNamesAssistProposal.class, AssignToVariableAssistProposal.class };
public void testInvertEquals() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(\"b\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"b\".equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(\"b\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals2() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= \"a\";\n");
buf.append(" s.equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= \"a\";\n");
buf.append(" \"a\".equals(s);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= \"a\";\n");
buf.append(" s.equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals3() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" private String b= \"b\";\n");
buf.append(" public void foo() {\n");
buf.append(" a.equals(b);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" private String b= \"b\";\n");
buf.append(" public void foo() {\n");
buf.append(" b.equals(a);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" private String b= \"b\";\n");
buf.append(" public void foo() {\n");
buf.append(" a.equals(b);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals4() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class S {\n");
buf.append(" protected String sup= \"a\";\n");
buf.append("}\n");
buf.append("public class E extends S {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" sup.equals(this.a);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class S {\n");
buf.append(" protected String sup= \"a\";\n");
buf.append("}\n");
buf.append("public class E extends S {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" this.a.equals(sup);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class S {\n");
buf.append(" protected String sup= \"a\";\n");
buf.append("}\n");
buf.append("public class E extends S {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" sup.equals(this.a);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals5() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String A= \"a\";\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(A.A);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String A= \"a\";\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" A.A.equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String A= \"a\";\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(A.A);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals6() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(A.get());\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" A.get().equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class A {\n");
buf.append(" static String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(A.get());\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals7() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".getClass().equals(String.class);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String.class.equals(\"a\".getClass());\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".getClass().equals(String.class);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals8() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" boolean x = false && \"a\".equals(get());\n");
buf.append(" }\n");
buf.append(" String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" boolean x = false && get().equals(\"a\");\n");
buf.append(" }\n");
buf.append(" String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" boolean x = false && \"a\".equals(get());\n");
buf.append(" }\n");
buf.append(" String get() {\n");
buf.append(" return \"a\";\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals9() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" equals(new E());\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(this);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" equals(new E());\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals10() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(null);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals11() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" boolean equals(Object o, boolean a) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(\"a\", false);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals12() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" boolean equals(boolean b) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(false);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals13() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" boolean equals(boolean b) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(true ? true : false);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals14() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("class Super {\n");
buf.append(" protected boolean sBool= false;\n");
buf.append("}\n");
buf.append("public class E extends Super {\n");
buf.append(" boolean equals(boolean b) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(sBool);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals15() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" boolean equals(int i) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" new E().equals(1 + 1);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals16() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" boolean equals(int i) {\n");
buf.append(" return false;\n");
buf.append(" }\n");
buf.append(" public void foo() {\n");
buf.append(" int i= 1;\n");
buf.append(" new E().equals(i + i);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals17() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(null);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals18() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public boolean equals(Object o) {\n");
buf.append(" return super.equals(o);\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 0);
assertCorrectLabels(proposals);
}
public void testInvertEquals19() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" a.equals((Object) \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" ((Object) \"a\").equals(a);\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" private String a= \"a\";\n");
buf.append(" public void foo() {\n");
buf.append(" a.equals((Object) \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals20() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= null;\n");
buf.append(" \"a\".equals(s = \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= null;\n");
buf.append(" (s = \"a\").equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" String s= null;\n");
buf.append(" \"a\".equals(s = \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals21() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"aaa\".equals(\"a\" + \"a\" + \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" (\"a\" + \"a\" + \"a\").equals(\"aaa\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"aaa\".equals(\"a\" + \"a\" + \"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals22() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(true ? \"a\" : \"b\");\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" (true ? \"a\" : \"b\").equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(true ? \"a\" : \"b\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
public void testInvertEquals23() throws Exception {
IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals((\"a\"));\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null);
String str= "equals";
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
List proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0);
String preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" (\"a\").equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null);
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0);
proposals= collectAssists(context, FILTER_EQ);
assertNumberOfProposals(proposals, 1);
assertCorrectLabels(proposals);
proposal= (CUCorrectionProposal) proposals.get(0);
preview= getPreviewContent(proposal);
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public void foo() {\n");
buf.append(" \"a\".equals(\"a\");\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
}
|
42,328
|
Bug 42328 assign parameter to new field should declare field final [quick assist]
|
When using the quick assist to assign to a new field from a constructor parameter it would be nice if the field created was final. The fields can be safely declared final around 99% of the time.
|
resolved fixed
|
8c5649a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-29T15:09:56Z
| 2003-09-01T12:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AssignToVariableAssistProposal.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.util.HashSet;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.NamingConventions;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTRewrite;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
/**
* Proposals for 'Assign to variable' quick assist
* - Assign an expression from an ExpressionStatement to a local or field
* - Assign a parameter to a field
* */
public class AssignToVariableAssistProposal extends LinkedCorrectionProposal {
public static final int LOCAL= 1;
public static final int FIELD= 2;
private final String KEY_NAME= "name"; //$NON-NLS-1$
private final String KEY_TYPE= "type"; //$NON-NLS-1$
private final int fVariableKind;
private final ASTNode fNodeToAssign; // ExpressionStatement or SingleVariableDeclaration
private final ITypeBinding fTypeBinding;
public AssignToVariableAssistProposal(ICompilationUnit cu, int variableKind, ExpressionStatement node, ITypeBinding typeBinding, int relevance) {
super("", cu, null, relevance, null); //$NON-NLS-1$
fVariableKind= variableKind;
fNodeToAssign= node;
fTypeBinding= typeBinding;
if (variableKind == LOCAL) {
setDisplayName(CorrectionMessages.getString("AssignToVariableAssistProposal.assigntolocal.description")); //$NON-NLS-1$
setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL));
} else {
setDisplayName(CorrectionMessages.getString("AssignToVariableAssistProposal.assigntofield.description")); //$NON-NLS-1$
setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
}
}
public AssignToVariableAssistProposal(ICompilationUnit cu, SingleVariableDeclaration parameter, ITypeBinding typeBinding, int relevance) {
super("", cu, null, relevance, null); //$NON-NLS-1$
fVariableKind= FIELD;
fNodeToAssign= parameter;
fTypeBinding= typeBinding;
setDisplayName(CorrectionMessages.getString("AssignToVariableAssistProposal.assignparamtofield.description")); //$NON-NLS-1$
setImage(JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE));
}
protected ASTRewrite getRewrite() throws CoreException {
if (fVariableKind == FIELD) {
return doAddField();
} else { // LOCAL
return doAddLocal();
}
}
private ASTRewrite doAddLocal() throws CoreException {
Expression expression= ((ExpressionStatement) fNodeToAssign).getExpression();
AST ast= fNodeToAssign.getAST();
ASTRewrite rewrite= new ASTRewrite(ast);
String varName= suggestLocalVariableNames(fTypeBinding);
VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment();
newDeclFrag.setName(ast.newSimpleName(varName));
newDeclFrag.setInitializer((Expression) rewrite.createCopyTarget(expression));
// trick for bug 43248: use an VariableDeclarationExpression and keep the ExpressionStatement
VariableDeclarationExpression newDecl= ast.newVariableDeclarationExpression(newDeclFrag);
Type type= evaluateType(ast);
newDecl.setType(type);
rewrite.replace(expression, newDecl, null);
addLinkedPosition(rewrite.track(newDeclFrag.getName()), true, KEY_NAME);
addLinkedPosition(rewrite.track(newDecl.getType()), false, KEY_TYPE);
setEndPosition(rewrite.track(newDecl));
return rewrite;
}
private ASTRewrite doAddField() throws CoreException {
boolean isParamToField= fNodeToAssign.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION;
ASTNode newTypeDecl= ASTResolving.findParentType(fNodeToAssign);
if (newTypeDecl == null) {
return null;
}
Expression expression= isParamToField ? ((SingleVariableDeclaration) fNodeToAssign).getName() : ((ExpressionStatement) fNodeToAssign).getExpression();
boolean isAnonymous= newTypeDecl.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION;
ChildListPropertyDescriptor property= isAnonymous ? AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY : TypeDeclaration.BODY_DECLARATIONS_PROPERTY;
List decls= (List) newTypeDecl.getStructuralProperty(property);
AST ast= newTypeDecl.getAST();
ASTRewrite rewrite= new ASTRewrite(ast);
BodyDeclaration bodyDecl= ASTResolving.findParentBodyDeclaration(fNodeToAssign);
Block body;
if (bodyDecl instanceof MethodDeclaration) {
body= ((MethodDeclaration) bodyDecl).getBody();
} else if (bodyDecl instanceof Initializer) {
body= ((Initializer) bodyDecl).getBody();
} else {
return null;
}
boolean isStatic= Modifier.isStatic(bodyDecl.getModifiers()) && !isAnonymous;
int modifiers= Modifier.PRIVATE;
if (isStatic) {
modifiers |= Modifier.STATIC;
}
String varName= suggestFieldNames(fTypeBinding, expression, modifiers);
VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment();
newDeclFrag.setName(ast.newSimpleName(varName));
FieldDeclaration newDecl= ast.newFieldDeclaration(newDeclFrag);
Type type= evaluateType(ast);
newDecl.setType(type);
newDecl.setModifiers(modifiers);
Assignment assignment= ast.newAssignment();
assignment.setRightHandSide((Expression) rewrite.createCopyTarget(expression));
boolean needsThis= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_KEYWORD_THIS);
if (isParamToField) {
needsThis |= varName.equals(((SimpleName) expression).getIdentifier());
}
SimpleName accessName= ast.newSimpleName(varName);
if (needsThis) {
FieldAccess fieldAccess= ast.newFieldAccess();
fieldAccess.setName(accessName);
if (isStatic) {
String typeName= ((TypeDeclaration) newTypeDecl).getName().getIdentifier();
fieldAccess.setExpression(ast.newSimpleName(typeName));
} else {
fieldAccess.setExpression(ast.newThisExpression());
}
assignment.setLeftHandSide(fieldAccess);
} else {
assignment.setLeftHandSide(accessName);
}
int insertIndex= findFieldInsertIndex(decls, fNodeToAssign.getStartPosition());
rewrite.getListRewrite(newTypeDecl, property).insertAt(newDecl, insertIndex, null);
ASTNode selectionNode;
if (isParamToField) {
// assign parameter to field
ExpressionStatement statement= ast.newExpressionStatement(assignment);
int insertIdx= findAssignmentInsertIndex(body.statements());
rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY).insertAt(statement, insertIdx, null);
selectionNode= statement;
} else {
rewrite.replace(expression, assignment, null);
selectionNode= fNodeToAssign;
}
addLinkedPosition(rewrite.track(newDeclFrag.getName()), false, KEY_NAME);
addLinkedPosition(rewrite.track(newDecl.getType()), false, KEY_TYPE);
addLinkedPosition(rewrite.track(accessName), true, KEY_NAME);
setEndPosition(rewrite.track(selectionNode));
return rewrite;
}
private Type evaluateType(AST ast) throws CoreException {
ITypeBinding[] proposals= ASTResolving.getRelaxingTypes(ast, fTypeBinding);
for (int i= 0; i < proposals.length; i++) {
addLinkedPositionProposal(KEY_TYPE, proposals[i]);
}
String typeName= getImportRewrite().addImport(fTypeBinding);
return ASTNodeFactory.newType(ast, typeName);
}
private String suggestLocalVariableNames(ITypeBinding binding) {
IJavaProject project= getCompilationUnit().getJavaProject();
ITypeBinding base= binding.isArray() ? binding.getElementType() : binding;
IPackageBinding packBinding= base.getPackage();
String packName= packBinding != null ? packBinding.getName() : ""; //$NON-NLS-1$
String[] excludedNames= getUsedVariableNames();
String typeName= base.getName();
String[] names= NamingConventions.suggestLocalVariableNames(project, packName, typeName, binding.getDimensions(), excludedNames);
if (names.length == 0) {
return "class1"; // fix for pr, remoev after 20030127 //$NON-NLS-1$
}
for (int i= 0; i < names.length; i++) {
addLinkedPositionProposal(KEY_NAME, names[i], null);
}
return names[0];
}
private String suggestFieldNames(ITypeBinding binding, Expression expression, int modifiers) {
IJavaProject project= getCompilationUnit().getJavaProject();
ITypeBinding base= binding.isArray() ? binding.getElementType() : binding;
IPackageBinding packBinding= base.getPackage();
String packName= packBinding != null ? packBinding.getName() : ""; //$NON-NLS-1$
String[] excludedNames= getUsedVariableNames();
String result= null;
HashSet taken= new HashSet();
if (expression instanceof SimpleName) {
String name= ((SimpleName) expression).getIdentifier();
// bug 38111
String[] argname= StubUtility.getFieldNameSuggestions(project, name, modifiers, excludedNames);
for (int i= 0; i < argname.length; i++) {
String curr= argname[i];
if (result == null || curr.length() > result.length()) {
result= curr;
}
if (taken.add(curr)) {
addLinkedPositionProposal(KEY_NAME, curr, null);
}
}
}
String typeName= base.getName();
String[] names= NamingConventions.suggestFieldNames(project, packName, typeName, binding.getDimensions(), modifiers, excludedNames);
if (names.length == 0) {
return "class1"; // fix for pr, remoev after 20030127 //$NON-NLS-1$
}
for (int i= 0; i < names.length; i++) {
String curr= names[i];
if (taken.add(curr)) {
addLinkedPositionProposal(KEY_NAME, curr, null);
}
}
if (result == null) {
result= names[0];
}
return result;
}
private String[] getUsedVariableNames() {
CompilationUnit root= (CompilationUnit) fNodeToAssign.getRoot();
IBinding[] bindings= (new ScopeAnalyzer(root)).getDeclarationsInScope(fNodeToAssign.getStartPosition(), ScopeAnalyzer.VARIABLES);
String[] names= new String[bindings.length];
for (int i= 0; i < names.length; i++) {
names[i]= bindings[i].getName();
}
return names;
}
private int findAssignmentInsertIndex(List statements) {
HashSet paramsBefore= new HashSet();
List params = ((MethodDeclaration) fNodeToAssign.getParent()).parameters();
for (int i = 0; i < params.size() && (params.get(i) != fNodeToAssign); i++) {
SingleVariableDeclaration decl= (SingleVariableDeclaration) params.get(i);
paramsBefore.add(decl.getName().getIdentifier());
}
int i= 0;
for (i = 0; i < statements.size(); i++) {
Statement curr= (Statement) statements.get(i);
switch (curr.getNodeType()) {
case ASTNode.CONSTRUCTOR_INVOCATION:
case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
break;
case ASTNode.EXPRESSION_STATEMENT:
Expression expr= ((ExpressionStatement) curr).getExpression();
if (expr instanceof Assignment) {
Assignment assignment= (Assignment) expr;
Expression rightHand = assignment.getRightHandSide();
if (rightHand instanceof SimpleName && paramsBefore.contains(((SimpleName) rightHand).getIdentifier())) {
IVariableBinding binding = Bindings.getAssignedVariable(assignment);
if (binding == null || binding.isField()) {
break;
}
}
}
return i;
default:
return i;
}
}
return i;
}
private int findFieldInsertIndex(List decls, int currPos) {
for (int i= decls.size() - 1; i >= 0; i--) {
ASTNode curr= (ASTNode) decls.get(i);
if (curr instanceof FieldDeclaration && currPos > curr.getStartPosition() + curr.getLength()) {
return i + 1;
}
}
return 0;
}
/**
* Returns the variable kind.
* @return int
*/
public int getVariableKind() {
return fVariableKind;
}
}
|
60,466
|
Bug 60466 ISE in Externalize Strings Wizard when editing key of ignored string [nls] [refactoring]
|
I200404281424.from20040429_1712 - Externalize Strings - Select a new string, press Ignore - click in "Key" field of ignored string, click somewhere else -> Error Dialog & Log: !ENTRY org.eclipse.core.runtime 4 2 Apr 29, 2004 19:01:00.765 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalStateException: Must be in Externalized State ! at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.jdt.internal.corext.refactoring.nls.NLSSubstitution.setKey(NLSSubstitution.java:97) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$CellModifier.modify(ExternalizeWizardPage.java:159) at org.eclipse.jface.viewers.TableViewerImpl.saveEditorValue(TableViewerImpl.java:270) at org.eclipse.jface.viewers.TableViewerImpl.applyEditorValue(TableViewerImpl.java:149) at org.eclipse.jface.viewers.TableViewerImpl$3.applyEditorValue(TableViewerImpl.java:247) at org.eclipse.jface.viewers.CellEditor$1.run(CellEditor.java:290) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.CellEditor.fireApplyEditorValue(CellEditor.java:288) at org.eclipse.jface.viewers.CellEditor.focusLost(CellEditor.java:659) at org.eclipse.jface.viewers.TextCellEditor$5.focusLost(TextCellEditor.java:176) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java) at org.eclipse.swt.widgets.Control.WM_KILLFOCUS(Control.java:3597) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) at org.eclipse.swt.widgets.Table.sendMouseDownEvent(Table.java:1950) at org.eclipse.swt.widgets.Table.WM_LBUTTONDOWN(Table.java:2916) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizard(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.openWizard(FindStringsToExternalizeAction.java:406) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.access$1(FindStringsToExternalizeAction.java:404) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$2.widgetDefaultSelected(FindStringsToExternalizeAction.java:375) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.showResults(FindStringsToExternalizeAction.java:196) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.run(FindStringsToExternalizeAction.java:150) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
|
resolved fixed
|
fdd877a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T13:30:30Z
| 2004-04-29T17:33:20Z
|
org.eclipse.jdt.ui/ui
| |
60,466
|
Bug 60466 ISE in Externalize Strings Wizard when editing key of ignored string [nls] [refactoring]
|
I200404281424.from20040429_1712 - Externalize Strings - Select a new string, press Ignore - click in "Key" field of ignored string, click somewhere else -> Error Dialog & Log: !ENTRY org.eclipse.core.runtime 4 2 Apr 29, 2004 19:01:00.765 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalStateException: Must be in Externalized State ! at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.jdt.internal.corext.refactoring.nls.NLSSubstitution.setKey(NLSSubstitution.java:97) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$CellModifier.modify(ExternalizeWizardPage.java:159) at org.eclipse.jface.viewers.TableViewerImpl.saveEditorValue(TableViewerImpl.java:270) at org.eclipse.jface.viewers.TableViewerImpl.applyEditorValue(TableViewerImpl.java:149) at org.eclipse.jface.viewers.TableViewerImpl$3.applyEditorValue(TableViewerImpl.java:247) at org.eclipse.jface.viewers.CellEditor$1.run(CellEditor.java:290) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.CellEditor.fireApplyEditorValue(CellEditor.java:288) at org.eclipse.jface.viewers.CellEditor.focusLost(CellEditor.java:659) at org.eclipse.jface.viewers.TextCellEditor$5.focusLost(TextCellEditor.java:176) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java) at org.eclipse.swt.widgets.Control.WM_KILLFOCUS(Control.java:3597) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) at org.eclipse.swt.widgets.Table.sendMouseDownEvent(Table.java:1950) at org.eclipse.swt.widgets.Table.WM_LBUTTONDOWN(Table.java:2916) at org.eclipse.swt.widgets.Control.windowProc(Control.java) at org.eclipse.swt.widgets.Display.windowProc(Display.java) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizard(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.openWizard(FindStringsToExternalizeAction.java:406) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.access$1(FindStringsToExternalizeAction.java:404) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$2.widgetDefaultSelected(FindStringsToExternalizeAction.java:375) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.showResults(FindStringsToExternalizeAction.java:196) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.run(FindStringsToExternalizeAction.java:150) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
|
resolved fixed
|
fdd877a
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T13:30:30Z
| 2004-04-29T17:33:20Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
| |
60,465
|
Bug 60465 NPE in Externalize Strings Wizard when enabling "Filer all existing ..." [nls] [refactoring]
|
java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:60) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateSourceView(ExternalizeWizardPage.java:969) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.selectionChanged(ExternalizeWizardPage.java:964) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.access$8(ExternalizeWizardPage.java:961) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$7.selectionChanged(ExternalizeWizardPage.java:624) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleInvalidSelection(StructuredViewer.java:634) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:868) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:830) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.doFilterCheckBoxPressed(ExternalizeWizardPage.java:796) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$9.widgetSelected(ExternalizeWizardPage.java:770) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizard(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.openWizard(FindStringsToExternalizeAction.java:406) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.access$1(FindStringsToExternalizeAction.java:404) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$2.widgetDefaultSelected(FindStringsToExternalizeAction.java:375) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.showResults(FindStringsToExternalizeAction.java:196) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.run(FindStringsToExternalizeAction.java:150) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
|
resolved fixed
|
678d2c3
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T13:32:56Z
| 2004-04-29T17:33:20Z
|
org.eclipse.jdt.ui/ui
| |
60,465
|
Bug 60465 NPE in Externalize Strings Wizard when enabling "Filer all existing ..." [nls] [refactoring]
|
java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:60) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateSourceView(ExternalizeWizardPage.java:969) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.selectionChanged(ExternalizeWizardPage.java:964) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.access$8(ExternalizeWizardPage.java:961) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$7.selectionChanged(ExternalizeWizardPage.java:624) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleInvalidSelection(StructuredViewer.java:634) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:868) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:830) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.doFilterCheckBoxPressed(ExternalizeWizardPage.java:796) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage$9.widgetSelected(ExternalizeWizardPage.java:770) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizard(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.openWizard(FindStringsToExternalizeAction.java:406) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$NonNLSListDialog.access$1(FindStringsToExternalizeAction.java:404) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction$2.widgetDefaultSelected(FindStringsToExternalizeAction.java:375) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.showResults(FindStringsToExternalizeAction.java:196) at org.eclipse.jdt.ui.actions.FindStringsToExternalizeAction.run(FindStringsToExternalizeAction.java:150) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
|
resolved fixed
|
678d2c3
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T13:32:56Z
| 2004-04-29T17:33:20Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
| |
60,116
|
Bug 60116 [Search] Hierarchical Layout ignores package name compression
|
eclipse-SDK-I20040427-win32.zip 1. Set the preference to compress package names to '3.' 2. Perform a search & select the hierarchical layout... notice the package names are not compressed 3. Switch to the flat layout & the package names are compressed
|
resolved fixed
|
66f25f2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T13:44:42Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PostfixLabelProvider.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.text.MessageFormat;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.graphics.Image;
public class PostfixLabelProvider extends SearchLabelProvider {
private ITreeContentProvider fContentProvider;
public PostfixLabelProvider(JavaSearchResultPage page) {
super(page, new AppearanceAwareLabelProvider());
fContentProvider= new LevelTreeContentProvider.FastJavaElementProvider();
}
public Image getImage(Object element) {
Image image= getLabelProvider().getImage(element);
if (image != null)
return image;
return getParticipantImage(element);
}
public String getText(Object element) {
ITreeContentProvider provider= (ITreeContentProvider) fPage.getViewer().getContentProvider();
Object visibleParent= provider.getParent(element);
Object realParent= fContentProvider.getParent(element);
Object lastElement= element;
StringBuffer postfix= new StringBuffer();
while (realParent != null && !(realParent instanceof IJavaModel) && !realParent.equals(visibleParent)) {
if (!isSameInformation(realParent, lastElement)) {
postfix.append(" - "); //$NON-NLS-1$
postfix.append(internalGetText(realParent));
}
lastElement= realParent;
realParent= fContentProvider.getParent(realParent);
}
int matchCount= fPage.getDisplayedMatchCount(element);
String text=internalGetText(element);
if (matchCount < 2) {
String label= getSingularLabel(element);
return MessageFormat.format(label, new String[] { text, postfix.toString() });
}
String label= getPluralLabel(element);
return MessageFormat.format(label, new Object[] { text, new Integer(matchCount), postfix.toString() });
}
private String getSingularLabel(Object element) {
if (hasPotentialMatches(element))
return SearchMessages.getString("PostfixLabelProvider.potential_singluar"); //$NON-NLS-1$
return SearchMessages.getString("PostfixLabelProvider.exact_singular"); //$NON-NLS-1$
}
private String getPluralLabel(Object element) {
if (hasPotentialMatches(element))
return SearchMessages.getString("PostfixLabelProvider.potential_plural"); //$NON-NLS-1$
return SearchMessages.getString("PostfixLabelProvider.exact_plural"); //$NON-NLS-1$
}
private String internalGetText(Object element) {
String text= getLabelProvider().getText(element);
if (text != null && !"".equals(text)) //$NON-NLS-1$
return text;
return getParticipantText(element); }
private boolean isSameInformation(Object realParent, Object lastElement) {
if (lastElement instanceof IType) {
IType type= (IType)lastElement;
if (realParent instanceof IClassFile) {
if (type.getClassFile().equals(realParent))
return true;
} else if (realParent instanceof ICompilationUnit) {
if (type.getCompilationUnit().equals(realParent))
return true;
}
}
return false;
}
}
|
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/refactoring/JUnitRenameParticipant.java
|
/*******************************************************************************
* Copyright (c) 2004 International Business Machines Corp. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.jdt.internal.junit.refactoring;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.internal.junit.ui.JUnitMessages;
import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
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;
public abstract class JUnitRenameParticipant extends RenameParticipant {
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) {
return new RefactoringStatus();
}
public Change createChange(IProgressMonitor pm) throws CoreException {
if (!getArguments().getUpdateReferences())
return null;
ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
List launchConfigTypes= JUnitPlugin.getDefault().getJUnitLaunchConfigTypeIDs();
List changes= new ArrayList();
for (Iterator types= launchConfigTypes.iterator(); types.hasNext();) {
String typeId= (String) types.next();
ILaunchConfigurationType type= manager.getLaunchConfigurationType(typeId);
ILaunchConfiguration configs[]= manager.getLaunchConfigurations(type);
createChangeForConfigs(changes, configs);
}
if (changes.size() > 0)
return new CompositeChange(getChangeName(), (Change[]) changes.toArray(new Change[changes.size()])); //$NON-NLS-1$
return null;
}
protected String getChangeName() {
return JUnitMessages.getString("TypeRenameParticipant.change.name");
}
protected abstract void createChangeForConfigs(List changes, ILaunchConfiguration[] configs) throws CoreException;
}
|
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringSearchEngine.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ConvertAnonymousToNestedRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractConstantRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractTempRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceParameterRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/PromoteTempToFieldRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeTypeRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceUtil.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PullUpRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/PushDownRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/SurroundWithTryCatchRefactoring.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/core
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/util/RefactoringASTParser.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.jdt.ui/ui
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java
| |
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/Refactoring.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ltk.core.refactoring;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.SubProgressMonitor;
/**
* Abstract super class for all refactorings. Refactorings are used to perform
* behaviour preserving work space transformations. A refactoring offers two
* different kind of methods:
* <ol>
* <li>methods to check conditions to determine if the refactoring can be carried out
* in general and if transformation will be behavioural persevering.
* </li>
* <li>a method to create a {@link org.eclipse.ltk.core.refactoring.Change} object
* that represents the actual work space modifications.
* </li>
* <p>
* The life cycle of a refactoring is as follows:
* <ul>
* <li>the refactoring gets created</li>
* <li>the refactoring is initialized with the elements to be refactored. It is
* up to a concrete refactoring implementation to provide corresponding API.
* <li>{@link #checkInitialConditions(IProgressMonitor)} is called. The method
* can be called more than once.</li>
* <li>additional arguments are provided to perform the refactoring (for example
* the new name of a element in the case of a rename refactoring). It is up
* to a concrete implementation to provide corresponding API.
* <li>{@link #checkFinalConditions(IProgressMonitor)} is called. The method
* can be called more than once. The method is not called if
* {@link #checkInitialConditions(IProgressMonitor)} returns a refactoring
* status of severity {@link RefactoringStatus#FATAL}.</li>
* <li>{@link #createChange(IProgressMonitor)} is called. The method is only
* called once and is not called if one of the condition checking methods
* return a refactoring status of severity {@link RefactoringStatus#FATAL}.
* </li>
* </ul>
*
* <p>
* A refactoring can not assume that all resources are saved before any methods
* are called on it. Therefore a refactoring must be able to deal with unsaved
* resources.
* </p>
* <p>
* The class should be subclassed by clients wishing to implement new refactorings.
* </p>
*
* @since 3.0
*/
public abstract class Refactoring extends PlatformObject {
/**
* Returns the refactoring's name.
*
* @return the refactoring's human readable name. Must not be
* <code>null</code>
*/
public abstract String getName();
//---- Conditions ------------------------------------------------------------
/**
* Checks all conditions. This implementation calls <code>checkInitialConditions</code>
* and <code>checkFinalConditions</code>.
* <p>
* Subclasses may extend this method to provide additional condition checks.
* </p>
*
* @param pm a progress monitor to report progress
*
* @return a refactoring status. If the status is <code>RefactoringStatus#FATAL</code>
* the refactoring is considered as not being executable.
*
* @throws CoreException if an exception occurred during condition checking.
* If this happens then the condition checking is interpreted as failed
*
* @throws OperationCanceledException if the condition checking got cancelled
*
* @see #checkInitialConditions(IProgressMonitor)
* @see #checkFinalConditions(IProgressMonitor)
*/
public RefactoringStatus checkAllConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
pm.beginTask("", 11); //$NON-NLS-1$
RefactoringStatus result= new RefactoringStatus();
result.merge(checkInitialConditions(new SubProgressMonitor(pm, 1)));
if (!result.hasFatalError())
result.merge(checkFinalConditions(new SubProgressMonitor(pm, 10)));
pm.done();
return result;
}
/**
* Checks some initial conditions based on the element to be refactored. The
* method is typically called by the UI to perform an initial checks after an
* action has been executed.
* <p>
* The refactoring is considered as not being executable if the returned status
* has the severity of <code>RefactoringStatus#FATAL</code>.
* </p>
* <p>
* This method can be called more than once.
* </p>
*
* @param pm a progress monitor to report progress. Although initial checks
* are supposed to execute fast, there can be certain situations where progress
* reporting is necessary. For example rebuilding a corrupted index may report
* progress.
*
* @return a refactoring status. If the status is <code>RefactoringStatus#FATAL</code>
* the refactoring is considered as not being executable.
*
* @throws CoreException if an exception occurred during initial condition checking.
* If this happens then the initial condition checking is interpreted as failed
*
* @throws OperationCanceledException if the condition checking got cancelled
*
* @see #checkFinalConditions(IProgressMonitor)
* @see RefactoringStatus#FATAL
*/
public abstract RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException;
/**
* After <code>checkInitialConditions</code> has been performed and the user has
* provided all input necessary to perform the refactoring this method is called
* to check the remaining preconditions.
* <p>
* The refactoring is considered as not being executable if the returned status
* has the severity of <code>RefactoringStatus#FATAL</code>.
* </p>
* <p>
* This method can be called more than once.
* </p>
*
* @param pm a progress monitor to report progress
*
* @return a refactoring status. If the status is <code>RefactoringStatus#FATAL</code>
* the refactoring is considered as not being executable.
*
* @throws CoreException if an exception occurred during final condition checking
* If this happens then the final condition checking is interpreted as failed
*
* @throws OperationCanceledException if the condition checking got cancelled
*
* @see #checkInitialConditions(IProgressMonitor)
* @see RefactoringStatus#FATAL
*/
public abstract RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException;
//---- change creation ------------------------------------------------------
/**
* Creates a {@link Change} object that performs the actual refactoring.
*
* @param pm a progress monitor to report progress
*
* @return the change representing the workspace modifications of the
* refactoring
*
* @throws CoreException if an error occurred while creating the change
*
* @throws OperationCanceledException if the condition checking got cancelled
*/
public abstract Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException;
/**
* Returns the scheduling rule associated with this refactoring element.
* This scheduling rule should be used whenever one of the refactoring's
* method is executed inside a {@linkplain org.eclipse.core.resources.IWorkspaceRunnable
* work space runnable} or when the change created by this refactoring is
* performed.
*
* @return the scheduling rule associated with this refactoring
*/
/* public abstract ISchedulingRule getSchedulingRule(); */
/**
* {@inheritDoc}
*/
public Object getAdapter(Class adapter) {
if (adapter.isInstance(this))
return this;
return super.getAdapter(adapter);
}
/* (non-Javadoc)
* for debugging only
*/
public String toString() {
return getName();
}
}
|
47,010
|
Bug 47010 Make refactorings more responsive to cancel [refactoring]
|
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
|
resolved fixed
|
b9f4fb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:11:37Z
| 2003-11-19T16:40:00Z
|
org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/ProcessorBasedRefactoring.java
|
/*******************************************************************************
* Copyright (c) 2003 International Business Machines Corp. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.ltk.core.refactoring.participants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.internal.core.refactoring.ParticipantDescriptor;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
/**
* An abstract base implementation for refactorings that are split into
* one refactoring processor and 0..n participants.
* <p>
* This class should be subclassed by clients wishing to provide a special
* refactoring which uses a processor/participant architecture.
* </p>
* @since 3.0
*/
public abstract class ProcessorBasedRefactoring extends Refactoring {
private RefactoringParticipant[] fParticipants;
private SharableParticipants fSharedParticipants= new SharableParticipants();
private static final RefactoringParticipant[] EMPTY_PARTICIPANTS= new RefactoringParticipant[0];
private static class ProcessorChange extends CompositeChange {
private Map fParticipantMap;
public ProcessorChange(String name) {
super(name);
}
public void setParticipantMap(Map map) {
fParticipantMap= map;
}
protected void internalHandleException(Change change, Throwable e) {
RefactoringParticipant participant= (RefactoringParticipant)fParticipantMap.get(change);
if (participant != null) {
ParticipantDescriptor descriptor= participant.getDescriptor();
descriptor.disable();
RefactoringCorePlugin.logRemovedParticipant(descriptor, e);
}
}
}
/**
* Creates a new processor based refactoring.
*/
protected ProcessorBasedRefactoring() {
}
/**
* Return the processor associated with this refactoring. The
* method must not return <code>null</code>.
*
* @return the processor associated with this refactoring
*/
public abstract RefactoringProcessor getProcessor();
/**
* Checks whether the refactoring is applicable to the elements to be
* refactored or not.
* <p>
* This default implementation forwards the call to the refactoring
* processor.
* </p>
* @return <code>true</code> if the refactoring is applicable to the
* elements; otherwise <code>false</code> is returned.
* @throws CoreException if the test fails
*/
public final boolean isApplicable() throws CoreException {
return getProcessor().isApplicable();
}
/**
* {@inheritDoc}
*/
public String getName() {
return getProcessor().getProcessorName();
}
/**
* {@inheritDoc}
*/
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
pm.beginTask("", 10); //$NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.getString("ProcessorBasedRefactoring.initial_conditions")); //$NON-NLS-1$
result.merge(getProcessor().checkInitialConditions(new SubProgressMonitor(pm, 8)));
if (result.hasFatalError()) {
pm.done();
return result;
}
pm.done();
return result;
}
/**
* {@inheritDoc}
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
RefactoringStatus result= new RefactoringStatus();
CheckConditionsContext context= createCheckConditionsContext();
pm.beginTask("", 9); //$NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.getString("ProcessorBasedRefactoring.final_conditions")); //$NON-NLS-1$
result.merge(getProcessor().checkFinalConditions(new SubProgressMonitor(pm, 5), context));
if (result.hasFatalError()) {
pm.done();
return result;
}
fParticipants= getProcessor().loadParticipants(result, fSharedParticipants);
if (fParticipants == null)
fParticipants= EMPTY_PARTICIPANTS;
if (result.hasFatalError()) {
pm.done();
return result;
}
IProgressMonitor sm= new SubProgressMonitor(pm, 2);
sm.beginTask("", fParticipants.length); //$NON-NLS-1$
for (int i= 0; i < fParticipants.length && !result.hasFatalError(); i++) {
result.merge(fParticipants[i].checkConditions(new SubProgressMonitor(sm, 1), context));
if (sm.isCanceled())
throw new OperationCanceledException();
}
sm.done();
if (result.hasFatalError()) {
pm.done();
return result;
}
result.merge(context.check(new SubProgressMonitor(pm, 1)));
pm.done();
return result;
}
/**
* {@inheritDoc}
*/
public Change createChange(IProgressMonitor pm) throws CoreException {
pm.beginTask("", fParticipants.length + 2); //$NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.getString("ProcessorBasedRefactoring.create_change")); //$NON-NLS-1$
Change processorChange= getProcessor().createChange(new SubProgressMonitor(pm, 1));
List changes= new ArrayList();
Map participantMap= new HashMap();
for (int i= 0; i < fParticipants.length; i++) {
RefactoringParticipant participant= fParticipants[i];
try {
Change change= participant.createChange(new SubProgressMonitor(pm, 1));
if (change != null) {
changes.add(change);
participantMap.put(change, participant);
}
} catch (CoreException e) {
ParticipantDescriptor descriptor= participant.getDescriptor();
descriptor.disable();
RefactoringCorePlugin.logRemovedParticipant(descriptor, e);
}
if (pm.isCanceled())
throw new OperationCanceledException();
}
Change postChange= getProcessor().postCreateChange(
(Change[])changes.toArray(new Change[changes.size()]),
new SubProgressMonitor(pm, 1));
ProcessorChange result= new ProcessorChange(getName());
result.add(processorChange);
result.addAll((Change[]) changes.toArray(new Change[changes.size()]));
result.setParticipantMap(participantMap);
if (postChange != null)
result.add(postChange);
return result;
}
/**
* Adapts the refactoring to the given type. The adapter is resolved
* as follows:
* <ol>
* <li>the refactoring itself is checked whether it is an instance
* of the requested type.</li>
* <li>its processor is checked whether it is an instance of the
* requested type.</li>
* <li>the request is delegated to the super class.</li>
* </ol>
*
* @param clazz the adapter class to look up
*
* @return the requested adapter or <code>null</code>if no adapter
* exists.
*/
public Object getAdapter(Class clazz) {
if (clazz.isInstance(this))
return this;
if (clazz.isInstance(getProcessor()))
return getProcessor();
return super.getAdapter(clazz);
}
/* non java-doc
* for debugging only
*/
public String toString() {
return getName();
}
//---- Helper methods ---------------------------------------------------------------------
private CheckConditionsContext createCheckConditionsContext() throws CoreException {
CheckConditionsContext result= new CheckConditionsContext();
IConditionChecker checker= new ValidateEditChecker(null);
result.add(checker);
return result;
}
}
|
60,542
|
Bug 60542 Externalize Strings Wizard: proposes lowercase messages.properties [nls] [refactoring]
|
I20040428 Externalize Strings Wizard proposes TitleCase class "Messages" and lowercase properties file "messages.properties". This is bad, since the NLS Search page tries to determine the .properties file from the CU name. It fails if the default names are used. The defaults should be "Messages.java" and "Messages.properties".
|
resolved fixed
|
610ed5d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:38:15Z
| 2004-04-30T10:13:20Z
|
org.eclipse.jdt.ui/ui
| |
60,542
|
Bug 60542 Externalize Strings Wizard: proposes lowercase messages.properties [nls] [refactoring]
|
I20040428 Externalize Strings Wizard proposes TitleCase class "Messages" and lowercase properties file "messages.properties". This is bad, since the NLS Search page tries to determine the .properties file from the CU name. It fails if the default names are used. The defaults should be "Messages.java" and "Messages.properties".
|
resolved fixed
|
610ed5d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T14:38:15Z
| 2004-04-30T10:13:20Z
|
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/NLSSearchPage.java
| |
24,046
|
Bug 24046 Override icon hides synchronize icon [icons]
|
Build 20020920 If you have the following cu: public class X { synchronized boolean equals(Object o) { } } The Outline for X.equals(Object) shows the override icon (green triangle) but it doesn't show the synhronize icon (watch).
|
resolved fixed
|
3dc3e69
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T15:17:20Z
| 2002-09-24T17:53:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPluginImages.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
/**
* Bundle of most images used by the Java plug-in.
*/
public class JavaPluginImages {
private static final String NAME_PREFIX= "org.eclipse.jdt.ui."; //$NON-NLS-1$
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
private static URL fgIconBaseURL= null;
// Determine display depth. If depth > 4 then we use high color images. Otherwise low color
// images are used
static {
fgIconBaseURL= JavaPlugin.getDefault().getBundle().getEntry("/icons/full/"); //$NON-NLS-1$
}
// The plug-in registry
private static ImageRegistry fgImageRegistry= null;
private static HashMap fgAvoidSWTErrorMap= null;
private static final String T_OBJ= "obj16"; //$NON-NLS-1$
private static final String T_OVR= "ovr16"; //$NON-NLS-1$
private static final String T_WIZBAN= "wizban"; //$NON-NLS-1$
private static final String T_ELCL= "elcl16"; //$NON-NLS-1$
private static final String T_DLCL= "dlcl16"; //$NON-NLS-1$
private static final String T_ETOOL= "etool16"; //$NON-NLS-1$
private static final String T_EVIEW= "eview16"; //$NON-NLS-1$
/*
* Available cached Images in the Java plug-in image registry.
*/
public static final String IMG_MISC_PUBLIC= NAME_PREFIX + "methpub_obj.gif"; //$NON-NLS-1$
public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif"; //$NON-NLS-1$
public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif"; //$NON-NLS-1$
public static final String IMG_MISC_DEFAULT= NAME_PREFIX + "methdef_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_PUBLIC= NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_PROTECTED= NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_PRIVATE= NAME_PREFIX + "field_private_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_DEFAULT= NAME_PREFIX + "field_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_ELCL_VIEW_MENU= NAME_PREFIX + T_ELCL + "view_menu.gif"; //$NON-NLS-1$
public static final String IMG_DLCL_VIEW_MENU= NAME_PREFIX + T_DLCL + "view_menu.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_GHOST= NAME_PREFIX + "ghost.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_TSK= NAME_PREFIX + "search_tsk.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_PACKDECL= NAME_PREFIX + "packd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_IMPDECL= NAME_PREFIX + "imp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_IMPCONT= NAME_PREFIX + "impc_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JSEARCH= NAME_PREFIX + "jsearch_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_DECL= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_REF= NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CLASSALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CLASS_DEFAULT= NAME_PREFIX + "class_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_CLASS_PUBLIC= NAME_PREFIX + "innerclass_public_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_CLASS_DEFAULT= NAME_PREFIX + "innerclass_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_CLASS_PROTECTED= NAME_PREFIX + "innerclass_protected_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_CLASS_PRIVATE= NAME_PREFIX + "innerclass_private_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INTERFACE= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INTERFACEALT= NAME_PREFIX + "intf_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INTERFACE_DEFAULT= NAME_PREFIX + "int_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_INTERFACE_PUBLIC= NAME_PREFIX + "innerinterface_public_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_INTERFACE_DEFAULT= NAME_PREFIX + "innerinterface_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_INTERFACE_PROTECTED= NAME_PREFIX + "innerinterface_protected_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_INNER_INTERFACE_PRIVATE= NAME_PREFIX + "innerinterface_private_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CUNIT= NAME_PREFIX + "jcu_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CUNIT_RESOURCE= NAME_PREFIX + "jcu_resource_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CFILE= NAME_PREFIX + "classf_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CFILECLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_CFILEINT= NAME_PREFIX + "int_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_LOGICAL_PACKAGE= NAME_PREFIX + "logical_package_obj.gif";//$NON-NLS-1$
public static final String IMG_OBJS_EMPTY_LOGICAL_PACKAGE= NAME_PREFIX + "empty_logical_package_obj.gif";//$NON-NLS-1$
public static final String IMG_OBJS_PACKAGE= NAME_PREFIX + "package_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EMPTY_PACK_RESOURCE= NAME_PREFIX + "empty_pack_fldr_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EMPTY_PACKAGE= NAME_PREFIX + "empty_pack_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_MISSING_PACKFRAG_ROOT= NAME_PREFIX + "packagefolder_nonexist_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_MISSING_JAR= NAME_PREFIX + "jar_nonexist_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JAR= NAME_PREFIX + "jar_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EXTJAR= NAME_PREFIX + "jar_l_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JAR_WSRC= NAME_PREFIX + "jar_src_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ENV_VAR= NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_MISSING_ENV_VAR= NAME_PREFIX + "envvar_nonexist_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JAVA_MODEL= NAME_PREFIX + "java_model_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_LOCAL_VARIABLE= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_JAVADOCTAG= NAME_PREFIX + "jdoc_tag_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_HTMLTAG= NAME_PREFIX + "html_tag_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_EXCEPTION= NAME_PREFIX + "jexception_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ERROR= NAME_PREFIX + "jrtexception_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_INSTALLED= NAME_PREFIX + "brkpi_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_QUICK_ASSIST= NAME_PREFIX + "quickassist_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_NLS_TRANSLATE= NAME_PREFIX + "translate.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_NLS_SKIP= NAME_PREFIX + "skip.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_READACCESS= NAME_PREFIX + "occ_read.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_WRITEACCESS= NAME_PREFIX + "occ_write.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_SEARCH_OCCURRENCE= NAME_PREFIX + "occ_match.gif"; //$NON-NLS-1$
/*
* Set of predefined Image Descriptors.
*/
public static final ImageDescriptor DESC_VIEW_ERRORWARNING_TAB= create(T_EVIEW, "errorwarning_tab.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_VIEW_CLASSFILEGENERATION_TAB= create(T_EVIEW, "classfilegeneration_tab.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_VIEW_JDKCOMPLIANCE_TAB= create(T_EVIEW, "jdkcompliance_tab.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_FILTER= create(T_ELCL, "filter_ps.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_FILTER= create(T_DLCL, "filter_ps.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_CODE_ASSIST= create(T_ELCL, "metharg_obj.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_CODE_ASSIST= create(T_DLCL, "metharg_obj.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_ELCL_VIEW_MENU= createManaged(T_ELCL, NAME_PREFIX + "view_menu.gif", IMG_ELCL_VIEW_MENU); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_VIEW_MENU= createManaged(T_DLCL, NAME_PREFIX + "view_menu.gif", IMG_DLCL_VIEW_MENU); //$NON-NLS-1$
public static final ImageDescriptor DESC_MISC_PUBLIC= createManaged(T_OBJ, IMG_MISC_PUBLIC);
public static final ImageDescriptor DESC_MISC_PROTECTED= createManaged(T_OBJ, IMG_MISC_PROTECTED);
public static final ImageDescriptor DESC_MISC_PRIVATE= createManaged(T_OBJ, IMG_MISC_PRIVATE);
public static final ImageDescriptor DESC_MISC_DEFAULT= createManaged(T_OBJ, IMG_MISC_DEFAULT);
public static final ImageDescriptor DESC_FIELD_PUBLIC= createManaged(T_OBJ, IMG_FIELD_PUBLIC); //$NON-NLS-1$
public static final ImageDescriptor DESC_FIELD_PROTECTED= createManaged(T_OBJ, IMG_FIELD_PROTECTED); //$NON-NLS-1$
public static final ImageDescriptor DESC_FIELD_PRIVATE= createManaged(T_OBJ, IMG_FIELD_PRIVATE); //$NON-NLS-1$
public static final ImageDescriptor DESC_FIELD_DEFAULT= createManaged(T_OBJ, IMG_FIELD_DEFAULT); //$NON-NLS-1$
public static final ImageDescriptor DESC_MENU_SHIFT_RIGHT= create(T_ETOOL, "shift_r_edit.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_MENU_SHIFT_LEFT= create(T_ETOOL, "shift_l_edit.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_GHOST= createManaged(T_OBJ, IMG_OBJS_GHOST);
public static final ImageDescriptor DESC_OBJS_PACKDECL= createManaged(T_OBJ, IMG_OBJS_PACKDECL);
public static final ImageDescriptor DESC_OBJS_IMPDECL= createManaged(T_OBJ, IMG_OBJS_IMPDECL);
public static final ImageDescriptor DESC_OBJS_IMPCONT= createManaged(T_OBJ, IMG_OBJS_IMPCONT);
public static final ImageDescriptor DESC_OBJS_JSEARCH= createManaged(T_OBJ, IMG_OBJS_JSEARCH);
public static final ImageDescriptor DESC_OBJS_SEARCH_DECL= createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
public static final ImageDescriptor DESC_OBJS_SEARCH_REF= createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
public static final ImageDescriptor DESC_OBJS_CUNIT= createManaged(T_OBJ, IMG_OBJS_CUNIT);
public static final ImageDescriptor DESC_OBJS_CUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_CUNIT_RESOURCE);
public static final ImageDescriptor DESC_OBJS_CFILE= createManaged(T_OBJ, IMG_OBJS_CFILE);
public static final ImageDescriptor DESC_OBJS_CFILECLASS= createManaged(T_OBJ, IMG_OBJS_CFILECLASS);
public static final ImageDescriptor DESC_OBJS_CFILEINT= createManaged(T_OBJ, IMG_OBJS_CFILEINT);
public static final ImageDescriptor DESC_OBJS_PACKAGE= createManaged(T_OBJ, IMG_OBJS_PACKAGE);
public static final ImageDescriptor DESC_OBJS_EMPTY_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OBJS_EMPTY_LOGICAL_PACKAGE);
public static final ImageDescriptor DESC_OBJS_LOGICAL_PACKAGE= createManaged(T_OBJ, IMG_OBJS_LOGICAL_PACKAGE);
public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE_RESOURCES= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACK_RESOURCE);
public static final ImageDescriptor DESC_OBJS_EMPTY_PACKAGE= createManaged(T_OBJ, IMG_OBJS_EMPTY_PACKAGE);
public static final ImageDescriptor DESC_OBJS_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_PACKFRAG_ROOT);
public static final ImageDescriptor DESC_OBJS_MISSING_PACKFRAG_ROOT= createManaged(T_OBJ, IMG_OBJS_MISSING_PACKFRAG_ROOT);
public static final ImageDescriptor DESC_OBJS_JAVA_MODEL= createManaged(T_OBJ, IMG_OBJS_JAVA_MODEL);
public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
public static final ImageDescriptor DESC_OBJS_CLASS_DEFAULT= createManaged(T_OBJ, IMG_OBJS_CLASS_DEFAULT);
public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PUBLIC= createManaged(T_OBJ, IMG_OBJS_INNER_CLASS_PUBLIC);
public static final ImageDescriptor DESC_OBJS_INNER_CLASS_DEFAULT= createManaged(T_OBJ, IMG_OBJS_INNER_CLASS_DEFAULT);
public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PROTECTED= createManaged(T_OBJ, IMG_OBJS_INNER_CLASS_PROTECTED);
public static final ImageDescriptor DESC_OBJS_INNER_CLASS_PRIVATE= createManaged(T_OBJ, IMG_OBJS_INNER_CLASS_PRIVATE);
public static final ImageDescriptor DESC_OBJS_CLASSALT= createManaged(T_OBJ, IMG_OBJS_CLASSALT);
public static final ImageDescriptor DESC_OBJS_INTERFACE= createManaged(T_OBJ, IMG_OBJS_INTERFACE);
public static final ImageDescriptor DESC_OBJS_INTERFACE_DEFAULT= createManaged(T_OBJ, IMG_OBJS_INTERFACE_DEFAULT);
public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PUBLIC= createManaged(T_OBJ, IMG_OBJS_INNER_INTERFACE_PUBLIC);
public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_DEFAULT= createManaged(T_OBJ, IMG_OBJS_INNER_INTERFACE_DEFAULT);
public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PROTECTED= createManaged(T_OBJ, IMG_OBJS_INNER_INTERFACE_PROTECTED);
public static final ImageDescriptor DESC_OBJS_INNER_INTERFACE_PRIVATE= createManaged(T_OBJ, IMG_OBJS_INNER_INTERFACE_PRIVATE);
public static final ImageDescriptor DESC_OBJS_INTERFACEALT= createManaged(T_OBJ, IMG_OBJS_INTERFACEALT);
public static final ImageDescriptor DESC_OBJS_JAR= createManaged(T_OBJ, IMG_OBJS_JAR);
public static final ImageDescriptor DESC_OBJS_MISSING_JAR= createManaged(T_OBJ, IMG_OBJS_MISSING_JAR);
public static final ImageDescriptor DESC_OBJS_EXTJAR= createManaged(T_OBJ, IMG_OBJS_EXTJAR);
public static final ImageDescriptor DESC_OBJS_JAR_WSRC= createManaged(T_OBJ, IMG_OBJS_JAR_WSRC);
public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManaged(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
public static final ImageDescriptor DESC_OBJS_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_ENV_VAR);
public static final ImageDescriptor DESC_OBJS_MISSING_ENV_VAR= createManaged(T_OBJ, IMG_OBJS_MISSING_ENV_VAR);
public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
public static final ImageDescriptor DESC_OBJS_JAVADOCTAG= createManaged(T_OBJ, IMG_OBJS_JAVADOCTAG);
public static final ImageDescriptor DESC_OBJS_HTMLTAG= createManaged(T_OBJ, IMG_OBJS_HTMLTAG);
public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
public static final ImageDescriptor DESC_OBJS_EXCEPTION= createManaged(T_OBJ, IMG_OBJS_EXCEPTION);
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED= createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_INSTALLED);
public static final ImageDescriptor DESC_OBJS_ERROR= createManaged(T_OBJ, IMG_OBJS_ERROR);
public static final ImageDescriptor DESC_OBJS_QUICK_ASSIST= createManaged(T_OBJ, IMG_OBJS_QUICK_ASSIST);
public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
// public static final ImageDescriptor DESC_OBJS_SNIPPET_EVALUATING= createManaged(T_OBJ, IMG_OBJS_SNIPPET_EVALUATING);
public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= create(T_OBJ, "change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE= create(T_OBJ, "composite_change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_CU_CHANGE= create(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= create(T_OBJ, "file_change.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= create(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB= create(T_OBJ, "exclusion_filter_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_INCLUSION_FILTER_ATTRIB= create(T_OBJ, "inclusion_filter_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER_ATTRIB= create(T_OBJ, "output_folder_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= create(T_OBJ, "source_attach_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_JAVADOC_LOCATION_ATTRIB= create(T_OBJ, "javadoc_location_attrib.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJS_REFACTORING_FATAL= createManaged(T_OBJ, IMG_OBJS_REFACTORING_FATAL);
public static final ImageDescriptor DESC_OBJS_REFACTORING_ERROR= createManaged(T_OBJ, IMG_OBJS_REFACTORING_ERROR);
public static final ImageDescriptor DESC_OBJS_REFACTORING_WARNING= createManaged(T_OBJ, IMG_OBJS_REFACTORING_WARNING);
public static final ImageDescriptor DESC_OBJS_REFACTORING_INFO= createManaged(T_OBJ, IMG_OBJS_REFACTORING_INFO);
public static final ImageDescriptor DESC_OBJS_NLS_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_TRANSLATE);
public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE= createManaged(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
public static final ImageDescriptor DESC_OBJS_NLS_SKIP= createManaged(T_OBJ, IMG_OBJS_NLS_SKIP);
public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
public static final ImageDescriptor DESC_OBJS_SEARCH_READACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_READACCESS);
public static final ImageDescriptor DESC_OBJS_SEARCH_WRITEACCESS= createManaged(T_OBJ, IMG_OBJS_SEARCH_WRITEACCESS);
public static final ImageDescriptor DESC_OBJS_SEARCH_OCCURRENCE= createManaged(T_OBJ, IMG_OBJS_SEARCH_OCCURRENCE);
public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
public static final ImageDescriptor DESC_OBJ_OVERRIDES= create(T_OBJ, "over_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJ_IMPLEMENTS= create(T_OBJ, "implm_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_FINAL= create(T_OVR, "final_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_ABSTRACT= create(T_OVR, "abstract_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_SYNCH= create(T_OVR, "synch_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_RUN= create(T_OVR, "run_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_OVERRIDES= create(T_OVR, "over_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_IMPLEMENTS= create(T_OVR, "implm_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_CONSTRUCTOR= create(T_OVR, "constr_ovr.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_FOCUS= create(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$
// Call Hierarchy
public static final ImageDescriptor DESC_OVR_RECURSIVE= create(T_OVR, "recursive_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_MAX_LEVEL= create(T_OVR, "maxlevel_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWINT= create(T_WIZBAN, "newint_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWJPRJ= create(T_WIZBAN, "newjprj_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= create(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWMETH= create(T_WIZBAN, "newmeth_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWPACK= create(T_WIZBAN, "newpack_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_NEWSCRAPPAGE= create(T_WIZBAN, "newsbook_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_JAVA_LAUNCH= create(T_WIZBAN, "java_app_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_JAVA_ATTACH= create(T_WIZBAN, "java_attach_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR= create(T_WIZBAN, "refactor_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= create(T_WIZBAN, "fieldrefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= create(T_WIZBAN, "methrefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= create(T_WIZBAN, "typerefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PACKAGE= create(T_WIZBAN, "packrefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CODE= create(T_WIZBAN, "coderefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_CU= create(T_WIZBAN, "compunitrefact_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_REFACTOR_PULL_UP= create(T_WIZBAN, "pullup_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_JAR_PACKAGER= create(T_WIZBAN, "jar_pack_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_JAVA_WORKINGSET= create(T_WIZBAN, "java_workingset_wiz.gif");//$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_EXPORT_JAVADOC= create(T_WIZBAN, "export_javadoc_wiz.gif");//$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_EXTERNALIZE_STRINGS= create(T_WIZBAN, "extstr_wiz.gif");//$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY= create(T_WIZBAN, "addlibrary_wiz.gif");//$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_SHOW_EMPTY_PKG= create(T_ETOOL, "show_empty_pkg.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_SHOW_SEGMENTS= create(T_ETOOL, "segment_edit.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_OPENTYPE= create(T_ETOOL, "opentype.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWPROJECT= create(T_ETOOL, "newjprj_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWPACKAGE= create(T_ETOOL, "newpack_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_ETOOL, "newclass_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWINTERFACE= create(T_ETOOL, "newint_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWSNIPPET= create(T_ETOOL, "newsbook_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_NEWPACKROOT= create(T_ETOOL, "newpackfolder_wiz.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_TOOL_CLASSPATH_ORDER= create(T_OBJ, "cp_order_obj.gif"); //$NON-NLS-1$
// Keys for correction proposal. We have to put the image into the registry since "code assist" doesn't
// have a life cycle. So no change to dispose icons.
public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_MOVE= NAME_PREFIX + "correction_move.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_DELETE_IMPORT= NAME_PREFIX + "correction_delete_import.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_LOCAL= NAME_PREFIX + "localvariable_obj.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_REMOVE= NAME_PREFIX + "remove_correction.gif"; //$NON-NLS-1$
public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "add_correction.gif"; //$NON-NLS-1$
static {
createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
createManaged(T_OBJ, IMG_CORRECTION_MOVE);
createManaged(T_OBJ, IMG_CORRECTION_RENAME);
createManaged(T_OBJ, IMG_CORRECTION_DELETE_IMPORT);
createManaged(T_OBJ, IMG_CORRECTION_LOCAL);
createManaged(T_OBJ, IMG_CORRECTION_REMOVE);
createManaged(T_OBJ, IMG_CORRECTION_ADD);
}
/**
* Returns the image managed under the given key in this registry.
*
* @param key the image's key
* @return the image managed under the given key
*/
public static Image get(String key) {
return getImageRegistry().get(key);
}
/**
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
* are retrieved from the *tool16 folders.
*
* @param action the action
* @param iconName the icon name
*/
public static void setToolImageDescriptors(IAction action, String iconName) {
setImageDescriptors(action, "tool16", iconName); //$NON-NLS-1$
}
/**
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
* are retrieved from the *lcl16 folders.
*
* @param action the action
* @param iconName the icon name
*/
public static void setLocalImageDescriptors(IAction action, String iconName) {
setImageDescriptors(action, "lcl16", iconName); //$NON-NLS-1$
}
/*
* Helper method to access the image registry from the JavaPlugin class.
*/
/* package */ static ImageRegistry getImageRegistry() {
if (fgImageRegistry == null) {
fgImageRegistry= new ImageRegistry();
for (Iterator iter= fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) {
String key= (String) iter.next();
fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap.get(key));
}
fgAvoidSWTErrorMap= null;
}
return fgImageRegistry;
}
//---- Helper methods to access icons on the file system --------------------------------------
private static void setImageDescriptors(IAction action, String type, String relPath) {
try {
ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$
if (id != null)
action.setDisabledImageDescriptor(id);
} catch (MalformedURLException e) {
}
/*
try {
ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath)); //$NON-NLS-1$
if (id != null)
action.setHoverImageDescriptor(id);
} catch (MalformedURLException e) {
}
*/
ImageDescriptor descriptor= create("e" + type, relPath); //$NON-NLS-1$
action.setHoverImageDescriptor(descriptor);
action.setImageDescriptor(descriptor);
}
private static ImageDescriptor createManaged(String prefix, String name) {
try {
ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
if (fgAvoidSWTErrorMap == null) {
fgAvoidSWTErrorMap= new HashMap();
}
fgAvoidSWTErrorMap.put(name, result);
if (fgImageRegistry != null) {
JavaPlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
}
return result;
} catch (MalformedURLException e) {
return ImageDescriptor.getMissingImageDescriptor();
}
}
private static ImageDescriptor createManaged(String prefix, String name, String key) {
try {
ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
if (fgAvoidSWTErrorMap == null) {
fgAvoidSWTErrorMap= new HashMap();
}
fgAvoidSWTErrorMap.put(key, result);
if (fgImageRegistry != null) {
JavaPlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
}
return result;
} catch (MalformedURLException e) {
return ImageDescriptor.getMissingImageDescriptor();
}
}
private static ImageDescriptor create(String prefix, String name) {
try {
return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
} catch (MalformedURLException e) {
return ImageDescriptor.getMissingImageDescriptor();
}
}
private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException {
if (fgIconBaseURL == null)
throw new MalformedURLException();
StringBuffer buffer= new StringBuffer(prefix);
buffer.append('/');
buffer.append(name);
return new URL(fgIconBaseURL, buffer.toString());
}
}
|
24,046
|
Bug 24046 Override icon hides synchronize icon [icons]
|
Build 20020920 If you have the following cu: public class X { synchronized boolean equals(Object o) { } } The Outline for X.equals(Object) shows the override icon (green triangle) but it doesn't show the synhronize icon (watch).
|
resolved fixed
|
3dc3e69
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T15:17:20Z
| 2002-09-24T17:53:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/JavaElementImageDescriptor.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ui;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
/**
* A JavaImageDescriptor consists of a base image and several adornments. The adornments
* are computed according to the flags either passed during creation or set via the method
* <code>setAdornments</code>.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class JavaElementImageDescriptor extends CompositeImageDescriptor {
/** Flag to render the abstract adornment */
public final static int ABSTRACT= 0x001;
/** Flag to render the final adornment */
public final static int FINAL= 0x002;
/** Flag to render the synchronized adornment */
public final static int SYNCHRONIZED= 0x004;
/** Flag to render the static adornment */
public final static int STATIC= 0x008;
/** Flag to render the runnable adornment */
public final static int RUNNABLE= 0x010;
/** Flag to render the waring adornment */
public final static int WARNING= 0x020;
/** Flag to render the error adornment */
public final static int ERROR= 0x040;
/** Flag to render the 'override' adornment */
public final static int OVERRIDES= 0x080;
/** Flag to render the 'implements' adornment */
public final static int IMPLEMENTS= 0x100;
/** Flag to render the 'constructor' adornment */
public final static int CONSTRUCTOR= 0x200;
private ImageDescriptor fBaseImage;
private int fFlags;
private Point fSize;
/**
* Creates a new JavaElementImageDescriptor.
*
* @param baseImage an image descriptor used as the base image
* @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code>
* for valid values.
* @param size the size of the resulting image
* @see #setAdornments(int)
*/
public JavaElementImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
fBaseImage= baseImage;
Assert.isNotNull(fBaseImage);
fFlags= flags;
Assert.isTrue(fFlags >= 0);
fSize= size;
Assert.isNotNull(fSize);
}
/**
* Sets the descriptors adornments. Valid values are: <code>ABSTRACT</code>, <code>FINAL</code>,
* <code>SYNCHRONIZED</code>, </code>STATIC<code>, </code>RUNNABLE<code>, </code>WARNING<code>,
* </code>ERROR<code>, </code>OVERRIDDES<code>, <code>IMPLEMENTS</code>, <code>CONSTRUCTOR</code>,
* or any combination of those.
*
* @param adornments the image descritpors adornments
*/
public void setAdornments(int adornments) {
Assert.isTrue(adornments >= 0);
fFlags= adornments;
}
/**
* Returns the current adornments.
*
* @return the current adornments
*/
public int getAdronments() {
return fFlags;
}
/**
* Sets the size of the image created by calling <code>createImage()</code>.
*
* @param size the size of the image returned from calling <code>createImage()</code>
* @see ImageDescriptor#createImage()
*/
public void setImageSize(Point size) {
Assert.isNotNull(size);
Assert.isTrue(size.x >= 0 && size.y >= 0);
fSize= size;
}
/**
* Returns the size of the image created by calling <code>createImage()</code>.
*
* @return the size of the image created by calling <code>createImage()</code>
* @see ImageDescriptor#createImage()
*/
public Point getImageSize() {
return new Point(fSize.x, fSize.y);
}
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
protected Point getSize() {
return fSize;
}
/* (non-Javadoc)
* Method declared on Object.
*/
public boolean equals(Object object) {
if (object == null || !JavaElementImageDescriptor.class.equals(object.getClass()))
return false;
JavaElementImageDescriptor other= (JavaElementImageDescriptor)object;
return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
}
/* (non-Javadoc)
* Method declared on Object.
*/
public int hashCode() {
return fBaseImage.hashCode() | fFlags | fSize.hashCode();
}
/* (non-Javadoc)
* Method declared in CompositeImageDescriptor
*/
protected void drawCompositeImage(int width, int height) {
ImageData bg= getImageData(fBaseImage);
drawImage(bg, 0, 0);
drawTopRight();
drawBottomRight();
drawBottomLeft();
}
private ImageData getImageData(ImageDescriptor descriptor) {
ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
if (data == null) {
data= DEFAULT_IMAGE_DATA;
JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
}
return data;
}
private void drawTopRight() {
int x= getSize().x;
ImageData data= null;
if ((fFlags & ABSTRACT) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_ABSTRACT);
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & CONSTRUCTOR) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_CONSTRUCTOR);
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & FINAL) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_FINAL);
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & STATIC) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_STATIC);
x-= data.width;
drawImage(data, x, 0);
}
}
private void drawBottomRight() {
Point size= getSize();
int x= size.x;
ImageData data= null;
if ((fFlags & OVERRIDES) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_OVERRIDES);
x-= data.width;
drawImage(data, x, size.y - data.height);
}
if ((fFlags & IMPLEMENTS) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_IMPLEMENTS);
x-= data.width;
drawImage(data, x, size.y - data.height);
}
if ((fFlags & SYNCHRONIZED) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_SYNCH);
x-= data.width;
drawImage(data, x, size.y - data.height);
}
if ((fFlags & RUNNABLE) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_RUN);
x-= data.width;
drawImage(data, x, size.y - data.height);
}
}
private void drawBottomLeft() {
Point size= getSize();
int x= 0;
ImageData data= null;
if ((fFlags & ERROR) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_ERROR);
drawImage(data, x, size.y - data.height);
x+= data.width;
}
if ((fFlags & WARNING) != 0) {
data= getImageData(JavaPluginImages.DESC_OVR_WARNING);
drawImage(data, x, size.y - data.height);
x+= data.width;
}
}
}
|
24,046
|
Bug 24046 Override icon hides synchronize icon [icons]
|
Build 20020920 If you have the following cu: public class X { synchronized boolean equals(Object o) { } } The Outline for X.equals(Object) shows the override icon (green triangle) but it doesn't show the synhronize icon (watch).
|
resolved fixed
|
3dc3e69
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T15:17:20Z
| 2002-09-24T17:53:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/OverrideIndicatorLabelDecorator.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.ui;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.SuperTypeHierarchyCache;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor;
/**
* LabelDecorator that decorates an method's image with override or implements overlays.
* The viewer using this decorator is responsible for updating the images on element changes.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class OverrideIndicatorLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator {
private ImageDescriptorRegistry fRegistry;
private boolean fUseNewRegistry= false;
/**
* Creates a decorator. The decorator creates an own image registry to cache
* images.
*/
public OverrideIndicatorLabelDecorator() {
this(null);
fUseNewRegistry= true;
}
/*
* Creates decorator with a shared image registry.
*
* @param registry The registry to use or <code>null</code> to use the Java plugin's
* image registry.
*/
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
* @param registry The registry to use.
*/
public OverrideIndicatorLabelDecorator(ImageDescriptorRegistry registry) {
fRegistry= registry;
}
private ImageDescriptorRegistry getRegistry() {
if (fRegistry == null) {
fRegistry= fUseNewRegistry ? new ImageDescriptorRegistry() : JavaPlugin.getImageDescriptorRegistry();
}
return fRegistry;
}
/* (non-Javadoc)
* @see ILabelDecorator#decorateText(String, Object)
*/
public String decorateText(String text, Object element) {
return text;
}
/* (non-Javadoc)
* @see ILabelDecorator#decorateImage(Image, Object)
*/
public Image decorateImage(Image image, Object element) {
int adornmentFlags= computeAdornmentFlags(element);
if (adornmentFlags != 0) {
ImageDescriptor baseImage= new ImageImageDescriptor(image);
Rectangle bounds= image.getBounds();
return getRegistry().get(new JavaElementImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height)));
}
return image;
}
/**
* Note: This method is for internal use only. Clients should not call this method.
* @param element The element to decorate
* @return Resulting decorations (combination of JavaElementImageDescriptor.IMPLEMENTS
* and JavaElementImageDescriptor.OVERRIDES)
*/
public int computeAdornmentFlags(Object element) {
if (element instanceof IMethod) {
try {
IMethod method= (IMethod) element;
if (!method.getJavaProject().isOnClasspath(method)) {
return 0;
}
int flags= method.getFlags();
if (method.getDeclaringType().isClass() && !method.isConstructor() && !Flags.isPrivate(flags) && !Flags.isStatic(flags)) {
return getOverrideIndicators(method);
}
} catch (JavaModelException e) {
if (!e.isDoesNotExist()) {
JavaPlugin.log(e);
}
}
}
return 0;
}
/**
* Note: This method is for internal use only. Clients should not call this method.
* @param method The element to decorate
* @return Resulting decorations (combination of JavaElementImageDescriptor.IMPLEMENTS
* and JavaElementImageDescriptor.OVERRIDES)
* @throws JavaModelException
*/
protected int getOverrideIndicators(IMethod method) throws JavaModelException {
IType type= method.getDeclaringType();
// if (type.isAnonymous() && !SuperTypeHierarchyCache.hasInCache(type)) {
// int flags= method.getFlags();
// // for performance reasons: cheat
// if (!Flags.isPublic(flags) || type.getSuperclassName().endsWith("Adapter")) { //$NON-NLS-1$
// return JavaElementImageDescriptor.OVERRIDES;
// }
// return JavaElementImageDescriptor.IMPLEMENTS;
// }
ITypeHierarchy hierarchy= SuperTypeHierarchyCache.getTypeHierarchy(type);
if (hierarchy != null) {
return findInHierarchy(type, hierarchy, method.getElementName(), method.getParameterTypes());
}
return 0;
}
/**
* Note: This method is for internal use only. Clients should not call this method.
* @param type The declaring type of the method to decorate.
* @param hierarchy The type hierarchy of the declaring type.
* @param name The name of the method to find.
* @param paramTypes The parameter types of the method to find.
* @return The resulting decoration.
* @throws JavaModelException
*/
protected int findInHierarchy(IType type, ITypeHierarchy hierarchy, String name, String[] paramTypes) throws JavaModelException {
IMethod impl= JavaModelUtil.findMethodDeclarationInHierarchy(hierarchy, type, name, paramTypes, false);
if (impl != null && JavaModelUtil.isVisibleInHierarchy(impl, type.getPackageFragment())) {
IMethod overridden= JavaModelUtil.findMethodImplementationInHierarchy(hierarchy, type, name, paramTypes, false);
if (overridden != null) {
return JavaElementImageDescriptor.OVERRIDES;
} else {
return JavaElementImageDescriptor.IMPLEMENTS;
}
}
return 0;
}
/* (non-Javadoc)
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
*/
public void addListener(ILabelProviderListener listener) {
}
/* (non-Javadoc)
* @see IBaseLabelProvider#dispose()
*/
public void dispose() {
if (fRegistry != null && fUseNewRegistry) {
fRegistry.dispose();
}
}
/* (non-Javadoc)
* @see IBaseLabelProvider#isLabelProperty(Object, String)
*/
public boolean isLabelProperty(Object element, String property) {
return true;
}
/* (non-Javadoc)
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
*/
public void removeListener(ILabelProviderListener listener) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
*/
public void decorate(Object element, IDecoration decoration) {
int adornmentFlags= computeAdornmentFlags(element);
if ((adornmentFlags & JavaElementImageDescriptor.IMPLEMENTS) != 0) {
decoration.addOverlay(JavaPluginImages.DESC_OVR_IMPLEMENTS);
} else if ((adornmentFlags & JavaElementImageDescriptor.OVERRIDES) != 0) {
decoration.addOverlay(JavaPluginImages.DESC_OVR_OVERRIDES);
}
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.junit.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jdt.internal.junit.ui.JUnitMessages;
import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
/**
* Custom Search engine for suite() methods
*/
public class TestSearchEngine {
private class JUnitSearchResultCollector extends SearchRequestor {
List fList;
Set fFailed= new HashSet();
Set fMatches= new HashSet();
public JUnitSearchResultCollector(List list) {
fList= list;
}
public void acceptSearchMatch(SearchMatch match) throws CoreException {
Object enclosingElement= match.getElement();
if (!(enclosingElement instanceof IMethod))
return;
IMethod method= (IMethod)enclosingElement;
IType declaringType= method.getDeclaringType();
if (fMatches.contains(declaringType) || fFailed.contains(declaringType))
return;
if (!hasSuiteMethod(declaringType) && !isTestType(declaringType)) {
fFailed.add(declaringType);
return;
}
fMatches.add(declaringType);
}
public void endReporting() {
fList.addAll(fMatches);
}
}
private List searchMethod(IProgressMonitor pm, final IJavaSearchScope scope) throws CoreException {
final List typesFound= new ArrayList(200);
searchMethod(typesFound, scope, pm);
return typesFound;
}
private List searchMethod(final List v, IJavaSearchScope scope, final IProgressMonitor progressMonitor) throws CoreException {
SearchRequestor requestor= new JUnitSearchResultCollector(v);
SearchPattern suitePattern= SearchPattern.createPattern("suite() Test", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH, true); //$NON-NLS-1$
SearchPattern testPattern= SearchPattern.createPattern("test*() void", IJavaSearchConstants.METHOD , IJavaSearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH, true); //$NON-NLS-1$
SearchPattern pattern= SearchPattern.createOrPattern(suitePattern, testPattern);
SearchParticipant[] participants= new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
new SearchEngine().search(pattern, participants, scope, requestor, progressMonitor);
return v;
}
public static IType[] findTests(final Object[] elements) throws InvocationTargetException, InterruptedException{
final Set result= new HashSet();
if (elements.length > 0) {
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InterruptedException {
doFindTests(elements, result, pm);
}
};
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
}
return (IType[]) result.toArray(new IType[result.size()]) ;
}
public static void doFindTests(Object[] elements, Set result, IProgressMonitor pm) throws InterruptedException {
int nElements= elements.length;
pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
try {
for (int i= 0; i < nElements; i++) {
try {
collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
} catch (CoreException e) {
JUnitPlugin.log(e.getStatus());
}
if (pm.isCanceled()) {
throw new InterruptedException();
}
}
} finally {
pm.done();
}
}
private static void collectTypes(Object element, IProgressMonitor pm, Set result) throws CoreException/*, InvocationTargetException*/ {
element= computeScope(element);
while((element instanceof IJavaElement) && !(element instanceof ICompilationUnit) && (element instanceof ISourceReference)) {
if(element instanceof IType) {
if (hasSuiteMethod((IType)element) || isTestType((IType)element)) {
result.add(element);
return;
}
}
element= ((IJavaElement)element).getParent();
}
if (element instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit)element;
IType[] types= cu.getAllTypes();
for (int i= 0; i < types.length; i++) {
if (hasSuiteMethod(types[i]) || isTestType(types[i]))
result.add(types[i]);
}
}
else if (element instanceof IJavaElement) {
List found= searchSuiteMethods(pm, (IJavaElement)element);
result.addAll(found);
}
}
private static Object computeScope(Object element) throws JavaModelException {
if (element instanceof IFileEditorInput)
element= ((IFileEditorInput)element).getFile();
if (element instanceof IResource)
element= JavaCore.create((IResource)element);
if (element instanceof IClassFile) {
IClassFile cf= (IClassFile)element;
element= cf.getType();
}
return element;
}
private static List searchSuiteMethods(IProgressMonitor pm, IJavaElement element) throws CoreException {
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { element });
TestSearchEngine searchEngine= new TestSearchEngine();
return searchEngine.searchMethod(pm, scope);
}
public static boolean hasSuiteMethod(IType type) throws JavaModelException {
IMethod method= type.getMethod("suite", new String[0]); //$NON-NLS-1$
if (method == null || !method.exists())
return false;
if (!Flags.isStatic(method.getFlags()) ||
!Flags.isPublic(method.getFlags()) ||
!Flags.isPublic(method.getDeclaringType().getFlags())) {
return false;
}
return true;
}
private static boolean isTestType(IType type) throws JavaModelException {
if (Flags.isAbstract(type.getFlags()))
return false;
if (!Flags.isPublic(type.getFlags()))
return false;
IType[] interfaces= type.newSupertypeHierarchy(null).getAllSuperInterfaces(type);
for (int i= 0; i < interfaces.length; i++)
if(interfaces[i].getFullyQualifiedName().equals(JUnitPlugin.TEST_INTERFACE_NAME))
return true;
return false;
}
public static boolean isTestImplementor(IType type) throws JavaModelException {
ITypeHierarchy typeHier= type.newSupertypeHierarchy(null);
IType[] superInterfaces= typeHier.getAllInterfaces();
for (int i= 0; i < superInterfaces.length; i++) {
if (superInterfaces[i].getFullyQualifiedName().equals(JUnitPlugin.TEST_INTERFACE_NAME))
return true;
}
return false;
}
public static boolean isTestOrTestSuite(IType type) throws JavaModelException {
return hasSuiteMethod(type) || isTestType(type);
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/OpenEditorAtLineAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids: sdavids@gmx.de bug 37333 Failure Trace cannot
* navigate to non-public class in CU throwing Exception
*******************************************************************************/
package org.eclipse.jdt.internal.junit.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* Open a test in the Java editor and reveal a given line
*/
public class OpenEditorAtLineAction extends OpenEditorAction {
//fix for bug 37333
private class NonPublicClassInCUCollector extends SearchRequestor {
private IJavaElement fFound;
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IJavaElement enclosingElement= (IJavaElement) match.getElement();
String resourceName= match.getResource().getName();
if ((enclosingElement instanceof IType) && (resourceName.equals(fCUName)))
fFound= enclosingElement;
}
}
private int fLineNumber;
private String fCUName;
/**
* Constructor for OpenEditorAtLineAction.
*/
public OpenEditorAtLineAction(TestRunnerViewPart testRunner, String cuName, String className, int line) {
super(testRunner, className);
WorkbenchHelp.setHelp(this, IJUnitHelpContextIds.OPENEDITORATLINE_ACTION);
fLineNumber= line;
fCUName= cuName;
}
protected void reveal(ITextEditor textEditor) {
if (fLineNumber >= 0) {
try {
IDocument document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
textEditor.selectAndReveal(document.getLineOffset(fLineNumber-1), document.getLineLength(fLineNumber-1));
} catch (BadLocationException x) {
// marker refers to invalid text position -> do nothing
}
}
}
protected IJavaElement findElement(IJavaProject project, String className) throws CoreException {
IJavaElement element= project.findType(className);
//fix for bug 37333
if (element == null) {
SearchPattern pattern= SearchPattern.createPattern(className, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH, true);
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { project }, false);
NonPublicClassInCUCollector requestor= new NonPublicClassInCUCollector();
SearchEngine searchEngine= new SearchEngine();
searchEngine.search(pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
scope, requestor, new NullProgressMonitor());
element= requestor.fFound;
}
return element;
}
public boolean isEnabled() {
try {
return getLaunchedProject().findType(getClassName()) != null;
} catch (JavaModelException e) {
}
return false;
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/util/TestSearchEngine.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.junit.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jdt.internal.junit.ui.JUnitMessages;
import org.eclipse.jdt.internal.junit.ui.JUnitPlugin;
/**
* Custom Search engine for suite() methods
*/
public class TestSearchEngine {
private class JUnitSearchResultCollector extends SearchRequestor {
List fList;
Set fFailed= new HashSet();
Set fMatches= new HashSet();
public JUnitSearchResultCollector(List list) {
fList= list;
}
public void acceptSearchMatch(SearchMatch match) throws CoreException {
Object enclosingElement= match.getElement();
if (!(enclosingElement instanceof IMethod))
return;
IMethod method= (IMethod)enclosingElement;
IType declaringType= method.getDeclaringType();
if (fMatches.contains(declaringType) || fFailed.contains(declaringType))
return;
if (!hasSuiteMethod(declaringType) && !isTestType(declaringType)) {
fFailed.add(declaringType);
return;
}
fMatches.add(declaringType);
}
public void endReporting() {
fList.addAll(fMatches);
}
}
private List searchMethod(IProgressMonitor pm, final IJavaSearchScope scope) throws CoreException {
final List typesFound= new ArrayList(200);
searchMethod(typesFound, scope, pm);
return typesFound;
}
private List searchMethod(final List v, IJavaSearchScope scope, final IProgressMonitor progressMonitor) throws CoreException {
SearchRequestor requestor= new JUnitSearchResultCollector(v);
SearchPattern suitePattern= SearchPattern.createPattern("suite() Test", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH, true); //$NON-NLS-1$
SearchPattern testPattern= SearchPattern.createPattern("test*() void", IJavaSearchConstants.METHOD , IJavaSearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH, true); //$NON-NLS-1$
SearchPattern pattern= SearchPattern.createOrPattern(suitePattern, testPattern);
SearchParticipant[] participants= new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
new SearchEngine().search(pattern, participants, scope, requestor, progressMonitor);
return v;
}
public static IType[] findTests(final Object[] elements) throws InvocationTargetException, InterruptedException{
final Set result= new HashSet();
if (elements.length > 0) {
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InterruptedException {
doFindTests(elements, result, pm);
}
};
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
}
return (IType[]) result.toArray(new IType[result.size()]) ;
}
public static void doFindTests(Object[] elements, Set result, IProgressMonitor pm) throws InterruptedException {
int nElements= elements.length;
pm.beginTask(JUnitMessages.getString("TestSearchEngine.message.searching"), nElements); //$NON-NLS-1$
try {
for (int i= 0; i < nElements; i++) {
try {
collectTypes(elements[i], new SubProgressMonitor(pm, 1), result);
} catch (CoreException e) {
JUnitPlugin.log(e.getStatus());
}
if (pm.isCanceled()) {
throw new InterruptedException();
}
}
} finally {
pm.done();
}
}
private static void collectTypes(Object element, IProgressMonitor pm, Set result) throws CoreException/*, InvocationTargetException*/ {
element= computeScope(element);
while((element instanceof IJavaElement) && !(element instanceof ICompilationUnit) && (element instanceof ISourceReference)) {
if(element instanceof IType) {
if (hasSuiteMethod((IType)element) || isTestType((IType)element)) {
result.add(element);
return;
}
}
element= ((IJavaElement)element).getParent();
}
if (element instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit)element;
IType[] types= cu.getAllTypes();
for (int i= 0; i < types.length; i++) {
if (hasSuiteMethod(types[i]) || isTestType(types[i]))
result.add(types[i]);
}
}
else if (element instanceof IJavaElement) {
List found= searchSuiteMethods(pm, (IJavaElement)element);
result.addAll(found);
}
}
private static Object computeScope(Object element) throws JavaModelException {
if (element instanceof IFileEditorInput)
element= ((IFileEditorInput)element).getFile();
if (element instanceof IResource)
element= JavaCore.create((IResource)element);
if (element instanceof IClassFile) {
IClassFile cf= (IClassFile)element;
element= cf.getType();
}
return element;
}
private static List searchSuiteMethods(IProgressMonitor pm, IJavaElement element) throws CoreException {
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { element });
TestSearchEngine searchEngine= new TestSearchEngine();
return searchEngine.searchMethod(pm, scope);
}
public static boolean hasSuiteMethod(IType type) throws JavaModelException {
IMethod method= type.getMethod("suite", new String[0]); //$NON-NLS-1$
if (method == null || !method.exists())
return false;
if (!Flags.isStatic(method.getFlags()) ||
!Flags.isPublic(method.getFlags()) ||
!Flags.isPublic(method.getDeclaringType().getFlags())) {
return false;
}
return true;
}
private static boolean isTestType(IType type) throws JavaModelException {
if (Flags.isAbstract(type.getFlags()))
return false;
if (!Flags.isPublic(type.getFlags()))
return false;
IType[] interfaces= type.newSupertypeHierarchy(null).getAllSuperInterfaces(type);
for (int i= 0; i < interfaces.length; i++)
if(interfaces[i].getFullyQualifiedName().equals(JUnitPlugin.TEST_INTERFACE_NAME))
return true;
return false;
}
public static boolean isTestImplementor(IType type) throws JavaModelException {
ITypeHierarchy typeHier= type.newSupertypeHierarchy(null);
IType[] superInterfaces= typeHier.getAllInterfaces();
for (int i= 0; i < superInterfaces.length; i++) {
if (superInterfaces[i].getFullyQualifiedName().equals(JUnitPlugin.TEST_INTERFACE_NAME))
return true;
}
return false;
}
public static boolean isTestOrTestSuite(IType type) throws JavaModelException {
return hasSuiteMethod(type) || isTestType(type);
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/core
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/core
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenamePackageProcessor.java
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/core
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java
| |
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/PackageSelectionDialog.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.internal.corext.util.SearchUtils;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
/**
* Dialog to browse for package fragments.
*/
public class PackageSelectionDialog extends ElementListSelectionDialog {
public static final int F_REMOVE_DUPLICATES= 1;
public static final int F_SHOW_PARENTS= 2;
public static final int F_HIDE_DEFAULT_PACKAGE= 4;
/** The dialog location. */
private Point fLocation;
/** The dialog size. */
private Point fSize;
private IRunnableContext fContext;
private IJavaSearchScope fScope;
private int fFlags;
/**
* Creates a package selection dialog.
* @param parent the parent shell
* @param context the runnable context to run the search in
* @param flags a combination of <code>F_REMOVE_DUPLICATES</code>, <code>F_SHOW_PARENTS</code>
* and <code>F_HIDE_DEFAULT_PACKAGE</code>
* @param scope the scope defining the available packages.
*/
public PackageSelectionDialog(Shell parent, IRunnableContext context, int flags, IJavaSearchScope scope) {
super(parent, createLabelProvider(flags));
fFlags= flags;
fScope= scope;
fContext= context;
}
private static ILabelProvider createLabelProvider(int dialogFlags) {
int flags= JavaElementLabelProvider.SHOW_DEFAULT;
if ((dialogFlags & F_REMOVE_DUPLICATES) == 0) {
flags= flags | JavaElementLabelProvider.SHOW_ROOT;
}
return new JavaElementLabelProvider(flags);
}
/*
* @see org.eclipse.jface.window.Window#open()
*/
public int open() {
final ArrayList packageList= new ArrayList();
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
SearchRequestor requestor= new SearchRequestor() {
private HashSet fSet= new HashSet();
private final boolean fAddDefault= (fFlags & F_HIDE_DEFAULT_PACKAGE) == 0;
private final boolean fDuplicates= (fFlags & F_REMOVE_DUPLICATES) == 0;
private final boolean fIncludeParents= (fFlags & F_SHOW_PARENTS) != 0;
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IJavaElement enclosingElement= (IJavaElement) match.getElement();
String name= enclosingElement.getElementName();
if (fAddDefault || name.length() > 0) {
if (fDuplicates || fSet.add(name)) {
packageList.add(enclosingElement);
if (fIncludeParents) {
addParentPackages(enclosingElement, name);
}
}
}
}
private void addParentPackages(IJavaElement enclosingElement, String name) {
IPackageFragmentRoot root= (IPackageFragmentRoot) enclosingElement.getParent();
int idx= name.lastIndexOf('.');
while (idx != -1) {
name= name.substring(0, idx);
if (fDuplicates || fSet.add(name)) {
packageList.add(root.getPackageFragment(name));
}
idx= name.lastIndexOf('.');
}
}
};
SearchPattern pattern= SearchPattern.createPattern("*", //$NON-NLS-1$
IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_PATTERN_MATCH, true);
new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), fScope, requestor, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
if (monitor.isCanceled()) {
throw new InterruptedException();
}
}
};
try {
fContext.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, JavaUIMessages.getString("PackageSelectionDialog.error.title"), JavaUIMessages.getString("TypeSelectionDialog.error3Message")); //$NON-NLS-1$ //$NON-NLS-2$
return CANCEL;
} catch (InterruptedException e) {
// cancelled by user
return CANCEL;
}
if (packageList.isEmpty()) {
String title= JavaUIMessages.getString("PackageSelectionDialog.nopackages.title"); //$NON-NLS-1$
String message= JavaUIMessages.getString("PackageSelectionDialog.nopackages.message"); //$NON-NLS-1$
MessageDialog.openInformation(getShell(), title, message);
return CANCEL;
}
setElements(packageList.toArray());
return super.open();
}
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.OPEN_PACKAGE_DIALOG);
}
/*
* @see Window#close()
*/
public boolean close() {
writeSettings();
return super.close();
}
/*
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
*/
protected Control createContents(Composite parent) {
Control control= super.createContents(parent);
readSettings();
return control;
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getInitialSize()
*/
protected Point getInitialSize() {
Point result= super.getInitialSize();
if (fSize != null) {
result.x= Math.max(result.x, fSize.x);
result.y= Math.max(result.y, fSize.y);
Rectangle display= getShell().getDisplay().getClientArea();
result.x= Math.min(result.x, display.width);
result.y= Math.min(result.y, display.height);
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
*/
protected Point getInitialLocation(Point initialSize) {
Point result= super.getInitialLocation(initialSize);
if (fLocation != null) {
result.x= fLocation.x;
result.y= fLocation.y;
Rectangle display= getShell().getDisplay().getClientArea();
int xe= result.x + initialSize.x;
if (xe > display.width) {
result.x-= xe - display.width;
}
int ye= result.y + initialSize.y;
if (ye > display.height) {
result.y-= ye - display.height;
}
}
return result;
}
/**
* Initializes itself from the dialog settings with the same state
* as at the previous invocation.
*/
private void readSettings() {
IDialogSettings s= getDialogSettings();
try {
int x= s.getInt("x"); //$NON-NLS-1$
int y= s.getInt("y"); //$NON-NLS-1$
fLocation= new Point(x, y);
int width= s.getInt("width"); //$NON-NLS-1$
int height= s.getInt("height"); //$NON-NLS-1$
fSize= new Point(width, height);
} catch (NumberFormatException e) {
fLocation= null;
fSize= null;
}
}
/**
* Stores it current configuration in the dialog store.
*/
private void writeSettings() {
IDialogSettings s= getDialogSettings();
Point location= getShell().getLocation();
s.put("x", location.x); //$NON-NLS-1$
s.put("y", location.y); //$NON-NLS-1$
Point size= getShell().getSize();
s.put("width", size.x); //$NON-NLS-1$
s.put("height", size.y); //$NON-NLS-1$
}
/**
* Returns the dialog settings object used to share state
* between several find/replace dialogs.
*
* @return the dialog settings to be used
*/
private IDialogSettings getDialogSettings() {
IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
String sectionName= getClass().getName();
IDialogSettings subSettings= settings.getSection(sectionName);
if (subSettings == null)
subSettings= settings.addNewSection(sectionName);
return subSettings;
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.preferences.SearchParticipantsPreferencePage;
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.jface.resource.ImageDescriptor;
import org.eclipse.search.internal.ui.SearchPreferencePage;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.text.Match;
public class JavaSearchQuery implements ISearchQuery {
private ISearchResult fResult;
private QuerySpecification fPatternData;
public JavaSearchQuery(QuerySpecification data) {
fPatternData= data;
}
private static class SearchRequestor implements ISearchRequestor {
private IQueryParticipant fParticipant;
private JavaSearchResult fSearchResult;
public void reportMatch(Match match) {
IMatchPresentation participant= fParticipant.getUIParticipant();
if (participant == null || match.getElement() instanceof IJavaElement || match.getElement() instanceof IResource) {
fSearchResult.addMatch(match);
} else {
fSearchResult.addMatch(match, participant);
}
}
protected SearchRequestor(IQueryParticipant participant, JavaSearchResult result) {
super();
fParticipant= participant;
fSearchResult= result;
}
}
private IQueryParticipant[] getSearchParticipants(IProject[] concernedProjects) throws CoreException {
Map participantMap= new HashMap();
collectParticipants(participantMap, concernedProjects);
IQueryParticipant[] participants= new IQueryParticipant[participantMap.size()];
return (IQueryParticipant[]) participantMap.values().toArray(participants);
}
private void collectParticipants(Map participants, IProject[] projects) throws CoreException {
Iterator activeParticipants= SearchParticipantsPreferencePage.readActiveParticipants().values().iterator();
while (activeParticipants.hasNext()) {
IConfigurationElement participant= (IConfigurationElement) activeParticipants.next();
String id= participant.getAttribute("id"); //$NON-NLS-1$
for (int i= 0; i < projects.length; i++) {
if (participants.containsKey(id))
break;
if (projects[i].hasNature(participant.getAttribute("nature"))) //$NON-NLS-1$
participants.put(id, participant.createExecutableExtension("class")); //$NON-NLS-1$
}
}
}
public IStatus run(IProgressMonitor monitor) {
final JavaSearchResult textResult= (JavaSearchResult) getSearchResult();
textResult.removeAll();
// Don't need to pass in working copies in 3.0 here
SearchEngine engine= new SearchEngine();
try {
int totalTicks= 1000;
IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
IQueryParticipant[] participants= getSearchParticipants(projects);
int[] ticks= new int[participants.length];
for (int i= 0; i < participants.length; i++) {
ticks[i]= participants[i].estimateTicks(fPatternData);
totalTicks+= ticks[i];
}
monitor.beginTask(SearchMessages.getString("JavaSearchQuery.task.label"), totalTicks); //$NON-NLS-1$
IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
boolean ignorePotentials= SearchPreferencePage.arePotentialMatchesIgnored();
NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
SearchPattern pattern;
String stringPattern= null;
if (fPatternData instanceof ElementQuerySpecification) {
pattern= SearchPattern.createPattern(((ElementQuerySpecification)fPatternData).getElement(), fPatternData.getLimitTo());
stringPattern= ((ElementQuerySpecification)fPatternData).getElement().getElementName();
} else {
PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
stringPattern = patternSpec.getPattern();
int matchMode = stringPattern.indexOf('*') != -1 || stringPattern.indexOf('?') != -1 ? SearchPattern.R_PATTERN_MATCH : SearchPattern.R_EXACT_MATCH;
pattern = SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode, patternSpec.isCaseSensitive());
}
if (pattern == null) {
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, SearchMessages.getFormattedString("JavaSearchQuery.error.unsupported_pattern", stringPattern), null); //$NON-NLS-1$
}
engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
for (int i= 0; i < participants.length; i++) {
ISearchRequestor requestor= new SearchRequestor(participants[i], textResult);
IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
participants[i].search(requestor, fPatternData, participantPM);
}
} catch (CoreException e) {
return e.getStatus();
}
// TODO fix status message
String message= SearchMessages.getString("JavaSearchQuery.status.ok.message"); //$NON-NLS-1$
MessageFormat.format(message, new Object[] { new Integer(textResult.getMatchCount()) });
return new Status(IStatus.OK, JavaPlugin.getPluginId(), 0, message, null);
}
public String getLabel() {
if (fPatternData.getLimitTo() == IJavaSearchConstants.REFERENCES)
return SearchMessages.getString("JavaSearchQuery.searchfor_references"); //$NON-NLS-1$
else if (fPatternData.getLimitTo() == IJavaSearchConstants.DECLARATIONS)
return SearchMessages.getString("JavaSearchQuery.searchfor_declarations"); //$NON-NLS-1$
else if (fPatternData.getLimitTo() == IJavaSearchConstants.READ_ACCESSES)
return SearchMessages.getString("JavaSearchQuery.searchfor_read_access"); //$NON-NLS-1$
else if (fPatternData.getLimitTo() == IJavaSearchConstants.WRITE_ACCESSES)
return SearchMessages.getString("JavaSearchQuery.searchfor_write_access"); //$NON-NLS-1$
else if (fPatternData.getLimitTo() == IJavaSearchConstants.IMPLEMENTORS)
return SearchMessages.getString("JavaSearchQuery.searchfor_implementors"); //$NON-NLS-1$
return SearchMessages.getString("JavaSearchQuery.search_label"); //$NON-NLS-1$
}
String getSingularLabel() {
String desc= null;
if (fPatternData instanceof ElementQuerySpecification) {
IJavaElement element= ((ElementQuerySpecification)fPatternData).getElement();
if (fPatternData.getLimitTo() == IJavaSearchConstants.REFERENCES
&& element.getElementType() == IJavaElement.METHOD)
desc= PrettySignature.getUnqualifiedMethodSignature((IMethod)element);
else
desc= element.getElementName();
if ("".equals(desc) && element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) //$NON-NLS-1$
desc= SearchMessages.getString("JavaSearchOperation.default_package"); //$NON-NLS-1$
} else {
desc= ((PatternQuerySpecification)fPatternData).getPattern();
}
desc= "\""+desc+"\""; //$NON-NLS-1$ //$NON-NLS-2$
String[] args= new String[] {desc, fPatternData.getScopeDescription()}; //$NON-NLS-1$
switch (fPatternData.getLimitTo()) {
case IJavaSearchConstants.IMPLEMENTORS:
return SearchMessages.getFormattedString("JavaSearchOperation.singularImplementorsPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.DECLARATIONS:
return SearchMessages.getFormattedString("JavaSearchOperation.singularDeclarationsPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.REFERENCES:
return SearchMessages.getFormattedString("JavaSearchOperation.singularReferencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.ALL_OCCURRENCES:
return SearchMessages.getFormattedString("JavaSearchOperation.singularOccurrencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.READ_ACCESSES:
return SearchMessages.getFormattedString("JavaSearchOperation.singularReadReferencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.WRITE_ACCESSES:
return SearchMessages.getFormattedString("JavaSearchOperation.singularWriteReferencesPostfix", args); //$NON-NLS-1$
default:
return SearchMessages.getFormattedString("JavaSearchOperation.singularOccurrencesPostfix", args); //$NON-NLS-1$;
}
}
String getPluralLabelPattern() {
String desc= null;
if (fPatternData instanceof ElementQuerySpecification) {
IJavaElement element= ((ElementQuerySpecification)fPatternData).getElement();
if (fPatternData.getLimitTo() == IJavaSearchConstants.REFERENCES
&& element.getElementType() == IJavaElement.METHOD)
desc= PrettySignature.getUnqualifiedMethodSignature((IMethod)element);
else
desc= element.getElementName();
if ("".equals(desc) && element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) //$NON-NLS-1$
desc= SearchMessages.getString("JavaSearchOperation.default_package"); //$NON-NLS-1$
}
else {
desc= ((PatternQuerySpecification)fPatternData).getPattern();
}
desc= "\""+desc+"\""; //$NON-NLS-1$ //$NON-NLS-2$
String[] args= new String[] {desc, "{0}", fPatternData.getScopeDescription()}; //$NON-NLS-1$
switch (fPatternData.getLimitTo()) {
case IJavaSearchConstants.IMPLEMENTORS:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralImplementorsPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.DECLARATIONS:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralDeclarationsPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.REFERENCES:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralReferencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.ALL_OCCURRENCES:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralOccurrencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.READ_ACCESSES:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralReadReferencesPostfix", args); //$NON-NLS-1$
case IJavaSearchConstants.WRITE_ACCESSES:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralWriteReferencesPostfix", args); //$NON-NLS-1$
default:
return SearchMessages.getFormattedString("JavaSearchOperation.pluralOccurrencesPostfix", args); //$NON-NLS-1$;
}
}
ImageDescriptor getImageDescriptor() {
if (fPatternData.getLimitTo() == IJavaSearchConstants.IMPLEMENTORS || fPatternData.getLimitTo() == IJavaSearchConstants.DECLARATIONS)
return JavaPluginImages.DESC_OBJS_SEARCH_DECL;
else
return JavaPluginImages.DESC_OBJS_SEARCH_REF;
}
public boolean canRerun() {
return true;
}
public boolean canRunInBackground() {
return true;
}
public ISearchResult getSearchResult() {
if (fResult == null)
fResult= new JavaSearchResult(this);
return fResult;
}
QuerySpecification getSpecification() {
return fPatternData;
}
}
|
60,257
|
Bug 60257 SearchPattern API: R_CASE_SENSITIVE vs. boolean isCaseSensitive
|
The SearchPattern API for stringPattern searches to java elements is somewhat odd: There's a public constant R_CASE_SENSITIVE, which is not mentioned in the javadoc of createPattern(String stringPattern, int searchFor, int limitTo, int matchMode, boolean isCaseSensitive) , and there's also an extra boolean parameter isCaseSensitive. I don't see why R_CASE_SENSITIVE is made public if it should not be used by clients. On the other hand, it could also be turned into an official bit-flag and the boolean isCaseSensitive removed. To have both options seems strange to me.
|
verified fixed
|
33d2bb2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-04-30T18:33:43Z
| 2004-04-28T13:46:40Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/util/MainMethodSearchEngine.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.util;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.SearchUtils;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
public class MainMethodSearchEngine{
private static class MethodCollector extends SearchRequestor {
private List fResult;
private int fStyle;
public MethodCollector(List result, int style) {
Assert.isNotNull(result);
fResult= result;
fStyle= style;
}
private boolean considerExternalJars() {
return (fStyle & IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS) != 0;
}
private boolean considerBinaries() {
return (fStyle & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
*/
public void acceptSearchMatch(SearchMatch match) throws CoreException {
Object enclosingElement= match.getElement();
if (enclosingElement instanceof IMethod) { // defensive code
try {
IMethod curr= (IMethod) enclosingElement;
if (curr.isMainMethod()) {
if (!considerExternalJars()) {
IPackageFragmentRoot root= JavaModelUtil.getPackageFragmentRoot(curr);
if (root == null || root.isArchive()) {
return;
}
}
if (!considerBinaries() && curr.isBinary()) {
return;
}
fResult.add(curr.getDeclaringType());
}
} catch (JavaModelException e) {
JavaPlugin.log(e.getStatus());
}
}
}
}
/**
* Searches for all main methods in the given scope.
* Valid styles are IJavaElementSearchConstants.CONSIDER_BINARIES and
* IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS
*/
public IType[] searchMainMethods(IProgressMonitor pm, IJavaSearchScope scope, int style) throws CoreException {
List typesFound= new ArrayList(200);
SearchPattern pattern= SearchPattern.createPattern("main(String[]) void", //$NON-NLS-1$
IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH, true);
SearchRequestor requestor= new MethodCollector(typesFound, style);
new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
return (IType[]) typesFound.toArray(new IType[typesFound.size()]);
}
/**
* Searches for all main methods in the given scope.
* Valid styles are IJavaElementSearchConstants.CONSIDER_BINARIES and
* IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS
*/
public IType[] searchMainMethods(IRunnableContext context, final IJavaSearchScope scope, final int style) throws InvocationTargetException, InterruptedException {
int allFlags= IJavaElementSearchConstants.CONSIDER_EXTERNAL_JARS | IJavaElementSearchConstants.CONSIDER_BINARIES;
Assert.isTrue((style | allFlags) == allFlags);
final IType[][] res= new IType[1][];
IRunnableWithProgress runnable= new IRunnableWithProgress() {
public void run(IProgressMonitor pm) throws InvocationTargetException {
try {
res[0]= searchMainMethods(pm, scope, style);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
context.run(true, true, runnable);
return res[0];
}
}
|
60,715
|
Bug 60715 Can't switch (read, ...) filters after search for method
|
I200404281424 + zrh-plugins from 20040430_1758: Can't switch (read, ...) filters after search for method - Search for references to a field - check "Filter Reads" - Search for refs to method (a) Reads filter filters all matches Read filter should have no effect on method references (b) Cannot uncheck read filter since menu entry is disabled. Workaround is to search for field refs, uncheck filter, go back to method refs search.
|
resolved fixed
|
7dfdb00
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T08:03:10Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/MatchFilter.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
import org.eclipse.jdt.ui.search.PatternQuerySpecification;
import org.eclipse.jdt.ui.search.QuerySpecification;
abstract class MatchFilter {
public abstract boolean isApplicable(JavaSearchQuery query);
public abstract boolean filters(JavaElementMatch match);
public abstract String getName();
public abstract String getDescription();
public abstract String getID();
private static final MatchFilter[] ALL_FILTERS= new MatchFilter[] {
new ImportFilter(),
new JavadocFilter(),
new ReadFilter(),
new WriteFilter()
};
public static MatchFilter[] allFilters() {
return ALL_FILTERS;
}
}
class ImportFilter extends MatchFilter {
public boolean filters(JavaElementMatch match) {
return match.getElement() instanceof IImportDeclaration;
}
public String getName() {
return SearchMessages.getString("MatchFilter.ImportFilter.name"); //$NON-NLS-1$
}
public String getDescription() {
return SearchMessages.getString("MatchFilter.ImportFilter.description"); //$NON-NLS-1$
}
public boolean isApplicable(JavaSearchQuery query) {
QuerySpecification spec= query.getSpecification();
if (spec instanceof ElementQuerySpecification) {
ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
return elementSpec.getElement() instanceof IType;
} else if (spec instanceof PatternQuerySpecification) {
PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
return patternSpec.getSearchFor() == IJavaSearchConstants.TYPE;
}
return false;
}
public String getID() {
return "filter_imports"; //$NON-NLS-1$
}
}
abstract class FieldFilter extends MatchFilter {
public boolean isApplicable(JavaSearchQuery query) {
QuerySpecification spec= query.getSpecification();
if (spec instanceof ElementQuerySpecification) {
ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
return elementSpec.getElement() instanceof IField;
} else if (spec instanceof ElementQuerySpecification) {
PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
}
return false;
}
}
class WriteFilter extends FieldFilter {
public boolean filters(JavaElementMatch match) {
return match.isWriteAccess();
}
public String getName() {
return SearchMessages.getString("MatchFilter.WriteFilter.name"); //$NON-NLS-1$
}
public String getDescription() {
return SearchMessages.getString("MatchFilter.WriteFilter.description"); //$NON-NLS-1$
}
public String getID() {
return "filter_writes"; //$NON-NLS-1$
}
}
class ReadFilter extends FieldFilter {
public boolean filters(JavaElementMatch match) {
return !match.isWriteAccess();
}
public String getName() {
return SearchMessages.getString("MatchFilter.ReadFilter.name"); //$NON-NLS-1$
}
public String getDescription() {
return SearchMessages.getString("MatchFilter.ReadFilter.description"); //$NON-NLS-1$
}
public String getID() {
return "filter_reads"; //$NON-NLS-1$
}
}
class JavadocFilter extends MatchFilter {
public boolean filters(JavaElementMatch match) {
return match.isJavadoc();
}
public String getName() {
return SearchMessages.getString("MatchFilter.JavadocFilter.name"); //$NON-NLS-1$
}
public String getDescription() {
return SearchMessages.getString("MatchFilter.JavadocFilter.description"); //$NON-NLS-1$
}
public boolean isApplicable(JavaSearchQuery query) {
return true;
}
public String getID() {
return "filter_javadoc"; //$NON-NLS-1$
}
}
|
60,715
|
Bug 60715 Can't switch (read, ...) filters after search for method
|
I200404281424 + zrh-plugins from 20040430_1758: Can't switch (read, ...) filters after search for method - Search for references to a field - check "Filter Reads" - Search for refs to method (a) Reads filter filters all matches Read filter should have no effect on method references (b) Cannot uncheck read filter since menu entry is disabled. Workaround is to search for field refs, uncheck filter, go back to method refs search.
|
resolved fixed
|
7dfdb00
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T08:03:10Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/NewSearchResultCollector.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.search.FieldReferenceMatch;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchRequestor;
public class NewSearchResultCollector extends SearchRequestor {
private JavaSearchResult fSearch;
private boolean fIgnorePotentials;
public NewSearchResultCollector(JavaSearchResult search, boolean ignorePotentials) {
super();
fSearch= search;
fIgnorePotentials= ignorePotentials;
}
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IJavaElement enclosingElement= (IJavaElement) match.getElement();
if (enclosingElement != null) {
if (fIgnorePotentials && (match.getAccuracy() == SearchMatch.A_INACCURATE))
return;
boolean isWriteAccess= false;
boolean isReadAccess= false;
if (match instanceof FieldReferenceMatch) {
FieldReferenceMatch fieldRef= ((FieldReferenceMatch)match);
isWriteAccess= fieldRef.isWriteAccess();
isReadAccess= fieldRef.isReadAccess();
}
fSearch.addMatch(new JavaElementMatch(enclosingElement, match.getOffset(), match.getLength(), match.getAccuracy(), isWriteAccess, isWriteAccess, match.isInsideDocComment()));
}
}
public void beginReporting() {
}
public void endReporting() {
}
public void enterParticipant(SearchParticipant participant) {
}
public void exitParticipant(SearchParticipant participant) {
}
}
|
53,603
|
Bug 53603 [search] the new search view needs expand all/collapse all actions
|
to make it convenient to work with the tree there should be both expand and collapse all action provided in the toolbar
|
resolved fixed
|
69d5a73
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T10:19:47Z
| 2004-03-03T13:20:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultPage.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.viewsupport.ProblemTableViewer;
import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer;
import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.ISearchResultViewPart;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.texteditor.ITextEditor;
public class JavaSearchResultPage extends AbstractTextSearchViewPage {
private static final String KEY_GROUPING= "org.eclipse.jdt.search.resultpage.grouping"; //$NON-NLS-1$
private static final String KEY_SORTING= "org.eclipse.jdt.search.resultpage.sorting"; //$NON-NLS-1$
private static final String KEY_FILTERS= "org.eclipse.jdt.search.resultpage.filters"; //$NON-NLS-1$
private NewSearchViewActionGroup fActionGroup;
private JavaSearchContentProvider fContentProvider;
private int fCurrentSortOrder;
private SortAction fSortByNameAction;
private SortAction fSortByParentName;
private SortAction fSortByPathAction;
private GroupAction fGroupTypeAction;
private GroupAction fGroupFileAction;
private GroupAction fGroupPackageAction;
private GroupAction fGroupProjectAction;
private int fCurrentGrouping;
private Set fMatchFilters= new HashSet();
private FilterAction[] fFilterActions;
public JavaSearchResultPage() {
initSortActions();
initGroupingActions();
initFilterActions();
}
private void initFilterActions() {
MatchFilter[] allFilters= MatchFilter.allFilters();
fFilterActions= new FilterAction[allFilters.length];
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i]= new FilterAction(this, allFilters[i]);
}
}
private void initSortActions() {
fSortByNameAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByName"), this, SortingLabelProvider.SHOW_ELEMENT_CONTAINER); //$NON-NLS-1$
fSortByPathAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByPath"), this, SortingLabelProvider.SHOW_PATH); //$NON-NLS-1$
fSortByParentName= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByParentName"), this, SortingLabelProvider.SHOW_CONTAINER_ELEMENT); //$NON-NLS-1$
}
private void initGroupingActions() {
fGroupProjectAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_project"), SearchMessages.getString("JavaSearchResultPage.groupby_project.tooltip"), this, LevelTreeContentProvider.LEVEL_PROJECT); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupProjectAction, "prj_mode.gif"); //$NON-NLS-1$
fGroupPackageAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_package"), SearchMessages.getString("JavaSearchResultPage.groupby_package.tooltip"), this, LevelTreeContentProvider.LEVEL_PACKAGE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupPackageAction, "package_mode.gif"); //$NON-NLS-1$
fGroupFileAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_file"), SearchMessages.getString("JavaSearchResultPage.groupby_file.tooltip"), this, LevelTreeContentProvider.LEVEL_FILE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupFileAction, "file_mode.gif"); //$NON-NLS-1$
fGroupTypeAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_type"), SearchMessages.getString("JavaSearchResultPage.groupby_type.tooltip"), this, LevelTreeContentProvider.LEVEL_TYPE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupTypeAction, "type_mode.gif"); //$NON-NLS-1$
}
public void setViewPart(ISearchResultViewPart part) {
super.setViewPart(part);
fActionGroup= new NewSearchViewActionGroup(part);
}
public void showMatch(Match match, int offset, int length) throws PartInitException {
IEditorPart editor= null;
Object element= match.getElement();
if (element instanceof IJavaElement) {
IJavaElement javaElement= (IJavaElement) element;
try {
editor= EditorUtility.openInEditor(javaElement, false);
} catch (PartInitException e1) {
return;
} catch (JavaModelException e1) {
return;
}
} else if (element instanceof IFile) {
editor= IDE.openEditor(JavaPlugin.getActivePage(), (IFile) element, false);
}
if (editor instanceof ITextEditor) {
ITextEditor textEditor= (ITextEditor) editor;
textEditor.selectAndReveal(offset, length);
} else if (editor != null){
if (element instanceof IFile) {
IFile file= (IFile) element;
showWithMarker(editor, file, offset, length);
}
} else {
JavaSearchResult result= (JavaSearchResult) getInput();
IMatchPresentation participant= result.getSearchParticpant(element);
if (participant != null)
participant.showMatch(match, offset, length);
}
}
private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
try {
IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER);
HashMap attributes= new HashMap(4);
attributes.put(IMarker.CHAR_START, new Integer(offset));
attributes.put(IMarker.CHAR_END, new Integer(offset + length));
marker.setAttributes(attributes);
IDE.gotoMarker(editor, marker);
marker.delete();
} catch (CoreException e) {
throw new PartInitException(SearchMessages.getString("JavaSearchResultPage.error.marker"), e); //$NON-NLS-1$
}
}
protected void fillContextMenu(IMenuManager mgr) {
super.fillContextMenu(mgr);
addSortActions(mgr);
fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
fActionGroup.fillContextMenu(mgr);
}
private void addFilterActions(IMenuManager viewMenu) {
String filteringGroup= "Filtering"; //$NON-NLS-1$
viewMenu.add(new Separator(filteringGroup));
MenuManager mgr= new MenuManager(SearchMessages.getString("JavaSearchResultPage.filter.submenu")); //$NON-NLS-1$
for (int i= 0; i < fFilterActions.length; i++) {
mgr.add(fFilterActions[i]);
}
viewMenu.appendToGroup(filteringGroup, mgr);
}
private void addSortActions(IMenuManager mgr) {
if (getLayout() != FLAG_LAYOUT_FLAT)
return;
MenuManager sortMenu= new MenuManager(SearchMessages.getString("JavaSearchResultPage.sortBylabel")); //$NON-NLS-1$
sortMenu.add(fSortByNameAction);
sortMenu.add(fSortByPathAction);
sortMenu.add(fSortByParentName);
fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());
fSortByParentName.setChecked(fCurrentSortOrder == fSortByParentName.getSortOrder());
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
}
protected void fillToolbar(IToolBarManager tbm) {
super.fillToolbar(tbm);
if (getLayout() != FLAG_LAYOUT_FLAT)
addGroupActions(tbm);
}
private void addGroupActions(IToolBarManager mgr) {
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fGroupProjectAction);
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fGroupPackageAction);
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fGroupFileAction);
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, fGroupTypeAction);
updateGroupingActions();
}
private void updateGroupingActions() {
fGroupProjectAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PROJECT);
fGroupPackageAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PACKAGE);
fGroupFileAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_FILE);
fGroupTypeAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_TYPE);
}
public void dispose() {
fActionGroup.dispose();
super.dispose();
}
protected void elementsChanged(Object[] objects) {
if (fContentProvider != null)
fContentProvider.elementsChanged(objects);
}
protected void clear() {
if (fContentProvider != null)
fContentProvider.clear();
}
protected void configureTableViewer(TableViewer viewer) {
viewer.setLabelProvider(new DecoratingLabelProvider(new SortingLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
fContentProvider=new JavaSearchTableContentProvider(this);
viewer.setContentProvider(fContentProvider);
setSortOrder(fCurrentSortOrder);
}
protected void configureTreeViewer(TreeViewer viewer) {
viewer.setSorter(new ViewerSorter());
viewer.setLabelProvider(new DecoratingLabelProvider(new PostfixLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping);
viewer.setContentProvider(fContentProvider);
}
protected TreeViewer createTreeViewer(Composite parent) {
return new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
protected TableViewer createTableViewer(Composite parent) {
return new ProblemTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
void setSortOrder(int order) {
fCurrentSortOrder= order;
StructuredViewer viewer= getViewer();
viewer.getControl().setRedraw(false);
DecoratingLabelProvider dlp= (DecoratingLabelProvider) viewer.getLabelProvider();
((SortingLabelProvider)dlp.getLabelProvider()).setOrder(order);
if (order == SortingLabelProvider.SHOW_ELEMENT_CONTAINER) {
viewer.setSorter(new NameSorter());
} else if (order == SortingLabelProvider.SHOW_PATH) {
viewer.setSorter(new PathSorter());
} else
viewer.setSorter(new ParentSorter());
viewer.getControl().setRedraw(true);
getSettings().put(KEY_SORTING, fCurrentSortOrder);
}
public void init(IPageSite site) {
super.init(site);
fActionGroup.fillActionBars(site.getActionBars());
addFilterActions(site.getActionBars().getMenuManager());
}
/**
* Precondition here: the viewer must be showing a tree with a LevelContentProvider.
* @param order
*/
void setGrouping(int grouping) {
fCurrentGrouping= grouping;
StructuredViewer viewer= getViewer();
LevelTreeContentProvider cp= (LevelTreeContentProvider) viewer.getContentProvider();
cp.setLevel(grouping);
updateGroupingActions();
getSettings().put(KEY_GROUPING, fCurrentGrouping);
}
protected StructuredViewer getViewer() {
// override so that it's visible in the package.
return super.getViewer();
}
/* (non-Javadoc)
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#restoreState(org.eclipse.ui.IMemento)
*/
public void restoreState(IMemento memento) {
super.restoreState(memento);
try {
fCurrentSortOrder= getSettings().getInt(KEY_SORTING);
} catch (NumberFormatException e) {
fCurrentSortOrder= SortingLabelProvider.SHOW_ELEMENT_CONTAINER;
}
try {
fCurrentGrouping= getSettings().getInt(KEY_GROUPING);
} catch (NumberFormatException e) {
fCurrentGrouping= LevelTreeContentProvider.LEVEL_PACKAGE;
}
String encodedFilters= getSettings().get(KEY_FILTERS);
restoreFilters(encodedFilters);
if (memento != null) {
Integer value= memento.getInteger(KEY_GROUPING);
if (value != null)
fCurrentGrouping= value.intValue();
value= memento.getInteger(KEY_SORTING);
if (value != null)
fCurrentSortOrder= value.intValue();
encodedFilters= memento.getString(KEY_FILTERS);
restoreFilters(encodedFilters);
}
}
private void restoreFilters(String encodedFilters) {
if (encodedFilters != null) {
fMatchFilters.clear();
String[] decodedFilters= decodeFiltersString(encodedFilters);
for (int i= 0; i < decodedFilters.length; i++) {
MatchFilter filter= findMatchFilter(decodedFilters[i]);
if (filter != null)
fMatchFilters.add(filter);
}
}
updateFilterActions();
}
private MatchFilter findMatchFilter(String id) {
MatchFilter[] allFilters= MatchFilter.allFilters();
for (int i= 0; i < allFilters.length; i++) {
if (allFilters[i].getID().equals(id))
return allFilters[i];
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#saveState(org.eclipse.ui.IMemento)
*/
public void saveState(IMemento memento) {
super.saveState(memento);
memento.putInteger(KEY_GROUPING, fCurrentGrouping);
memento.putInteger(KEY_SORTING, fCurrentSortOrder);
memento.putString(KEY_FILTERS, encodeFilters());
}
void addMatchFilter(MatchFilter filter) {
fMatchFilters.add(filter);
filtersChanged();
}
void removeMatchFilter(MatchFilter filter) {
fMatchFilters.remove(filter);
filtersChanged();
}
private void filtersChanged() {
StructuredViewer viewer= getViewer();
JavaSearchContentProvider cp= (JavaSearchContentProvider) viewer.getContentProvider();
cp.filtersChanged(getMatchFilters());
updateFilterActions();
getViewPart().updateLabel();
getSettings().put(KEY_FILTERS, encodeFilters());
}
private void updateFilterActions() {
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i].updateCheckState();
}
getSite().getActionBars().updateActionBars();
getSite().getActionBars().getMenuManager().updateAll(true);
}
private String encodeFilters() {
StringBuffer buf= new StringBuffer();
MatchFilter[] enabledFilters= getMatchFilters();
buf.append(enabledFilters.length);
for (int i= 0; i < enabledFilters.length; i++) {
buf.append(';');
buf.append(enabledFilters[i].getID());
}
return buf.toString();
}
private String[] decodeFiltersString(String encodedString) {
StringTokenizer tokenizer= new StringTokenizer(encodedString, ";"); //$NON-NLS-1$
int count= Integer.valueOf(tokenizer.nextToken()).intValue();
String[] ids= new String[count];
for (int i= 0; i < count; i++) {
ids[i]= tokenizer.nextToken();
}
return ids;
}
boolean hasMatchFilter(MatchFilter filter) {
return fMatchFilters.contains(filter);
}
MatchFilter[] getMatchFilters() {
MatchFilter[] filters= new MatchFilter[fMatchFilters.size()];
return (MatchFilter[]) fMatchFilters.toArray(filters);
}
public int getDisplayedMatchCount(Object element) {
if (getMatchFilters().length == 0)
return super.getDisplayedMatchCount(element);
Match[] matches= super.getDisplayedMatches(element);
int count= 0;
for (int i= 0; i < matches.length; i++) {
if (!isFiltered(matches[i]))
count++;
}
return count;
}
public Match[] getDisplayedMatches(Object element) {
if (getMatchFilters().length == 0)
return super.getDisplayedMatches(element);
Match[] matches= super.getDisplayedMatches(element);
int count= 0;
for (int i= 0; i < matches.length; i++) {
if (isFiltered(matches[i]))
matches[i]= null;
else
count++;
}
Match[] filteredMatches= new Match[count];
int writeIndex= 0;
for (int i= 0; i < matches.length; i++) {
if (matches[i] != null)
filteredMatches[writeIndex++]= matches[i];
}
return filteredMatches;
}
private boolean isFiltered(Match match) {
MatchFilter[] filters= getMatchFilters();
for (int j= 0; j < filters.length; j++) {
if (filters[j].filters((JavaElementMatch) match))
return true;
}
return false;
}
public void setInput(ISearchResult search, Object viewState) {
updateFilterEnablement((JavaSearchResult)search);
super.setInput(search, viewState);
}
private void updateFilterEnablement(JavaSearchResult result) {
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i].setEnabled(shouldEnable(result, fFilterActions[i]));
}
}
private boolean shouldEnable(JavaSearchResult result, FilterAction filterAction) {
if (result == null) {
return false;
}
JavaSearchQuery query= (JavaSearchQuery) result.getQuery();
if (query == null)
return false;
return filterAction.getFilter().isApplicable(query);
}
private boolean isQueryRunning() {
AbstractTextSearchResult result= getInput();
if (result != null) {
return NewSearchUI.isQueryRunning(result.getQuery());
}
return false;
}
public String getLabel() {
String label= super.getLabel();
int matchFilterCount= getMatchFiltersCount();
if (matchFilterCount > 0) {
if (isQueryRunning()) {
String message= SearchMessages.getString("JavaSearchResultPage.filtered.message"); //$NON-NLS-1$
return MessageFormat.format(message, new Object[] { label });
} else {
String message= SearchMessages.getString("JavaSearchResultPage.filteredWithCount.message"); //$NON-NLS-1$
return MessageFormat.format(message, new Object[] { label, new Integer(getFilteredMatchCount()) });
}
}
return label;
}
private int getMatchFiltersCount() {
MatchFilter[] filters= getMatchFilters();
AbstractTextSearchResult result= getInput();
if (result == null)
return 0;
int filterCount= 0;
for (int i= 0; i < filters.length; i++) {
if (filters[i].isApplicable((JavaSearchQuery) result.getQuery()))
filterCount++;
}
return filterCount;
}
private int getFilteredMatchCount() {
AbstractTextSearchResult result= getInput();
if (result == null)
return 0;
Object[] elements= result.getElements();
int count= 0;
for (int i= 0; i < elements.length; i++) {
count+= getDisplayedMatchCount(elements[i]);
}
return count;
}
}
|
60,117
|
Bug 60117 [Viewers] Need a DeferredTableContentProvider
|
eclipse-SDK-I20040427-win32.zip 1. Perform a search & display the results with the flat layout 2. Now sort the results by 'Parent Name'... notice the type names do not come first 2. Switch to the hierarchical layout, then back to the flat - now the type names are first
|
verified fixed
|
b1845d2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T15:06:59Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultPage.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.viewsupport.ProblemTableViewer;
import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer;
import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.ISearchResultViewPart;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.texteditor.ITextEditor;
public class JavaSearchResultPage extends AbstractTextSearchViewPage {
private static final String KEY_GROUPING= "org.eclipse.jdt.search.resultpage.grouping"; //$NON-NLS-1$
private static final String KEY_SORTING= "org.eclipse.jdt.search.resultpage.sorting"; //$NON-NLS-1$
private static final String KEY_FILTERS= "org.eclipse.jdt.search.resultpage.filters"; //$NON-NLS-1$
private static final String GROUP_GROUPING= "org.eclipse.jdt.search.resultpage.grouping"; //$NON-NLS-1$
private NewSearchViewActionGroup fActionGroup;
private JavaSearchContentProvider fContentProvider;
private int fCurrentSortOrder;
private SortAction fSortByNameAction;
private SortAction fSortByParentName;
private SortAction fSortByPathAction;
private GroupAction fGroupTypeAction;
private GroupAction fGroupFileAction;
private GroupAction fGroupPackageAction;
private GroupAction fGroupProjectAction;
private int fCurrentGrouping;
private Set fMatchFilters= new HashSet();
private FilterAction[] fFilterActions;
public JavaSearchResultPage() {
initSortActions();
initGroupingActions();
initFilterActions();
}
private void initFilterActions() {
MatchFilter[] allFilters= MatchFilter.allFilters();
fFilterActions= new FilterAction[allFilters.length];
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i]= new FilterAction(this, allFilters[i]);
}
}
private void initSortActions() {
fSortByNameAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByName"), this, SortingLabelProvider.SHOW_ELEMENT_CONTAINER); //$NON-NLS-1$
fSortByPathAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByPath"), this, SortingLabelProvider.SHOW_PATH); //$NON-NLS-1$
fSortByParentName= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByParentName"), this, SortingLabelProvider.SHOW_CONTAINER_ELEMENT); //$NON-NLS-1$
}
private void initGroupingActions() {
fGroupProjectAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_project"), SearchMessages.getString("JavaSearchResultPage.groupby_project.tooltip"), this, LevelTreeContentProvider.LEVEL_PROJECT); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupProjectAction, "prj_mode.gif"); //$NON-NLS-1$
fGroupPackageAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_package"), SearchMessages.getString("JavaSearchResultPage.groupby_package.tooltip"), this, LevelTreeContentProvider.LEVEL_PACKAGE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupPackageAction, "package_mode.gif"); //$NON-NLS-1$
fGroupFileAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_file"), SearchMessages.getString("JavaSearchResultPage.groupby_file.tooltip"), this, LevelTreeContentProvider.LEVEL_FILE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupFileAction, "file_mode.gif"); //$NON-NLS-1$
fGroupTypeAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_type"), SearchMessages.getString("JavaSearchResultPage.groupby_type.tooltip"), this, LevelTreeContentProvider.LEVEL_TYPE); //$NON-NLS-1$ //$NON-NLS-2$
JavaPluginImages.setLocalImageDescriptors(fGroupTypeAction, "type_mode.gif"); //$NON-NLS-1$
}
public void setViewPart(ISearchResultViewPart part) {
super.setViewPart(part);
fActionGroup= new NewSearchViewActionGroup(part);
}
public void showMatch(Match match, int offset, int length) throws PartInitException {
IEditorPart editor= null;
Object element= match.getElement();
if (element instanceof IJavaElement) {
IJavaElement javaElement= (IJavaElement) element;
try {
editor= EditorUtility.openInEditor(javaElement, false);
} catch (PartInitException e1) {
return;
} catch (JavaModelException e1) {
return;
}
} else if (element instanceof IFile) {
editor= IDE.openEditor(JavaPlugin.getActivePage(), (IFile) element, false);
}
if (editor instanceof ITextEditor) {
ITextEditor textEditor= (ITextEditor) editor;
textEditor.selectAndReveal(offset, length);
} else if (editor != null){
if (element instanceof IFile) {
IFile file= (IFile) element;
showWithMarker(editor, file, offset, length);
}
} else {
JavaSearchResult result= (JavaSearchResult) getInput();
IMatchPresentation participant= result.getSearchParticpant(element);
if (participant != null)
participant.showMatch(match, offset, length);
}
}
private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
try {
IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER);
HashMap attributes= new HashMap(4);
attributes.put(IMarker.CHAR_START, new Integer(offset));
attributes.put(IMarker.CHAR_END, new Integer(offset + length));
marker.setAttributes(attributes);
IDE.gotoMarker(editor, marker);
marker.delete();
} catch (CoreException e) {
throw new PartInitException(SearchMessages.getString("JavaSearchResultPage.error.marker"), e); //$NON-NLS-1$
}
}
protected void fillContextMenu(IMenuManager mgr) {
super.fillContextMenu(mgr);
addSortActions(mgr);
fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
fActionGroup.fillContextMenu(mgr);
}
private void addFilterActions(IMenuManager viewMenu) {
String filteringGroup= "Filtering"; //$NON-NLS-1$
viewMenu.add(new Separator(filteringGroup));
MenuManager mgr= new MenuManager(SearchMessages.getString("JavaSearchResultPage.filter.submenu")); //$NON-NLS-1$
for (int i= 0; i < fFilterActions.length; i++) {
mgr.add(fFilterActions[i]);
}
viewMenu.appendToGroup(filteringGroup, mgr);
}
private void addSortActions(IMenuManager mgr) {
if (getLayout() != FLAG_LAYOUT_FLAT)
return;
MenuManager sortMenu= new MenuManager(SearchMessages.getString("JavaSearchResultPage.sortBylabel")); //$NON-NLS-1$
sortMenu.add(fSortByNameAction);
sortMenu.add(fSortByPathAction);
sortMenu.add(fSortByParentName);
fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder());
fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder());
fSortByParentName.setChecked(fCurrentSortOrder == fSortByParentName.getSortOrder());
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
}
protected void fillToolbar(IToolBarManager tbm) {
super.fillToolbar(tbm);
if (getLayout() != FLAG_LAYOUT_FLAT)
addGroupActions(tbm);
}
private void addGroupActions(IToolBarManager mgr) {
mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, new Separator(GROUP_GROUPING));
mgr.appendToGroup(GROUP_GROUPING, fGroupProjectAction);
mgr.appendToGroup(GROUP_GROUPING, fGroupPackageAction);
mgr.appendToGroup(GROUP_GROUPING, fGroupFileAction);
mgr.appendToGroup(GROUP_GROUPING, fGroupTypeAction);
updateGroupingActions();
}
private void updateGroupingActions() {
fGroupProjectAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PROJECT);
fGroupPackageAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PACKAGE);
fGroupFileAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_FILE);
fGroupTypeAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_TYPE);
}
public void dispose() {
fActionGroup.dispose();
super.dispose();
}
protected void elementsChanged(Object[] objects) {
if (fContentProvider != null)
fContentProvider.elementsChanged(objects);
}
protected void clear() {
if (fContentProvider != null)
fContentProvider.clear();
}
protected void configureTableViewer(TableViewer viewer) {
viewer.setLabelProvider(new DecoratingLabelProvider(new SortingLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
fContentProvider=new JavaSearchTableContentProvider(this);
viewer.setContentProvider(fContentProvider);
setSortOrder(fCurrentSortOrder);
}
protected void configureTreeViewer(TreeViewer viewer) {
viewer.setSorter(new ViewerSorter());
viewer.setLabelProvider(new DecoratingLabelProvider(new PostfixLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping);
viewer.setContentProvider(fContentProvider);
}
protected TreeViewer createTreeViewer(Composite parent) {
return new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
protected TableViewer createTableViewer(Composite parent) {
return new ProblemTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
void setSortOrder(int order) {
fCurrentSortOrder= order;
StructuredViewer viewer= getViewer();
viewer.getControl().setRedraw(false);
DecoratingLabelProvider dlp= (DecoratingLabelProvider) viewer.getLabelProvider();
((SortingLabelProvider)dlp.getLabelProvider()).setOrder(order);
if (order == SortingLabelProvider.SHOW_ELEMENT_CONTAINER) {
viewer.setSorter(new NameSorter());
} else if (order == SortingLabelProvider.SHOW_PATH) {
viewer.setSorter(new PathSorter());
} else
viewer.setSorter(new ParentSorter());
viewer.getControl().setRedraw(true);
getSettings().put(KEY_SORTING, fCurrentSortOrder);
}
public void init(IPageSite site) {
super.init(site);
fActionGroup.fillActionBars(site.getActionBars());
addFilterActions(site.getActionBars().getMenuManager());
}
/**
* Precondition here: the viewer must be showing a tree with a LevelContentProvider.
* @param order
*/
void setGrouping(int grouping) {
fCurrentGrouping= grouping;
StructuredViewer viewer= getViewer();
LevelTreeContentProvider cp= (LevelTreeContentProvider) viewer.getContentProvider();
cp.setLevel(grouping);
updateGroupingActions();
getSettings().put(KEY_GROUPING, fCurrentGrouping);
}
protected StructuredViewer getViewer() {
// override so that it's visible in the package.
return super.getViewer();
}
/* (non-Javadoc)
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#restoreState(org.eclipse.ui.IMemento)
*/
public void restoreState(IMemento memento) {
super.restoreState(memento);
try {
fCurrentSortOrder= getSettings().getInt(KEY_SORTING);
} catch (NumberFormatException e) {
fCurrentSortOrder= SortingLabelProvider.SHOW_ELEMENT_CONTAINER;
}
try {
fCurrentGrouping= getSettings().getInt(KEY_GROUPING);
} catch (NumberFormatException e) {
fCurrentGrouping= LevelTreeContentProvider.LEVEL_PACKAGE;
}
String encodedFilters= getSettings().get(KEY_FILTERS);
restoreFilters(encodedFilters);
if (memento != null) {
Integer value= memento.getInteger(KEY_GROUPING);
if (value != null)
fCurrentGrouping= value.intValue();
value= memento.getInteger(KEY_SORTING);
if (value != null)
fCurrentSortOrder= value.intValue();
encodedFilters= memento.getString(KEY_FILTERS);
restoreFilters(encodedFilters);
}
}
private void restoreFilters(String encodedFilters) {
if (encodedFilters != null) {
fMatchFilters.clear();
String[] decodedFilters= decodeFiltersString(encodedFilters);
for (int i= 0; i < decodedFilters.length; i++) {
MatchFilter filter= findMatchFilter(decodedFilters[i]);
if (filter != null)
fMatchFilters.add(filter);
}
}
updateFilterActions();
}
private MatchFilter findMatchFilter(String id) {
MatchFilter[] allFilters= MatchFilter.allFilters();
for (int i= 0; i < allFilters.length; i++) {
if (allFilters[i].getID().equals(id))
return allFilters[i];
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#saveState(org.eclipse.ui.IMemento)
*/
public void saveState(IMemento memento) {
super.saveState(memento);
memento.putInteger(KEY_GROUPING, fCurrentGrouping);
memento.putInteger(KEY_SORTING, fCurrentSortOrder);
memento.putString(KEY_FILTERS, encodeFilters());
}
void addMatchFilter(MatchFilter filter) {
fMatchFilters.add(filter);
filtersChanged();
}
void removeMatchFilter(MatchFilter filter) {
fMatchFilters.remove(filter);
filtersChanged();
}
private void filtersChanged() {
StructuredViewer viewer= getViewer();
JavaSearchContentProvider cp= (JavaSearchContentProvider) viewer.getContentProvider();
cp.filtersChanged(getMatchFilters());
updateFilterActions();
getViewPart().updateLabel();
getSettings().put(KEY_FILTERS, encodeFilters());
}
private void updateFilterActions() {
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i].updateCheckState();
}
getSite().getActionBars().updateActionBars();
getSite().getActionBars().getMenuManager().updateAll(true);
}
private String encodeFilters() {
StringBuffer buf= new StringBuffer();
MatchFilter[] enabledFilters= getMatchFilters();
buf.append(enabledFilters.length);
for (int i= 0; i < enabledFilters.length; i++) {
buf.append(';');
buf.append(enabledFilters[i].getID());
}
return buf.toString();
}
private String[] decodeFiltersString(String encodedString) {
StringTokenizer tokenizer= new StringTokenizer(encodedString, ";"); //$NON-NLS-1$
int count= Integer.valueOf(tokenizer.nextToken()).intValue();
String[] ids= new String[count];
for (int i= 0; i < count; i++) {
ids[i]= tokenizer.nextToken();
}
return ids;
}
boolean hasMatchFilter(MatchFilter filter) {
return fMatchFilters.contains(filter);
}
MatchFilter[] getMatchFilters() {
MatchFilter[] filters= new MatchFilter[fMatchFilters.size()];
return (MatchFilter[]) fMatchFilters.toArray(filters);
}
public int getDisplayedMatchCount(Object element) {
if (getMatchFilters().length == 0)
return super.getDisplayedMatchCount(element);
Match[] matches= super.getDisplayedMatches(element);
int count= 0;
for (int i= 0; i < matches.length; i++) {
if (!isFiltered(matches[i]))
count++;
}
return count;
}
public Match[] getDisplayedMatches(Object element) {
if (getMatchFilters().length == 0)
return super.getDisplayedMatches(element);
Match[] matches= super.getDisplayedMatches(element);
int count= 0;
for (int i= 0; i < matches.length; i++) {
if (isFiltered(matches[i]))
matches[i]= null;
else
count++;
}
Match[] filteredMatches= new Match[count];
int writeIndex= 0;
for (int i= 0; i < matches.length; i++) {
if (matches[i] != null)
filteredMatches[writeIndex++]= matches[i];
}
return filteredMatches;
}
private boolean isFiltered(Match match) {
MatchFilter[] filters= getMatchFilters();
for (int j= 0; j < filters.length; j++) {
if (filters[j].filters((JavaElementMatch) match))
return true;
}
return false;
}
public void setInput(ISearchResult search, Object viewState) {
updateFilterEnablement((JavaSearchResult)search);
super.setInput(search, viewState);
}
private void updateFilterEnablement(JavaSearchResult result) {
for (int i= 0; i < fFilterActions.length; i++) {
fFilterActions[i].setEnabled(shouldEnable(result, fFilterActions[i]));
}
}
private boolean shouldEnable(JavaSearchResult result, FilterAction filterAction) {
if (result == null) {
return false;
}
JavaSearchQuery query= (JavaSearchQuery) result.getQuery();
if (query == null)
return false;
return filterAction.getFilter().isApplicable(query);
}
private boolean isQueryRunning() {
AbstractTextSearchResult result= getInput();
if (result != null) {
return NewSearchUI.isQueryRunning(result.getQuery());
}
return false;
}
public String getLabel() {
String label= super.getLabel();
int matchFilterCount= getMatchFiltersCount();
if (matchFilterCount > 0) {
if (isQueryRunning()) {
String message= SearchMessages.getString("JavaSearchResultPage.filtered.message"); //$NON-NLS-1$
return MessageFormat.format(message, new Object[] { label });
} else {
String message= SearchMessages.getString("JavaSearchResultPage.filteredWithCount.message"); //$NON-NLS-1$
return MessageFormat.format(message, new Object[] { label, new Integer(getFilteredMatchCount()) });
}
}
return label;
}
private int getMatchFiltersCount() {
MatchFilter[] filters= getMatchFilters();
AbstractTextSearchResult result= getInput();
if (result == null)
return 0;
int filterCount= 0;
for (int i= 0; i < filters.length; i++) {
if (filters[i].isApplicable((JavaSearchQuery) result.getQuery()))
filterCount++;
}
return filterCount;
}
private int getFilteredMatchCount() {
AbstractTextSearchResult result= getInput();
if (result == null)
return 0;
Object[] elements= result.getElements();
int count= 0;
for (int i= 0; i < elements.length; i++) {
count+= getDisplayedMatchCount(elements[i]);
}
return count;
}
}
|
60,117
|
Bug 60117 [Viewers] Need a DeferredTableContentProvider
|
eclipse-SDK-I20040427-win32.zip 1. Perform a search & display the results with the flat layout 2. Now sort the results by 'Parent Name'... notice the type names do not come first 2. Switch to the hierarchical layout, then back to the flat - now the type names are first
|
verified fixed
|
b1845d2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T15:06:59Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchTableContentProvider.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.TableViewer;
public class JavaSearchTableContentProvider extends JavaSearchContentProvider implements IStructuredContentProvider {
public JavaSearchTableContentProvider(JavaSearchResultPage page) {
super(page);
}
public Object[] getElements(Object inputElement) {
if (inputElement instanceof JavaSearchResult) {
Set filteredElements= new HashSet();
Object[] rawElements= ((JavaSearchResult)inputElement).getElements();
for (int i= 0; i < rawElements.length; i++) {
if (getPage().getDisplayedMatchCount(rawElements[i]) > 0)
filteredElements.add(rawElements[i]);
}
return filteredElements.toArray();
}
return EMPTY_ARR;
}
public void elementsChanged(Object[] updatedElements) {
if (fResult == null)
return;
int addCount= 0;
int removeCount= 0;
TableViewer viewer= (TableViewer) getPage().getViewer();
for (int i= 0; i < updatedElements.length; i++) {
if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0) {
if (viewer.testFindItem(updatedElements[i]) != null)
viewer.refresh(updatedElements[i]);
else
viewer.add(updatedElements[i]);
addCount++;
} else {
viewer.remove(updatedElements[i]);
removeCount++;
}
}
}
public void filtersChanged(MatchFilter[] filters) {
super.filtersChanged(filters);
getPage().getViewer().refresh();
}
public void clear() {
getPage().getViewer().refresh();
}
}
|
60,117
|
Bug 60117 [Viewers] Need a DeferredTableContentProvider
|
eclipse-SDK-I20040427-win32.zip 1. Perform a search & display the results with the flat layout 2. Now sort the results by 'Parent Name'... notice the type names do not come first 2. Switch to the hierarchical layout, then back to the flat - now the type names are first
|
verified fixed
|
b1845d2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T15:06:59Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/NameSorter.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
public class NameSorter extends ViewerSorter {
public int compare(Viewer viewer, Object e1, Object e2) {
String property1= getProperty(e1);
String property2= getProperty(e2);
return collator.compare(property1, property2);
}
protected String getProperty(Object element) {
if (element instanceof IJavaElement)
return ((IJavaElement)element).getElementName();
if (element instanceof IResource)
return ((IResource)element).getName();
return ""; //$NON-NLS-1$
}
public boolean isSorterProperty(Object element, String property) {
return true;
}
}
|
60,117
|
Bug 60117 [Viewers] Need a DeferredTableContentProvider
|
eclipse-SDK-I20040427-win32.zip 1. Perform a search & display the results with the flat layout 2. Now sort the results by 'Parent Name'... notice the type names do not come first 2. Switch to the hierarchical layout, then back to the flat - now the type names are first
|
verified fixed
|
b1845d2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T15:06:59Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchLabelProvider.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jdt.ui.ProblemsLabelDecorator;
import org.eclipse.jdt.ui.search.IMatchPresentation;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.internal.ui.SearchPreferencePage;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.Match;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
public abstract class SearchLabelProvider extends LabelProvider implements IColorProvider, IPropertyChangeListener {
private Color fPotentialMatchFgColor;
private Map fLabelProviderMap;
protected JavaSearchResultPage fPage;
private AppearanceAwareLabelProvider fLabelProvider;
public SearchLabelProvider(JavaSearchResultPage page, AppearanceAwareLabelProvider inner) {
fPage= page;
fLabelProvider= inner;
fLabelProviderMap= new HashMap(5);
fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator());
SearchPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
public void propertyChange(PropertyChangeEvent event) {
if (fPotentialMatchFgColor == null)
return;
if (SearchPreferencePage.POTENTIAL_MATCH_FG_COLOR.equals(event.getProperty()) || SearchPreferencePage.EMPHASIZE_POTENTIAL_MATCHES.equals(event.getProperty())) {
fPotentialMatchFgColor.dispose();
fPotentialMatchFgColor= null;
LabelProviderChangedEvent lpEvent= new LabelProviderChangedEvent(SearchLabelProvider.this, null); // refresh all
fireLabelProviderChanged(lpEvent);
}
}
public AppearanceAwareLabelProvider getLabelProvider() {
return fLabelProvider;
}
public Color getForeground(Object element) {
if (SearchPreferencePage.arePotentialMatchesEmphasized()) {
if (hasPotentialMatches(element))
return getForegroundColor();
}
if (fLabelProvider != null)
return fLabelProvider.getForeground(element);
return null;
}
protected boolean hasPotentialMatches(Object element) {
AbstractTextSearchResult result= fPage.getInput();
if (result != null) {
Match[] matches= result.getMatches(element);
for (int i = 0; i < matches.length; i++) {
if ((matches[i]) instanceof JavaElementMatch) {
if (((JavaElementMatch)matches[i]).getAccuracy() == SearchMatch.A_INACCURATE)
return true;
}
}
}
return false;
}
public Color getBackground(Object element) {
if (fLabelProvider != null)
return fLabelProvider.getBackground(element);
return null;
}
private Color getForegroundColor() {
if (fPotentialMatchFgColor == null) {
fPotentialMatchFgColor= new Color(JavaPlugin.getActiveWorkbenchShell().getDisplay(), SearchPreferencePage.getPotentialMatchForegroundColor());
}
return fPotentialMatchFgColor;
}
public void dispose() {
if (fPotentialMatchFgColor != null) {
fPotentialMatchFgColor.dispose();
}
SearchPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
fLabelProvider.dispose();
for (Iterator labelProviders = fLabelProviderMap.values().iterator(); labelProviders.hasNext();) {
ILabelProvider labelProvider = (ILabelProvider) labelProviders.next();
labelProvider.dispose();
}
super.dispose();
}
public void addListener(ILabelProviderListener listener) {
super.addListener(listener);
getLabelProvider().addListener(listener);
}
public boolean isLabelProperty(Object element, String property) {
return getLabelProvider().isLabelProperty(element, property);
}
public void removeListener(ILabelProviderListener listener) {
super.removeListener(listener);
getLabelProvider().removeListener(listener);
}
protected String getParticipantText(Object element) {
ILabelProvider labelProvider= getLabelProvider(element);
if (labelProvider != null)
return labelProvider.getText(element);
return ""; //$NON-NLS-1$
}
protected Image getParticipantImage(Object element) {
ILabelProvider lp= getLabelProvider(element);
if (lp == null)
return null;
return lp.getImage(element);
}
private ILabelProvider getLabelProvider(Object element) {
IMatchPresentation participant= ((JavaSearchResult)fPage.getInput()).getSearchParticpant(element);
if (participant == null)
return null;
ILabelProvider lp= (ILabelProvider) fLabelProviderMap.get(participant);
if (lp == null) {
lp= participant.createLabelProvider();
fLabelProviderMap.put(participant, lp);
}
return lp;
}
}
|
60,117
|
Bug 60117 [Viewers] Need a DeferredTableContentProvider
|
eclipse-SDK-I20040427-win32.zip 1. Perform a search & display the results with the flat layout 2. Now sort the results by 'Parent Name'... notice the type names do not come first 2. Switch to the hierarchical layout, then back to the flat - now the type names are first
|
verified fixed
|
b1845d2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-03T15:06:59Z
| 2004-04-27T15:33:20Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SortAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.search;
import org.eclipse.jface.action.Action;
public class SortAction extends Action {
private int fSortOrder;
private JavaSearchResultPage fPage;
public SortAction(String label, JavaSearchResultPage page, int sortOrder) {
super(label);
fPage= page;
fSortOrder= sortOrder;
}
public void run() {
fPage.setSortOrder(fSortOrder);
}
public int getSortOrder() {
return fSortOrder;
}
}
|
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test38/in/A.java
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui.tests.refactoring/resources/RenameVirtualMethodInClass/test38/out/A.java
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui.tests.refactoring/test
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
cases/org/eclipse/jdt/ui/tests/refactoring/RenamePrivateMethodTests.java
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui.tests.refactoring/test
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
cases/org/eclipse/jdt/ui/tests/refactoring/RenameVirtualMethodInClassTests.java
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui/core
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameMethodProcessor.java
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
org.eclipse.jdt.ui/core
| |
54,457
|
Bug 54457 Rename Refactoring: Wrong warning: another name shadows [refactoring]
|
20040311 Selfhosting workspace with extra plugin org.eclipse.jdt.rewrite (from SNZ rep) Rename NewASTRewrite.createCopyPlaceholder Afor all references an error is created: 'Another name shadows access to the renamed element' Thsi makes no sense here: There is only one createCopyPlaceholder in the class and also the new name is not used. What could be the problem is that I have two projects with class NewASTRewrite. The two projects are unrelated, however.
|
resolved fixed
|
9c46655
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T06:49:11Z
| 2004-03-11T13:00:00Z
|
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RippleMethodFinder.java
| |
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.actions.CCPActionGroup;
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
import org.eclipse.jdt.ui.actions.OpenEditorActionGroup;
import org.eclipse.jdt.ui.actions.OpenViewActionGroup;
import org.eclipse.jdt.ui.actions.RefactorActionGroup;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter;
import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter;
import org.eclipse.jdt.internal.ui.dnd.LocalSelectionTransfer;
import org.eclipse.jdt.internal.ui.dnd.TransferDragSourceListener;
import org.eclipse.jdt.internal.ui.dnd.TransferDropTargetListener;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy;
import org.eclipse.jdt.internal.corext.callhierarchy.CallLocation;
import org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper;
/**
* This is the main view for the callers plugin. It builds a tree of callers/callees
* and allows the user to double click an entry to go to the selected method.
*
*/
public class CallHierarchyViewPart extends ViewPart implements ICallHierarchyViewPart,
ISelectionChangedListener {
private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$
private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$
private static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$
private static final String TAG_CALL_MODE = "call_mode"; //$NON-NLS-1$
private static final String TAG_RATIO = "ratio"; //$NON-NLS-1$
static final int VIEW_ORIENTATION_VERTICAL = 0;
static final int VIEW_ORIENTATION_HORIZONTAL = 1;
static final int VIEW_ORIENTATION_SINGLE = 2;
static final int VIEW_ORIENTATION_AUTOMATIC = 3;
static final int CALL_MODE_CALLERS = 0;
static final int CALL_MODE_CALLEES = 1;
static final String GROUP_SEARCH_SCOPE = "MENU_SEARCH_SCOPE"; //$NON-NLS-1$
static final String ID_CALL_HIERARCHY = "org.eclipse.jdt.callhierarchy.view"; //$NON-NLS-1$
private static final String GROUP_FOCUS = "group.focus"; //$NON-NLS-1$
private static final int PAGE_EMPTY = 0;
private static final int PAGE_VIEWER = 1;
private Label fNoHierarchyShownLabel;
private PageBook fPagebook;
private IDialogSettings fDialogSettings;
private int fCurrentOrientation;
int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
private int fCurrentCallMode;
private MethodWrapper fCalleeRoot;
private MethodWrapper fCallerRoot;
private IMemento fMemento;
private IMethod fShownMethod;
private SelectionProviderMediator fSelectionProviderMediator;
private List fMethodHistory;
private LocationViewer fLocationViewer;
private SashForm fHierarchyLocationSplitter;
private Clipboard fClipboard;
private SearchScopeActionGroup fSearchScopeActions;
private ToggleOrientationAction[] fToggleOrientationActions;
private ToggleCallModeAction[] fToggleCallModeActions;
private CallHierarchyFiltersActionGroup fFiltersActionGroup;
private HistoryDropDownAction fHistoryDropDownAction;
private RefreshAction fRefreshAction;
private OpenLocationAction fOpenLocationAction;
private FocusOnSelectionAction fFocusOnSelectionAction;
private CopyCallHierarchyAction fCopyAction;
private CancelSearchAction fCancelSearchAction;
private CompositeActionGroup fActionGroups;
private CallHierarchyViewer fCallHierarchyViewer;
private boolean fShowCallDetails;
protected Composite fParent;
public CallHierarchyViewPart() {
super();
fDialogSettings = JavaPlugin.getDefault().getDialogSettings();
fMethodHistory = new ArrayList();
}
public void setFocus() {
fPagebook.setFocus();
}
/**
* Sets the history entries
*/
public void setHistoryEntries(IMethod[] elems) {
fMethodHistory.clear();
for (int i = 0; i < elems.length; i++) {
fMethodHistory.add(elems[i]);
}
updateHistoryEntries();
}
/**
* Gets all history entries.
*/
public IMethod[] getHistoryEntries() {
if (fMethodHistory.size() > 0) {
updateHistoryEntries();
}
return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]);
}
/**
* Method setMethod.
* @param method
*/
public void setMethod(IMethod method) {
if (method == null) {
showPage(PAGE_EMPTY);
return;
}
if ((method != null) && !method.equals(fShownMethod)) {
addHistoryEntry(method);
}
this.fShownMethod = method;
refresh();
}
public IMethod getMethod() {
return fShownMethod;
}
public MethodWrapper getCurrentMethodWrapper() {
if (fCurrentCallMode == CALL_MODE_CALLERS) {
return fCallerRoot;
} else {
return fCalleeRoot;
}
}
/**
* called from ToggleOrientationAction.
* @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
*/
void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed() &&
(fHierarchyLocationSplitter != null) &&
!fHierarchyLocationSplitter.isDisposed()) {
if (orientation == VIEW_ORIENTATION_SINGLE) {
setShowCallDetails(false);
} else {
if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
setShowCallDetails(true);
}
boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL;
fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL
: SWT.VERTICAL);
}
fHierarchyLocationSplitter.layout();
}
updateCheckedState();
fCurrentOrientation = orientation;
fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
}
}
private void updateCheckedState() {
for (int i= 0; i < fToggleOrientationActions.length; i++) {
fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
}
}
/**
* called from ToggleCallModeAction.
* @param orientation CALL_MODE_CALLERS or CALL_MODE_CALLEES
*/
void setCallMode(int mode) {
if (fCurrentCallMode != mode) {
for (int i = 0; i < fToggleCallModeActions.length; i++) {
fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode());
}
fCurrentCallMode = mode;
fDialogSettings.put(DIALOGSTORE_CALL_MODE, mode);
updateView();
}
}
public IJavaSearchScope getSearchScope() {
return fSearchScopeActions.getSearchScope();
}
public void setShowCallDetails(boolean show) {
fShowCallDetails = show;
showOrHideCallDetailsView();
}
private void initDragAndDrop() {
Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
addDragAdapters(fCallHierarchyViewer, ops, transfers);
addDropAdapters(fCallHierarchyViewer, ops | DND.DROP_DEFAULT, transfers);
addDropAdapters(fLocationViewer, ops | DND.DROP_DEFAULT, transfers);
//dnd on empty hierarchy
DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT);
dropTarget.setTransfer(transfers);
dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer));
}
private void addDropAdapters(StructuredViewer viewer, int ops, Transfer[] transfers){
TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
new CallHierarchyTransferDropAdapter(this, viewer)
};
viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
}
private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) {
TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
new SelectionTransferDragAdapter(viewer)
};
viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners));
}
public void createPartControl(Composite parent) {
fParent= parent;
addResizeListener(parent);
fPagebook = new PageBook(parent, SWT.NONE);
// Page 1: Viewers
createHierarchyLocationSplitter(fPagebook);
createCallHierarchyViewer(fHierarchyLocationSplitter);
createLocationViewer(fHierarchyLocationSplitter);
// Page 2: Nothing selected
fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(CallHierarchyMessages.getString(
"CallHierarchyViewPart.empty")); //$NON-NLS-1$
initDragAndDrop();
showPage(PAGE_EMPTY);
WorkbenchHelp.setHelp(fPagebook, IJavaHelpContextIds.CALL_HIERARCHY_VIEW);
fSelectionProviderMediator = new SelectionProviderMediator(new Viewer[] {
fCallHierarchyViewer, fLocationViewer
});
IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager();
fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
getSite().setSelectionProvider(fSelectionProviderMediator);
fClipboard= new Clipboard(parent.getDisplay());
makeActions();
fillViewMenu();
fillActionBars();
initOrientation();
initCallMode();
if (fMemento != null) {
restoreState(fMemento);
}
}
private void addResizeListener(Composite parent) {
parent.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
computeOrientation();
}
});
}
void computeOrientation() {
if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
setOrientation(fOrientation);
}
else {
if (fOrientation == VIEW_ORIENTATION_SINGLE)
return;
Point size= fParent.getSize();
if (size.x != 0 && size.y != 0) {
if (size.x > size.y)
setOrientation(VIEW_ORIENTATION_HORIZONTAL);
else
setOrientation(VIEW_ORIENTATION_VERTICAL);
}
}
}
/**
* @param PAGE_EMPTY
*/
private void showPage(int page) {
if (page == PAGE_EMPTY) {
fPagebook.showPage(fNoHierarchyShownLabel);
} else {
fPagebook.showPage(fHierarchyLocationSplitter);
}
}
/**
* Restores the type hierarchy settings from a memento.
*/
private void restoreState(IMemento memento) {
Integer orientation= memento.getInteger(TAG_ORIENTATION);
if (orientation != null) {
fOrientation= orientation.intValue();
}
computeOrientation();
updateCheckedState();
Integer callMode= memento.getInteger(TAG_CALL_MODE);
if (callMode != null) {
setCallMode(callMode.intValue());
}
Integer ratio = memento.getInteger(TAG_RATIO);
if (ratio != null) {
fHierarchyLocationSplitter.setWeights(new int[] {
ratio.intValue(), 1000 - ratio.intValue()
});
}
fSearchScopeActions.restoreState(memento);
}
private void initCallMode() {
int mode;
try {
mode = fDialogSettings.getInt(DIALOGSTORE_CALL_MODE);
if ((mode < 0) || (mode > 1)) {
mode = CALL_MODE_CALLERS;
}
} catch (NumberFormatException e) {
mode = CALL_MODE_CALLERS;
}
// force the update
fCurrentCallMode = -1;
// will fill the main tool bar
setCallMode(mode);
}
private void initOrientation() {
try {
fOrientation = fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION);
if ((fOrientation < 0) || (fOrientation > 3)) {
fOrientation = VIEW_ORIENTATION_AUTOMATIC;
}
} catch (NumberFormatException e) {
fOrientation = VIEW_ORIENTATION_AUTOMATIC;
}
// force the update
fCurrentOrientation = -1;
setOrientation(fOrientation);
}
private void fillViewMenu() {
IActionBars actionBars = getViewSite().getActionBars();
IMenuManager viewMenu = actionBars.getMenuManager();
viewMenu.add(new Separator());
for (int i = 0; i < fToggleCallModeActions.length; i++) {
viewMenu.add(fToggleCallModeActions[i]);
}
viewMenu.add(new Separator());
for (int i = 0; i < fToggleOrientationActions.length; i++) {
viewMenu.add(fToggleOrientationActions[i]);
}
}
/**
*
*/
public void dispose() {
if (fActionGroups != null)
fActionGroups.dispose();
if (fClipboard != null)
fClipboard.dispose();
super.dispose();
}
/**
* Goes to the selected entry, without updating the order of history entries.
*/
public void gotoHistoryEntry(IMethod entry) {
if (fMethodHistory.contains(entry)) {
setMethod(entry);
}
}
/* (non-Javadoc)
* Method declared on IViewPart.
*/
public void init(IViewSite site, IMemento memento)
throws PartInitException {
super.init(site, memento);
fMemento = memento;
}
/**
*
*/
public void refresh() {
setCalleeRoot(null);
setCallerRoot(null);
updateView();
}
public void saveState(IMemento memento) {
if (fPagebook == null) {
// part has not been created
if (fMemento != null) { //Keep the old state;
memento.putMemento(fMemento);
}
return;
}
memento.putInteger(TAG_CALL_MODE, fCurrentCallMode);
memento.putInteger(TAG_ORIENTATION, fOrientation);
int[] weigths = fHierarchyLocationSplitter.getWeights();
int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
fSearchScopeActions.saveState(memento);
}
public void selectionChanged(SelectionChangedEvent e) {
if (e.getSelectionProvider() == fCallHierarchyViewer) {
methodSelectionChanged(e.getSelection());
}
}
/**
* @param selection
*/
private void methodSelectionChanged(ISelection selection) {
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
if (selectedElement instanceof MethodWrapper) {
MethodWrapper methodWrapper = (MethodWrapper) selectedElement;
revealElementInEditor(methodWrapper, fCallHierarchyViewer);
updateLocationsView(methodWrapper);
} else {
updateLocationsView(null);
}
}
}
private void revealElementInEditor(Object elem, Viewer originViewer) {
// only allow revealing when the type hierarchy is the active pagae
// no revealing after selection events due to model changes
if (getSite().getPage().getActivePart() != this) {
return;
}
if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
return;
}
if (elem instanceof MethodWrapper) {
CallLocation callLocation = CallHierarchy.getCallLocation(elem);
if (callLocation != null) {
IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation);
if (editorPart != null) {
getSite().getPage().bringToTop(editorPart);
if (editorPart instanceof ITextEditor) {
ITextEditor editor = (ITextEditor) editorPart;
editor.selectAndReveal(callLocation.getStart(),
(callLocation.getEnd() - callLocation.getStart()));
}
}
} else {
IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem);
getSite().getPage().bringToTop(editorPart);
EditorUtility.revealInEditor(editorPart,
((MethodWrapper) elem).getMember());
}
} else if (elem instanceof IJavaElement) {
IEditorPart editorPart = EditorUtility.isOpenInEditor(elem);
if (editorPart != null) {
// getSite().getPage().removePartListener(fPartListener);
getSite().getPage().bringToTop(editorPart);
EditorUtility.revealInEditor(editorPart, (IJavaElement) elem);
// getSite().getPage().addPartListener(fPartListener);
}
}
}
/**
* Returns the current selection.
*/
protected ISelection getSelection() {
return fSelectionProviderMediator.getRawSelection();
}
protected void fillLocationViewerContextMenu(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenLocationAction);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
}
protected void handleKeyEvent(KeyEvent event) {
if (event.stateMask == 0) {
if (event.keyCode == SWT.F5) {
if ((fRefreshAction != null) && fRefreshAction.isEnabled()) {
fRefreshAction.run();
return;
}
}
}
}
private IActionBars getActionBars() {
return getViewSite().getActionBars();
}
private void setCalleeRoot(MethodWrapper calleeRoot) {
this.fCalleeRoot = calleeRoot;
}
private MethodWrapper getCalleeRoot() {
if (fCalleeRoot == null) {
fCalleeRoot = CallHierarchy.getDefault().getCalleeRoot(fShownMethod);
}
return fCalleeRoot;
}
private void setCallerRoot(MethodWrapper callerRoot) {
this.fCallerRoot = callerRoot;
}
private MethodWrapper getCallerRoot() {
if (fCallerRoot == null) {
fCallerRoot = CallHierarchy.getDefault().getCallerRoot(fShownMethod);
}
return fCallerRoot;
}
/**
* Adds the entry if new. Inserted at the beginning of the history entries list.
*/
private void addHistoryEntry(IJavaElement entry) {
if (fMethodHistory.contains(entry)) {
fMethodHistory.remove(entry);
}
fMethodHistory.add(0, entry);
fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty());
}
/**
* @param parent
*/
private void createLocationViewer(Composite parent) {
fLocationViewer= new LocationViewer(parent);
fLocationViewer.getControl().addKeyListener(createKeyListener());
fLocationViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillLocationViewerContextMenu(menu);
}
}, ID_CALL_HIERARCHY, getSite());
}
private void createHierarchyLocationSplitter(Composite parent) {
fHierarchyLocationSplitter = new SashForm(parent, SWT.NONE);
fHierarchyLocationSplitter.addKeyListener(createKeyListener());
}
private void createCallHierarchyViewer(Composite parent) {
fCallHierarchyViewer = new CallHierarchyViewer(parent, this);
fCallHierarchyViewer.addKeyListener(createKeyListener());
fCallHierarchyViewer.addSelectionChangedListener(this);
fCallHierarchyViewer.initContextMenu(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
fillCallHierarchyViewerContextMenu(menu);
}
}, ID_CALL_HIERARCHY, getSite());
}
/**
* @param menu
*/
protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) {
JavaPlugin.createStandardGroups(menu);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS));
if (fFocusOnSelectionAction.canActionBeAdded()) {
menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction);
}
menu.appendToGroup(GROUP_FOCUS, fCopyAction);
fActionGroups.setContext(new ActionContext(getSelection()));
fActionGroups.fillContextMenu(menu);
fActionGroups.setContext(null);
}
private void fillActionBars() {
IActionBars actionBars = getActionBars();
IToolBarManager toolBar = actionBars.getToolBarManager();
fActionGroups.fillActionBars(actionBars);
toolBar.add(fCancelSearchAction);
for (int i = 0; i < fToggleCallModeActions.length; i++) {
toolBar.add(fToggleCallModeActions[i]);
}
toolBar.add(fHistoryDropDownAction);
}
private KeyListener createKeyListener() {
KeyListener keyListener = new KeyAdapter() {
public void keyReleased(KeyEvent event) {
handleKeyEvent(event);
}
};
return keyListener;
}
/**
*
*/
private void makeActions() {
fRefreshAction = new RefreshAction(this);
fOpenLocationAction = new OpenLocationAction(this, getSite());
fLocationViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
fOpenLocationAction.run();
}
});
fFocusOnSelectionAction = new FocusOnSelectionAction(this);
fCopyAction= new CopyCallHierarchyAction(this, fClipboard, fCallHierarchyViewer);
fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
fCallHierarchyViewer);
fHistoryDropDownAction = new HistoryDropDownAction(this);
fHistoryDropDownAction.setEnabled(false);
fCancelSearchAction = new CancelSearchAction(this);
setCancelEnabled(false);
fToggleOrientationActions = new ToggleOrientationAction[] {
new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
};
fToggleCallModeActions = new ToggleCallModeAction[] {
new ToggleCallModeAction(this, CALL_MODE_CALLERS),
new ToggleCallModeAction(this, CALL_MODE_CALLEES)
};
fActionGroups = new CompositeActionGroup(new ActionGroup[] {
new OpenEditorActionGroup(this),
new OpenViewActionGroup(this),
new CCPActionGroup(this),
new GenerateActionGroup(this),
new RefactorActionGroup(this),
new JavaSearchActionGroup(this),
fSearchScopeActions, fFiltersActionGroup
});
}
private void showOrHideCallDetailsView() {
if (fShowCallDetails) {
fHierarchyLocationSplitter.setMaximizedControl(null);
} else {
fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl());
}
}
private void updateLocationsView(MethodWrapper methodWrapper) {
if (methodWrapper != null && methodWrapper.getMethodCall().hasCallLocations()) {
fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations());
} else {
fLocationViewer.clearViewer();
}
}
private void updateHistoryEntries() {
for (int i = fMethodHistory.size() - 1; i >= 0; i--) {
IMethod method = (IMethod) fMethodHistory.get(i);
if (!method.exists()) {
fMethodHistory.remove(i);
}
}
fHistoryDropDownAction.setEnabled(!fMethodHistory.isEmpty());
}
/**
* Method updateView.
*/
private void updateView() {
if ((fShownMethod != null)) {
showPage(PAGE_VIEWER);
CallHierarchy.getDefault().setSearchScope(getSearchScope());
String elementName= JavaElementLabels.getElementLabel(fShownMethod, JavaElementLabels.ALL_DEFAULT);
if (fCurrentCallMode == CALL_MODE_CALLERS) {
setTitle(CallHierarchyMessages.getFormattedString("CallHierarchyViewPart.callsToMethod", elementName)); //$NON-NLS-1$
fCallHierarchyViewer.setMethodWrapper(getCallerRoot());
} else {
setTitle(CallHierarchyMessages.getFormattedString("CallHierarchyViewPart.callsFromMethod", elementName)); //$NON-NLS-1$
fCallHierarchyViewer.setMethodWrapper(getCalleeRoot());
}
}
}
static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) {
IWorkbenchPage workbenchPage = site.getPage();
CallHierarchyViewPart callersView = null;
try {
callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
} catch (PartInitException e) {
JavaPlugin.log(e);
}
return callersView;
}
/**
* Cancels the caller/callee search jobs that are currently running.
*/
void cancelJobs() {
fCallHierarchyViewer.cancelJobs();
}
/**
* Sets the enablement state of the cancel button.
* @param enabled
*/
void setCancelEnabled(boolean enabled) {
fCancelSearchAction.setEnabled(enabled);
}
}
|
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jface.action.Action;
abstract class SearchScopeAction extends Action {
private final SearchScopeActionGroup fGroup;
public SearchScopeAction(SearchScopeActionGroup group, String text) {
super(text, AS_RADIO_BUTTON);
this.fGroup = group;
}
public abstract IJavaSearchScope getSearchScope();
public abstract int getSearchScopeType();
public void run() {
this.fGroup.setSelected(this, true);
}
}
|
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeActionGroup.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.jdt.ui.IContextMenuConstants;
class SearchScopeActionGroup extends ActionGroup {
private static final String TAG_SEARCH_SCOPE_TYPE= "search_scope_type"; //$NON-NLS-1$
private static final String TAG_SELECTED_WORKING_SET= "working_set"; //$NON-NLS-1$
private static final String TAG_WORKING_SET_COUNT = "working_set_count"; //$NON-NLS-1$
private static final String DIALOGSTORE_SCOPE_TYPE= "SearchScopeActionGroup.search_scope_type"; //$NON-NLS-1$
private static final String DIALOGSTORE_SELECTED_WORKING_SET= "SearchScopeActionGroup.working_set"; //$NON-NLS-1$
static final int SEARCH_SCOPE_TYPE_WORKSPACE= 1;
static final int SEARCH_SCOPE_TYPE_PROJECT= 2;
static final int SEARCH_SCOPE_TYPE_HIERARCHY= 3;
static final int SEARCH_SCOPE_TYPE_WORKING_SET= 4;
private SearchScopeAction fSelectedAction = null;
private String[] fSelectedWorkingSetNames = null;
private CallHierarchyViewPart fView;
private IDialogSettings fDialogSettings;
private SearchScopeHierarchyAction fSearchScopeHierarchyAction;
private SearchScopeProjectAction fSearchScopeProjectAction;
private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction;
private SelectWorkingSetAction fSelectWorkingSetAction;
public SearchScopeActionGroup(CallHierarchyViewPart view, IDialogSettings dialogSettings) {
this.fView= view;
this.fDialogSettings= dialogSettings;
createActions();
}
/**
* @return IJavaSearchScope
*/
public IJavaSearchScope getSearchScope() {
if (fSelectedAction != null) {
return fSelectedAction.getSearchScope();
}
return null;
}
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
fillContextMenu(actionBars.getMenuManager());
}
/**
* @param set
* @param b
*/
protected void setActiveWorkingSets(IWorkingSet[] sets) {
if (sets != null) {
fSelectedWorkingSetNames = getWorkingSetNames(sets);
fSelectedAction = new SearchScopeWorkingSetAction(this, sets, getScopeDescription(sets));
} else {
fSelectedWorkingSetNames = null;
fSelectedAction = null;
}
}
/**
* @param sets
*/
private String[] getWorkingSetNames(IWorkingSet[] sets) {
String[] result= new String[sets.length];
for (int i = 0; i < sets.length; i++) {
result[i]= sets[i].getName();
}
return result;
}
/**
* @return
*/
protected IWorkingSet[] getActiveWorkingSets() {
if (fSelectedWorkingSetNames != null) {
return getWorkingSets(fSelectedWorkingSetNames);
}
return null;
}
private IWorkingSet[] getWorkingSets(String[] workingSetNames) {
if (workingSetNames == null) {
return null;
}
Set workingSets= new HashSet(2);
for (int j= 0; j < workingSetNames.length; j++) {
IWorkingSet workingSet= getWorkingSetManager().getWorkingSet(workingSetNames[j]);
if (workingSet != null) {
workingSets.add(workingSet);
}
}
return (IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]);
}
/**
* Sets the new search scope type.
*
* @param newSelection New action which should be the checked one
* @param ignoreUnchecked Ignores actions which are unchecked (necessary since both the old and the new action fires).
*/
protected void setSelected(SearchScopeAction newSelection, boolean ignoreUnchecked) {
if (!ignoreUnchecked || newSelection.isChecked()) {
if (newSelection instanceof SearchScopeWorkingSetAction) {
fSelectedWorkingSetNames = getWorkingSetNames(((SearchScopeWorkingSetAction) newSelection).getWorkingSets());
} else {
fSelectedWorkingSetNames = null;
}
if (newSelection != null) {
fSelectedAction= newSelection;
} else {
fSelectedAction= fSearchScopeWorkspaceAction;
}
fDialogSettings.put(DIALOGSTORE_SCOPE_TYPE, getSearchScopeType());
fDialogSettings.put(DIALOGSTORE_SELECTED_WORKING_SET, fSelectedWorkingSetNames);
}
}
/**
* @return CallHierarchyViewPart
*/
protected CallHierarchyViewPart getView() {
return fView;
}
protected IWorkingSetManager getWorkingSetManager() {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench()
.getWorkingSetManager();
return workingSetManager;
}
protected void fillSearchActions(IMenuManager javaSearchMM) {
Action[] actions = getActions();
for (int i = 0; i < actions.length; i++) {
Action action = actions[i];
if (action.isEnabled()) {
javaSearchMM.add(action);
}
}
javaSearchMM.setVisible(!javaSearchMM.isEmpty());
}
public void fillContextMenu(IMenuManager menu) {
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.getString("SearchScopeActionGroup.searchScope"), //$NON-NLS-1$
IContextMenuConstants.GROUP_SEARCH);
javaSearchMM.setRemoveAllWhenShown(true);
javaSearchMM.addMenuListener(new IMenuListener() {
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
*/
public void menuAboutToShow(IMenuManager manager) {
fillSearchActions(manager);
}
});
fillSearchActions(javaSearchMM);
menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM);
}
/**
* @return SearchScopeAction[]
*/
private Action[] getActions() {
List actions = new ArrayList(SearchUtil.LRU_WORKINGSET_LIST_SIZE + 4);
addAction(actions, fSearchScopeWorkspaceAction);
addAction(actions, fSearchScopeProjectAction);
addAction(actions, fSearchScopeHierarchyAction);
addAction(actions, fSelectWorkingSetAction);
Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
while (iter.hasNext()) {
IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
String description = SearchUtil.toString(workingSets);
SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(this, workingSets, description);
if (isSelectedWorkingSet(workingSets)) {
workingSetAction.setChecked(true);
}
actions.add(workingSetAction);
}
Action[] result = (Action[]) actions.toArray(new Action[actions.size()]);
ensureExactlyOneCheckedAction(result);
return result;
}
/**
* @param result
*/
private void ensureExactlyOneCheckedAction(Action[] result) {
int checked = getCheckedActionCount(result);
if (checked != 1) {
if (checked > 1) {
for (int i = 0; i < result.length; i++) {
Action action = result[i];
action.setChecked(false);
}
}
fSearchScopeWorkspaceAction.setChecked(true);
}
}
/**
* @param result
* @return
*/
private int getCheckedActionCount(Action[] result) {
// Ensure that exactly one action is selected
int checked= 0;
for (int i = 0; i < result.length; i++) {
Action action = result[i];
if (action.isChecked()) {
checked++;
}
}
return checked;
}
private void addAction(List actions, Action action) {
if (action == fSelectedAction) {
action.setChecked(true);
} else {
action.setChecked(false);
}
actions.add(action);
}
/**
* @param view
*/
private void createActions() {
fSearchScopeWorkspaceAction = new SearchScopeWorkspaceAction(this);
fSelectWorkingSetAction = new SelectWorkingSetAction(this);
fSearchScopeHierarchyAction = new SearchScopeHierarchyAction(this);
fSearchScopeProjectAction = new SearchScopeProjectAction(this);
int searchScopeType;
try {
searchScopeType= fDialogSettings.getInt(DIALOGSTORE_SCOPE_TYPE);
} catch (NumberFormatException e) {
searchScopeType= SEARCH_SCOPE_TYPE_WORKSPACE;
}
String[] workingSetNames= fDialogSettings.getArray(DIALOGSTORE_SELECTED_WORKING_SET);
setSelected(getSearchScopeAction(searchScopeType, workingSetNames), false);
}
/**
* @param memento
*/
public void saveState(IMemento memento) {
int type= getSearchScopeType();
memento.putInteger(TAG_SEARCH_SCOPE_TYPE, type);
if (type == SEARCH_SCOPE_TYPE_WORKING_SET) {
memento.putInteger(TAG_WORKING_SET_COUNT, fSelectedWorkingSetNames.length);
for (int i = 0; i < fSelectedWorkingSetNames.length; i++) {
String workingSetName = fSelectedWorkingSetNames[i];
memento.putString(TAG_SELECTED_WORKING_SET+i, workingSetName);
}
}
}
/**
* @param memento
*/
public void restoreState(IMemento memento) {
String[] workingSetNames= null;
Integer scopeType= memento.getInteger(TAG_SEARCH_SCOPE_TYPE);
if (scopeType != null) {
if (scopeType.intValue() == SEARCH_SCOPE_TYPE_WORKING_SET) {
Integer workingSetCount= memento.getInteger(TAG_WORKING_SET_COUNT);
if (workingSetCount != null) {
workingSetNames = new String[workingSetCount.intValue()];
for (int i = 0; i < workingSetCount.intValue(); i++) {
workingSetNames[i]= memento.getString(TAG_SELECTED_WORKING_SET+i);
}
}
}
}
setSelected(getSearchScopeAction(scopeType.intValue(), workingSetNames), false);
}
/**
* @param i
* @return
*/
private SearchScopeAction getSearchScopeAction(int searchScopeType, String[] workingSetNames) {
switch (searchScopeType) {
case SEARCH_SCOPE_TYPE_WORKSPACE:
return fSearchScopeWorkspaceAction;
case SEARCH_SCOPE_TYPE_PROJECT:
return fSearchScopeProjectAction;
case SEARCH_SCOPE_TYPE_HIERARCHY:
return fSearchScopeHierarchyAction;
case SEARCH_SCOPE_TYPE_WORKING_SET:
IWorkingSet[] workingSets= getWorkingSets(workingSetNames);
if (workingSets != null && workingSets.length > 0) {
return new SearchScopeWorkingSetAction(this, workingSets, getScopeDescription(workingSets));
}
return null;
}
return null;
}
/**
* @return
*/
private int getSearchScopeType() {
if (fSelectedAction != null) {
return fSelectedAction.getSearchScopeType();
}
return 0;
}
private String getScopeDescription(IWorkingSet[] workingSets) {
return CallHierarchyMessages.getFormattedString("WorkingSetScope", new String[] {SearchUtil.toString(workingSets)}); //$NON-NLS-1$
}
/**
* Determines whether the specified working sets correspond to the currently selected working sets.
* @param workingSets
* @return
*/
private boolean isSelectedWorkingSet(IWorkingSet[] workingSets) {
if (fSelectedWorkingSetNames != null && fSelectedWorkingSetNames.length == workingSets.length) {
Set workingSetNames= new HashSet(workingSets.length);
for (int i = 0; i < workingSets.length; i++) {
workingSetNames.add(workingSets[i].getName());
}
for (int i = 0; i < fSelectedWorkingSetNames.length; i++) {
if (!workingSetNames.contains(fSelectedWorkingSetNames[i])) {
return false;
}
}
return true;
}
return false;
}
}
|
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
class SearchScopeHierarchyAction extends SearchScopeAction {
private final SearchScopeActionGroup fGroup;
public SearchScopeHierarchyAction(SearchScopeActionGroup group) {
super(group, CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.text")); //$NON-NLS-1$
this.fGroup = group;
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
}
public IJavaSearchScope getSearchScope() {
try {
IMethod method = this.fGroup.getView().getMethod();
if (method != null) {
return SearchEngine.createHierarchyScope(method.getDeclaringType());
} else {
return null;
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_HIERARCHY;
}
}
|
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeProjectAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
class SearchScopeProjectAction extends SearchScopeAction {
private final SearchScopeActionGroup fGroup;
public SearchScopeProjectAction(SearchScopeActionGroup group) {
super(group, CallHierarchyMessages.getString("SearchScopeActionGroup.project.text")); //$NON-NLS-1$
this.fGroup = group;
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.project.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
}
public IJavaSearchScope getSearchScope() {
IMethod method = this.fGroup.getView().getMethod();
IJavaProject project = null;
if (method != null) {
project = method.getJavaProject();
}
if (project != null) {
return SearchEngine.createJavaSearchScope(new IJavaElement[] { project },
false);
} else {
return null;
}
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_PROJECT;
}
}
|
60,714
|
Bug 60714 Call Hierarchy: display search scope in view title
|
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
|
resolved fixed
|
1854c92
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-05-04T07:45:19Z
| 2004-05-03T07:40:00Z
|
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeWorkingSetAction.java
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
* (report 36180: Callers/Callees view)
******************************************************************************/
package org.eclipse.jdt.internal.ui.callhierarchy;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
class SearchScopeWorkingSetAction extends SearchScopeAction {
private IWorkingSet[] fWorkingSets;
public SearchScopeWorkingSetAction(SearchScopeActionGroup group, IWorkingSet[] workingSets, String name) {
super(group, name);
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
this.fWorkingSets = workingSets;
}
public IJavaSearchScope getSearchScope() {
return JavaSearchScopeFactory.getInstance().createJavaSearchScope(fWorkingSets);
}
/**
*
*/
public IWorkingSet[] getWorkingSets() {
return fWorkingSets;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_WORKING_SET;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.