Skip to content

Commit 21b6bc4

Browse files
committed
Remove pre 1.8 support
ECJ supports min 1.8 and JDT UI provides no way to set BREE lower than that thus all this code is non reachable.
1 parent f5e22a7 commit 21b6bc4

File tree

8 files changed

+13
-170
lines changed

8 files changed

+13
-170
lines changed

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/codemanipulation/StubUtility2Core.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,6 @@ public static ASTNode getNodeToInsertBefore(ListRewrite listRewrite, IJavaElemen
10951095
public static void addOverrideAnnotation(CodeGenerationSettings settings, IJavaProject project, ASTRewrite rewrite, ImportRewrite imports, MethodDeclaration methodDecl,
10961096
boolean isDeclaringTypeInterface, TextEditGroup group) {
10971097
if (isDeclaringTypeInterface) {
1098-
String version= project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
1099-
if (JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_1_6))
1100-
return; // not allowed in 1.5
11011098
if (JavaCore.DISABLED.equals(project.getOption(JavaCore.COMPILER_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION, true)))
11021099
return; // user doesn't want to use 1.6 style
11031100
}

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/refactoring/structure/constraints/SuperTypeRefactoringProcessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,8 +1230,6 @@ public final void acceptBinding(final String key, final IBinding binding) {
12301230
subMonitor.beginTask("", keySet.size() * 100); //$NON-NLS-1$
12311231
subMonitor.setTaskName(RefactoringCoreMessages.SuperTypeRefactoringProcessor_creating);
12321232
for (IJavaProject project : keySet) {
1233-
if (level == 3 && !JavaModelUtil.is50OrHigher(project))
1234-
level= 2;
12351233
Collection<ICompilationUnit> cuCollection= secondPass.get(project);
12361234
if (cuCollection != null) {
12371235
parser.setWorkingCopyOwner(fOwner);

org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,6 @@ public static boolean is50OrHigher(String compliance) {
792792
return !isVersionLessThan(compliance, JavaCore.VERSION_1_5);
793793
}
794794

795-
public static boolean is1d6OrHigher(String compliance) {
796-
return !isVersionLessThan(compliance, JavaCore.VERSION_1_6);
797-
}
798-
799795
public static boolean is1d7OrHigher(String compliance) {
800796
return !isVersionLessThan(compliance, JavaCore.VERSION_1_7);
801797
}

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ComplianceConfigurationBlock.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private void validateComplianceStatus() {
649649
args[1]= getVersionLabel(version);
650650
}
651651
if (JavaModelUtil.is9OrHigher(compilerCompliance)) {
652-
if (!JavaModelUtil.is1d6OrHigher(compliance) || !fCompilerReleaseCheck.getSelection()) {
652+
if (!fCompilerReleaseCheck.getSelection()) {
653653
if (fProject == null) {
654654
fJRE50InfoText.setText(Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
655655
} else {
@@ -748,7 +748,6 @@ private void updateReleaseOptionStatus() {
748748
if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance
749749
if (JavaModelUtil.is9OrHigher(compilerCompliance)) {
750750
if (!JavaModelUtil.isVersionLessThan(compliance, compilerCompliance)
751-
|| !JavaModelUtil.is1d6OrHigher(compliance)
752751
|| ( JavaModelUtil.is12OrHigher(compilerCompliance))
753752
&& !JavaModelUtil.is1d7OrHigher(compliance)) {
754753
fCompilerReleaseCheck.setEnabled(false);
@@ -773,7 +772,7 @@ private void updateReleaseOptionStatus() {
773772
setValue(PREF_RELEASE, JavaCore.DISABLED);
774773
} else {
775774
if (fProject == null
776-
|| (isJREUnsupportedAndGreater && JavaModelUtil.is1d6OrHigher(compliance))
775+
|| isJREUnsupportedAndGreater
777776
|| JavaModelUtil.is9OrHigher(compliance)) {
778777
fCompilerReleaseCheck.setEnabled(true);
779778
}
@@ -921,7 +920,7 @@ private void updateComplianceEnableSourceTargetState() {
921920
String complianceFollowsEE= getValue(INTR_COMPLIANCE_FOLLOWS_EE);
922921
enableComplianceControls= hasProjectSpecificOptions && !DEFAULT_CONF.equals(complianceFollowsEE); // is disabled or user
923922
}
924-
boolean enableBasedOnRelease= !fCompilerReleaseCheck.getSelection() || !JavaModelUtil.is1d6OrHigher(getValue(PREF_COMPLIANCE));
923+
boolean enableBasedOnRelease= !fCompilerReleaseCheck.getSelection();
925924
boolean enableComplianceChildren= enableComplianceControls && checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF) && enableBasedOnRelease;
926925
for (int i= fComplianceChildControls.size() - 1; i >= 0; i--) {
927926
Control curr= fComplianceChildControls.get(i);
@@ -1055,7 +1054,7 @@ private void updateComplianceDefaultSettings(boolean rememberOld, String oldComp
10551054
boolean isDefault= checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF);
10561055
boolean isFollowEE= checkValue(INTR_COMPLIANCE_FOLLOWS_EE, DEFAULT_CONF);
10571056
String complianceLevel= getValue(PREF_COMPLIANCE);
1058-
boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED) && JavaModelUtil.is1d6OrHigher(complianceLevel) && !isDefault;
1057+
boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED) && !isDefault;
10591058

10601059
if (isDefault || isFollowEE || isRelease) {
10611060
if (rememberOld) {
@@ -1139,7 +1138,7 @@ private void updateComplianceDefaultSettings(boolean rememberOld, String oldComp
11391138

11401139
private void updateComplianceReleaseSettings() {
11411140
String compliance= getValue(PREF_COMPLIANCE);
1142-
boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED) && JavaModelUtil.is1d6OrHigher(compliance);
1141+
boolean isRelease= checkValue(PREF_RELEASE, JavaCore.ENABLED);
11431142
if (isRelease) {
11441143
setValue(PREF_SOURCE_COMPATIBILITY, compliance);
11451144
setValue(PREF_CODEGEN_TARGET_PLATFORM, compliance);

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -72,7 +72,6 @@ private final static class CorePrefs {
7272
final boolean prefIndentBracesForMethods;
7373
final boolean prefIndentBracesForTypes;
7474
final int prefContinuationIndent;
75-
final boolean prefHasGenerics;
7675
final String prefTabChar;
7776

7877
private final IJavaProject fProject;
@@ -129,7 +128,6 @@ private String getCoreFormatterOption(String key) {
129128
prefIndentBracesForArrays= false;
130129
prefIndentBracesForMethods= false;
131130
prefIndentBracesForTypes= false;
132-
prefHasGenerics= false;
133131
prefTabChar= JavaCore.TAB;
134132
} else {
135133
prefUseTabs= prefUseTabs();
@@ -158,7 +156,6 @@ private String getCoreFormatterOption(String key) {
158156
prefIndentBracesForArrays= prefIndentBracesForArrays();
159157
prefIndentBracesForMethods= prefIndentBracesForMethods();
160158
prefIndentBracesForTypes= prefIndentBracesForTypes();
161-
prefHasGenerics= hasGenerics();
162159
prefTabChar= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
163160
}
164161
}
@@ -363,9 +360,6 @@ private int prefContinuationIndentForArrayInitializer() {
363360

364361
return 2; // sensible default
365362
}
366-
private boolean hasGenerics() {
367-
return JavaCore.compareJavaVersions(JavaCore.VERSION_1_5, getCoreFormatterOption(JavaCore.COMPILER_SOURCE)) <= 0;
368-
}
369363
}
370364

371365
/** The document being scanned. */
@@ -1593,8 +1587,6 @@ private boolean skipScope() {
15931587
case Symbols.TokenRBRACE:
15941588
return skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE);
15951589
case Symbols.TokenGREATERTHAN:
1596-
if (!fPrefs.prefHasGenerics)
1597-
return false;
15981590
int storedPosition= fPosition;
15991591
int storedToken= fToken;
16001592
nextToken();

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,7 +32,6 @@
3232
import org.eclipse.jdt.core.ICompilationUnit;
3333
import org.eclipse.jdt.core.IJavaProject;
3434
import org.eclipse.jdt.core.IType;
35-
import org.eclipse.jdt.core.JavaCore;
3635
import org.eclipse.jdt.core.dom.AST;
3736
import org.eclipse.jdt.core.dom.ASTNode;
3837
import org.eclipse.jdt.core.dom.Annotation;
@@ -52,7 +51,6 @@
5251

5352
import org.eclipse.jdt.internal.core.manipulation.dom.ASTResolving;
5453
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
55-
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
5654

5755
import org.eclipse.jdt.internal.ui.JavaPlugin;
5856
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
@@ -86,10 +84,6 @@ private void addOverrideAnnotation(IDocument document) throws CoreException {
8684
MethodDeclaration oldMethodDeclaration= (MethodDeclaration) ASTNodes.findDeclaration(fMethod, getInvocationNode());
8785
CompilationUnit findParentCompilationUnit= ASTResolving.findParentCompilationUnit(oldMethodDeclaration);
8886
IJavaProject javaProject= findParentCompilationUnit.getJavaElement().getJavaProject();
89-
String version= javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
90-
if (JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_1_5)) {
91-
return;
92-
}
9387
IType type= javaProject.findType(fMethod.getDeclaringClass().getQualifiedName());
9488
ICompilationUnit compilationUnit= type.getCompilationUnit();
9589
ImportRewrite importRewrite= CodeStyleConfiguration.createImportRewrite(compilationUnit, true);

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

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2022 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,9 +26,7 @@
2626
import org.eclipse.jdt.core.CompletionContext;
2727
import org.eclipse.jdt.core.CompletionProposal;
2828
import org.eclipse.jdt.core.IJavaElement;
29-
import org.eclipse.jdt.core.IJavaProject;
3029
import org.eclipse.jdt.core.IType;
31-
import org.eclipse.jdt.core.JavaCore;
3230
import org.eclipse.jdt.core.JavaModelException;
3331
import org.eclipse.jdt.core.Signature;
3432

@@ -124,35 +122,9 @@ private IJavaCompletionProposal createTypeProposal(int relevance, String fullyQu
124122
proposal.setReplaceRange(context.getInvocationOffset(), context.getInvocationOffset());
125123
proposal.setSignature(Signature.createTypeSignature(fullyQualifiedType, true).toCharArray());
126124

127-
if (shouldProposeGenerics(context.getProject())) {
128-
LazyGenericTypeProposal p= new LazyGenericTypeProposal(proposal, context);
129-
p.setRelevance(relevance);
130-
return p;
131-
} else {
132-
LazyJavaTypeCompletionProposal p= new LazyJavaTypeCompletionProposal(proposal, context);
133-
p.setRelevance(relevance);
134-
return p;
135-
}
136-
}
137-
138-
/**
139-
* Returns <code>true</code> if generic proposals should be allowed,
140-
* <code>false</code> if not. Note that even though code (in a library)
141-
* may be referenced that uses generics, it is still possible that the
142-
* current source does not allow generics.
143-
*
144-
* @param project the Java project
145-
* @return <code>true</code> if the generic proposals should be allowed,
146-
* <code>false</code> if not
147-
*/
148-
protected final boolean shouldProposeGenerics(IJavaProject project) {
149-
String sourceVersion;
150-
if (project != null)
151-
sourceVersion= project.getOption(JavaCore.COMPILER_SOURCE, true);
152-
else
153-
sourceVersion= JavaCore.getOption(JavaCore.COMPILER_SOURCE);
154-
155-
return sourceVersion != null && JavaCore.compareJavaVersions(JavaCore.VERSION_1_5, sourceVersion) <= 0;
125+
LazyGenericTypeProposal p= new LazyGenericTypeProposal(proposal, context);
126+
p.setRelevance(relevance);
127+
return p;
156128
}
157129

158130
@Override

org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewPackageWizardPage.java

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
*******************************************************************************/
1616
package org.eclipse.jdt.ui.wizards;
1717

18-
import java.io.ByteArrayInputStream;
19-
import java.io.IOException;
20-
import java.io.Reader;
21-
import java.io.UnsupportedEncodingException;
2218
import java.lang.reflect.InvocationTargetException;
2319
import java.net.URI;
2420

@@ -44,12 +40,9 @@
4440
import org.eclipse.core.runtime.IProgressMonitor;
4541
import org.eclipse.core.runtime.IStatus;
4642
import org.eclipse.core.runtime.NullProgressMonitor;
47-
import org.eclipse.core.runtime.Status;
4843

4944
import org.eclipse.core.resources.IFile;
50-
import org.eclipse.core.resources.IFolder;
5145
import org.eclipse.core.resources.IResource;
52-
import org.eclipse.core.resources.IWorkspace;
5346
import org.eclipse.core.resources.ResourcesPlugin;
5447

5548
import org.eclipse.jface.dialogs.Dialog;
@@ -70,20 +63,15 @@
7063
import org.eclipse.jdt.core.JavaModelException;
7164

7265
import org.eclipse.jdt.internal.core.manipulation.StubUtility;
73-
import org.eclipse.jdt.internal.corext.javadoc.JavaDocCommentReader;
7466
import org.eclipse.jdt.internal.corext.util.InfoFilesUtil;
7567
import org.eclipse.jdt.internal.corext.util.JavaConventionsUtil;
7668
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
7769
import org.eclipse.jdt.internal.corext.util.Messages;
7870

79-
import org.eclipse.jdt.ui.JavaUI;
80-
8171
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
8272
import org.eclipse.jdt.internal.ui.JavaPlugin;
8373
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
8474
import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler;
85-
import org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter;
86-
import org.eclipse.jdt.internal.ui.text.javadoc.JavaDoc2HTMLTextReader;
8775
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
8876
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
8977
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
@@ -465,11 +453,7 @@ public IResource getModifiedResource() {
465453
IPackageFragment pack= root.getPackageFragment(getPackageText());
466454
IResource packRes= pack.getResource();
467455
if (isCreatePackageDocumentation()) {
468-
if (JavaModelUtil.is50OrHigher(getJavaProject())) {
469-
return pack.getCompilationUnit(PACKAGE_INFO_JAVA_FILENAME).getResource();
470-
} else if (packRes instanceof IFolder){
471-
return ((IFolder) packRes).getFile(PACKAGE_HTML_FILENAME);
472-
}
456+
return pack.getCompilationUnit(PACKAGE_INFO_JAVA_FILENAME).getResource();
473457
}
474458

475459
return packRes;
@@ -531,11 +515,7 @@ public void createPackage(IProgressMonitor monitor) throws CoreException, Interr
531515
}
532516

533517
if (isCreatePackageDocumentation()) {
534-
if (JavaModelUtil.is50OrHigher(getJavaProject())) {
535-
createPackageInfoJava(monitor);
536-
} else {
537-
createPackageHtml(root, monitor);
538-
}
518+
createPackageInfoJava(monitor);
539519
}
540520

541521
// save whether package documentation should be created
@@ -561,89 +541,4 @@ private void createPackageInfoJava(IProgressMonitor monitor) throws CoreExceptio
561541

562542
InfoFilesUtil.createInfoJavaFile(PACKAGE_INFO_JAVA_FILENAME, fileContent.toString(), fCreatedPackageFragment,this.isAddComments(), monitor);
563543
}
564-
565-
private void createPackageHtml(IPackageFragmentRoot root, IProgressMonitor monitor) throws CoreException {
566-
IWorkspace workspace= ResourcesPlugin.getWorkspace();
567-
IFolder createdPackage= workspace.getRoot().getFolder(fCreatedPackageFragment.getPath());
568-
IFile packageHtml= createdPackage.getFile(PACKAGE_HTML_FILENAME);
569-
String charset= packageHtml.getCharset();
570-
String content= buildPackageHtmlContent(root, charset);
571-
try {
572-
packageHtml.create(new ByteArrayInputStream(content.getBytes(charset)), false, monitor);
573-
} catch (UnsupportedEncodingException e) {
574-
String message= "charset " + charset + " not supported by platform"; //$NON-NLS-1$ //$NON-NLS-2$
575-
throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, message, e));
576-
}
577-
}
578-
579-
private String buildPackageHtmlContent(IPackageFragmentRoot root, String charset) throws CoreException {
580-
String lineDelimiter= StubUtility.getLineDelimiterUsed(root.getJavaProject());
581-
StringBuilder content = new StringBuilder();
582-
String fileComment= InfoFilesUtil.getFileComment(PACKAGE_INFO_JAVA_FILENAME, fCreatedPackageFragment, lineDelimiter);
583-
String typeComment= InfoFilesUtil.getTypeComment(PACKAGE_INFO_JAVA_FILENAME, fCreatedPackageFragment, lineDelimiter);
584-
585-
content.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">"); //$NON-NLS-1$
586-
content.append(lineDelimiter);
587-
if (fileComment != null) {
588-
content.append("<!--"); //$NON-NLS-1$
589-
content.append(lineDelimiter);
590-
content.append(stripJavaComments(fileComment));
591-
content.append(lineDelimiter);
592-
content.append("-->"); //$NON-NLS-1$
593-
content.append(lineDelimiter);
594-
}
595-
content.append("<html>"); //$NON-NLS-1$
596-
content.append(lineDelimiter);
597-
content.append("<head>"); //$NON-NLS-1$
598-
content.append(lineDelimiter);
599-
content.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); //$NON-NLS-1$
600-
content.append(charset);
601-
content.append("\">"); //$NON-NLS-1$
602-
content.append(lineDelimiter);
603-
content.append("<title>"); //$NON-NLS-1$
604-
content.append(fCreatedPackageFragment.getElementName());
605-
content.append("</title>"); //$NON-NLS-1$
606-
content.append(lineDelimiter);
607-
content.append("</head>"); //$NON-NLS-1$
608-
content.append(lineDelimiter);
609-
content.append("<body>"); //$NON-NLS-1$
610-
content.append(lineDelimiter);
611-
612-
if (typeComment != null) {
613-
content.append(stripJavaComments(typeComment));
614-
content.append(lineDelimiter);
615-
}
616-
617-
content.append("</body>"); //$NON-NLS-1$
618-
content.append(lineDelimiter);
619-
content.append("</html>"); //$NON-NLS-1$
620-
621-
return content.toString();
622-
}
623-
624-
private String stripJavaComments(String comment) {
625-
DocumentAdapter documentAdapter= new DocumentAdapter(null, fCreatedPackageFragment.getPath());
626-
documentAdapter.setContents(comment);
627-
try (JavaDoc2HTMLTextReader reader= new JavaDoc2HTMLTextReader(new JavaDocCommentReader(documentAdapter, 0, comment.length()))) {
628-
return getString(reader);
629-
} catch (IOException e) {
630-
throw new RuntimeException(e);
631-
} finally {
632-
documentAdapter.close();
633-
}
634-
}
635-
636-
private static String getString(Reader reader) {
637-
StringBuilder buf= new StringBuilder();
638-
char[] buffer= new char[1024];
639-
int count;
640-
try {
641-
while ((count= reader.read(buffer)) != -1)
642-
buf.append(buffer, 0, count);
643-
} catch (IOException e) {
644-
return null;
645-
}
646-
return buf.toString();
647-
}
648-
649544
}

0 commit comments

Comments
 (0)