Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Matela2018-03-02 19:46:21 +0000
committerMateusz Matela2018-03-02 19:46:21 +0000
commitf6d965b3e788271d4d6495c36d02cdd306d044aa (patch)
tree0a63004fb2e028aeca5c7b08acccf69f3d10ccf0 /org.eclipse.jdt.core.tests.model
parentfd81ec3c9365b23909a03f0a3ecb9f1cc5a692e7 (diff)
downloadeclipse.jdt.core-f6d965b3e788271d4d6495c36d02cdd306d044aa.tar.gz
eclipse.jdt.core-f6d965b3e788271d4d6495c36d02cdd306d044aa.tar.xz
eclipse.jdt.core-f6d965b3e788271d4d6495c36d02cdd306d044aa.zip
Bug 487686 - [formatter] Make default profiles work with auto-format: Disable formatting for commented codeI20180303-0800I20180303-0335I20180303-0155I20180303-0055I20180302-2000
Diffstat (limited to 'org.eclipse.jdt.core.tests.model')
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java3
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java21
4 files changed, 36 insertions, 14 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index daacae43df..06c32a4042 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1476,6 +1476,7 @@ public void testBug199265c1() throws JavaModelException {
);
}
public void testBug199265c2() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.comment_format_header = true;
String source =
"import java.util.List;\n" +
@@ -4447,6 +4448,7 @@ public void testBug293300_wksp2_10() {
);
}
public void testBug293300_wksp2_11() {
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp2;\n" +
"\n" +
@@ -4582,6 +4584,7 @@ public void testBug293300_wksp2_12b() {
}
public void testBug293300_wksp2_13() {
useOldCommentWidthCounting();
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp2;\n" +
"\n" +
@@ -4613,6 +4616,7 @@ public void testBug293300_wksp2_13() {
);
}
public void testBug293300_wksp2_14() {
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp2;\n" +
"\n" +
@@ -4697,6 +4701,7 @@ public void testBug293300_wksp2_15b() {
);
}
public void testBug293300_wksp3_01() {
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp3;\n" +
"\n" +
@@ -5714,6 +5719,7 @@ public void testBug298243() {
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=298844"
*/
public void testBug298844a() {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.insert_new_line_in_empty_method_body = false;
String source =
"public class X01 {\n" +
@@ -6154,6 +6160,7 @@ public void testBug311578a() throws JavaModelException {
);
}
public void testBug311578b() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.use_tags = true;
this.formatterPrefs.disabling_tag = "/* J- */".toCharArray();
this.formatterPrefs.enabling_tag = "/* J+ */".toCharArray();
@@ -6289,6 +6296,8 @@ public void testBug311578c() throws JavaModelException {
);
}
public void testBug311578d() throws JavaModelException {
+ this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN,
+ DefaultCodeFormatterConstants.TRUE);
this.formatterPrefs = null;
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE);
this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, "/*F--*/");
@@ -9370,6 +9379,7 @@ public void testBug330313_wksp1_40_njl() {
);
}
public void testBug330313_wksp1_41_njl() {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.join_wrapped_lines = false;
String source =
"package wksp1;\n" +
@@ -10959,6 +10969,7 @@ public void testBug465669() throws Exception {
);
}
public void testBug471090() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.tab_char = DefaultCodeFormatterOptions.SPACE;
this.formatterPrefs.indentation_size = 2;
String source =
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
index 25b984d749..658571ccdb 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2117,6 +2117,7 @@ public void testBug236230() throws JavaModelException {
);
}
public void testBug236230b() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
String source =
"/**\n" +
" * Need a javadoc comment before to get the exception.\n" +
@@ -2309,6 +2310,7 @@ public void testBug236406_CDB1() {
);
}
public void testBug236406_CDB2() {
+ setFormatLineCommentOnFirstColumn();
String source =
"/** Javadoc comment */void foo1() {System.out.println();}\n" +
"// Line comment \n" +
@@ -2351,6 +2353,7 @@ public void testBug236406_EX1() {
);
}
public void testBug236406_EX2() {
+ setFormatLineCommentOnFirstColumn();
String source =
"// Line comment \n" +
"i = \n" +
@@ -2388,6 +2391,7 @@ public void testBug236406_ST1() {
);
}
public void testBug236406_ST2() {
+ setFormatLineCommentOnFirstColumn();
String source =
"/** Javadoc comment */foo1();\n" +
"// Line comment \n" +
@@ -3650,6 +3654,7 @@ public void testBug241687() throws JavaModelException {
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=251133"
*/
public void testBug251133() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
String source =
"public class X01 {\n" +
"// int a = 1;\n" +
@@ -6291,6 +6296,7 @@ public void testBug300379b() {
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=304705"
*/
public void testBug304705() {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.never_indent_line_comments_on_first_column = true;
String source =
"public interface Example {\n" +
@@ -6976,6 +6982,7 @@ public void testBug313651_01b() {
formatSource(source);
}
public void testBug313651_01c() {
+ setFormatLineCommentOnFirstColumn();
String source =
"public class X01 {\n" +
" public void testMethod() {\n" +
@@ -7032,6 +7039,7 @@ public void testBug313651_02b() {
formatSource(source);
}
public void testBug313651_02c() {
+ setFormatLineCommentOnFirstColumn();
String source =
"public class X02 {\n" +
" public void testMethod() {\n" +
@@ -7088,6 +7096,7 @@ public void testBug313651_03b() {
formatSource(source);
}
public void testBug313651_03c() {
+ setFormatLineCommentOnFirstColumn();
String source =
"public class X03 {\n" +
" public void testMethod() {\n" +
@@ -7111,6 +7120,7 @@ public void testBug313651_03c() {
);
}
public void testBug313651_wksp3_01() {
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp3;\n" +
"public class X01 implements\n" +
@@ -7131,6 +7141,7 @@ public void testBug313651_wksp3_01() {
);
}
public void testBug313651_wksp3_02() {
+ setFormatLineCommentOnFirstColumn();
String source =
"package wksp3;\n" +
"public class X02 implements MyOtherInterface, \n" +
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
index 192044bb8e..afa74b11fd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -802,6 +802,7 @@ public void testLineComments05() throws JavaModelException {
formatUnit("comments.line", "X05.java");
}
public void testLineComments06() throws JavaModelException {
+ setFormatLineCommentOnFirstColumn();
formatUnit("comments.line", "X06.java");
}
public void testLineComments07() throws JavaModelException {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
index f6521a9af1..dacaf3a405 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java
@@ -125,19 +125,14 @@ public class FormatterRegressionTests extends AbstractJavaModelTests {
protected void useOldCommentWidthCounting() {
this.formatterPrefs.comment_count_line_length_from_starting_position = false;
}
+
/**
- * Returns the OS path to the directory that contains this plugin.
- *
- protected String getPluginDirectoryPath() {
- try {
- URL platformURL = Platform.getBundle("org.eclipse.jdt.core.tests.model").getEntry("/");
- return new File(FileLocator.toFileURL(platformURL).getFile()).getAbsolutePath();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
+ * Helper function for old tests that are expect comment line comments
+ * on first column to be formatted.
+ */
+ protected void setFormatLineCommentOnFirstColumn() {
+ this.formatterPrefs.comment_format_line_comment_starting_on_first_column = true;
}
- */
private String getResource(String packageName, String resourceName) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
@@ -7987,6 +7982,7 @@ public class FormatterRegressionTests extends AbstractJavaModelTests {
public void test553() {
Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings();
DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
+ preferences.comment_format_line_comment_starting_on_first_column = true;
preferences.tab_char = DefaultCodeFormatterOptions.SPACE;
preferences.tab_size = 4;
DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
@@ -8001,6 +7997,7 @@ public class FormatterRegressionTests extends AbstractJavaModelTests {
public void test554() {
Map options = DefaultCodeFormatterConstants.getJavaConventionsSettings();
DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
+ preferences.comment_format_line_comment_starting_on_first_column = true;
preferences.tab_char = DefaultCodeFormatterOptions.SPACE;
preferences.tab_size = 4;
DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
@@ -13301,6 +13298,7 @@ public void testBug479109c() {
* https://bugs.eclipse.org/479109 - [formatter] Add option to group aligned fields with blank lines
*/
public void testBug479109d() {
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.align_type_members_on_columns = true;
this.formatterPrefs.align_fields_grouping_blank_lines = 2;
String source =
@@ -13942,6 +13940,7 @@ public void testBug493296() throws JavaModelException {
*/
public void testBug362260a() throws JavaModelException {
setPageWidth80();
+ setFormatLineCommentOnFirstColumn();
this.formatterPrefs.comment_line_length = 40;
this.formatterPrefs.comment_format_header = true;
this.formatterPrefs.comment_count_line_length_from_starting_position = true;

Back to the top