| /******************************************************************************* |
| * Copyright (c) 2000, 2004 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.jdt.ui.tests.quickfix; |
| |
| import java.util.ArrayList; |
| import java.util.Hashtable; |
| |
| import junit.framework.Test; |
| import junit.framework.TestSuite; |
| |
| import org.eclipse.jdt.testplugin.JavaProjectHelper; |
| import org.eclipse.jdt.testplugin.TestOptions; |
| |
| import org.eclipse.jface.preference.IPreferenceStore; |
| |
| import org.eclipse.jdt.core.ICompilationUnit; |
| import org.eclipse.jdt.core.IJavaProject; |
| import org.eclipse.jdt.core.IPackageFragment; |
| import org.eclipse.jdt.core.IPackageFragmentRoot; |
| import org.eclipse.jdt.core.JavaCore; |
| import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; |
| |
| import org.eclipse.jdt.ui.PreferenceConstants; |
| import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; |
| |
| import org.eclipse.jdt.internal.ui.JavaPlugin; |
| import org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal; |
| |
| public class JavadocQuickFixTest extends QuickFixTest { |
| |
| private static final Class THIS= JavadocQuickFixTest.class; |
| |
| private IJavaProject fJProject1; |
| private IPackageFragmentRoot fSourceFolder; |
| |
| public JavadocQuickFixTest(String name) { |
| super(name); |
| } |
| |
| |
| public static Test allTests() { |
| return new ProjectTestSetup(new TestSuite(THIS)); |
| } |
| |
| public static Test suite() { |
| if (true) { |
| return allTests(); |
| } else { |
| TestSuite suite= new TestSuite(); |
| suite.addTest(new JavadocQuickFixTest("testInsertAllMissing2")); |
| return new ProjectTestSetup(suite); |
| } |
| } |
| |
| |
| protected void setUp() throws Exception { |
| Hashtable options= TestOptions.getFormatterOptions(); |
| options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); |
| options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); |
| options.put(JavaCore.COMPILER_PB_INVALID_JAVADOC, JavaCore.ERROR); |
| options.put(JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS, JavaCore.ERROR); |
| JavaCore.setOptions(options); |
| |
| IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); |
| store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); |
| |
| fJProject1= ProjectTestSetup.getProject(); |
| |
| fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); |
| } |
| |
| |
| protected void tearDown() throws Exception { |
| JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); |
| } |
| |
| |
| public void testMissingParam1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| |
| public void testMissingParam2() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| public void testMissingParam3() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int b, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| |
| public void testMissingReturn1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int b, int c) {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" * @return\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int b, int c) {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| |
| public void testMissingReturn2() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo() {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @return\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo() {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| |
| public void testMissingReturn3() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo() throws Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @return\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo() throws Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| assertEqualString(preview2, expected); |
| } |
| |
| public void testInsertAllMissing1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 4); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @return\n"); |
| buf.append(" * @throws NullPointerException\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected1= buf.toString(); |
| |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @return\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected2= buf.toString(); |
| |
| assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); |
| |
| } |
| |
| public void testInsertAllMissing2() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @return a number\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b, int c) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 4); |
| assertNumberOfProposals(proposals, 2); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| proposal= (CUCorrectionProposal) proposals.get(1); |
| String preview2= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" * @return a number\n"); |
| buf.append(" * @throws NullPointerException\n"); |
| buf.append(" * @throws Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b, int c) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected1= buf.toString(); |
| |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * @param b\n"); |
| buf.append(" * @return a number\n"); |
| buf.append(" */\n"); |
| buf.append(" public int foo(int a, int b, int c) throws NullPointerException, Exception {\n"); |
| buf.append(" return 1;\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected2= buf.toString(); |
| |
| assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); |
| |
| } |
| |
| public void testRemoveParamTag1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| public void testRemoveParamTag2() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| |
| public void testRemoveThrowsTag1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" * @throws Exception Thrown by surprise.\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @param c\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a, int c) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| public void testRemoveThrowsTag2() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| public void testRemoveThrowsTag3() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("import java.io.IOException;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" * @exception java.io.IOException\n"); |
| buf.append(" * @exception NullPointerException\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws IOException {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("import java.io.IOException;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception java.io.IOException\n"); |
| buf.append(" * @exception NullPointerException\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws IOException {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| public void testRemoveReturnTag1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @return Returns the result.\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws Exception {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws Exception {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| public void testRemoveUnknownTag1() throws Exception { |
| IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); |
| StringBuffer buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @return Returns the result.\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws Exception {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); |
| |
| ArrayList proposals= collectCorrections2(cu, 1); |
| assertNumberOfProposals(proposals, 1); |
| assertCorrectLabels(proposals); |
| |
| CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
| String preview1= getPreviewContent(proposal); |
| |
| buf= new StringBuffer(); |
| buf.append("package test1;\n"); |
| buf.append("/**\n"); |
| buf.append(" */\n"); |
| buf.append("public class E {\n"); |
| buf.append(" /**\n"); |
| buf.append(" * @param a\n"); |
| buf.append(" * comment on second line.\n"); |
| buf.append(" * @exception Exception\n"); |
| buf.append(" */\n"); |
| buf.append(" public void foo(int a) throws Exception {\n"); |
| buf.append(" }\n"); |
| buf.append("}\n"); |
| String expected= buf.toString(); |
| assertEqualString(preview1, expected); |
| } |
| |
| |
| } |