@@ -1,21 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="src" path="src"/> | |||
<classpathentry kind="src" path="java5-testsrc"/> | |||
<classpathentry kind="src" path="/bridge"/> | |||
<classpathentry kind="src" path="/weaver"/> | |||
<classpathentry kind="src" path="/asm"/> | |||
<classpathentry kind="src" path="/util"/> | |||
<classpathentry kind="src" path="/runtime"/> | |||
<classpathentry kind="src" path="testsrc"/> | |||
<classpathentry kind="lib" path="/lib/bcel/bcel.jar" sourcepath="/lib/bcel/bcel-src.zip"/> | |||
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/> | |||
<classpathentry kind="src" path="/testing-util"/> | |||
<classpathentry kind="src" path="/testing-client"/> | |||
<classpathentry kind="src" path="/org.eclipse.jdt.core"/> | |||
<classpathentry combineaccessrules="false" kind="src" path="/loadtime"/> | |||
<classpathentry kind="lib" path="/lib/bcel/bcel-verifier.jar"/> | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | |||
<classpathentry combineaccessrules="false" kind="src" path="/org.aspectj.matcher"/> | |||
<classpathentry kind="output" path="bin"/> | |||
</classpath> |
@@ -1,5 +0,0 @@ | |||
out | |||
bin | |||
default.ajsym | |||
default.lst | |||
bintest |
@@ -1 +0,0 @@ | |||
@@ -1,25 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>org.aspectj.ajdt.core</name> | |||
<comment></comment> | |||
<projects> | |||
<project>asm</project> | |||
<project>bridge</project> | |||
<project>org.eclipse.jdt.core</project> | |||
<project>runtime</project> | |||
<project>testing-client</project> | |||
<project>testing-util</project> | |||
<project>util</project> | |||
<project>weaver</project> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
</natures> | |||
</projectDescription> |
@@ -1,6 +0,0 @@ | |||
<?xml version="1.0"?> | |||
<!-- see ../build/*.html for explanation --> | |||
<project name="org.aspectj.ajdt.core" default="test" basedir="."> | |||
<import file="${basedir}/../build/build.xml"/> | |||
</project> | |||
@@ -1,24 +0,0 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2006 IBM Corporation and others. | |||
* All rights reserved. This program and the accompanying materials | |||
* are made available under the terms of the Eclipse Public License v1.0 | |||
* which accompanies this distribution, and is available at | |||
* http://www.eclipse.org/legal/epl-v10.html | |||
* | |||
* Contributors: | |||
* Matthew Webster - initial implementation | |||
*******************************************************************************/ | |||
import junit.framework.*; | |||
import junit.framework.Test; | |||
public class Eajc515ModuleTests extends TestCase { | |||
public static Test suite() { | |||
TestSuite suite = new TestSuite(Eajc515ModuleTests.class.getName()); | |||
suite.addTest(org.aspectj.tools.ajc.Ajc5Tests.suite()); | |||
return suite; | |||
} | |||
public Eajc515ModuleTests(String name) { super(name); } | |||
} |
@@ -0,0 +1,74 @@ | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>aspectj-parent</artifactId> | |||
<version>1.9.3.BUILD-SNAPSHOT</version> | |||
<relativePath>..</relativePath> | |||
</parent> | |||
<artifactId>org.aspectj.ajdt.core</artifactId> | |||
<packaging>jar</packaging> | |||
<name>org.aspectj.ajdt.core</name> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>bridge</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>weaver</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>asm</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>util</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>runtime</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>bcel-builder</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>testing-util</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>testing-client</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>org.eclipse.jdt.core</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>loadtime</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>org.aspectj.matcher</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -1,242 +0,0 @@ | |||
Index: .classpath | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/.classpath,v | |||
retrieving revision 1.6 | |||
diff -u -r1.6 .classpath | |||
--- .classpath 3 May 2005 13:31:17 -0000 1.6 | |||
+++ .classpath 2 Sep 2005 07:39:42 -0000 | |||
@@ -13,5 +13,6 @@ | |||
<classpathentry kind="src" path="/testing-util"/> | |||
<classpathentry kind="src" path="/testing-client"/> | |||
<classpathentry kind="src" path="/org.eclipse.jdt.core"/> | |||
+ <classpathentry combineaccessrules="false" kind="src" path="/aspectj5rt"/> | |||
<classpathentry kind="output" path="bin"/> | |||
</classpath> | |||
Index: .project | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/.project,v | |||
retrieving revision 1.2 | |||
diff -u -r1.2 .project | |||
--- .project 13 Aug 2004 15:18:01 -0000 1.2 | |||
+++ .project 2 Sep 2005 07:39:42 -0000 | |||
@@ -4,6 +4,7 @@ | |||
<comment></comment> | |||
<projects> | |||
<project>asm</project> | |||
+ <project>aspectj5rt</project> | |||
<project>bridge</project> | |||
<project>org.eclipse.jdt.core</project> | |||
<project>runtime</project> | |||
Index: src/org/aspectj/ajdt/ajc/BuildArgParser.java | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java,v | |||
retrieving revision 1.40 | |||
diff -u -r1.40 BuildArgParser.java | |||
--- src/org/aspectj/ajdt/ajc/BuildArgParser.java 23 Aug 2005 08:47:32 -0000 1.40 | |||
+++ src/org/aspectj/ajdt/ajc/BuildArgParser.java 2 Sep 2005 07:39:43 -0000 | |||
@@ -171,6 +171,7 @@ | |||
} | |||
buildConfig.setFiles(fileList); | |||
+ buildConfig.setUserFileNameMap(parser.getUserFileNameMap()); | |||
if (destinationPath != null) { // XXX ?? unparsed but set? | |||
buildConfig.setOutputDir(new File(destinationPath)); | |||
} | |||
Index: src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java,v | |||
retrieving revision 1.28 | |||
diff -u -r1.28 AjBuildConfig.java | |||
--- src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java 23 Aug 2005 08:47:14 -0000 1.28 | |||
+++ src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java 2 Sep 2005 07:39:43 -0000 | |||
@@ -44,6 +44,7 @@ | |||
private File outputJar; | |||
private List/*File*/ sourceRoots = new ArrayList(); | |||
private List/*File*/ files = new ArrayList(); | |||
+ private Map/*File -> File*/ userFileNameMap = new HashMap(); | |||
private List /*File*/ binaryFiles = new ArrayList(); // .class files in indirs... | |||
private List/*File*/ inJars = new ArrayList(); | |||
private List/*File*/ inPath = new ArrayList(); | |||
@@ -117,6 +118,10 @@ | |||
public List/*File*/ getFiles() { | |||
return files; | |||
} | |||
+ | |||
+ public Map/* File -> File*/ getUserFileNameMap() { | |||
+ return userFileNameMap; | |||
+ } | |||
/** | |||
* returned files includes all .class files found in | |||
@@ -134,6 +139,10 @@ | |||
public void setFiles(List files) { | |||
this.files = files; | |||
} | |||
+ | |||
+ public void setUserFileNameMap(Map userFileNameMap) { | |||
+ this.userFileNameMap = userFileNameMap; | |||
+ } | |||
public void setOutputDir(File outputDir) { | |||
this.outputDir = outputDir; | |||
Index: src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java,v | |||
retrieving revision 1.73 | |||
diff -u -r1.73 AjBuildManager.java | |||
--- src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java 23 Aug 2005 21:30:11 -0000 1.73 | |||
+++ src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java 2 Sep 2005 07:39:45 -0000 | |||
@@ -165,8 +165,11 @@ | |||
if (!canIncremental && !batch) { // retry as batch? | |||
return doBuild(buildConfig, baseHandler, true); | |||
} | |||
+ IMessageHandler userTranslatingHandler = | |||
+ new UserFileLocationTranslatingHandler(baseHandler,buildConfig.getUserFileNameMap()); | |||
this.handler = | |||
- CountingMessageHandler.makeCountingMessageHandler(baseHandler); | |||
+ CountingMessageHandler.makeCountingMessageHandler(userTranslatingHandler); | |||
+ ; | |||
// XXX duplicate, no? remove? | |||
String check = checkRtJar(buildConfig); | |||
if (check != null) { | |||
Index: testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java | |||
=================================================================== | |||
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java,v | |||
retrieving revision 1.16 | |||
diff -u -r1.16 AjBuildManagerTest.java | |||
--- testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java 23 Jan 2004 19:07:52 -0000 1.16 | |||
+++ testsrc/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java 2 Sep 2005 07:39:46 -0000 | |||
@@ -89,6 +89,29 @@ | |||
// ((StructureNode)StructureModelManager.INSTANCE.getStructureModel().getRoot().getChildren().get(0)).getChildren() | |||
// ); | |||
} | |||
+ | |||
+ public void testUserFileTranslationInErrorMessages() throws IOException { | |||
+ AjBuildManager manager = new AjBuildManager(messageWriter); | |||
+ BuildArgParser parser = new BuildArgParser(messageWriter); | |||
+ String javaClassPath = System.getProperty("java.class.path"); | |||
+ AjBuildConfig buildConfig = | |||
+ parser.genBuildConfig(new String[] { | |||
+ "-d", "out", | |||
+ "-classpath", | |||
+ javaClassPath, | |||
+ AjdtAjcTests.TESTDATA_PATH | |||
+ + "/src1/DeclareWarning.java", | |||
+// EajcModuleTests.TESTDATA_PATH + "/src1/Hello.java", | |||
+ }); | |||
+ String err = parser.getOtherMessages(true); | |||
+ assertTrue(err, null == err); | |||
+ manager.setStructureModel(AsmManager.getDefault().getHierarchy()); | |||
+ MessageHandler handler = new MessageHandler(); | |||
+ manager.batchBuild(buildConfig, handler); | |||
+ IMessage[] warnings = handler.getMessages(IMessage.WARNING, false); | |||
+ assertEquals("1 warning",1,warnings.length); | |||
+ assertTrue("source file mapped back to user location",warnings[0].getSourceLocation().getSourceFile().getPath().startsWith("..")); | |||
+ } | |||
Index: src/org/aspectj/ajdt/internal/core/builder/UserFileLocationTranslatingHandler.java | |||
=================================================================== | |||
RCS file: src/org/aspectj/ajdt/internal/core/builder/UserFileLocationTranslatingHandler.java | |||
diff -N src/org/aspectj/ajdt/internal/core/builder/UserFileLocationTranslatingHandler.java | |||
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |||
+++ src/org/aspectj/ajdt/internal/core/builder/UserFileLocationTranslatingHandler.java 1 Jan 1970 00:00:00 -0000 | |||
@@ -0,0 +1,97 @@ | |||
+/* ******************************************************************* | |||
+ * Copyright (c) 2005 Contributors. | |||
+ * All rights reserved. | |||
+ * This program and the accompanying materials are made available | |||
+ * under the terms of the Eclipse Public License v1.0 | |||
+ * which accompanies this distribution and is available at | |||
+ * http://eclipse.org/legal/epl-v10.html | |||
+ * | |||
+ * Contributors: | |||
+ * Adrian Colyer Initial implementation | |||
+ * ******************************************************************/ | |||
+package org.aspectj.ajdt.internal.core.builder; | |||
+ | |||
+import java.io.File; | |||
+import java.util.ArrayList; | |||
+import java.util.Iterator; | |||
+import java.util.List; | |||
+import java.util.Map; | |||
+ | |||
+import org.aspectj.bridge.AbortException; | |||
+import org.aspectj.bridge.IMessage; | |||
+import org.aspectj.bridge.IMessageHandler; | |||
+import org.aspectj.bridge.ISourceLocation; | |||
+import org.aspectj.bridge.Message; | |||
+import org.aspectj.bridge.SourceLocation; | |||
+import org.aspectj.bridge.IMessage.Kind; | |||
+ | |||
+/** | |||
+ * @author colyer | |||
+ * | |||
+ */ | |||
+public class UserFileLocationTranslatingHandler implements IMessageHandler { | |||
+ | |||
+ private IMessageHandler delegate; | |||
+ private Map userFileNameMap; | |||
+ | |||
+ public UserFileLocationTranslatingHandler(IMessageHandler delegateHandler, Map canonicalFileToUserFile) { | |||
+ this.delegate = delegateHandler; | |||
+ this.userFileNameMap = canonicalFileToUserFile; | |||
+ } | |||
+ | |||
+ /* (non-Javadoc) | |||
+ * @see org.aspectj.bridge.IMessageHandler#handleMessage(org.aspectj.bridge.IMessage) | |||
+ */ | |||
+ public boolean handleMessage(IMessage message) throws AbortException { | |||
+ IMessage messageToIssue = message; | |||
+ ISourceLocation location = message.getSourceLocation(); | |||
+ if (location != null) { | |||
+ File sourceFile = location.getSourceFile(); | |||
+ if (userFileNameMap.containsKey(sourceFile)) { | |||
+ File userFile = (File) userFileNameMap.get(sourceFile); | |||
+ if (!sourceFile.getPath().equals(userFile.getPath())) { | |||
+ // path as known to user is different to the canonical path we have been | |||
+ // working with. Could be due to eg. symbolic links in filesystem etc. | |||
+ // this upsets clients such as AJDT | |||
+ messageToIssue = replaceLocationsIn(message); | |||
+ } | |||
+ } | |||
+ } | |||
+ return delegate.handleMessage(messageToIssue); | |||
+ } | |||
+ | |||
+ /* (non-Javadoc) | |||
+ * @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind) | |||
+ */ | |||
+ public boolean isIgnoring(Kind kind) { | |||
+ return delegate.isIgnoring(kind); | |||
+ } | |||
+ | |||
+ /* (non-Javadoc) | |||
+ * @see org.aspectj.bridge.IMessageHandler#dontIgnore(org.aspectj.bridge.IMessage.Kind) | |||
+ */ | |||
+ public void dontIgnore(Kind kind) { | |||
+ delegate.dontIgnore(kind); | |||
+ } | |||
+ | |||
+ private IMessage replaceLocationsIn(IMessage message) { | |||
+ ISourceLocation newSourceLocation = replaceLocationIn(message.getSourceLocation()); | |||
+ List extraLocations = message.getExtraSourceLocations(); | |||
+ List newExtraLocations = new ArrayList(); | |||
+ for (Iterator iter = extraLocations.iterator(); iter.hasNext();) { | |||
+ ISourceLocation loc = (ISourceLocation) iter.next(); | |||
+ newExtraLocations.add(replaceLocationIn(loc)); | |||
+ } | |||
+ Message copyWithUpdatedLocation = new Message(message,newSourceLocation,newExtraLocations); | |||
+ return copyWithUpdatedLocation; | |||
+ } | |||
+ | |||
+ private ISourceLocation replaceLocationIn(ISourceLocation location) { | |||
+ File newSourceFile = location.getSourceFile(); | |||
+ if (userFileNameMap.containsKey(newSourceFile)) { | |||
+ newSourceFile = (File) userFileNameMap.get(newSourceFile); | |||
+ } | |||
+ SourceLocation newSourceLocation = new SourceLocation(location,newSourceFile); | |||
+ return newSourceLocation; | |||
+ } | |||
+} |
@@ -1,31 +0,0 @@ | |||
import os, string | |||
DIR = "c:\\eclipse\\workspace\\weaver" | |||
old_text = "declare dominates:" | |||
new_text = "declare precedence:" | |||
def doit(arg, dirname, filenames): | |||
for name in filenames: | |||
fullname = os.path.join(dirname, name) | |||
if os.path.isfile(fullname): | |||
do_replace(fullname) | |||
def do_replace(filename): | |||
if filename.endswith(".py"): return | |||
s = open(filename, 'r') | |||
text = s.read() | |||
s.close() | |||
if string.find(text, old_text) == -1: | |||
return | |||
s = open(filename, 'w') | |||
s.write(text.replace(old_text, new_text)) | |||
s.close() | |||
print "changed", filename | |||
os.path.walk(DIR, doit, None) |
@@ -1,28 +0,0 @@ | |||
inputFile = "c:/eclipse/workspace/org.eclipse.jdt.core/aspectj/org/aspectj/workbench/resources/FileAdapter.java" | |||
text = open(inputFile, 'r').read() | |||
#print text | |||
import re, string | |||
methodPat = re.compile(r"public [^{]*\([^{]*{[^}]*}") #^[{]\)^[{]{", re.DOTALL) #{ .* }", re.DOTALL) | |||
throwException = """throw new RuntimeException("unimplemented");""" | |||
for method in methodPat.findall(text): | |||
print method | |||
newMethod = method[:len(method)-1] | |||
startBody = newMethod.find("{") | |||
newMethod = newMethod[:startBody+1] | |||
newMethod = newMethod + "\n\t" + throwException + "\n\t}" | |||
text = text.replace(method, newMethod) | |||
print text | |||
open(inputFile, 'w').write(text) | |||
@@ -1,125 +0,0 @@ | |||
# set these first four variables appropriately for your system | |||
eclipseWorkspace = "c:/aspectj/2.1/eclipse/workspace" | |||
workingDir = "c:/apps/jikespg/jdt/tmp" | |||
jikespg = "c:/apps/jikespg/src/jikespg.exe" | |||
makersc = "c:/j2sdk1.4/bin/java -classpath c:/aspectj/2.1/eclipse/workspace/org.eclipse.jdt.core/bin;c:/apps/jikespg/jdt UpdateParserFiles" | |||
# the rest of this should never change | |||
ajCompilerHomeRel = "org.aspectj.ajdt.core/src/" | |||
javaCompilerHomeRel = "org.eclipse.jdt.core/compiler/" | |||
compilerHomeRel = ajCompilerHomeRel | |||
parserHomeRel = ajCompilerHomeRel + "org/aspectj/ajdt/internal/compiler/parser" | |||
parserInfoFileRel = javaCompilerHomeRel + "org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java" | |||
symbolsHomeRel = javaCompilerHomeRel + "org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java" | |||
# symbolsHomeRel = "org/aspectj/ajdt/compiler/IAjTerminalSymbols.java" | |||
parserClass = "AjParser.java" | |||
grammarFileRel = javaCompilerHomeRel + "../grammar/java_1_4.g" | |||
import os | |||
from os import path | |||
import re | |||
def readFile(name, mode=''): | |||
f = open(name, 'r'+mode) | |||
text = f.read() | |||
f.close() | |||
return text | |||
def writeFile(name, text, mode=''): | |||
f = open(name, 'w'+mode) | |||
f.write(text) | |||
f.close() | |||
compilerHome = path.join(eclipseWorkspace, compilerHomeRel) | |||
parserHome = path.join(eclipseWorkspace, parserHomeRel) | |||
symbolFile = path.join(eclipseWorkspace, symbolsHomeRel) | |||
parserInfoFile = path.join(eclipseWorkspace, parserInfoFileRel) | |||
parserFile = path.join(parserHome, parserClass) | |||
parserText = readFile(parserFile) | |||
if grammarFileRel == None: | |||
r = re.compile(r"public final static void grammar\(\){.*(--main.*\$end\n)-- need", re.DOTALL) | |||
match = r.search(parserText) | |||
grammar = match.group(1) | |||
else: | |||
grammar = readFile(path.join(eclipseWorkspace, grammarFileRel), 'b') | |||
#print grammar | |||
grammarFile = path.join(workingDir, "java.g") | |||
writeFile(grammarFile, grammar, 'b') | |||
os.chdir(workingDir) | |||
os.system("%s java.g" % jikespg) | |||
#3.1 Copy the contents of the JavaAction.java file into the consumeRule(int) method of the org.eclipse.jdt.internal.compiler.parser.Parser class. | |||
newConsumeRule = readFile(path.join(workingDir, "JavaAction.java")) | |||
#print newConsumeRule | |||
r = re.compile(r"(// This method is part of an automatic generation : do NOT edit-modify\W+protected void consumeRule\(int act\) {.*)protected void consumeSimpleAssertStatement\(\) {", re.DOTALL) | |||
match = r.search(parserText) | |||
parserText = parserText.replace(match.group(1), newConsumeRule) | |||
#3.2 The definition of the Parser needs to be updated with two tables from javadcl.java. Those are rhs[] and name[]. | |||
newTables = readFile(path.join(workingDir, "javadcl.java")) | |||
r = re.compile(r"(public final static byte rhs\[\] = \{[^}]*\};)", re.DOTALL) | |||
rhsTable = r.search(newTables).group(0) | |||
parserText = parserText.replace(r.search(parserText).group(0), rhsTable) | |||
r = re.compile(r"(public final static String name\[\] = \{[^}]*\}[^}]*\};)", re.DOTALL) | |||
nameTable = r.search(newTables).group(0) | |||
nameTable = nameTable.replace("\"$eof\"", "UNEXPECTED_EOF") | |||
nameTable = nameTable.replace("$error", "Invalid Character") | |||
parserText = parserText.replace(r.search(parserText).group(0), nameTable) | |||
#we're done w/ Parser.java | |||
writeFile(parserFile, parserText) | |||
#3.3 The class org.eclipse.jdt.internal.compiler.parser.ParserBasicInformation needs to be updated with the content of the file javadef.java. | |||
defs = readFile(path.join(workingDir, "javadef.java")) | |||
r = re.compile(r"(public final static int[^;]*;)", re.DOTALL) | |||
syms = r.search(defs).group(0) | |||
#print syms | |||
text = readFile(parserInfoFile) | |||
text = text.replace(r.search(text).group(0), syms) | |||
writeFile(parserInfoFile, text) | |||
#3.4 This is the contents of the class org.eclipse.jdt.internal.compiler.parser.TerminalSymbols. | |||
defs = readFile(path.join(workingDir, "javasym.java")) | |||
r = re.compile(r"(int\s+TokenNameIdentifier[^;]*;)", re.DOTALL) | |||
syms = r.search(defs).group(0) | |||
syms = syms.replace("$eof", "EOF") | |||
syms = syms.replace("$error", "ERROR") | |||
print syms | |||
text = readFile(symbolFile) | |||
text = text.replace(r.search(text).group(0), syms) | |||
writeFile(symbolFile, text) | |||
#3.5 The last step is to update the resource files: | |||
os.chdir(workingDir) | |||
os.system("%s javadcl.java" % makersc) | |||
for i in range(1,6): | |||
name = "parser%d.rsc" % i | |||
print "moving", name | |||
t = readFile(path.join(workingDir, name), 'b') | |||
writeFile(path.join(parserHome, name), t, 'b') |