Adapt to Suite API change in core.tests. Change-Id: Ia6bfa2f411bdd41a2ca4ef71059ed7f8b7a7e1bc Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/assist/RubySelectionTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/assist/RubySelectionTests.java index e57f432..147ace6 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/assist/RubySelectionTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/assist/RubySelectionTests.java
@@ -3,14 +3,12 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ package org.eclipse.dltk.ruby.core.tests.assist; -import junit.framework.Test; - import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.NullProgressMonitor; @@ -22,6 +20,8 @@ import org.eclipse.dltk.core.tests.model.AbstractModelCompletionTests; import org.eclipse.dltk.ruby.internal.core.codeassist.RubySelectionEngine; +import junit.framework.Test; + public class RubySelectionTests extends AbstractModelCompletionTests { // Used only for testing checkSelection method @@ -51,23 +51,21 @@ private static final ThinkRubySelectionEngine thinkEngine = new ThinkRubySelectionEngine(); public RubySelectionTests(String name) { - super("org.eclipse.dltk.ruby.core.tests", name); + super(name); } @Override public void setUpSuite() throws Exception { - PROJECT = setUpScriptProjectTo(SELECTION_PROJECT, "Selection"); + PROJECT = setUpScriptProjectTo(SELECTION_PROJECT, "Selection", "org.eclipse.dltk.ruby.core.tests"); super.setUpSuite(); waitUntilIndexesReady(); - ResourcesPlugin.getWorkspace() - .build(IncrementalProjectBuilder.FULL_BUILD, - new NullProgressMonitor()); + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); waitForAutoBuild(); } - + @Override - public void tearDownSuite () throws Exception { + public void tearDownSuite() throws Exception { deleteProject(SELECTION_PROJECT); super.tearDownSuite(); } @@ -77,10 +75,10 @@ } /* - * + * * ckeckSelection() method tests - * - * + * + * */ public String getCheckrbSource() throws ModelException { @@ -88,8 +86,8 @@ return cu.getSource(); } - public void selectionPosChecker0(int start, int end, boolean expRes, - int expStart, int expEnd) throws ModelException { + public void selectionPosChecker0(int start, int end, boolean expRes, int expStart, int expEnd) + throws ModelException { String source = getCheckrbSource(); boolean res = thinkEngine.checkSelection(source, start, end); assertEquals(expRes, res); @@ -105,11 +103,9 @@ assertTrue(start != -1); int end = start - 1; for (int i = 0; i < word.length(); i++) { - boolean res = thinkEngine - .checkSelection(source, start + i, end + i); + boolean res = thinkEngine.checkSelection(source, start + i, end + i); assertEquals(true, res); - String sel = source.substring(thinkEngine.getActualStart(), - thinkEngine.getActualEnd()); + String sel = source.substring(thinkEngine.getActualStart(), thinkEngine.getActualEnd()); assertEquals(word, sel); } } @@ -183,8 +179,7 @@ } public void testSelectionOnMethod() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("cool_method"); @@ -198,8 +193,7 @@ } public void testSelectionOnClassDeclaraion() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("Fooo"); @@ -213,8 +207,7 @@ } public void testSelectionOnClassUsage() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("Bar"); @@ -228,8 +221,7 @@ } public void testSelectionOnMethodDeclaration() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("doo"); @@ -244,14 +236,12 @@ public void testSelectionOnMethod2() throws ModelException { // NIM = not // in method - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("Bar.new.cool_method"); - IModelElement[] elements = cu.codeSelect(start + "Bar.new.".length() - + 2, 0); + IModelElement[] elements = cu.codeSelect(start + "Bar.new.".length() + 2, 0); assertNotNull(elements); assertEquals(1, elements.length); IMethod method = cu.getType("Bar").getMethod("cool_method"); @@ -263,8 +253,7 @@ // not // in // method - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("ff = Fooo.new") + 1; @@ -280,8 +269,7 @@ // not // in // method - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method1.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method1.rb"); String source = cu.getSource(); int start = source.indexOf("f.doo"); @@ -295,8 +283,7 @@ } public void testSelectionOnMethod2_1() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method2.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method2.rb"); String source = cu.getSource(); int start = source.indexOf("boz.dining_philosopher") + 5; @@ -310,8 +297,7 @@ } public void testSelectionOnMethod2_2() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method2.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method2.rb"); String source = cu.getSource(); int start = source.indexOf("ultimate_answer") + 1; @@ -325,8 +311,7 @@ } public void testSelectionOnMethod3_2() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_method3.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_method3.rb"); String source = cu.getSource(); int start = source.indexOf("megathing") + 1; @@ -338,10 +323,9 @@ assertNotNull(method); assertEquals(method, elements[0]); } - + public void testSelectionOnSuper() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_super.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_super.rb"); String source = cu.getSource(); int start = source.indexOf("super") + 1; @@ -352,8 +336,7 @@ } public void testBug185487() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "dsl/behaviour.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "dsl/behaviour.rb"); String source = cu.getSource(); int start = source.indexOf("example_finished") + 1; @@ -364,8 +347,7 @@ } public void testBug193105() throws ModelException { - ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "b193105.rb"); + ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "b193105.rb"); String source = cu.getSource(); int start = source.indexOf("instance_variable_set") + 1; @@ -374,30 +356,27 @@ assertNotNull(elements); assertEquals(1, elements.length); } - + public void testBug194721() throws ModelException { - final ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", - "selection_on_var.rb"); + final ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", "selection_on_var.rb"); final String source = cu.getSource(); final String variableName = "boolean"; final int start = source.lastIndexOf(variableName); final IModelElement[] before = cu.codeSelect(start, 0); assertNotNull(before); assertEquals(1, before.length); - final IModelElement[] after = cu.codeSelect(start - + variableName.length(), 0); + final IModelElement[] after = cu.codeSelect(start + variableName.length(), 0); assertNotNull(after); assertEquals(1, after.length); } - + // //// - public void executeTest(String module, int offset, int length) - throws ModelException { + public void executeTest(String module, int offset, int length) throws ModelException { ISourceModule cu = getSourceModule(SELECTION_PROJECT, "src", module); if (offset == 657) // for breakpoints System.out.println(); - + IModelElement[] elements = cu.codeSelect(offset, length); assertNotNull(elements); assertTrue(elements.length > 0); @@ -408,5 +387,4 @@ } - }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java index ba60d2a..1d569c9 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractASTTest.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -18,12 +18,10 @@ import org.eclipse.dltk.core.DLTKLanguageManager; import org.eclipse.dltk.core.tests.model.AbstractModelTests; import org.eclipse.dltk.ruby.core.RubyNature; -import org.eclipse.dltk.ruby.core.tests.Activator; public abstract class AbstractASTTest extends AbstractModelTests { - protected static class CountingProblemReporter extends - AbstractProblemReporter { + protected static class CountingProblemReporter extends AbstractProblemReporter { public int count = 0; public String lastInfo = "<no errors>"; @@ -51,33 +49,29 @@ protected final static CountingProblemReporter problems = new CountingProblemReporter(); public AbstractASTTest(String testProjectName, String name) { - super(testProjectName, name); + super(name); } public AbstractASTTest(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } protected ModuleDeclaration getAST(String content) { problems.reset(); - return (ModuleDeclaration) DLTKLanguageManager.getSourceParser( - RubyNature.NATURE_ID).parse(new ModuleSource(content), problems); + return (ModuleDeclaration) DLTKLanguageManager.getSourceParser(RubyNature.NATURE_ID) + .parse(new ModuleSource(content), problems); } - protected ASTNode getNodeAt(ASTNode root, final int start, final int end) - throws Exception { + protected ASTNode getNodeAt(ASTNode root, final int start, final int end) throws Exception { assertTrue((start != -1) || (end != -1)); final ASTNode[] result = new ASTNode[] { null }; ASTVisitor visitor = new ASTVisitor() { @Override public boolean visitGeneral(ASTNode node) throws Exception { - if ((node.sourceStart() == start || start == -1) - && (node.sourceEnd() == end || end == -1)) { - if (result[0] != null - && !(result[0] instanceof ModuleDeclaration)) - throw new RuntimeException("Two different nodes on " - + start + ":" + end); + if ((node.sourceStart() == start || start == -1) && (node.sourceEnd() == end || end == -1)) { + if (result[0] != null && !(result[0] instanceof ModuleDeclaration)) + throw new RuntimeException("Two different nodes on " + start + ":" + end); result[0] = node; } return true; @@ -92,8 +86,7 @@ protected abstract Class<?> getExpectedClass(); - protected ASTNode checkNode(String content, int start, int end) - throws Exception { + protected ASTNode checkNode(String content, int start, int end) throws Exception { ModuleDeclaration ast = getAST(content); assertNotNull(ast); if (problems.getCount() != 0) {
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractRubyParserTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractRubyParserTests.java index f29e295..5ecb646 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractRubyParserTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/parser/AbstractRubyParserTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -22,7 +22,7 @@ public abstract class AbstractRubyParserTests extends AbstractModelTests { public AbstractRubyParserTests(String testProjectName, String name) { - super(testProjectName, name); + super(name); } public ModuleDeclaration processScript(String name) throws Exception { @@ -39,9 +39,8 @@ buffer.append('\n'); } } - module = (ModuleDeclaration) DLTKLanguageManager.getSourceParser( - RubyNature.NATURE_ID).parse( - new ModuleSource(name, buffer.toString()), null); + module = (ModuleDeclaration) DLTKLanguageManager.getSourceParser(RubyNature.NATURE_ID) + .parse(new ModuleSource(name, buffer.toString()), null); assertNotNull(module); assertFalse(module.isEmpty()); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/resources/RubyResourcesTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/resources/RubyResourcesTests.java index b72c5dc..fd0ec22 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/resources/RubyResourcesTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/resources/RubyResourcesTests.java
@@ -3,12 +3,12 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * xored software, Inc. - initial API and Implementation - * xored software, Inc. - Search All occurences bugfix, + * xored software, Inc. - Search All occurences bugfix, * hilight only class name when class is in search results ( Alex Panchenko <alex@xored.com>) *******************************************************************************/ @@ -32,7 +32,7 @@ private static final String PROJECT2 = "resource2"; public RubyResourcesTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -42,8 +42,8 @@ @Override public void setUpSuite() throws Exception { super.setUpSuite(); - setUpScriptProject(PROJECT1); - setUpScriptProject(PROJECT2); + setUpScriptProject(PROJECT1, Activator.PLUGIN_ID); + setUpScriptProject(PROJECT2, Activator.PLUGIN_ID); waitUntilIndexesReady(); } @@ -73,11 +73,9 @@ assertTrue(project2.equals(project2a)); assertTrue(project2a.equals(project2)); // - final ISourceModule module1 = (ISourceModule) project1 - .findElement(new Path("resource001.rb")); + final ISourceModule module1 = (ISourceModule) project1.findElement(new Path("resource001.rb")); assertNotNull(module1); - final ISourceModule module1a = (ISourceModule) project1a - .findElement(new Path("resource001.rb")); + final ISourceModule module1a = (ISourceModule) project1a.findElement(new Path("resource001.rb")); assertNotNull(module1a); assertTrue(module1.equals(module1a)); assertTrue(module1a.equals(module1)); @@ -85,10 +83,8 @@ public void testTypeEquals() { final IProject project = getProject(PROJECT1); - final ISourceModule module1 = (ISourceModule) DLTKCore.create(project - .getFile("class1.rb")); - final ISourceModule module2 = (ISourceModule) DLTKCore.create(project - .getFile("class2.rb")); + final ISourceModule module1 = (ISourceModule) DLTKCore.create(project.getFile("class1.rb")); + final ISourceModule module2 = (ISourceModule) DLTKCore.create(project.getFile("class2.rb")); final IType type1 = module1.getType("A001"); final IType type2 = module2.getType("A001"); assertFalse(type1.equals(type2)); @@ -96,10 +92,8 @@ public void testSourceModuleEquals() { final IProject project = getProject(PROJECT1); - final ISourceModule module1 = (ISourceModule) DLTKCore.create(project - .getFile("folder1/class3.rb")); - final ISourceModule module2 = (ISourceModule) DLTKCore.create(project - .getFile("folder2/class3.rb")); + final ISourceModule module1 = (ISourceModule) DLTKCore.create(project.getFile("folder1/class3.rb")); + final ISourceModule module2 = (ISourceModule) DLTKCore.create(project.getFile("folder2/class3.rb")); assertFalse(module1.equals(module2)); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/rewriter/RewriterTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/rewriter/RewriterTests.java index b3c79b5..3820d1c 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/rewriter/RewriterTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/rewriter/RewriterTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -23,23 +23,36 @@ /** * @author mhowe - * - * The tests in this test case are intended to test class def's, type ref's, method def's, method ref's, block's, variable def's, variable ref's, hash - * expressions (very common in Ruby), expressions or statement. The tests don't go into detail for specific AST's, such as for, if etc. The intent here is to - * define the common top level AST's required for a majority of work with a rewriter, such as fix ups, re-factorings, renames, insertions/removal of high level - * elements at various points etc. - * - * The tests are intended to exercise the ability to locate a specific AST (such as a block, method def, statement etc) and then modify that AST or insert a new - * AST before or after the discovered AST. These are common use cases for modifying code from an AST perspective. - * - * The first pass of this test case uses ModuleDeclaration as a starting point but this is for demonstration only, no restriction on the API is suggested by - * this. ModuleDeclaration should be replaced with whatever is appropriate from the real API once created. These tests are fairly simple either using ruby files - * defined in the associated workspace or if the test is simple enough from strings in the test itself. Also many of tests so far are just method stubs with - * descriptive names to be filled in as the rewriter evolves. All tests require the rewriter API to be filled in. The checkResults method always fails, this - * requires converting an AST to a string and then comparing with the expected result. - * - * Once this stage of the rewriter is complete more test cases should be written which test the specific detailed AST's not covered by the tests in this test - * case. + * + * The tests in this test case are intended to test class def's, type + * ref's, method def's, method ref's, block's, variable def's, variable + * ref's, hash expressions (very common in Ruby), expressions or + * statement. The tests don't go into detail for specific AST's, such as + * for, if etc. The intent here is to define the common top level AST's + * required for a majority of work with a rewriter, such as fix ups, + * re-factorings, renames, insertions/removal of high level elements at + * various points etc. + * + * The tests are intended to exercise the ability to locate a specific + * AST (such as a block, method def, statement etc) and then modify that + * AST or insert a new AST before or after the discovered AST. These are + * common use cases for modifying code from an AST perspective. + * + * The first pass of this test case uses ModuleDeclaration as a starting + * point but this is for demonstration only, no restriction on the API + * is suggested by this. ModuleDeclaration should be replaced with + * whatever is appropriate from the real API once created. These tests + * are fairly simple either using ruby files defined in the associated + * workspace or if the test is simple enough from strings in the test + * itself. Also many of tests so far are just method stubs with + * descriptive names to be filled in as the rewriter evolves. All tests + * require the rewriter API to be filled in. The checkResults method + * always fails, this requires converting an AST to a string and then + * comparing with the expected result. + * + * Once this stage of the rewriter is complete more test cases should be + * written which test the specific detailed AST's not covered by the + * tests in this test case. */ public class RewriterTests extends AbstractModelTests { @@ -47,12 +60,12 @@ private static final String SRC_PROJECT = "rewriter"; public RewriterTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } @Override public void setUpSuite() throws Exception { - setUpScriptProject(SRC_PROJECT); + setUpScriptProject(SRC_PROJECT, Activator.PLUGIN_ID); super.setUpSuite(); waitUntilIndexesReady(); ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); @@ -65,43 +78,43 @@ } /////////////////////////////////////////////////////// - //Series of tests for adding various types of AST's + // Series of tests for adding various types of AST's /////////////////////////////////////////////////////// /** * Start with empty file and a header comment - * + * */ public void testAddCommentToEmptyScript() throws IOException { String content = loadContent(PATH_PREFIX + "empty_script.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //add header to to ast + // add header to to ast checkResults(ast, loadContent(PATH_PREFIX + "empty_script_with_header.rb")); } /** * Start with empty file and add class declaration - * + * */ public void testAddSimpleClassToEmptyScript() throws IOException { String content = loadContent(PATH_PREFIX + "empty_script.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //add class "Simple" after comment + // modify ast + // add class "Simple" after comment checkResults(ast, loadContent(PATH_PREFIX + "simple_class.rb")); } /** * Start with empty file and add class declaration - * + * */ public void testAddClassAfterHeader() throws IOException { String content = loadContent(PATH_PREFIX + "empty_script_with_header.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //add class "Simple" after comment + // modify ast + // add class "Simple" after comment checkResults(ast, loadContent(PATH_PREFIX + "simple_class_with_header.rb")); } @@ -110,100 +123,106 @@ public void testAddInnerClass() throws IOException { String content = loadContent(PATH_PREFIX + "simple_class.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //classAst.newClass("Inner"); + // modify ast + // classAst.newClass("Inner"); checkResults(ast, loadContent(PATH_PREFIX + "simple_nested_class.rb")); } /** * Insert new method before first method - * + * * @throws IOException */ public void testInsertMethodBeforeFirstMethod() throws IOException { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //insert new_method as first method + // modify ast + // insert new_method as first method checkResults(ast, loadContent(PATH_PREFIX + "simple1a.result")); } /** * Insert method after specific method - * + * * @throws IOException */ public void testInsertMethodAfterMethod() throws IOException { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //insert new_method after method m1 + // modify ast + // insert new_method after method m1 checkResults(ast, loadContent(PATH_PREFIX + "simple1b.result")); } /** * Insert method before specific method - * + * * @throws IOException */ public void testInsertMethodBeforeMethod() throws IOException { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //insert new_method before method m2 + // modify ast + // insert new_method before method m2 checkResults(ast, loadContent(PATH_PREFIX + "simple1b.result")); } /** * Append method after last method - * + * * @throws IOException */ public void testAppendMethod() throws IOException { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast - //append new_method after last method + // modify ast + // append new_method after last method checkResults(ast, loadContent(PATH_PREFIX + "simple1c.result")); } /** - * Tests discovering a block and then inserting a method call as the first call in that block + * Tests discovering a block and then inserting a method call as the first call + * in that block */ public void testInsertAsFirstMethodCallInBlock() { assertTrue(false); } /** - * Tests discovering a block and then inserting a method call as the last call in that block + * Tests discovering a block and then inserting a method call as the last call + * in that block */ public void testInsertAsLastMethodCallInBlock() { assertTrue(false); } /** - * Tests discovering a method definition and then inserting a method call as the first call in that block + * Tests discovering a method definition and then inserting a method call as the + * first call in that block */ public void testInsertAsFirstMethodCallInMethodDef() { assertTrue(false); } /** - * Tests discovering a method definition and then inserting a method call as the last call in that block + * Tests discovering a method definition and then inserting a method call as the + * last call in that block */ public void testInsertAsLastMethodCallInMetohdDef() { assertTrue(false); } /** - * Tests discovering a specific statement and then inserting a method call before that statement + * Tests discovering a specific statement and then inserting a method call + * before that statement */ public void testMethodCallBeforeStatement() { assertTrue(false); } /** - * Tests discovering a specific statement and then inserting a method call after that statement + * Tests discovering a specific statement and then inserting a method call after + * that statement */ public void testMethodCallAfterStatement() { assertTrue(false); @@ -238,7 +257,8 @@ } /** - * Tests inserting a parameter as a specific parameter in a method def, i.e. test adding a parameter between parameter 0 and parameter 1 + * Tests inserting a parameter as a specific parameter in a method def, i.e. + * test adding a parameter between parameter 0 and parameter 1 */ public void testInsertParameterInSpecificPosInMethodDef() { assertTrue(false); @@ -259,22 +279,24 @@ } /** - * Tests inserting a parameter before the block in a method call (similar to appending a parameter as the last parameter but specifically tests the case where - * a block is used) + * Tests inserting a parameter before the block in a method call (similar to + * appending a parameter as the last parameter but specifically tests the case + * where a block is used) */ public void testInsertBeforeBlockInMethodCall() { assertTrue(false); } /** - * Tests inserting a parameter as a specific parameter in a method call, i.e. test adding a parameter between parameter 0 and parameter 1 + * Tests inserting a parameter as a specific parameter in a method call, i.e. + * test adding a parameter between parameter 0 and parameter 1 */ public void testInsertParameterInSpecificPosInMethodCall() { assertTrue(false); } /////////////////////////////////////////////////////// - //Series of tests for modifying references + // Series of tests for modifying references /////////////////////////////////////////////////////// /** * Change variable reference @@ -282,7 +304,7 @@ public void testChangeClassVariableReference() { String content = "@@class_var = 'hello'"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change @var to @new_var + // change @var to @new_var checkResults(ast, "@@new_class_var = 'hello')"); } @@ -292,7 +314,7 @@ public void testChangeInstanceVariableReference() { String content = "puts(@instance_var = 'hello')"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change @var to @new_var + // change @var to @new_var checkResults(ast, "puts(@new_instance_var = 'hello')"); } @@ -302,7 +324,7 @@ public void testChangeVariableReference() { String content = "puts(var = 'hello')"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change @var to @new_var + // change @var to @new_var checkResults(ast, "puts(new_var = 'hello')"); } @@ -312,7 +334,7 @@ public void testChangeTypeReference() { String content = "@var = Stringx.new"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change type reference Stringx to String + // change type reference Stringx to String checkResults(ast, "@var = String.new"); } @@ -322,7 +344,7 @@ public void testChangeMethodReference() { String content = "@var = String.newx"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change method reference newx to new + // change method reference newx to new checkResults(ast, "@var = String.new"); } @@ -332,7 +354,7 @@ public void testChangeSymbolReference() { String content = "var = :my_symbol"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //change symbol ref from :my_symbol to :your_symbol + // change symbol ref from :my_symbol to :your_symbol checkResults(ast, "var = :your_symbol"); } @@ -342,27 +364,28 @@ public void testChangeStringLiteral() { String content = "var = 'my_string'"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast + // modify ast checkResults(ast, "var = 'your_string'"); } - //TODO + // TODO public void testChangeNumericLiteral() { String content = "var = 123"; ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); - //modify ast + // modify ast checkResults(ast, "var = 4567"); } /** - * Test adding parenthesis around a method call (tests finding all the parameters to a call) + * Test adding parenthesis around a method call (tests finding all the + * parameters to a call) */ public void testAddParenthesisAroundMethodCall() { assertTrue(false); } /////////////////////////////////////////////////////// - //Series of tests for modifying whitespace and delimeters + // Series of tests for modifying whitespace and delimeters /////////////////////////////////////////////////////// public void testRemoveLeadingWhiteSpace() { assertTrue(false); @@ -389,7 +412,7 @@ } /////////////////////////////////////////////////////// - //Series of tests for removing various types of AST's + // Series of tests for removing various types of AST's /////////////////////////////////////////////////////// /** @@ -441,7 +464,7 @@ assertTrue(false); } - //This assumes some way of resolving the formatted text from an AST + // This assumes some way of resolving the formatted text from an AST private void checkResults(ModuleDeclaration ast, String contents) { assertTrue(false); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinModelManipulationTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinModelManipulationTests.java index 3eae2b5..9d97701 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinModelManipulationTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinModelManipulationTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -26,18 +26,18 @@ /** * Tests for mixin model. Checks operations with a source modules and * buildpaths. For model building tests see AutoMixinTests. - * + * * Warning! Tests results depends of test execution order cause tests modifies a * project. - * + * * @author fourdman - * + * */ public class MixinModelManipulationTests extends AbstractDLTKSearchTests { private static final String PROJECT_NAME = "mixins"; public MixinModelManipulationTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -47,7 +47,7 @@ @Override protected void setUp() throws Exception { super.setUp(); - SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME); + SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME, Activator.PLUGIN_ID); waitUntilIndexesReady(); } @@ -81,8 +81,7 @@ assertNotNull(objs); assertEquals(2, objs.length); - ISourceModule sourceModule = getSourceModule(PROJECT_NAME, "src", - "src2.rb"); + ISourceModule sourceModule = getSourceModule(PROJECT_NAME, "src", "src2.rb"); sourceModule.delete(true, null); waitUntilIndexesReady(); @@ -101,10 +100,8 @@ assertNotNull(objs); assertEquals(2, objs.length); - getProjectFragment(PROJECT_NAME, "src").delete( - IResource.KEEP_HISTORY, - IProjectFragment.ORIGINATING_PROJECT_BUILDPATH - | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH, + getProjectFragment(PROJECT_NAME, "src").delete(IResource.KEEP_HISTORY, + IProjectFragment.ORIGINATING_PROJECT_BUILDPATH | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH, null); waitUntilIndexesReady(); @@ -123,11 +120,9 @@ assertNotNull(objs); assertEquals(2, objs.length); - getScriptFolder(PROJECT_NAME, "src", new Path("folder1")).delete(true, - null); + getScriptFolder(PROJECT_NAME, "src", new Path("folder1")).delete(true, null); waitUntilIndexesReady(); - getScriptFolder(PROJECT_NAME, "src", new Path("folder2")).delete(true, - null); + getScriptFolder(PROJECT_NAME, "src", new Path("folder2")).delete(true, null); waitUntilIndexesReady(); assertEquals(0, model.find("Folder", new NullProgressMonitor()).length); @@ -144,8 +139,7 @@ assertNotNull(objs); assertEquals(2, objs.length); - ISourceModule sourceModule = getSourceModule(PROJECT_NAME, "src", - "src1.rb"); + ISourceModule sourceModule = getSourceModule(PROJECT_NAME, "src", "src1.rb"); sourceModule.delete(true, null); waitUntilIndexesReady(); @@ -163,8 +157,7 @@ Object[] objs = mixinElement.getAllObjects(); assertEquals(2, objs.length); - IScriptFolder scriptFolder = getScriptFolder(PROJECT_NAME, "src", - new Path("")); + IScriptFolder scriptFolder = getScriptFolder(PROJECT_NAME, "src", new Path("")); String contents = "class Foo\n def bar\n end\n end\n"; scriptFolder.createSourceModule("MoreFoo.rb", contents, true, null); @@ -181,10 +174,8 @@ IMixinElement mixinElement = model.get("Buzzy"); assertNull(mixinElement); - IScriptFolder scriptFolder = getScriptFolder(PROJECT_NAME, "src", - new Path("")); - String contents = "class Buzzy\n" + " def myFyb\n " + " end\n " - + "end\n"; + IScriptFolder scriptFolder = getScriptFolder(PROJECT_NAME, "src", new Path("")); + String contents = "class Buzzy\n" + " def myFyb\n " + " end\n " + "end\n"; scriptFolder.createSourceModule("Buzzy.rb", contents, true, null); @@ -203,10 +194,8 @@ IBuildpathEntry[] rawBuildpath = SCRIPT_PROJECT.getRawBuildpath(); IBuildpathEntry[] newRawBuildpath = new IBuildpathEntry[rawBuildpath.length + 1]; - System.arraycopy(rawBuildpath, 0, newRawBuildpath, 0, - rawBuildpath.length); - newRawBuildpath[rawBuildpath.length] = DLTKCore - .newSourceEntry(new Path("/mixins/src3")); + System.arraycopy(rawBuildpath, 0, newRawBuildpath, 0, rawBuildpath.length); + newRawBuildpath[rawBuildpath.length] = DLTKCore.newSourceEntry(new Path("/mixins/src3")); SCRIPT_PROJECT.setRawBuildpath(newRawBuildpath, null); waitUntilIndexesReady();
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinProjectIsolationTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinProjectIsolationTests.java index 233f79a..78afc0a 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinProjectIsolationTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinProjectIsolationTests.java
@@ -4,7 +4,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -41,7 +41,7 @@ private static final String METHOD2_NAME = "testProjectIsolation2"; public MixinProjectIsolationTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -54,8 +54,8 @@ @Override protected void setUp() throws Exception { super.setUp(); - project1 = setUpScriptProject(PROJECT1_NAME); - project2 = setUpScriptProject(PROJECT2_NAME); + project1 = setUpScriptProject(PROJECT1_NAME, Activator.PLUGIN_ID); + project2 = setUpScriptProject(PROJECT2_NAME, Activator.PLUGIN_ID); waitUntilIndexesReady(); } @@ -69,29 +69,21 @@ private static final String TEST_CLASS_NAME = "TestClass20080818"; public void testSimple() { - checkModel(RubyMixinModel.getInstance(project1), - new String[] { METHOD1_NAME }); - checkModel(RubyMixinModel.getInstance(project2), - new String[] { METHOD2_NAME }); - checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { - METHOD1_NAME, METHOD2_NAME }); + checkModel(RubyMixinModel.getInstance(project1), new String[] { METHOD1_NAME }); + checkModel(RubyMixinModel.getInstance(project2), new String[] { METHOD2_NAME }); + checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { METHOD1_NAME, METHOD2_NAME }); } public void testComplex2to1() throws ModelException { testSimple(); - addBuildpathEntry(project1, DLTKCore.newProjectEntry(new Path("/" - + PROJECT2_NAME))); + addBuildpathEntry(project1, DLTKCore.newProjectEntry(new Path("/" + PROJECT2_NAME))); waitUntilIndexesReady(); // - checkModel(RubyMixinModel.getInstance(project1), new String[] { - METHOD1_NAME, METHOD2_NAME }); - checkModel(RubyMixinModel.getInstance(project2), - new String[] { METHOD2_NAME }); - checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { - METHOD1_NAME, METHOD2_NAME }); + checkModel(RubyMixinModel.getInstance(project1), new String[] { METHOD1_NAME, METHOD2_NAME }); + checkModel(RubyMixinModel.getInstance(project2), new String[] { METHOD2_NAME }); + checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { METHOD1_NAME, METHOD2_NAME }); // - removeBuildpathEntry(project1, DLTKCore.newProjectEntry(new Path("/" - + PROJECT2_NAME))); + removeBuildpathEntry(project1, DLTKCore.newProjectEntry(new Path("/" + PROJECT2_NAME))); waitUntilIndexesReady(); // testSimple(); @@ -99,26 +91,20 @@ public void testComplex1to2() throws ModelException { testSimple(); - addBuildpathEntry(project2, DLTKCore.newProjectEntry(new Path("/" - + PROJECT1_NAME))); + addBuildpathEntry(project2, DLTKCore.newProjectEntry(new Path("/" + PROJECT1_NAME))); waitUntilIndexesReady(); // - checkModel(RubyMixinModel.getInstance(project1), - new String[] { METHOD1_NAME }); - checkModel(RubyMixinModel.getInstance(project2), new String[] { - METHOD1_NAME, METHOD2_NAME }); - checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { - METHOD1_NAME, METHOD2_NAME }); + checkModel(RubyMixinModel.getInstance(project1), new String[] { METHOD1_NAME }); + checkModel(RubyMixinModel.getInstance(project2), new String[] { METHOD1_NAME, METHOD2_NAME }); + checkModel(RubyMixinModel.getWorkspaceInstance(), new String[] { METHOD1_NAME, METHOD2_NAME }); // - removeBuildpathEntry(project2, DLTKCore.newProjectEntry(new Path("/" - + PROJECT1_NAME))); + removeBuildpathEntry(project2, DLTKCore.newProjectEntry(new Path("/" + PROJECT1_NAME))); waitUntilIndexesReady(); // testSimple(); } - private void addBuildpathEntry(final IScriptProject project, - final IBuildpathEntry newEntry) throws ModelException { + private void addBuildpathEntry(final IScriptProject project, final IBuildpathEntry newEntry) throws ModelException { IBuildpathEntry[] originalCP = project.getRawBuildpath(); IBuildpathEntry[] newCP = new IBuildpathEntry[originalCP.length + 1]; System.arraycopy(originalCP, 0, newCP, 0, originalCP.length); @@ -128,21 +114,18 @@ project.setRawBuildpath(newCP, null); } - private void removeBuildpathEntry(final IScriptProject project, - final IBuildpathEntry entry) throws ModelException { + private void removeBuildpathEntry(final IScriptProject project, final IBuildpathEntry entry) throws ModelException { final List<IBuildpathEntry> cp = new ArrayList<>(); cp.addAll(Arrays.asList(project.getRawBuildpath())); assertTrue(cp.remove(entry)); - IBuildpathEntry[] newCP = cp - .toArray(new IBuildpathEntry[cp.size()]); + IBuildpathEntry[] newCP = cp.toArray(new IBuildpathEntry[cp.size()]); IModelStatus status = BuildpathEntry.validateBuildpath(project, newCP); assertEquals(IStatus.OK, status.getSeverity()); project.setRawBuildpath(newCP, null); } private void checkModel(RubyMixinModel model, String[] childrenNames) { - IMixinElement element = model.getRawModel().get( - TEST_CLASS_NAME + RubyMixin.INSTANCE_SUFFIX); + IMixinElement element = model.getRawModel().get(TEST_CLASS_NAME + RubyMixin.INSTANCE_SUFFIX); assertNotNull(element); IMixinElement[] children = element.getChildren(); assertNotNull(children); @@ -152,8 +135,7 @@ names.add(children[i].getLastKeySegment()); } for (int i = 0; i < childrenNames.length; ++i) { - assertTrue(childrenNames[i] + " is not found", names - .contains(childrenNames[i])); + assertTrue(childrenNames[i] + " is not found", names.contains(childrenNames[i])); } }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinTestsSuite.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinTestsSuite.java index 5d0c46b..fb3377c 100755 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinTestsSuite.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/MixinTestsSuite.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -56,8 +56,7 @@ String line = lines[i].trim(); int pos = line.indexOf("##"); if (pos >= 0) { - StringTokenizer tok = new StringTokenizer(line - .substring(pos + 2)); + StringTokenizer tok = new StringTokenizer(line.substring(pos + 2)); String test = tok.nextToken(); if ("exit".equals(test)) { return; @@ -80,8 +79,7 @@ } private CharSequence loadContent(String path) throws IOException { - return new CharArraySequence(Util.getInputStreamAsCharArray( - Activator.openResource(path), -1, null)); + return new CharArraySequence(Util.getInputStreamAsCharArray(Activator.openResource(path), -1, null)); } } @@ -95,8 +93,7 @@ @Override public void check() throws Exception { - final MixinModel model = new MixinModel(RubyLanguageToolkit - .getDefault()); + final MixinModel model = new MixinModel(RubyLanguageToolkit.getDefault()); try { IMixinElement mixinElement = model.get(key); if (mixinElement == null) { @@ -104,16 +101,13 @@ } Object[] allObjects = mixinElement.getAllObjects(); if (allObjects == null || allObjects.length == 0) - throw new AssertionFailedError("Key " + key - + " has null or empty object set"); + throw new AssertionFailedError("Key " + key + " has null or empty object set"); for (int i = 0; i < allObjects.length; i++) { if (allObjects[i] == null) - throw new AssertionFailedError("Key " + key - + " has null object at index " + i); + throw new AssertionFailedError("Key " + key + " has null object at index " + i); RubyMixinElementInfo info = (RubyMixinElementInfo) allObjects[i]; if (info.getObject() == null) - throw new AssertionFailedError("Key " + key - + " has info with a null object at index " + i + throw new AssertionFailedError("Key " + key + " has info with a null object at index " + i + " (kind=" + info.getKind() + ")"); } } finally { @@ -126,8 +120,7 @@ public MixinTestsSuite(String testsDirectory) { super(testsDirectory); - Enumeration<String> entryPaths = Activator.getDefault().getBundle() - .getEntryPaths(testsDirectory); + Enumeration<String> entryPaths = Activator.getDefault().getBundle().getEntryPaths(testsDirectory); while (entryPaths.hasMoreElements()) { final String path = entryPaths.nextElement(); URL entry = Activator.getDefault().getBundle().getEntry(path); @@ -148,13 +141,13 @@ private static final String SRC_PROJECT = "automixins"; public SuiteSetupTeardown() { - super(Activator.PLUGIN_ID, Util.EMPTY_STRING); + super(Util.EMPTY_STRING); } @Override public void setUpSuite() throws Exception { super.setUpSuite(); - setUpScriptProject(SRC_PROJECT); + setUpScriptProject(SRC_PROJECT, Activator.PLUGIN_ID); waitUntilIndexesReady(); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/RubyMixinClassTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/RubyMixinClassTests.java index fb48fee..f702036 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/RubyMixinClassTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/RubyMixinClassTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -19,7 +19,7 @@ public class RubyMixinClassTests extends AbstractModelTests { public RubyMixinClassTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -31,7 +31,7 @@ @Override public void setUpSuite() throws Exception { super.setUpSuite(); - setUpScriptProject(PROJECT_NAME); + setUpScriptProject(PROJECT_NAME, Activator.PLUGIN_ID); waitUntilIndexesReady(); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/ThreadedMixinTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/ThreadedMixinTests.java index 261e74d..8fddbf8 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/ThreadedMixinTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/search/mixin/ThreadedMixinTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -22,7 +22,7 @@ private static final String PROJECT_NAME = "mixins"; public ThreadedMixinTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -38,9 +38,7 @@ } private void buildAll() throws CoreException { - ResourcesPlugin.getWorkspace() - .build(IncrementalProjectBuilder.FULL_BUILD, - new NullProgressMonitor()); + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); // waitForAutoBuild(); } @@ -56,8 +54,7 @@ String id = null; do { id = String.valueOf(System.currentTimeMillis()); - } while (InterpreterType.findInterpreterInstall(id) != null - || id.equals(fgLastUsedID)); + } while (InterpreterType.findInterpreterInstall(id) != null || id.equals(fgLastUsedID)); fgLastUsedID = id; return id; } @@ -66,7 +63,7 @@ if (SCRIPT_PROJECT != null) { deleteProject(SCRIPT_PROJECT.getElementName()); } - SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME); + SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME, Activator.PLUGIN_ID); } class Access implements Runnable { @@ -77,8 +74,7 @@ public boolean finish = false; private final RubyMixinModel mixinModel; - public Access(RubyMixinModel mixinModel, String keys[], int start, - int stop, int cycles) { + public Access(RubyMixinModel mixinModel, String keys[], int start, int stop, int cycles) { this.mixinModel = mixinModel; this.start = start; this.stop = stop; @@ -108,13 +104,11 @@ int d = findKeys.length / count; for (int i = 0; i < count; i++) { if (i != count - 1) { - Access a = new Access(mixinModel, findKeys, d * (i), d - * (i + 1), 1); + Access a = new Access(mixinModel, findKeys, d * (i), d * (i + 1), 1); access[i] = a; threads[i] = new Thread(a); } else { - Access a = new Access(mixinModel, findKeys, d * (i), - findKeys.length, 10); + Access a = new Access(mixinModel, findKeys, d * (i), findKeys.length, 10); access[i] = a; threads[i] = new Thread(a); }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/text/completion/RubyCompletionTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/text/completion/RubyCompletionTests.java index 61a8005..f2c64d4 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/text/completion/RubyCompletionTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/text/completion/RubyCompletionTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -29,18 +29,16 @@ // RelevanceConstants.R_NON_RESTRICTED); public RubyCompletionTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } @Override public void setUpSuite() throws Exception { // We need to initialie at least one interpreter. - PROJECT = setUpScriptProject("completion"); + PROJECT = setUpScriptProject("completion", Activator.PLUGIN_ID); waitUntilIndexesReady(); - ResourcesPlugin.getWorkspace() - .build(IncrementalProjectBuilder.FULL_BUILD, - new NullProgressMonitor()); + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); waitForAutoBuild(); // RubyPlugin.initialized = true; super.setUpSuite(); @@ -60,9 +58,9 @@ // relevance) { // StringBuffer buffer = new StringBuffer(); // for (int i = 0; i < elements.length; ++i) { - // buffer.append("element:" + elements[i] + " completion:" + + // buffer.append("element:" + elements[i] + " completion:" + // completions[i] - // + " relevance:" + relevance[i]); + // + " relevance:" + relevance[i]); // // if (i != elements.length - 1) { // buffer.append("\n"); @@ -95,8 +93,7 @@ String str = cu.getSource(); String completeBehind = "Foo.new."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -110,8 +107,7 @@ String str = cu.getSource(); String completeBehind = "Foo42::"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -125,8 +121,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -140,8 +135,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -155,8 +149,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -170,8 +163,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -185,8 +177,7 @@ String str = cu.getSource(); String completeBehind = "::"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -202,14 +193,12 @@ String str = cu.getSource(); String completeBehind = "::"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); - assertTrue((requestor.getResults().indexOf("Mine") != -1) - && (requestor.getResults().indexOf("Mix") != -1)); + assertTrue((requestor.getResults().indexOf("Mine") != -1) && (requestor.getResults().indexOf("Mix") != -1)); } @@ -219,8 +208,7 @@ String str = cu.getSource(); String completeBehind = "Min"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -235,8 +223,7 @@ String str = cu.getSource(); String completeBehind = "@a"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -251,8 +238,7 @@ String str = cu.getSource(); String completeBehind = "@a"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -267,8 +253,7 @@ String str = cu.getSource(); String completeBehind = "@@a"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -283,8 +268,7 @@ String str = cu.getSource(); String completeBehind = "Mega"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -299,8 +283,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -315,8 +298,7 @@ String str = cu.getSource(); String completeBehind = "t."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -331,8 +313,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -347,8 +328,7 @@ String str = cu.getSource(); String completeBehind = "Foo66."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -364,8 +344,7 @@ String str = cu.getSource(); String completeBehind = "Foo66.cool2."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -380,8 +359,7 @@ String str = cu.getSource(); String completeBehind = "@categ"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -396,8 +374,7 @@ String str = cu.getSource(); String completeBehind = "::"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); @@ -410,8 +387,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -426,8 +402,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -442,8 +417,7 @@ String str = cu.getSource(); String completeBehind = "t."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -458,8 +432,7 @@ String str = cu.getSource(); String completeBehind = ".x"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -473,8 +446,7 @@ String str = cu.getSource(); String completeBehind = "::x"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -488,8 +460,7 @@ String str = cu.getSource(); String completeBehind = "fo"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -499,13 +470,11 @@ public void testCompletion027() throws ModelException { CompletionTestsRequestor requestor = new CompletionTestsRequestor(); - ISourceModule cu = getSourceModule("completion", "src", - "inside_block.rb"); + ISourceModule cu = getSourceModule("completion", "src", "inside_block.rb"); String str = cu.getSource(); String completeBehind = "v.tu"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -519,8 +488,7 @@ String str = cu.getSource(); String completeBehind = "p"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -534,8 +502,7 @@ String str = cu.getSource(); String completeBehind = "arg3['sdsd'] = "; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -549,8 +516,7 @@ String str = cu.getSource(); String completeBehind = "ff g"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -564,8 +530,7 @@ String str = cu.getSource(); String completeBehind = "_f"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -578,8 +543,7 @@ String str = cu.getSource(); String completeBehind = "puts v"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -592,8 +556,7 @@ String str = cu.getSource(); String completeBehind = "@data[@i"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -606,8 +569,7 @@ String str = cu.getSource(); String completeBehind = "@data[@"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -620,8 +582,7 @@ String str = cu.getSource(); String completeBehind = "xx"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -634,8 +595,7 @@ String str = cu.getSource(); String completeBehind = "t"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -648,8 +608,7 @@ String str = cu.getSource(); String completeBehind = "Test."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -670,8 +629,7 @@ for (int i = 0; i < keyWords.length; i++) { CompletionTestsRequestor requestor = new CompletionTestsRequestor(); String completeBehind = keyWords[i]; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); cursorLocation--;// try to complete one char before the end waitForAutoBuild(); @@ -687,8 +645,7 @@ String str = cu.getSource(); String completeBehind = "::"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -702,8 +659,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -717,8 +673,7 @@ String str = cu.getSource(); String completeBehind = "y."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -732,8 +687,7 @@ String str = cu.getSource(); String completeBehind = ".se"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -748,8 +702,7 @@ String str = cu.getSource(); String completeBehind = ".n"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -764,8 +717,7 @@ String str = cu.getSource(); String completeBehind = "l."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -773,27 +725,20 @@ Vector<String> methods = new Vector<>(); int lastElementsOccurance = 0; - while ((lastElementsOccurance = completionResults.indexOf("element:", - lastElementsOccurance)) > -1) { + while ((lastElementsOccurance = completionResults.indexOf("element:", lastElementsOccurance)) > -1) { int lastElementsIndex = lastElementsOccurance + "element:".length(); - lastElementsOccurance = completionResults.indexOf(" ", - lastElementsOccurance); - methods.add(completionResults.substring(lastElementsIndex, - lastElementsOccurance)); + lastElementsOccurance = completionResults.indexOf(" ", lastElementsOccurance); + methods.add(completionResults.substring(lastElementsIndex, lastElementsOccurance)); } Vector<String> relevances = new Vector<>(); int lastRelevanceOccurance = 0; while (lastRelevanceOccurance > -1) { - lastRelevanceOccurance = completionResults.indexOf("relevance:", - lastRelevanceOccurance); - int lastRelevanceIndex = lastRelevanceOccurance - + "relevance:".length(); - lastRelevanceOccurance = completionResults.indexOf("\n", - lastRelevanceOccurance); + lastRelevanceOccurance = completionResults.indexOf("relevance:", lastRelevanceOccurance); + int lastRelevanceIndex = lastRelevanceOccurance + "relevance:".length(); + lastRelevanceOccurance = completionResults.indexOf("\n", lastRelevanceOccurance); if (lastRelevanceOccurance > -1) - relevances.add(completionResults.substring(lastRelevanceIndex, - lastRelevanceOccurance)); + relevances.add(completionResults.substring(lastRelevanceIndex, lastRelevanceOccurance)); else relevances.add(completionResults.substring(lastRelevanceIndex)); } @@ -807,8 +752,7 @@ String str = cu.getSource(); String completeBehind = "File."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -822,8 +766,7 @@ String str = cu.getSource(); String completeBehind = "File."; - int cursorLocation = str.indexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.indexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -837,8 +780,7 @@ String str = cu.getSource(); String completeBehind = "File.ex"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -852,8 +794,7 @@ String str = cu.getSource(); String completeBehind = "@f"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -867,8 +808,7 @@ String str = cu.getSource(); String completeBehind = "y."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -882,8 +822,7 @@ String str = cu.getSource(); String completeBehind = "self.m"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -897,8 +836,7 @@ String str = cu.getSource(); String completeBehind = ".new; @parser.s"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -912,8 +850,7 @@ String str = cu.getSource(); String completeBehind = "z2."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -927,8 +864,7 @@ String str = cu.getSource(); String completeBehind = "t."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -942,8 +878,7 @@ String str = cu.getSource(); String completeBehind = "val."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -960,8 +895,7 @@ String str = cu.getSource(); String completeBehind = "val."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -978,8 +912,7 @@ String str = cu.getSource(); String completeBehind = "@body.i"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -992,8 +925,7 @@ String str = cu.getSource(); String completeBehind = "4."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1006,8 +938,7 @@ String str = cu.getSource(); String completeBehind = "--1."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1020,8 +951,7 @@ String str = cu.getSource(); String completeBehind = "w."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1036,8 +966,7 @@ String str = cu.getSource(); String completeBehind = "as.methods.so"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1052,8 +981,7 @@ String str = cu.getSource(); String completeBehind = "__FILE_"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1067,8 +995,7 @@ String str = cu.getSource(); String completeBehind = "String.new."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1082,8 +1009,7 @@ String str = cu.getSource(); String completeBehind = "protecte"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1099,8 +1025,7 @@ String str = cu.getSource(); String completeBehind = "med"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1118,8 +1043,7 @@ String str = cu.getSource(); String completeBehind = "x"; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1134,8 +1058,7 @@ String str = cu.getSource(); String completeBehind = "."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1150,8 +1073,7 @@ String str = cu.getSource(); String completeBehind = "3."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1167,8 +1089,7 @@ String str = cu.getSource(); String completeBehind = "str1."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor); @@ -1183,8 +1104,7 @@ String str = cu.getSource(); String completeBehind = "x."; - int cursorLocation = str.lastIndexOf(completeBehind) - + completeBehind.length(); + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); waitForAutoBuild(); cu.codeComplete(cursorLocation, requestor);
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typehierarchy/TypeHierarchyTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typehierarchy/TypeHierarchyTests.java index 2b19370..be5a9b5 100755 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typehierarchy/TypeHierarchyTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typehierarchy/TypeHierarchyTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -15,12 +15,11 @@ import org.eclipse.dltk.core.tests.model.AbstractDLTKSearchTests; import org.eclipse.dltk.ruby.core.tests.Activator; - public class TypeHierarchyTests extends AbstractDLTKSearchTests { private static final String PROJECT = "typehierarchy"; public TypeHierarchyTests(String name) { - super(Activator.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -44,7 +43,7 @@ private void up() throws Exception { if (SCRIPT_PROJECT == null) { - SCRIPT_PROJECT = setUpScriptProject(PROJECT); + SCRIPT_PROJECT = setUpScriptProject(PROJECT, Activator.PLUGIN_ID); } }
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/AbstractTypeInferencingTests.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/AbstractTypeInferencingTests.java index bdbc93a..ed9978a 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/AbstractTypeInferencingTests.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/AbstractTypeInferencingTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -27,9 +27,9 @@ import junit.framework.ComparisonFailure; - public abstract class AbstractTypeInferencingTests extends AbstractModelTests { protected static IScriptProject PROJECT; + protected class CompletionResult { public String proposals; public String context; @@ -43,8 +43,8 @@ private static final int COMPLETE_TIMEOUT = 5000; - public AbstractTypeInferencingTests(String projectName, String name) { - super(projectName, name); + public AbstractTypeInferencingTests(String name) { + super(name); } @Override @@ -56,12 +56,13 @@ return this.complete(path, source, false, completeBehind); } - protected CompletionResult complete(String path, String source, boolean showPositions, String completeBehind) throws ModelException { + protected CompletionResult complete(String path, String source, boolean showPositions, String completeBehind) + throws ModelException { return this.complete(path, source, showPositions, completeBehind, null, null); } - protected CompletionResult complete(String path, String source, boolean showPositions, String completeBehind, String tokenStartBehind, - String token) throws ModelException { + protected CompletionResult complete(String path, String source, boolean showPositions, String completeBehind, + String tokenStartBehind, String token) throws ModelException { this.wc = getWorkingCopy(path, source); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, showPositions); String str = this.wc.getSource(); @@ -87,7 +88,7 @@ try (InputStream input = Activator.openResource(path);) { InputStreamReader reader = new InputStreamReader(input); BufferedReader br = new BufferedReader(reader); - char[] data = new char[100*1024]; // tests shouldnt be more that 100 kb + char[] data = new char[100 * 1024]; // tests shouldnt be more that 100 kb int size = br.read(data); buffer.append(data, 0, size); } @@ -105,10 +106,11 @@ return result; } - protected CompletionResult snippetContextComplete(IType type, String snippet, int insertion, int cursorLocation, boolean isStatic) - throws ModelException { + protected CompletionResult snippetContextComplete(IType type, String snippet, int insertion, int cursorLocation, + boolean isStatic) throws ModelException { CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, false, false, false); - type.codeComplete(snippet.toCharArray(), insertion, cursorLocation, null, null, null, isStatic, requestor, this.wcOwner); + type.codeComplete(snippet.toCharArray(), insertion, cursorLocation, null, null, null, isStatic, requestor, + this.wcOwner); CompletionResult result = new CompletionResult(); result.proposals = requestor.getResults(); result.context = requestor.getContext();
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/TypeInferenceTest.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/TypeInferenceTest.java index 558e612..6756a30 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/TypeInferenceTest.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/TypeInferenceTest.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -25,18 +25,18 @@ private static final String SRC_PROJECT = "typeinference"; public TypeInferenceTest(String name) { - super("org.eclipse.dltk.ruby.core.tests", name); + super(name); } @Override public void setUpSuite() throws Exception { - PROJECT = setUpScriptProject(SRC_PROJECT); + PROJECT = setUpScriptProject(SRC_PROJECT, "org.eclipse.dltk.ruby.core.tests"); super.setUpSuite(); waitUntilIndexesReady(); ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); waitForAutoBuild(); } - + @Override public void tearDownSuite() throws Exception { deleteProject(SRC_PROJECT);
diff --git a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/utils/LocalVariablesInspectionTest.java b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/utils/LocalVariablesInspectionTest.java index 3045198..1d34e95 100644 --- a/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/utils/LocalVariablesInspectionTest.java +++ b/tests/org.eclipse.dltk.ruby.core.tests/src/org/eclipse/dltk/ruby/core/tests/typeinference/utils/LocalVariablesInspectionTest.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -26,18 +26,18 @@ private static final String SRC_PROJECT = "typeinference2"; public LocalVariablesInspectionTest(String name) { - super("org.eclipse.dltk.ruby.core.tests", name); + super(name); } @Override public void setUpSuite() throws Exception { - PROJECT = setUpScriptProject(SRC_PROJECT); + PROJECT = setUpScriptProject(SRC_PROJECT, "org.eclipse.dltk.ruby.core.tests"); super.setUpSuite(); waitUntilIndexesReady(); ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor()); - + } - + @Override public void tearDownSuite() throws Exception { deleteProject(SRC_PROJECT); @@ -48,306 +48,305 @@ String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testGlobalExistant2() throws Exception { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts y") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "y"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testGlobalNotExistant() throws Exception { String content = loadContent(PATH_PREFIX + "simple1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "y"); assertEquals(0, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testGlobalConditional1() throws Exception { String content = loadContent(PATH_PREFIX + "conditional1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(2, info.getConditionalAssignments().length); } - + public void testGlobalConditional2() throws Exception { String content = loadContent(PATH_PREFIX + "conditional2.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(2, info.getConditionalAssignments().length); } - + public void testGlobalConditional3() throws Exception { String content = loadContent(PATH_PREFIX + "conditional3.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testGlobalConditional4() throws Exception { String content = loadContent(PATH_PREFIX + "conditional4.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("bye") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + public void testInsideMethod1() throws Exception { String content = loadContent(PATH_PREFIX + "method1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); } - + public void testInsideMethod1_2() throws Exception { String content = loadContent(PATH_PREFIX + "method1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("y = 53") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); } public void testInsideMethod1_3() throws Exception { String content = loadContent(PATH_PREFIX + "method1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts \"") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); - assertTrue (info.getDeclaringScope() instanceof ModuleDeclaration); + assertTrue(info.getDeclaringScope() instanceof ModuleDeclaration); } - + public void testInsideMethod1_4() throws Exception { String content = loadContent(PATH_PREFIX + "method1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("bye") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "y"); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); } - + public void testInsideType1() throws Exception { String content = loadContent(PATH_PREFIX + "class1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts x") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof TypeDeclaration); + assertTrue(info.getDeclaringScope() instanceof TypeDeclaration); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + public void testInsideType1_2() throws Exception { String content = loadContent(PATH_PREFIX + "class1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("yyyy") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); assertEquals(0, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testInsideType1_3() throws Exception { String content = loadContent(PATH_PREFIX + "class1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("bye") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof TypeDeclaration); + assertTrue(info.getDeclaringScope() instanceof TypeDeclaration); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testInsideType1_4() throws Exception { String content = loadContent(PATH_PREFIX + "class1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("putx") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof TypeDeclaration); - assertEquals ("Cool", ((TypeDeclaration)(info.getDeclaringScope())).getName()); + assertTrue(info.getDeclaringScope() instanceof TypeDeclaration); + assertEquals("Cool", ((TypeDeclaration) (info.getDeclaringScope())).getName()); assertEquals(0, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testInsideMethod2() throws Exception { String content = loadContent(PATH_PREFIX + "method2.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("haha") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + public void testInsideMethod2_1() throws Exception { String content = loadContent(PATH_PREFIX + "method2.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts x") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testInsideMethod2_2() throws Exception { String content = loadContent(PATH_PREFIX + "method2.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("gigi") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "x"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + public void testLoops1() throws Exception { String content = loadContent(PATH_PREFIX + "loop1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("puts var") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof TypeDeclaration); + assertTrue(info.getDeclaringScope() instanceof TypeDeclaration); assertEquals(LocalVariableInfo.KIND_DEFAULT, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testLoops1_2() throws Exception { String content = loadContent(PATH_PREFIX + "loop1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("for") - 2; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_METHOD_ARG, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testLoops1_3() throws Exception { String content = loadContent(PATH_PREFIX + "loop1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("putX var") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_LOOP_VAR, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testLoops1_4() throws Exception { String content = loadContent(PATH_PREFIX + "loop1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("putxxx") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_LOOP_VAR, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - - + public void testBlocks1() throws Exception { String content = loadContent(PATH_PREFIX + "blocks1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("label1") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_BLOCK_ARG, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testBlocks1_2() throws Exception { String content = loadContent(PATH_PREFIX + "blocks1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("label2") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_DEFAULT, info.getKind()); assertNotNull(info.getLastAssignment()); assertEquals(0, info.getConditionalAssignments().length); } - + public void testBlocks1_3() throws Exception { String content = loadContent(PATH_PREFIX + "blocks1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("label3") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof MethodDeclaration); + assertTrue(info.getDeclaringScope() instanceof MethodDeclaration); assertEquals(LocalVariableInfo.KIND_BLOCK_ARG, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + public void testBlocks1_4() throws Exception { String content = loadContent(PATH_PREFIX + "blocks1.rb"); ModuleDeclaration ast = ASTUtils.getAST(content.toCharArray()); int offset = content.indexOf("label4") + 1; - + LocalVariableInfo info = RubyTypeInferencingUtils.inspectLocalVariable(ast, offset, "var"); - assertTrue (info.getDeclaringScope() instanceof TypeDeclaration); + assertTrue(info.getDeclaringScope() instanceof TypeDeclaration); assertEquals(LocalVariableInfo.KIND_DEFAULT, info.getKind()); assertNull(info.getLastAssignment()); assertEquals(1, info.getConditionalAssignments().length); } - + }
diff --git a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java index 411656c..ce1ae3b 100644 --- a/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java +++ b/tests/org.eclipse.dltk.ruby.debug.tests/src/org/eclipse/dltk/ruby/debug/tests/launching/RubyLaunchingTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -34,11 +34,7 @@ public class RubyLaunchingTests extends ScriptLaunchingTests { public RubyLaunchingTests(String name) { - super("org.eclipse.dltk.ruby.debug.tests", name); - } - - public RubyLaunchingTests(String testProjectName, String name) { - super(testProjectName, name); + super(name); } public static Test suite() { @@ -162,4 +158,9 @@ protected boolean hasPredefinedInterpreters() { return true; } + + @Override + protected String getBundleName() { + return "org.eclipse.dltk.ruby.debug.tests"; + } }
diff --git a/tests/org.eclipse.dltk.ruby.testing.tests/src/org/eclipse/dltk/ruby/testing/tests/RubyTestingTestUnitResolverTests.java b/tests/org.eclipse.dltk.ruby.testing.tests/src/org/eclipse/dltk/ruby/testing/tests/RubyTestingTestUnitResolverTests.java index 4f3cb66..202c23e 100644 --- a/tests/org.eclipse.dltk.ruby.testing.tests/src/org/eclipse/dltk/ruby/testing/tests/RubyTestingTestUnitResolverTests.java +++ b/tests/org.eclipse.dltk.ruby.testing.tests/src/org/eclipse/dltk/ruby/testing/tests/RubyTestingTestUnitResolverTests.java
@@ -38,7 +38,7 @@ * @param name */ public RubyTestingTestUnitResolverTests(String name) { - super(AllTests.BUNDLE_ID, name); + super(name); } final static String projectName = "testing1"; //$NON-NLS-1$ @@ -46,7 +46,7 @@ @Override public void setUpSuite() throws Exception { super.setUpSuite(); - setUpProject(projectName); + setUpProject(projectName, AllTests.BUNDLE_ID); waitUntilIndexesReady(); }
diff --git a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/folding/RubyCommentElementTests.java b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/folding/RubyCommentElementTests.java index 50bf198..32684e5 100644 --- a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/folding/RubyCommentElementTests.java +++ b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/folding/RubyCommentElementTests.java
@@ -17,13 +17,13 @@ } public RubyCommentElementTests(String name) { - super(RubyUITestsPlugin.PLUGIN_ID, name); + super(name); } @Override public void setUpSuite() throws Exception { super.setUpSuite(); - setUpScriptProject(PROJECT_NAME); + setUpScriptProject(PROJECT_NAME, RubyUITestsPlugin.PLUGIN_ID); } @Override @@ -33,8 +33,7 @@ } public void testCommentPositioning1() throws ModelException { - ISourceModule module = getSourceModule(PROJECT_NAME, "src", - "comments1.rb"); + ISourceModule module = getSourceModule(PROJECT_NAME, "src", "comments1.rb"); assertEquals("proc1", getElementByComment(module, "proc1_before")); assertEquals("proc1", getElementByComment(module, "proc1_inside")); @@ -53,16 +52,13 @@ /** * - * Gets a string pattern, searches for the comment that contains this - * pattern and returns IModelElement to which the comment corresponds + * Gets a string pattern, searches for the comment that contains this pattern + * and returns IModelElement to which the comment corresponds * */ - protected String getElementByComment(ISourceModule module, - String commentPattern) throws ModelException { - final IElementCommentResolver resolver = new DefaultElementCommentResolver( - module); - IModelElement el = resolver.getElementByCommentPosition(module - .getSource().indexOf(commentPattern), 0); + protected String getElementByComment(ISourceModule module, String commentPattern) throws ModelException { + final IElementCommentResolver resolver = new DefaultElementCommentResolver(module); + IModelElement el = resolver.getElementByCommentPosition(module.getSource().indexOf(commentPattern), 0); if (el != null) return el.getElementName(); else
diff --git a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/MixinCompleteTests.java b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/MixinCompleteTests.java index 7686fee..62c0a3d 100644 --- a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/MixinCompleteTests.java +++ b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/MixinCompleteTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -21,7 +21,7 @@ private static final String PROJECT_NAME = "mixins"; public MixinCompleteTests(String name) { - super(RubyUITestsPlugin.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -62,7 +62,7 @@ if (SCRIPT_PROJECT != null) { deleteProject(SCRIPT_PROJECT.getElementName()); } - SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME); + SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME, RubyUITestsPlugin.PLUGIN_ID); } public void testMultiAccess() {
diff --git a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/ThreadedUIMixinTests.java b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/ThreadedUIMixinTests.java index 9cd8ab4..ffcd258 100644 --- a/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/ThreadedUIMixinTests.java +++ b/tests/org.eclipse.dltk.ruby.ui.tests/src/org/eclipse/dltk/ruby/ui/tests/search/ThreadedUIMixinTests.java
@@ -3,7 +3,7 @@ * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. - * + * * SPDX-License-Identifier: EPL-2.0 * *******************************************************************************/ @@ -22,7 +22,7 @@ private static final String PROJECT_NAME = "mixins"; public ThreadedUIMixinTests(String name) { - super(RubyUITestsPlugin.PLUGIN_ID, name); + super(name); } public static Suite suite() { @@ -63,7 +63,7 @@ if (SCRIPT_PROJECT != null) { deleteProject(SCRIPT_PROJECT.getElementName()); } - SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME); + SCRIPT_PROJECT = setUpScriptProject(PROJECT_NAME, RubyUITestsPlugin.PLUGIN_ID); } class Access implements Runnable {