You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ma...@apache.org on 2006/07/25 00:24:18 UTC
svn commit: r425235 [8/11] - in
/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins: ./
maven-adf-archetype/
maven-adf-archetype/src/main/resources/archetype-resources/
maven-adf-archetype/src/main/resources/archetype-resources/src/main/ja...
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserTest15.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserTest15.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserTest15.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserTest15.java Mon Jul 24 17:24:16 2006
@@ -1,101 +1,101 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-
-public class JSParserTest15
-{
- protected InputStream _in;
-
- public JSParserTest15(InputStream in)
- {
- _in = in;
- }
-
- public void start()
- {
- // create an instance of the parser
- JSParser15 jsParser = new JSParser15(_in);
-
- Token t;
-
- try
- {
- for (t = jsParser.Program(); t != null; t = t.next)
- {
- System.out
- .println(t.kind + "\t" + JSParser15.tokenImage[t.kind] + "\t" +
- t.image + "\t" +
- ((AnnotatedToken) t).getAnnotationKind() +
- "\t" + ((AnnotatedToken) t).canRemove());
- printSpecialTokens((AnnotatedToken) t);
- }
-
- // jsParser.getRootNode().dump("p");
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- }
- }
-
- public void printSpecialTokens(AnnotatedToken token)
- {
- AnnotatedToken specialToken = token.getSpecialToken();
-
- while (specialToken != null)
- {
- System.out.println(specialToken.image);
- specialToken = specialToken.getSpecialToken();
- }
- }
-
- public static void main(String[] args)
- {
- if (args.length == 0)
- {
- System.out.println("Usage: JSParserTest15 <JS File>");
-
- return;
- }
-
- File jsFile = new File(args[0]);
- FileInputStream inFileStream;
-
- try
- {
- inFileStream = new FileInputStream(jsFile);
-
- JSParserTest15 jsParserTest = new JSParserTest15(inFileStream);
- jsParserTest.start();
- inFileStream.close();
- }
- catch (FileNotFoundException e)
- {
- System.out.println("FileNotFound");
- }
- catch (IOException e)
- {
- System.out.println("FileIO");
- }
- }
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+public class JSParserTest15
+{
+ protected InputStream _in;
+
+ public JSParserTest15(InputStream in)
+ {
+ _in = in;
+ }
+
+ public void start()
+ {
+ // create an instance of the parser
+ JSParser15 jsParser = new JSParser15(_in);
+
+ Token t;
+
+ try
+ {
+ for (t = jsParser.Program(); t != null; t = t.next)
+ {
+ System.out
+ .println(t.kind + "\t" + JSParser15.tokenImage[t.kind] + "\t" +
+ t.image + "\t" +
+ ((AnnotatedToken) t).getAnnotationKind() +
+ "\t" + ((AnnotatedToken) t).canRemove());
+ printSpecialTokens((AnnotatedToken) t);
+ }
+
+ // jsParser.getRootNode().dump("p");
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void printSpecialTokens(AnnotatedToken token)
+ {
+ AnnotatedToken specialToken = token.getSpecialToken();
+
+ while (specialToken != null)
+ {
+ System.out.println(specialToken.image);
+ specialToken = specialToken.getSpecialToken();
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ if (args.length == 0)
+ {
+ System.out.println("Usage: JSParserTest15 <JS File>");
+
+ return;
+ }
+
+ File jsFile = new File(args[0]);
+ FileInputStream inFileStream;
+
+ try
+ {
+ inFileStream = new FileInputStream(jsFile);
+
+ JSParserTest15 jsParserTest = new JSParserTest15(inFileStream);
+ jsParserTest.start();
+ inFileStream.close();
+ }
+ catch (FileNotFoundException e)
+ {
+ System.out.println("FileNotFound");
+ }
+ catch (IOException e)
+ {
+ System.out.println("FileIO");
+ }
+ }
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserTest15.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserUtils.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserUtils.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserUtils.java Mon Jul 24 17:24:16 2006
@@ -1,378 +1,378 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-
-public class JSParserUtils
-{
- public JSParserUtils()
- {
- }
-
- /**
- *
- * @param funcToken
- * @param bodyStart
- * @param bodyEnd
- */
- public static void tagEvalCalls(Token funcToken, Token bodyStart,
- Token bodyEnd)
- {
- boolean hasEval = false;
- Token token = bodyStart;
-
- while (token != bodyEnd)
- {
- if ((token.kind == JSParser15Constants.IDENTIFIER) &&
- token.image.equals("eval") && (token.next != null) &&
- (token.next.kind == JSParser15Constants.LPAREN))
- {
- hasEval = true;
-
- break;
- }
-
- token = token.next;
- }
-
- ((AnnotatedToken) funcToken).setFunctionUsesEval(hasEval);
- }
-
- /**
- *
- * @param contextStack
- * @param token
- */
- public static void pushToken(ProgramContextStack contextStack,
- AnnotatedToken token)
- {
- ProgramContext context = (ProgramContext) contextStack.peek();
- context.addToken(token.image, token);
- }
-
- /**
- *
- * @param contextStack
- * @param v
- */
- public static void pushTokens(ProgramContextStack contextStack, Vector v)
- {
- for (Enumeration item = v.elements(); item.hasMoreElements(); )
- {
- AnnotatedToken t = (AnnotatedToken) item.nextElement();
- pushToken(contextStack, t);
- }
- }
-
- /**
- *
- * @param objToken
- * @param end
- */
- public static void tagObjectIdentifier(Token objToken, Token end)
- {
- Token t = objToken.next;
- Token suffixToken = null;
-
- while (t != end)
- {
- if (t.kind == JSParser15Constants.DOT)
- {
- annotateToken(objToken, AnnotationConstants.OBJECT_IDENTIFIER,
- null, -1);
- suffixToken = t.next;
-
- if ((suffixToken != null) &&
- (suffixToken.kind == JSParser15Constants.IDENTIFIER))
- {
- annotateToken(suffixToken,
- AnnotationConstants.OBJECT_FIELD_IDENTIFIER, null,
- -1);
- }
- }
-
- if ((t.kind == JSParser15Constants.LPAREN) && (suffixToken != null))
- {
- annotateToken(suffixToken,
- AnnotationConstants.OBJECT_METHOD_IDENTIFIER, null,
- -1);
- }
-
- t = t.next;
- }
- }
-
- /**
- *
- * @param contextStack
- * @param start
- * @param end
- */
- public static void tagMethodInvocation(ProgramContextStack contextStack,
- AnnotatedToken start,
- AnnotatedToken end)
- {
- if (tagAssertProfilerCalls(contextStack, start, end))
- {
- return;
- }
-
- tagLoggerCalls(contextStack, start, end);
- }
-
- /**
- *
- * @param contextStack
- * @param start
- * @param end
- * @return
- */
- private static boolean tagAssertProfilerCalls(ProgramContextStack contextStack,
- AnnotatedToken start,
- AnnotatedToken end)
- {
- AnnotatedToken token = start;
- boolean isSpecialType = false;
- boolean isRemovable = false;
-
- while (token != end)
- {
- // This checks for:
- // "Profiler.xxx=...;"
- // or "foo.<profiler method>;" where foo is a var of type Profiler
- AnnotatedToken objToken = contextStack.getToken(token.image);
-
- if ((token.isSpecialClassType() ||
- ((objToken != null) && objToken.isSpecialObjectType())) &&
- (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
- {
- isSpecialType = true;
- }
-
- if (isSpecialType &&
- (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
- {
- isRemovable = true;
-
- break;
- }
-
- token = token.getNext();
- }
-
- if (isRemovable)
- {
- token = start;
-
- while (token != end)
- {
- token.setRemovable(true);
- token = token.getNext();
- }
-
- if (token.kind == JSParser15Constants.SEMICOLON)
- {
- token.setRemovable(true);
- }
- }
-
- return isRemovable;
- }
-
- /**
- *
- * @param contextStack
- * @param start
- * @param end
- * @return
- */
- private static boolean tagLoggerCalls(ProgramContextStack contextStack,
- AnnotatedToken start,
- AnnotatedToken end)
- {
- AnnotatedToken token = start;
- boolean isSpecialType = false;
- boolean isLOGGER = false;
- boolean isRemovable = false;
-
- while (token != end)
- {
- // This checks for:
- // "Logger.LOGGER.<static method>"
- if ((token.isSpecialClassType()) &&
- (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
- {
- isSpecialType = true;
- }
-
- if (isSpecialType &&
- (token.getKind() == AnnotationConstants.OBJECT_FIELD_IDENTIFIER) &&
- token.image.equals("LOGGER"))
- {
- isLOGGER = true;
- }
-
- if (isLOGGER &&
- (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
- {
- isRemovable = true;
-
- break;
- }
-
- token = token.getNext();
- }
-
- if (isRemovable)
- {
- token = start;
-
- while (token != end)
- {
- token.setRemovable(true);
- token = token.getNext();
- }
-
- if (token.kind == JSParser15Constants.SEMICOLON)
- {
- token.setRemovable(true);
- }
- }
-
- return isRemovable;
- }
-
- /**
- *
- * @param contextStack
- * @param lhs
- * @param op
- * @param rhs
- * @param end
- */
- public static void tagAssignmentExpression(ProgramContextStack contextStack,
- AnnotatedToken varToken,
- AnnotatedToken lhs,
- AnnotatedToken op,
- AnnotatedToken rhs,
- AnnotatedToken end)
- {
- AnnotatedToken token = (varToken != null)? varToken: lhs;
- boolean isSpecialType = false;
- boolean isRemovable = false;
- ProgramContext context = (ProgramContext) contextStack.peek();
-
- if (rhs.kind != JSParser15Constants.IDENTIFIER)
- {
- return;
- }
-
- while (token != end)
- {
- // This checks for:
- // "var foo = Profiler.xxx=...;"
- // or "var bar = foo.<profiler method>;"
- AnnotatedToken objToken = contextStack.getToken(token.image);
-
- if ((token.isSpecialClassType() ||
- ((objToken != null) && objToken.isSpecialObjectType())) &&
- (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
- {
- isSpecialType = true;
- }
-
- if (isSpecialType &&
- (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
- {
- isRemovable = true;
-
- break;
- }
-
- token = token.getNext();
- }
-
- if (isRemovable)
- {
- token = (varToken != null)? varToken: lhs;
-
- AnnotatedToken prevToken = lhs;
-
- while (token != end)
- {
- token.setRemovable(true);
-
- if (token.getNext().isSpecialClassType() &&
- (token.kind == JSParser15Constants.ASSIGN))
- {
- // This saves the LHS var name "foo" to be removed later. It also assigns the LHS type
- // "var foo = Profiler.xxx=...;"
- prevToken.setType(token.next.image);
- context.addToken(prevToken.image, prevToken);
- }
-
- prevToken = token;
- token = token.getNext();
- }
- }
- }
-
- /**
- *
- * @param t
- * @param annotationId
- * @param annotationObject
- * @param wsSensitive
- */
- public static void annotateToken(Token t, int annotationId,
- Object annotationObject,
- int wsSensitive)
- {
- AnnotatedToken annToken = (AnnotatedToken) t;
- annToken.setAnnotationKind(annotationId);
-
- if (annotationObject != null)
- {
- annToken.setAnnotationObject(annotationObject);
- }
-
- if (wsSensitive >= 0)
- {
- annToken.setWSSensitive(wsSensitive);
- }
- }
-
- /**
- *
- * @param v
- * @param annotationId
- * @param annotationObject
- * @param wsSensitive
- */
- public static void annotateTokens(Vector v, int annotationId,
- Object annotationObject,
- int wsSensitive)
- {
- for (Enumeration item = v.elements(); item.hasMoreElements(); )
- {
- Token t = (Token) item.nextElement();
- annotateToken(t, annotationId, annotationObject, wsSensitive);
- }
- }
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+
+public class JSParserUtils
+{
+ public JSParserUtils()
+ {
+ }
+
+ /**
+ *
+ * @param funcToken
+ * @param bodyStart
+ * @param bodyEnd
+ */
+ public static void tagEvalCalls(Token funcToken, Token bodyStart,
+ Token bodyEnd)
+ {
+ boolean hasEval = false;
+ Token token = bodyStart;
+
+ while (token != bodyEnd)
+ {
+ if ((token.kind == JSParser15Constants.IDENTIFIER) &&
+ token.image.equals("eval") && (token.next != null) &&
+ (token.next.kind == JSParser15Constants.LPAREN))
+ {
+ hasEval = true;
+
+ break;
+ }
+
+ token = token.next;
+ }
+
+ ((AnnotatedToken) funcToken).setFunctionUsesEval(hasEval);
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param token
+ */
+ public static void pushToken(ProgramContextStack contextStack,
+ AnnotatedToken token)
+ {
+ ProgramContext context = (ProgramContext) contextStack.peek();
+ context.addToken(token.image, token);
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param v
+ */
+ public static void pushTokens(ProgramContextStack contextStack, Vector v)
+ {
+ for (Enumeration item = v.elements(); item.hasMoreElements(); )
+ {
+ AnnotatedToken t = (AnnotatedToken) item.nextElement();
+ pushToken(contextStack, t);
+ }
+ }
+
+ /**
+ *
+ * @param objToken
+ * @param end
+ */
+ public static void tagObjectIdentifier(Token objToken, Token end)
+ {
+ Token t = objToken.next;
+ Token suffixToken = null;
+
+ while (t != end)
+ {
+ if (t.kind == JSParser15Constants.DOT)
+ {
+ annotateToken(objToken, AnnotationConstants.OBJECT_IDENTIFIER,
+ null, -1);
+ suffixToken = t.next;
+
+ if ((suffixToken != null) &&
+ (suffixToken.kind == JSParser15Constants.IDENTIFIER))
+ {
+ annotateToken(suffixToken,
+ AnnotationConstants.OBJECT_FIELD_IDENTIFIER, null,
+ -1);
+ }
+ }
+
+ if ((t.kind == JSParser15Constants.LPAREN) && (suffixToken != null))
+ {
+ annotateToken(suffixToken,
+ AnnotationConstants.OBJECT_METHOD_IDENTIFIER, null,
+ -1);
+ }
+
+ t = t.next;
+ }
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param start
+ * @param end
+ */
+ public static void tagMethodInvocation(ProgramContextStack contextStack,
+ AnnotatedToken start,
+ AnnotatedToken end)
+ {
+ if (tagAssertProfilerCalls(contextStack, start, end))
+ {
+ return;
+ }
+
+ tagLoggerCalls(contextStack, start, end);
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param start
+ * @param end
+ * @return
+ */
+ private static boolean tagAssertProfilerCalls(ProgramContextStack contextStack,
+ AnnotatedToken start,
+ AnnotatedToken end)
+ {
+ AnnotatedToken token = start;
+ boolean isSpecialType = false;
+ boolean isRemovable = false;
+
+ while (token != end)
+ {
+ // This checks for:
+ // "Profiler.xxx=...;"
+ // or "foo.<profiler method>;" where foo is a var of type Profiler
+ AnnotatedToken objToken = contextStack.getToken(token.image);
+
+ if ((token.isSpecialClassType() ||
+ ((objToken != null) && objToken.isSpecialObjectType())) &&
+ (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
+ {
+ isSpecialType = true;
+ }
+
+ if (isSpecialType &&
+ (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
+ {
+ isRemovable = true;
+
+ break;
+ }
+
+ token = token.getNext();
+ }
+
+ if (isRemovable)
+ {
+ token = start;
+
+ while (token != end)
+ {
+ token.setRemovable(true);
+ token = token.getNext();
+ }
+
+ if (token.kind == JSParser15Constants.SEMICOLON)
+ {
+ token.setRemovable(true);
+ }
+ }
+
+ return isRemovable;
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param start
+ * @param end
+ * @return
+ */
+ private static boolean tagLoggerCalls(ProgramContextStack contextStack,
+ AnnotatedToken start,
+ AnnotatedToken end)
+ {
+ AnnotatedToken token = start;
+ boolean isSpecialType = false;
+ boolean isLOGGER = false;
+ boolean isRemovable = false;
+
+ while (token != end)
+ {
+ // This checks for:
+ // "Logger.LOGGER.<static method>"
+ if ((token.isSpecialClassType()) &&
+ (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
+ {
+ isSpecialType = true;
+ }
+
+ if (isSpecialType &&
+ (token.getKind() == AnnotationConstants.OBJECT_FIELD_IDENTIFIER) &&
+ token.image.equals("LOGGER"))
+ {
+ isLOGGER = true;
+ }
+
+ if (isLOGGER &&
+ (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
+ {
+ isRemovable = true;
+
+ break;
+ }
+
+ token = token.getNext();
+ }
+
+ if (isRemovable)
+ {
+ token = start;
+
+ while (token != end)
+ {
+ token.setRemovable(true);
+ token = token.getNext();
+ }
+
+ if (token.kind == JSParser15Constants.SEMICOLON)
+ {
+ token.setRemovable(true);
+ }
+ }
+
+ return isRemovable;
+ }
+
+ /**
+ *
+ * @param contextStack
+ * @param lhs
+ * @param op
+ * @param rhs
+ * @param end
+ */
+ public static void tagAssignmentExpression(ProgramContextStack contextStack,
+ AnnotatedToken varToken,
+ AnnotatedToken lhs,
+ AnnotatedToken op,
+ AnnotatedToken rhs,
+ AnnotatedToken end)
+ {
+ AnnotatedToken token = (varToken != null)? varToken: lhs;
+ boolean isSpecialType = false;
+ boolean isRemovable = false;
+ ProgramContext context = (ProgramContext) contextStack.peek();
+
+ if (rhs.kind != JSParser15Constants.IDENTIFIER)
+ {
+ return;
+ }
+
+ while (token != end)
+ {
+ // This checks for:
+ // "var foo = Profiler.xxx=...;"
+ // or "var bar = foo.<profiler method>;"
+ AnnotatedToken objToken = contextStack.getToken(token.image);
+
+ if ((token.isSpecialClassType() ||
+ ((objToken != null) && objToken.isSpecialObjectType())) &&
+ (token.getKind() == AnnotationConstants.OBJECT_IDENTIFIER))
+ {
+ isSpecialType = true;
+ }
+
+ if (isSpecialType &&
+ (token.getKind() == AnnotationConstants.OBJECT_METHOD_IDENTIFIER))
+ {
+ isRemovable = true;
+
+ break;
+ }
+
+ token = token.getNext();
+ }
+
+ if (isRemovable)
+ {
+ token = (varToken != null)? varToken: lhs;
+
+ AnnotatedToken prevToken = lhs;
+
+ while (token != end)
+ {
+ token.setRemovable(true);
+
+ if (token.getNext().isSpecialClassType() &&
+ (token.kind == JSParser15Constants.ASSIGN))
+ {
+ // This saves the LHS var name "foo" to be removed later. It also assigns the LHS type
+ // "var foo = Profiler.xxx=...;"
+ prevToken.setType(token.next.image);
+ context.addToken(prevToken.image, prevToken);
+ }
+
+ prevToken = token;
+ token = token.getNext();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param t
+ * @param annotationId
+ * @param annotationObject
+ * @param wsSensitive
+ */
+ public static void annotateToken(Token t, int annotationId,
+ Object annotationObject,
+ int wsSensitive)
+ {
+ AnnotatedToken annToken = (AnnotatedToken) t;
+ annToken.setAnnotationKind(annotationId);
+
+ if (annotationObject != null)
+ {
+ annToken.setAnnotationObject(annotationObject);
+ }
+
+ if (wsSensitive >= 0)
+ {
+ annToken.setWSSensitive(wsSensitive);
+ }
+ }
+
+ /**
+ *
+ * @param v
+ * @param annotationId
+ * @param annotationObject
+ * @param wsSensitive
+ */
+ public static void annotateTokens(Vector v, int annotationId,
+ Object annotationObject,
+ int wsSensitive)
+ {
+ for (Enumeration item = v.elements(); item.hasMoreElements(); )
+ {
+ Token t = (Token) item.nextElement();
+ annotateToken(t, annotationId, annotationObject, wsSensitive);
+ }
+ }
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/JSParserUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/NameGen.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/NameGen.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/NameGen.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/NameGen.java Mon Jul 24 17:24:16 2006
@@ -1,30 +1,30 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-public class NameGen
-{
- private int _nextId = 0;
-
- public NameGen()
- {
- }
-
- public String getName()
- {
- return "x" + _nextId++;
- }
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+public class NameGen
+{
+ private int _nextId = 0;
+
+ public NameGen()
+ {
+ }
+
+ public String getName()
+ {
+ return "x" + _nextId++;
+ }
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/NameGen.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContext.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContext.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContext.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContext.java Mon Jul 24 17:24:16 2006
@@ -1,90 +1,90 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.HashMap;
-
-//~--- classes ----------------------------------------------------------------
-
-public class ProgramContext
-{
-
- // Table of symbol name, AnnotatedToken
- protected HashMap _symbolTable = new HashMap();
- protected String _name;
- protected NameGen _nameGen;
-
- //~--- constructors -------------------------------------------------------
-
- public ProgramContext(String name)
- {
- this(name, new NameGen());
- }
-
- public ProgramContext(String name, NameGen nameGen)
- {
- _name = name;
- _nameGen = nameGen;
- }
-
- //~--- methods ------------------------------------------------------------
-
- public void addToken(String name, AnnotatedToken token)
- {
- _symbolTable.put(name, token);
- }
-
- public String generateSymbolName()
- {
- return _nameGen.getName();
- }
-
- //~--- get methods --------------------------------------------------------
-
- public String getName()
- {
- return _name;
- }
-
- public NameGen getNameGen()
- {
- return _nameGen;
- }
-
- public AnnotatedToken getToken(String key)
- {
- return (AnnotatedToken) _symbolTable.get(key);
- }
-
- //~--- set methods --------------------------------------------------------
-
- public void setName(String name)
- {
- _name = name;
- }
-
- public void setNameGen(NameGen nameGen)
- {
- _nameGen = nameGen;
- }
-}
-
-
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.util.HashMap;
+
+//~--- classes ----------------------------------------------------------------
+
+public class ProgramContext
+{
+
+ // Table of symbol name, AnnotatedToken
+ protected HashMap _symbolTable = new HashMap();
+ protected String _name;
+ protected NameGen _nameGen;
+
+ //~--- constructors -------------------------------------------------------
+
+ public ProgramContext(String name)
+ {
+ this(name, new NameGen());
+ }
+
+ public ProgramContext(String name, NameGen nameGen)
+ {
+ _name = name;
+ _nameGen = nameGen;
+ }
+
+ //~--- methods ------------------------------------------------------------
+
+ public void addToken(String name, AnnotatedToken token)
+ {
+ _symbolTable.put(name, token);
+ }
+
+ public String generateSymbolName()
+ {
+ return _nameGen.getName();
+ }
+
+ //~--- get methods --------------------------------------------------------
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public NameGen getNameGen()
+ {
+ return _nameGen;
+ }
+
+ public AnnotatedToken getToken(String key)
+ {
+ return (AnnotatedToken) _symbolTable.get(key);
+ }
+
+ //~--- set methods --------------------------------------------------------
+
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public void setNameGen(NameGen nameGen)
+ {
+ _nameGen = nameGen;
+ }
+}
+
+
//~ Formatted by Jindent --- http://www.jindent.com
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContextStack.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContextStack.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContextStack.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContextStack.java Mon Jul 24 17:24:16 2006
@@ -1,81 +1,81 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-//~--- JDK imports ------------------------------------------------------------
-
-import java.util.Stack;
-
-//~--- classes ----------------------------------------------------------------
-
-public class ProgramContextStack extends Stack {
- public ProgramContextStack() {}
-
- //~--- methods ------------------------------------------------------------
-
- public ProgramContext popContext() {
- return ((ProgramContext) pop());
- }
-
- public void pushContext(ProgramContext context) {
- push(context);
- }
-
- //~--- get methods --------------------------------------------------------
-
- public AnnotatedToken getToken(String name) {
- AnnotatedToken token = null;
-
- for (int i = size() - 1; i >= 0; i--) {
- ProgramContext context = (ProgramContext) get(i);
-
- if (null != (token = context.getToken(name))) {
- break;
- }
- }
-
- return token;
- }
-
- /**
- *
- * @param name
- * @param depth
- * @return
- */
- public AnnotatedToken getToken(String name, int depth) {
- int end;
-
- end = size() - depth;
- end = Math.max(end, 0);
-
- AnnotatedToken token = null;
-
- for (int i = size() - 1; i >= end; i--) {
- ProgramContext context = (ProgramContext) get(i);
-
- if (null != (token = context.getToken(name))) {
- break;
- }
- }
-
- return token;
- }
-}
-
-
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import java.util.Stack;
+
+//~--- classes ----------------------------------------------------------------
+
+public class ProgramContextStack extends Stack {
+ public ProgramContextStack() {}
+
+ //~--- methods ------------------------------------------------------------
+
+ public ProgramContext popContext() {
+ return ((ProgramContext) pop());
+ }
+
+ public void pushContext(ProgramContext context) {
+ push(context);
+ }
+
+ //~--- get methods --------------------------------------------------------
+
+ public AnnotatedToken getToken(String name) {
+ AnnotatedToken token = null;
+
+ for (int i = size() - 1; i >= 0; i--) {
+ ProgramContext context = (ProgramContext) get(i);
+
+ if (null != (token = context.getToken(name))) {
+ break;
+ }
+ }
+
+ return token;
+ }
+
+ /**
+ *
+ * @param name
+ * @param depth
+ * @return
+ */
+ public AnnotatedToken getToken(String name, int depth) {
+ int end;
+
+ end = size() - depth;
+ end = Math.max(end, 0);
+
+ AnnotatedToken token = null;
+
+ for (int i = size() - 1; i >= end; i--) {
+ ProgramContext context = (ProgramContext) get(i);
+
+ if (null != (token = context.getToken(name))) {
+ break;
+ }
+ }
+
+ return token;
+ }
+}
+
+
//~ Formatted by Jindent --- http://www.jindent.com
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/ProgramContextStack.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/Token.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/Token.java?rev=425235&r1=425234&r2=425235&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/Token.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/Token.java Mon Jul 24 17:24:16 2006
@@ -1,96 +1,96 @@
-/*
-* Copyright 2006 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
-package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
-
-/**
- * Describes the input token stream.
- */
-
-public class Token {
-
- /**
- * An integer that describes the kind of this token. This numbering
- * system is determined by JavaCCParser, and a table of these numbers is
- * stored in the file ...Constants.java.
- */
- public int kind;
-
- /**
- * beginLine and beginColumn describe the position of the first character
- * of this token; endLine and endColumn describe the position of the
- * last character of this token.
- */
- public int beginLine, beginColumn, endLine, endColumn;
-
- /**
- * The string image of the token.
- */
- public String image;
-
- /**
- * A reference to the next regular (non-special) token from the input
- * stream. If this is the last token from the input stream, or if the
- * token manager has not read tokens beyond this one, this field is
- * set to null. This is true only if this token is also a regular
- * token. Otherwise, see below for a description of the contents of
- * this field.
- */
- public Token next;
-
- /**
- * This field is used to access special tokens that occur prior to this
- * token, but after the immediately preceding regular (non-special) token.
- * If there are no such special tokens, this field is set to null.
- * When there are more than one such special token, this field refers
- * to the last of these special tokens, which in turn refers to the next
- * previous special token through its specialToken field, and so on
- * until the first special token (whose specialToken field is null).
- * The next fields of special tokens refer to other special tokens that
- * immediately follow it (without an intervening regular token). If there
- * is no such token, this field is null.
- */
- public Token specialToken;
-
- /**
- * Returns the image.
- */
- public String toString()
- {
- return image;
- }
-
- /**
- * Returns a new Token object, by default. However, if you want, you
- * can create and return subclass objects based on the value of ofKind.
- * Simply add the cases to the switch for all those special cases.
- * For example, if you have a subclass of Token called IDToken that
- * you want to create if ofKind is ID, simlpy add something like :
- *
- * case MyParserConstants.ID : return new IDToken();
- *
- * to the following switch statement. Then you can cast matchedToken
- * variable to the appropriate type and use it in your lexical actions.
- */
- public static final Token newToken(int ofKind)
- {
- switch(ofKind)
- {
- default : return new AnnotatedToken();
- }
- }
-
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package org.apache.myfaces.trinidadbuild.plugin.javascript.obfuscator.javascript15parser;
+
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new AnnotatedToken();
+ }
+ }
+
}
Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/plugins/maven-javascript-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/javascript/obfuscator/javascript15parser/Token.java
------------------------------------------------------------------------------
svn:eol-style = native