Skip to content

Commit e293b05

Browse files
authored
Fix deprecations (#1686)
* fix deprecations
1 parent 3cea1a7 commit e293b05

File tree

9 files changed

+30
-21
lines changed

9 files changed

+30
-21
lines changed

org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/ControlStatementsFix.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private IfStatement findStart(IfStatement item) {
169169
}
170170
}
171171

172-
private static final class AddBlockOperation extends CompilationUnitRewriteOperation {
172+
private static final class AddBlockOperation extends CompilationUnitRewriteOperationWithSourceRange {
173173

174174
private final ChildPropertyDescriptor fBodyProperty;
175175
private final Statement fBody;
@@ -266,7 +266,7 @@ public void rewriteASTInternal(CompilationUnitRewrite cuRewrite, LinkedProposalM
266266

267267
}
268268

269-
static class RemoveBlockOperation extends CompilationUnitRewriteOperation {
269+
static class RemoveBlockOperation extends CompilationUnitRewriteOperationWithSourceRange {
270270

271271
private final Statement fStatement;
272272
private final ChildPropertyDescriptor fChild;
@@ -437,42 +437,42 @@ public static ControlStatementsFix[] createRemoveBlockFix(CompilationUnit compil
437437
RemoveBlockOperation op= new RemoveBlockOperation(item, IfStatement.THEN_STATEMENT_PROPERTY);
438438
removeAllList.add(op);
439439
if (item == statement)
440-
result.add(new ControlStatementsFix(FixMessages.ControlStatementsFix_removeIfBlock_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op}));
440+
result.add(new ControlStatementsFix(FixMessages.ControlStatementsFix_removeIfBlock_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op}));
441441
}
442442
}
443443

444444
if (RemoveBlockOperation.satisfiesQuickAssistPrecondition(item, IfStatement.ELSE_STATEMENT_PROPERTY)) {
445445
RemoveBlockOperation op= new RemoveBlockOperation(item, IfStatement.ELSE_STATEMENT_PROPERTY);
446446
removeAllList.add(op);
447447
if (item == statement)
448-
result.add(new ControlStatementsFix(FixMessages.ControlStatementsFix_removeElseBlock_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op}));
448+
result.add(new ControlStatementsFix(FixMessages.ControlStatementsFix_removeElseBlock_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op}));
449449
}
450450

451451
if (removeAllList.size() > 1) {
452-
CompilationUnitRewriteOperation[] allConvert= removeAllList.toArray(new CompilationUnitRewriteOperation[removeAllList.size()]);
452+
CompilationUnitRewriteOperationWithSourceRange[] allConvert= removeAllList.toArray(new CompilationUnitRewriteOperationWithSourceRange[removeAllList.size()]);
453453
result.add(new ControlStatementsFix(FixMessages.ControlStatementsFix_removeIfElseBlock_proposalDescription, compilationUnit, allConvert));
454454
}
455455

456456
return result.toArray(new ControlStatementsFix[result.size()]);
457457
} else if (statement instanceof WhileStatement) {
458458
if (RemoveBlockOperation.satisfiesQuickAssistPrecondition(statement, WhileStatement.BODY_PROPERTY)) {
459459
RemoveBlockOperation op= new RemoveBlockOperation(statement, WhileStatement.BODY_PROPERTY);
460-
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op})};
460+
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op})};
461461
}
462462
} else if (statement instanceof ForStatement) {
463463
if (RemoveBlockOperation.satisfiesQuickAssistPrecondition(statement, ForStatement.BODY_PROPERTY)) {
464464
RemoveBlockOperation op= new RemoveBlockOperation(statement, ForStatement.BODY_PROPERTY);
465-
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op})};
465+
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op})};
466466
}
467467
} else if (statement instanceof EnhancedForStatement) {
468468
if (RemoveBlockOperation.satisfiesQuickAssistPrecondition(statement, EnhancedForStatement.BODY_PROPERTY)) {
469469
RemoveBlockOperation op= new RemoveBlockOperation(statement, EnhancedForStatement.BODY_PROPERTY);
470-
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op})};
470+
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op})};
471471
}
472472
} else if (statement instanceof DoStatement) {
473473
if (RemoveBlockOperation.satisfiesQuickAssistPrecondition(statement, DoStatement.BODY_PROPERTY)) {
474474
RemoveBlockOperation op= new RemoveBlockOperation(statement, DoStatement.BODY_PROPERTY);
475-
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperation[] {op})};
475+
return new ControlStatementsFix[] {new ControlStatementsFix(FixMessages.ControlStatementsFix_removeBrackets_proposalDescription, compilationUnit, new CompilationUnitRewriteOperationWithSourceRange[] {op})};
476476
}
477477
}
478478

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/JavaPlugin.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,11 +655,17 @@ public JavaTextTools getJavaTextTools() {
655655
*
656656
* @return the Java Core plug-in preferences
657657
* @since 3.7
658+
* deprecated use getJavaCorePluginPreferencesNew
658659
*/
659660
public static org.eclipse.core.runtime.Preferences getJavaCorePluginPreferences() {
660661
return JavaCore.getPlugin().getPluginPreferences();
661662
}
662663

664+
public static IEclipsePreferences getJavaCorePluginPreferencesNew() {
665+
return InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
666+
}
667+
668+
663669
/**
664670
* Returns the AST provider.
665671
*
@@ -941,11 +947,11 @@ public IPreferenceStore getCombinedPreferenceStore() {
941947
return fCombinedPreferenceStore;
942948
}
943949
}
944-
950+
945951
// Block below may init other bundles and shouldn't be executed with lock held
946952
IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
947953
ChainedPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(getJavaCorePluginPreferences()), generalTextStore });
948-
954+
949955
synchronized (this) {
950956
if (fCombinedPreferenceStore == null) {
951957
fCombinedPreferenceStore = store;

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorBreadcrumb.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.eclipse.ui.PartInitException;
4848
import org.eclipse.ui.actions.ActionContext;
4949
import org.eclipse.ui.actions.ActionGroup;
50+
import org.eclipse.ui.contexts.IContextService;
5051
import org.eclipse.ui.views.WorkbenchViewerSetup;
5152

5253
import org.eclipse.jdt.core.ElementChangedEvent;
@@ -568,7 +569,8 @@ public JavaEditorBreadcrumb(JavaEditor javaEditor) {
568569
protected void activateBreadcrumb() {
569570
fEditorSelection= getJavaEditor().getSelectionProvider().getSelection();
570571
IEditorSite editorSite= getJavaEditor().getEditorSite();
571-
editorSite.getKeyBindingService().setScopes(new String[] { "org.eclipse.jdt.ui.breadcrumbEditorScope" }); //$NON-NLS-1$
572+
IContextService contextService = editorSite.getService(IContextService.class);
573+
contextService.activateContext("org.eclipse.jdt.ui.breadcrumbEditorScope"); //$NON-NLS-1$
572574
getJavaEditor().setActionsActivated(false);
573575
fBreadcrumbActionGroup.fillActionBars(editorSite.getActionBars());
574576
}
@@ -579,7 +581,8 @@ protected void activateBreadcrumb() {
579581
@Override
580582
protected void deactivateBreadcrumb() {
581583
IEditorSite editorSite= getJavaEditor().getEditorSite();
582-
editorSite.getKeyBindingService().setScopes(new String[] { "org.eclipse.jdt.ui.javaEditorScope" }); //$NON-NLS-1$
584+
IContextService contextService = editorSite.getService(IContextService.class);
585+
contextService.activateContext("org.eclipse.jdt.ui.javaEditorScope"); //$NON-NLS-1$
583586
getJavaEditor().getActionGroup().fillActionBars(editorSite.getActionBars());
584587
getJavaEditor().setActionsActivated(true);
585588
fEditorSelection= null;

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaCodeReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import java.io.IOException;
1818

19-
import org.eclipse.jface.internal.text.html.SingleCharReader;
19+
import org.eclipse.text.readers.SingleCharacterReader;
2020

2121
import org.eclipse.jface.text.BadLocationException;
2222
import org.eclipse.jface.text.IDocument;
@@ -26,7 +26,7 @@
2626
* Reads from a document either forwards or backwards. May be configured to
2727
* skip comments and strings.
2828
*/
29-
public class JavaCodeReader extends SingleCharReader {
29+
public class JavaCodeReader extends SingleCharacterReader {
3030

3131
/** The EOF character */
3232
public static final int EOF= -1;

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/FixCorrectionProposal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public Image getImage() {
140140
flag= JavaElementImageDescriptor.INFO;
141141
}
142142

143-
ImageDescriptor composite= new JavaElementImageDescriptor(image, flag, new Point(image.getImageData().width, image.getImageData().height));
143+
ImageDescriptor composite= new JavaElementImageDescriptor(image, flag, new Point(image.getImageData(100).width, image.getImageData(100).height));
144144
return composite.createImage();
145145
} else {
146146
return super.getImage();

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/SourceViewerInformationControl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,11 @@ public boolean isVisible() {
703703
public Point computeSizeConstraints(int widthInChars, int heightInChars) {
704704
GC gc= new GC(fText);
705705
gc.setFont(fTextFont);
706-
int width= gc.getFontMetrics().getAverageCharWidth();
706+
double width= gc.getFontMetrics().getAverageCharacterWidth();
707707
int height= fText.getLineHeight(); //https://bugs.eclipse.org/bugs/show_bug.cgi?id=377109
708708
gc.dispose();
709709

710-
return new Point(widthInChars * width, heightInChars * height);
710+
return new Point((int) (widthInChars * width), heightInChars * height);
711711
}
712712

713713
protected void setContentFrom(ISourceViewer other) {

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/FilteredElementTreeSelectionDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static class FilteredTreeWithFilter extends FilteredTree {
125125
private String previousFilterText;
126126

127127
public FilteredTreeWithFilter(Composite parent, int treeStyle, String initialFilter, boolean deepFiltering) {
128-
super(parent, treeStyle, new MultiplePatternFilter(deepFiltering), true);
128+
super(parent, treeStyle, new MultiplePatternFilter(deepFiltering), true, true);
129129
if (initialFilter != null) {
130130
setFilterText(initialFilter);
131131
textChanged();

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ProjectsWorkbookPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private CPListElement[] addProjectDialog() {
649649
Object[] selectArr= getNotYetRequiredProjects();
650650
new JavaElementComparator().sort(null, selectArr);
651651

652-
ListSelectionDialog dialog= new ListSelectionDialog(getShell(), Arrays.asList(selectArr), ArrayContentProvider.getInstance(), new JavaUILabelProvider(), NewWizardMessages.ProjectsWorkbookPage_chooseProjects_message);
652+
ListSelectionDialog dialog= ListSelectionDialog.of(Arrays.asList(selectArr)).contentProvider(ArrayContentProvider.getInstance()).labelProvider(new JavaUILabelProvider()).message(NewWizardMessages.ProjectsWorkbookPage_chooseProjects_message).create(getShell());
653653
dialog.setTitle(NewWizardMessages.ProjectsWorkbookPage_chooseProjects_title);
654654
dialog.setHelpAvailable(false);
655655
if (dialog.open() == Window.OK) {

org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OpenProjectAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void run(IStructuredSelection selection) {
166166
}
167167

168168
private void internalRun(List<?> initialSelection) {
169-
ListSelectionDialog dialog= new ListSelectionDialog(getShell(), getClosedProjectsInWorkspace(), ArrayContentProvider.getInstance(), new JavaElementLabelProvider(), ActionMessages.OpenProjectAction_dialog_message);
169+
ListSelectionDialog dialog= ListSelectionDialog.of(getClosedProjectsInWorkspace()).contentProvider(ArrayContentProvider.getInstance()).labelProvider(new JavaElementLabelProvider()).message(ActionMessages.OpenProjectAction_dialog_message).create(getShell());
170170
dialog.setTitle(ActionMessages.OpenProjectAction_dialog_title);
171171
if (initialSelection != null && !initialSelection.isEmpty()) {
172172
dialog.setInitialElementSelections(initialSelection);

0 commit comments

Comments
 (0)