diff --git a/README.md b/README.md index 709818a4..81182146 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Please file your bug reports, enhancement requests, questions and other support ## How to Build -1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 18.2.0 +1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 18.3.0 2. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.5.4 3. [Download](https://git-scm.com/downloads) and install a git command line client 4. Clone the utPLSQL-SQLDeveloper repository @@ -57,7 +57,7 @@ Please file your bug reports, enhancement requests, questions and other support 6. Run maven build by the following command - mvn -Dsqldev.basedir=/Applications/SQLDeveloper18.2.0.app/Contents/Resources/sqldeveloper -DskipTests=true clean package + mvn -Dsqldev.basedir=/Applications/SQLDeveloper18.3.0.app/Contents/Resources/sqldeveloper -DskipTests=true clean package Amend the parameter sqldev.basedir to match the path of your SQL Developer installation. This folder is used to reference Oracle jar files which are not available in public Maven repositories 7. The resulting file ```utplsql_for_SQLDev_x.x.x-SNAPSHOT.zip``` in the ```target``` directory can be installed within SQL Developer diff --git a/sqldev/pom.xml b/sqldev/pom.xml index 26c8f61d..bf66b79d 100644 --- a/sqldev/pom.xml +++ b/sqldev/pom.xml @@ -13,7 +13,7 @@ 1.8 2.15.0 - /Applications/SQLDeveloper18.2.0.app/Contents/Resources/sqldeveloper + /Applications/SQLDeveloper18.3.0.app/Contents/Resources/sqldeveloper utplsql_for_SQLDev_${project.version} diff --git a/sqldev/src/main/java/org/utplsql/sqldev/UtplsqlWorksheet.xtend b/sqldev/src/main/java/org/utplsql/sqldev/UtplsqlWorksheet.xtend index 44e60e90..5a055081 100644 --- a/sqldev/src/main/java/org/utplsql/sqldev/UtplsqlWorksheet.xtend +++ b/sqldev/src/main/java/org/utplsql/sqldev/UtplsqlWorksheet.xtend @@ -16,8 +16,10 @@ package org.utplsql.sqldev import java.util.ArrayList +import java.util.HashSet import java.util.List import java.util.logging.Logger +import java.util.regex.Pattern import javax.swing.JSplitPane import oracle.dbtools.raptor.utils.Connections import oracle.dbtools.worksheet.editor.OpenWorksheetWizard @@ -57,6 +59,30 @@ class UtplsqlWorksheet { } } + private def dedupPathList() { + val set = new HashSet + for (path : pathList) { + set.add(path) + } + val ret = new ArrayList + val p = Pattern.compile("((((\\w+)\\.)?\\w+)\\.)?\\w+") + for (path : set) { + val m = p.matcher(path) + if (m.matches()) { + val parent1 = m.group(4) // user + val parent2 = m.group(2) // user.package + if (parent1 === null || !set.contains(parent1)) { + if (parent2 === null || !set.contains(parent2)) { + ret.add(path) + } + } + } else { + logger.severe('''path: «path» did not pattern «p.toString», this is unexected!''') + } + } + return ret + } + private def getCode() ''' «IF preferences.resetPackage» EXECUTE dbms_session.reset_package; @@ -65,10 +91,11 @@ class UtplsqlWorksheet { «IF preferences.clearScreen» CLEAR SCREEN «ENDIF» - «IF pathList.size == 1» - EXECUTE ut.run('«pathList.get(0)»'); + «val paths = dedupPathList» + «IF paths.size == 1» + EXECUTE ut.run('«paths.get(0)»'); «ELSE» - EXECUTE ut.run(ut_varchar2_list(«FOR path : pathList SEPARATOR ', '»'«path»'«ENDFOR»)); + EXECUTE ut.run(ut_varchar2_list(«FOR path : paths SEPARATOR ', '»'«path»'«ENDFOR»)); «ENDIF» ''' @@ -117,7 +144,7 @@ class UtplsqlWorksheet { thread.start } - def static void openWithCode(String code, String connectionName) { + static def void openWithCode(String code, String connectionName) { val worksheet = OpenWorksheetWizard.openNewTempWorksheet(connectionName, code) as Worksheet if (connectionName === null) { worksheet.comboConnection = null diff --git a/sqldev/src/main/java/org/utplsql/sqldev/oddgen/RunGenerator.xtend b/sqldev/src/main/java/org/utplsql/sqldev/oddgen/RunGenerator.xtend index d4f23568..ba7743f0 100644 --- a/sqldev/src/main/java/org/utplsql/sqldev/oddgen/RunGenerator.xtend +++ b/sqldev/src/main/java/org/utplsql/sqldev/oddgen/RunGenerator.xtend @@ -100,7 +100,7 @@ class RunGenerator implements OddgenGenerator2 { return new HashMap } - def private getPath(Node node, Connection conn) { + private def getPath(Node node, Connection conn) { if (node.id == "SUITE" || node.id == "SUITEPATH") { return conn.metaData.userName } else { @@ -108,7 +108,7 @@ class RunGenerator implements OddgenGenerator2 { } } - def replaceTabsWithSpaces(CharSequence input, int indentSpaces) { + private def replaceTabsWithSpaces(CharSequence input, int indentSpaces) { val spaces = String.format("%1$"+indentSpaces+"s", "") return input.toString.replace("\t", spaces) } diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend index eadcd989..5979320d 100644 --- a/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend +++ b/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend @@ -16,6 +16,7 @@ package org.utplsql.sqldev.tests import java.util.ArrayList +import java.util.HashMap import org.junit.AfterClass import org.junit.Assert import org.junit.BeforeClass @@ -244,4 +245,53 @@ class DalTest extends AbstractJdbcTest { Assert.assertEquals("PROCEDURE.JUNIT_P", effective.get(0).id) } + @Test + def void runnables() { + val dao = new UtplsqlDao(dataSource.connection) + jdbcTemplate.execute(''' + CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS + -- %suite + -- %suitepath(a.b.c) + + -- %test + PROCEDURE t0; + + -- %context(mycontext) + + -- %test + PROCEDURE t1; + + -- %test + PROCEDURE t2; + + -- %endcontext + + -- %test + PROCEDURE t3; + END junit_utplsql_test_pkg; + ''') + val effectiveNodes = dao.runnables() + Assert.assertEquals(16, effectiveNodes.size) + val effective = new HashMap + for (node : effectiveNodes) { + effective.put(node.id, node.parentId) + } + Assert.assertEquals(null, effective.get("SUITE")) + Assert.assertEquals("SUITE", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG")) + Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t0")) + Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t1")) + Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t2")) + Assert.assertEquals("SCOTT.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT.JUNIT_UTPLSQL_TEST_PKG.t3")) + Assert.assertEquals(null, effective.get("SUITEPATH")) + Assert.assertEquals("SUITEPATH", effective.get("SCOTT:a")) + Assert.assertEquals("SCOTT:a", effective.get("SCOTT:a.b")) + Assert.assertEquals("SCOTT:a.b", effective.get("SCOTT:a.b.c")) + Assert.assertEquals("SCOTT:a.b.c", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG")) + Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext")) + Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.t0")) + Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.t3")) + Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext.t1")) + Assert.assertEquals("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext", effective.get("SCOTT:a.b.c.JUNIT_UTPLSQL_TEST_PKG.mycontext.t2")) + } + } \ No newline at end of file