Lines 1976-1979
Link Here
|
1976 |
"}\n" |
1976 |
"}\n" |
1977 |
); |
1977 |
); |
1978 |
} |
1978 |
} |
|
|
1979 |
|
1980 |
/** |
1981 |
* @bug 295238: [formatter] The comment formatter add an unexpected new line in block comment |
1982 |
* @test Verify that formatting a block comment with a tag does not add an unexpected new line |
1983 |
* when the 'Never join lines' option is set |
1984 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295238" |
1985 |
*/ |
1986 |
public void testBug295238() { |
1987 |
this.formatterPrefs.join_lines_in_comments = false; |
1988 |
String source = |
1989 |
"package wksp1;\n" + |
1990 |
"\n" + |
1991 |
"public interface X03 {\n" + |
1992 |
" \n" + |
1993 |
" class Inner {\n" + |
1994 |
" \n" + |
1995 |
" /* (non-Javadoc)\n" + |
1996 |
" * @see org.eclipse.jface.text.TextViewer#customizeDocumentCommand(org.eclipse.jface.text.DocumentCommand)\n" + |
1997 |
" */\n" + |
1998 |
" protected void foo() {\n" + |
1999 |
" }\n" + |
2000 |
" }\n" + |
2001 |
"}\n"; |
2002 |
formatSource(source, |
2003 |
"package wksp1;\n" + |
2004 |
"\n" + |
2005 |
"public interface X03 {\n" + |
2006 |
"\n" + |
2007 |
" class Inner {\n" + |
2008 |
"\n" + |
2009 |
" /*\n" + |
2010 |
" * (non-Javadoc)\n" + |
2011 |
" * \n" + |
2012 |
" * @see\n" + |
2013 |
" * org.eclipse.jface.text.TextViewer#customizeDocumentCommand(org.eclipse\n" + |
2014 |
" * .jface.text.DocumentCommand)\n" + |
2015 |
" */\n" + |
2016 |
" protected void foo() {\n" + |
2017 |
" }\n" + |
2018 |
" }\n" + |
2019 |
"}\n" |
2020 |
); |
2021 |
} |
2022 |
// the following test already passed with v_A21, but failed with first version of the patch |
2023 |
public void testBug295238b1() { |
2024 |
this.formatterPrefs.join_lines_in_comments = false; |
2025 |
String source = |
2026 |
"package wksp1;\n" + |
2027 |
"\n" + |
2028 |
"public class X02 {\n" + |
2029 |
"\n" + |
2030 |
" void foo() {\n" + |
2031 |
"/* if ((operatorSignature & CompareMASK) == (alternateOperatorSignature & CompareMASK)) { // same promotions and result\n" + |
2032 |
" scope.problemReporter().unnecessaryCastForArgument((CastExpression)expression, TypeBinding.wellKnownType(scope, expression.implicitConversion >> 4)); \n" + |
2033 |
" }\n" + |
2034 |
"*/ \n" + |
2035 |
" }\n" + |
2036 |
"}\n"; |
2037 |
formatSource(source, |
2038 |
"package wksp1;\n" + |
2039 |
"\n" + |
2040 |
"public class X02 {\n" + |
2041 |
"\n" + |
2042 |
" void foo() {\n" + |
2043 |
" /*\n" + |
2044 |
" * if ((operatorSignature & CompareMASK) == (alternateOperatorSignature\n" + |
2045 |
" * & CompareMASK)) { // same promotions and result\n" + |
2046 |
" * scope.problemReporter().unnecessaryCastForArgument((CastExpression)\n" + |
2047 |
" * expression, TypeBinding.wellKnownType(scope,\n" + |
2048 |
" * expression.implicitConversion >> 4));\n" + |
2049 |
" * }\n" + |
2050 |
" */\n" + |
2051 |
" }\n" + |
2052 |
"}\n" |
2053 |
); |
2054 |
} |
2055 |
// the following test failed with v_A21 and with the version v00 of the patch |
2056 |
public void testBug295238b2() { |
2057 |
this.formatterPrefs.join_lines_in_comments = false; |
2058 |
String source = |
2059 |
"package wksp1;\n" + |
2060 |
"\n" + |
2061 |
"public class X02 {\n" + |
2062 |
"\n" + |
2063 |
" void foo() {\n" + |
2064 |
"/* scope.problemReporter().unnecessaryCastForArgument((CastExpression)expression, TypeBinding.wellKnownType(scope, expression.implicitConversion >> 4)); \n" + |
2065 |
"*/ \n" + |
2066 |
" }\n" + |
2067 |
"}\n"; |
2068 |
formatSource(source, |
2069 |
"package wksp1;\n" + |
2070 |
"\n" + |
2071 |
"public class X02 {\n" + |
2072 |
"\n" + |
2073 |
" void foo() {\n" + |
2074 |
" /*\n" + |
2075 |
" * scope.problemReporter().unnecessaryCastForArgument((CastExpression)\n" + |
2076 |
" * expression, TypeBinding.wellKnownType(scope,\n" + |
2077 |
" * expression.implicitConversion >> 4));\n" + |
2078 |
" * }\n" + |
2079 |
" */\n" + |
2080 |
" }\n" + |
2081 |
"}\n" |
2082 |
); |
2083 |
} |
2084 |
// the following test failed with v_A21 and with the version v00 of the patch |
2085 |
public void testBug295238b3() { |
2086 |
this.formatterPrefs.join_lines_in_comments = false; |
2087 |
String source = |
2088 |
"package wksp1;\n" + |
2089 |
"\n" + |
2090 |
"public class X02 {\n" + |
2091 |
"\n" + |
2092 |
" void foo() {\n" + |
2093 |
"/*\n" + |
2094 |
" scope.problemReporter().unnecessaryCastForArgument((CastExpression)expression, TypeBinding.wellKnownType(scope, expression.implicitConversion >> 4)); \n" + |
2095 |
" }\n" + |
2096 |
"*/ \n" + |
2097 |
" }\n" + |
2098 |
"}\n"; |
2099 |
formatSource(source, |
2100 |
"package wksp1;\n" + |
2101 |
"\n" + |
2102 |
"public class X02 {\n" + |
2103 |
"\n" + |
2104 |
" void foo() {\n" + |
2105 |
" /*\n" + |
2106 |
" * scope.problemReporter().unnecessaryCastForArgument((CastExpression)\n" + |
2107 |
" * expression, TypeBinding.wellKnownType(scope,\n" + |
2108 |
" * expression.implicitConversion >> 4));\n" + |
2109 |
" * }\n" + |
2110 |
" */\n" + |
2111 |
" }\n" + |
2112 |
"}\n" |
2113 |
); |
2114 |
} |
1979 |
} |
2115 |
} |