autoconvert.trunk.15266.patch
new/src/com/goldencode/p2j/cfg/Configuration.java 2024-06-07 10:29:14 +0000 | ||
---|---|---|
85 | 85 |
** ECF 20230127 Added mutable schema configuration option. |
86 | 86 |
** 024 VVT 20230318 Constant added: default legacy unit test framework type. See #6237. |
87 | 87 |
** 025 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus. |
88 |
** 026 ME 20240604 Added support for automatic dependency conversion when file list is used. |
|
88 | 89 |
*/ |
89 | 90 | |
90 | 91 |
/* |
... | ... | |
353 | 354 |
/** The loaded schema configuration. */ |
354 | 355 |
private SchemaConfig schemaConfig = null; |
355 | 356 |
|
357 |
/** The list of conversion dependencies listeners */ |
|
358 |
private static Set<Consumer<String>> conversionDepsListeners; |
|
359 |
|
|
356 | 360 |
/** |
357 | 361 |
* Holds a set of configuration parameter names whose values are OS dependent. These are |
358 | 362 |
* related to the system we run now, and are invisible for original P4GL code. |
... | ... | |
1402 | 1406 |
loadConfigProfiles(profiles); |
1403 | 1407 |
// schema will have the default profile set if profile switching occurs |
1404 | 1408 |
} |
1409 |
|
|
1410 |
/** |
|
1411 |
* Add a dependency listener used for conversion only, no-op for runtime configuration. |
|
1412 |
* |
|
1413 |
* Automatic dependency resolution during conversion is enabled by setting the |
|
1414 |
* 'convert-deps' general parameter to true. |
|
1415 |
* |
|
1416 |
* @param listener the dependency listener |
|
1417 |
*/ |
|
1418 |
public static void addConversionDependencyListener(Consumer<String> listener) |
|
1419 |
{ |
|
1420 |
if (listener != null && !isRuntimeConfig() && getParameter("convert-deps", false)) |
|
1421 |
{ |
|
1422 |
if (conversionDepsListeners == null) |
|
1423 |
{ |
|
1424 |
conversionDepsListeners = new HashSet<>(); |
|
1425 |
} |
|
1426 |
|
|
1427 |
conversionDepsListeners.add(listener); |
|
1428 |
} |
|
1429 |
} |
|
1430 |
|
|
1431 |
/** |
|
1432 |
* Remove a dependency listener used for conversion only, no-op for runtime configuration. |
|
1433 |
* |
|
1434 |
* @param listener the dependency listener |
|
1435 |
*/ |
|
1436 |
public static void removeConversionDependencyListener(Consumer<String> listener) |
|
1437 |
{ |
|
1438 |
if (listener != null && conversionDepsListeners != null) |
|
1439 |
{ |
|
1440 |
conversionDepsListeners.remove(listener); |
|
1441 |
} |
|
1442 |
} |
|
1443 |
|
|
1444 |
/** |
|
1445 |
* Notify dependency listeners a new dependency has been found (class or procedure). |
|
1446 |
* |
|
1447 |
* @param filename the dependency file name |
|
1448 |
*/ |
|
1449 |
public static void foundConversionDependency(String filename) { |
|
1450 |
if (conversionDepsListeners != null) |
|
1451 |
{ |
|
1452 |
conversionDepsListeners.forEach(l -> l.accept(filename)); |
|
1453 |
} |
|
1454 |
} |
|
1405 | 1455 | |
1406 | 1456 |
/** |
1407 | 1457 |
* Create a Configuration instance. |
... | ... | |
1417 | 1467 |
// always start with P2J_HOME parameter; this is reserved |
1418 | 1468 |
config.parmMap.put(PROP_HOME_DIR, home()); |
1419 | 1469 |
|
1420 |
InputStream cfgStream; |
|
1470 |
InputStream cfgStream = null;
|
|
1421 | 1471 |
|
1422 |
// attempt to load from jar first |
|
1423 |
ClassLoader cl = ClassLoader.getSystemClassLoader(); |
|
1424 |
cfgStream = cl.getResourceAsStream(CFG_DIR + "/" + DEF_CFG_FILE); |
|
1472 |
// runtime configuration attempt to load from jar first |
|
1473 |
if (isRuntimeConfig()) |
|
1474 |
{ |
|
1475 |
ClassLoader cl = ClassLoader.getSystemClassLoader(); |
|
1476 |
cfgStream = cl.getResourceAsStream(CFG_DIR + "/" + DEF_CFG_FILE); |
|
1477 |
} |
|
1425 | 1478 |
|
1426 | 1479 |
if (cfgStream == null) |
1427 | 1480 |
{ |
new/src/com/goldencode/p2j/convert/ConversionDriver.java 2024-06-07 10:29:14 +0000 | ||
---|---|---|
142 | 142 |
** CA 20220603 Allow the generation of proxy Java programs in the folder specified by |
143 | 143 |
** 'proxy-output-root'. |
144 | 144 |
** 047 OM 20240311 Do not generate the <schema>.meta.xml any more. The information is already |
145 |
** present in DMO interface annotations. |
|
145 |
** present in DMO interface annotations. |
|
146 |
** 048 ME 20240604 Add support for automatic dependencies conversion when using file list. |
|
146 | 147 |
*/ |
147 | 148 | |
148 | 149 |
/* |
... | ... | |
215 | 216 |
import com.goldencode.p2j.schema.*; |
216 | 217 |
import com.goldencode.p2j.uast.*; |
217 | 218 |
import com.goldencode.p2j.util.*; |
219 |
import com.goldencode.util.StringHelper; |
|
218 | 220 |
import java.io.*; |
219 | 221 |
import java.util.*; |
220 | 222 | |
... | ... | |
343 | 345 |
/** The list of Progress source file specific P2O files. */ |
344 | 346 |
private FileList sp2os = null; |
345 | 347 |
|
348 |
/** The list of Progress source files dependencies (used but not in convert list). */ |
|
349 |
private Set<String> dependencies = null; |
|
350 |
|
|
346 | 351 |
/** |
347 | 352 |
* Creates an instance with a specific configuration. |
348 | 353 |
* |
... | ... | |
583 | 588 |
brew(jasts, "Business Logic and Frames Classes"); |
584 | 589 |
} |
585 | 590 |
|
591 |
|
|
592 |
@Override |
|
593 |
protected void executeJob(String title) |
|
594 |
{ |
|
595 |
// add conversion dependency listener |
|
596 |
Configuration.addConversionDependencyListener(file -> { |
|
597 |
if (dependencies == null) |
|
598 |
{ |
|
599 |
dependencies = new HashSet<>(); |
|
600 |
} |
|
601 |
|
|
602 |
file = StringHelper.removeQuotes(file); |
|
603 |
|
|
604 |
if (dependencies.add(file)) |
|
605 |
{ |
|
606 |
// remove old java ast if we need to convert it |
|
607 |
zapFiles(new String[] { file }, new String[] { ".jast" }); |
|
608 |
} |
|
609 |
}); |
|
610 |
|
|
611 |
super.executeJob(title); |
|
612 |
} |
|
613 | ||
586 | 614 |
/** |
587 | 615 |
* Gather all SOAP operations from all files, regardless if they are included in the incremental conversion |
588 | 616 |
* or not, and generate the WSDLs. |
... | ... | |
1080 | 1108 |
jasts = new ExplicitFileList(oldjasts.toArray(new String[0])); |
1081 | 1109 |
} |
1082 | 1110 |
|
1111 |
@Override |
|
1112 |
protected void runScanDriver(boolean preproc, boolean schema, boolean abortOnError, |
|
1113 |
int threads) throws Exception |
|
1114 |
{ |
|
1115 |
// update source dependencies with database schema triggers before scan |
|
1116 |
updateSourceDependencies(); |
|
1117 |
|
|
1118 |
super.runScanDriver(preproc, schema, abortOnError, threads); |
|
1119 |
|
|
1120 |
// update source dependencies with those found during scan |
|
1121 |
updateSourceDependencies(); |
|
1122 |
} |
|
1123 |
|
|
1124 |
private void updateSourceDependencies () |
|
1125 |
{ |
|
1126 |
if (dependencies != null) { |
|
1127 |
for (String src : source.listFilenames()) |
|
1128 |
{ |
|
1129 |
dependencies.remove(src); |
|
1130 |
} |
|
1131 |
|
|
1132 |
if (!dependencies.isEmpty()) |
|
1133 |
{ |
|
1134 |
dependencies.addAll(Arrays.asList(source.listFilenames())); |
|
1135 |
source = new ExplicitFileList(dependencies.toArray(new String[0])); |
|
1136 |
job.files = source; |
|
1137 |
} |
|
1138 |
|
|
1139 |
dependencies = null; |
|
1140 |
} |
|
1141 |
} |
|
1142 | ||
1083 | 1143 |
/** |
1084 | 1144 |
* Container class that aggregates a set of options to control a run of the conversion |
1085 | 1145 |
* driver. |
new/src/com/goldencode/p2j/schema/schema.g 2024-06-07 10:29:14 +0000 | ||
---|---|---|
110 | 110 |
** CA 20230321 A table's signature must include index information (this includes the index |
111 | 111 |
** name, options, field position and type). |
112 | 112 |
** 041 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus. |
113 |
** 042 ME 20240604 Add database schema trigger procedures as conversion dependencies. |
|
113 | 114 |
*/ |
114 | 115 | |
115 | 116 |
/* |
... | ... | |
2064 | 2065 |
*/ |
2065 | 2066 |
proc_clause |
2066 | 2067 |
: |
2067 |
KW_PROC^ STRING |
|
2068 |
KW_PROC^ s:STRING |
|
2069 |
{ |
|
2070 |
Configuration.foundConversionDependency(#s.getText()); |
|
2071 |
} |
|
2068 | 2072 |
; |
2069 | 2073 |
|
2070 | 2074 |
/** |
new/src/com/goldencode/p2j/uast/AstGenerator.java 2024-06-07 10:29:14 +0000 | ||
---|---|---|
191 | 191 |
** 060 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus. |
192 | 192 |
** 061 OM 20230115 Replaced absolutePath(), relativePath(), upPath() and downPath() with faster |
193 | 193 |
** versions, based on node types. |
194 |
** 062 ME 20240604 Automatic add OO dependencies found during conversion using file list. |
|
194 | 195 |
*/ |
195 | 196 | |
196 | 197 |
/* |
... | ... | |
1638 | 1639 |
String qname = ref.getText(); |
1639 | 1640 |
ClassDefinition cdef = SymbolResolver.getClassDefinition(qname); |
1640 | 1641 |
cdef.parseFinished(false); |
1642 |
|
|
1643 |
if (!cdef.isBuiltIn()) |
|
1644 |
{ |
|
1645 |
// flag non built-in OO elements as conversion dependencies |
|
1646 |
Configuration.foundConversionDependency(filename); |
|
1647 |
} |
|
1648 |
} |
|
1649 |
else |
|
1650 |
{ |
|
1651 |
// flag procedures as conversion dependencies |
|
1652 |
Configuration.foundConversionDependency(filename); |
|
1641 | 1653 |
} |
1642 | 1654 |
// save off output if requested, THIS MUST BE DONE AFTER FIXUPS! |
1643 | 1655 |
if (dumpParser) |
new/src/com/goldencode/p2j/uast/SymbolResolver.java 2024-06-07 10:29:14 +0000 | ||
---|---|---|
514 | 514 |
** the type. |
515 | 515 |
** 100 CA 20231019 Show linkage errors when resolving Java class names. |
516 | 516 |
** 101 OM 20240305 Added [word-indexed] annotation on word indexed fields. |
517 |
** 102 ME 20240604 Parse procedures that were not resolved before (dependencies from RUN statements). |
|
517 | 518 |
*/ |
518 | 519 | |
519 | 520 |
/* |
... | ... | |
4059 | 4060 |
*/ |
4060 | 4061 |
public int lookupProcedure(String name) |
4061 | 4062 |
{ |
4062 |
return lookupWorkerExact(procDict, name); |
|
4063 |
int ret = lookupWorkerExact(procDict, name); |
|
4064 |
|
|
4065 |
if (ret == -1) |
|
4066 |
{ |
|
4067 |
// if not resolved already parse the procedure |
|
4068 |
getAstGenerator().processFile(name, null, -1); |
|
4069 |
} |
|
4070 |
|
|
4071 |
return ret; |
|
4063 | 4072 |
} |
4064 | 4073 |
|
4065 | 4074 |
/** |
... | ... | |
4580 | 4589 |
// at this point found.filename must be valid |
4581 | 4590 |
} |
4582 | 4591 | |
4583 |
if (generator == null) |
|
4584 |
{ |
|
4585 |
generator = new AstGenerator(); |
|
4586 |
generator.setSilent(silent); |
|
4587 |
generator.setPreprocess(true); |
|
4588 |
generator.setCache(true); |
|
4589 |
generator.setDumpLexer(true); |
|
4590 |
generator.setDumpParser(true); |
|
4591 |
generator.setAstPersist(true); |
|
4592 |
} |
|
4593 | ||
4594 | 4592 |
String relative = Configuration.normalizeFilename(found.filename); |
4595 | 4593 |
|
4596 | 4594 |
if (wa.preScanPass == 0) |
... | ... | |
4614 | 4612 |
} |
4615 | 4613 | |
4616 | 4614 |
// the PROPATH is inherited from the caller |
4617 |
generator.preScanClass(relative, found.builtin, found.dotnet, this.propath);
|
|
4615 |
getAstGenerator().preScanClass(relative, found.builtin, found.dotnet, this.propath);
|
|
4618 | 4616 |
|
4619 | 4617 |
// save all referenced classes/interfaces except for the genesis object |
4620 | 4618 |
if (wa.preScanPass > 1) |
... | ... | |
8738 | 8736 |
|
8739 | 8737 |
if (!cdef.isBuiltIn() && new File(file).exists()) |
8740 | 8738 |
{ |
8741 |
generator.processFile(file, null, -1);
|
|
8739 |
getAstGenerator().processFile(file, null, -1);
|
|
8742 | 8740 |
|
8743 | 8741 |
// at this point we have been fully parsed and all parents have been fully parsed, so |
8744 | 8742 |
// it is safe to detect whether or not one of our ancestors is a .NET class |
... | ... | |
9962 | 9960 |
} |
9963 | 9961 |
|
9964 | 9962 |
/** |
9963 |
* Lazy load the AST Generator when new class/procedure needs to be processed. |
|
9964 |
* |
|
9965 |
* @return the AST generator |
|
9966 |
*/ |
|
9967 |
private AstGenerator getAstGenerator () { |
|
9968 |
if (generator == null) |
|
9969 |
{ |
|
9970 |
generator = new AstGenerator(); |
|
9971 |
generator.setSilent(silent); |
|
9972 |
generator.setPreprocess(true); |
|
9973 |
generator.setCache(true); |
|
9974 |
generator.setDumpLexer(true); |
|
9975 |
generator.setDumpParser(true); |
|
9976 |
generator.setAstPersist(true); |
|
9977 |
} |
|
9978 |
|
|
9979 |
return generator; |
|
9980 |
} |
|
9981 |
|
|
9982 |
/** |
|
9965 | 9983 |
* Create a new {@link Variable}, with the specified details. |
9966 | 9984 |
* |
9967 | 9985 |
* @param name |