Skip to content

Commit

Permalink
Javadoc: fix unclosed <code>
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and jukzi committed Nov 30, 2023
1 parent b2cad64 commit 8e7bc9c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import junit.framework.ComparisonFailure;
import junit.framework.Test;

import org.eclipse.core.runtime.IPath;
Expand Down Expand Up @@ -252,8 +254,21 @@ void formatUnit(String packageName, String unitName) throws JavaModelException{
void formatUnit(String packageName, String unitName, int kind, int indentationLevel, boolean checkNull, int offset, int length, String lineSeparator) throws JavaModelException{
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getCompilationUnit(JAVA_PROJECT.getElementName() , "", "test."+packageName, unitName); //$NON-NLS-1$ //$NON-NLS-2$
String outputSource = getOutputSource(this.workingCopies[0]);
formatSource(this.workingCopies[0].getSource(), outputSource, kind, indentationLevel, offset, length, lineSeparator, true);
File expectedFile = getExpectedOutput(this.workingCopies[0]);
String expectedOutput;
try {
expectedOutput = expectedFile == null ? null : Files.readString(expectedFile.toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
formatSource(this.workingCopies[0].getSource(), expectedOutput, kind, indentationLevel, offset, length,
lineSeparator, true);
} catch (ComparisonFailure e) {
e.addSuppressed(new RuntimeException("Happend when formating: \n\"" + this.workingCopies[0].getPath()
+ "\"\nExpected output:\n\"" + expectedFile + "\""));
throw e;
}
}

/**
Expand All @@ -277,7 +292,7 @@ protected List getProjectCompilationUnits(IJavaProject javaProject) throws JavaM
return allUnits;
}

private String getOutputSource(ICompilationUnit unit) throws JavaModelException {
private File getExpectedOutput(ICompilationUnit unit) throws JavaModelException {
IPath outputPath = JAVA_PROJECT.getProject().getLocation().removeLastSegments(1)
.append(unit.getParent().getPath())
.append(getOutputFolder())
Expand All @@ -295,14 +310,7 @@ private String getOutputSource(ICompilationUnit unit) throws JavaModelException
return null;
}
}
try {
return new String(org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(outputFile, null));
}
catch (IOException e) {
// should never happen
throw new RuntimeException(e);
}

return outputFile;
}

IPath getOutputFolder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3611,7 +3611,7 @@ public void testBug60689() throws JavaModelException {
" /**\n" +
" * Returns the length of the string representing the number of \n" +
" * indents in the given string <code>line</code>. Returns \n" +
" * <code>-1<code> if the line isn't prefixed with an indent of\n" +
" * <code>-1</code> if the line isn't prefixed with an indent of\n" +
" * the given number of indents. \n" +
" */\n" +
" public static int computeIndentLength(String line, int numberOfIndents, int tabWidth) {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class X08 {
/**
* @param parent the parent control under which the control must be created
* @param direction the layout direction of the contents, either </code>SWT.HORIZONTAL<code> or </code>SWT.VERTICAL<code>
* @param direction the layout direction of the contents, either <code>SWT.HORIZONTAL</code> or <code>SWT.VERTICAL</code>
* @return the SWT control hierarchy for the outline part of the compare editor
* @since 3.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class X08 {
* the parent control under which the control must be created
* @param direction
* the layout direction of the contents, either
* </code>SWT.HORIZONTAL<code> or </code>SWT.VERTICAL<code>
* <code>SWT.HORIZONTAL</code> or <code>SWT.VERTICAL</code>
* @return the SWT control hierarchy for the outline part of the compare
* editor
* @since 3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class X08 {
* the parent control under which the control must be created
* @param direction
* the layout direction of the contents, either
* </code>SWT.HORIZONTAL<code> or </code>SWT.VERTICAL<code>
* <code>SWT.HORIZONTAL</code> or <code>SWT.VERTICAL</code>
* @return the SWT control hierarchy for the outline part of the compare
* editor
* @since 3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class X08 {
* @param parent
* the parent control under which the control must be created
* @param direction
* the layout direction of the contents, either
* </code>SWT.HORIZONTAL<code> or </code>SWT.VERTICAL<code>
* the layout direction of the contents, either <code>SWT.HORIZONTAL</code>
* or <code>SWT.VERTICAL</code>
* @return the SWT control hierarchy for the outline part of the compare
* editor
* @since 3.0
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ public static CompilationUnit parseCompilationUnit(
private int bits;

/**
* Default value of <code>flag<code> when a new node is created.
* Default value of <code>flag</code> when a new node is created.
*/
private int defaultNodeFlag = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ IVariableBinding resolveVariable(VariableDeclaration variable) {
* </p>
*
* @param name the name of a well known type
* @return the corresponding type binding, or <code>null<code> if the
* @return the corresponding type binding, or <code>null</code> if the
* named type is not considered well known or if no binding can be found
* for it
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public static ReplaceEdit[] getChangeIndentEdits(String source, int indentUnitsT

/*
* Returns the index where the indent of the given size ends.
* Returns <code>-1<code> if the line isn't prefixed with an indent of
* Returns <code>-1</code> if the line isn't prefixed with an indent of
* the given number of indents.
*/
private static int indexOfIndent(CharSequence line, int numberOfIndentUnits, int tabWidth, int indentWidth) {
Expand Down

0 comments on commit 8e7bc9c

Please sign in to comment.