Fixit on missing svn props.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1154 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JUnaryOperation.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JUnaryOperation.java
index 38770ea..382b3b3 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JUnaryOperation.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JUnaryOperation.java
@@ -1,55 +1,55 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.jjs.ast;
-
-import com.google.gwt.dev.jjs.SourceInfo;
-
-/**
- * Java prefix or postfix operation expression.
- */
-public abstract class JUnaryOperation extends JExpression {
-
- private JExpression arg;
- private final JUnaryOperator op;
-
- public JUnaryOperation(JProgram program, SourceInfo info,
- JUnaryOperator op, JExpression arg) {
- super(program, info);
- this.op = op;
- this.arg = arg;
- }
-
- public JExpression getArg() {
- return arg;
- }
-
- public JUnaryOperator getOp() {
- return op;
- }
-
- public JType getType() {
- // Unary operators don't change the type of their expression
- return arg.getType();
- }
-
- public boolean hasSideEffects() {
- return getOp().isModifying() || arg.hasSideEffects();
- }
-
- public void traverse(JVisitor visitor, Context ctx) {
- arg = visitor.accept(arg);
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.jjs.ast;
+
+import com.google.gwt.dev.jjs.SourceInfo;
+
+/**
+ * Java prefix or postfix operation expression.
+ */
+public abstract class JUnaryOperation extends JExpression {
+
+ private JExpression arg;
+ private final JUnaryOperator op;
+
+ public JUnaryOperation(JProgram program, SourceInfo info,
+ JUnaryOperator op, JExpression arg) {
+ super(program, info);
+ this.op = op;
+ this.arg = arg;
+ }
+
+ public JExpression getArg() {
+ return arg;
+ }
+
+ public JUnaryOperator getOp() {
+ return op;
+ }
+
+ public JType getType() {
+ // Unary operators don't change the type of their expression
+ return arg.getType();
+ }
+
+ public boolean hasSideEffects() {
+ return getOp().isModifying() || arg.hasSideEffects();
+ }
+
+ public void traverse(JVisitor visitor, Context ctx) {
+ arg = visitor.accept(arg);
+ }
+}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JValueLiteral.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JValueLiteral.java
index 0bef745..30a055d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JValueLiteral.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JValueLiteral.java
@@ -1,29 +1,29 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.jjs.ast;
-
-/**
- * Base class for any Java literal expression.
- */
-public abstract class JValueLiteral extends JLiteral {
-
- public JValueLiteral(JProgram program) {
- super(program);
- }
-
- public abstract Object getValueObj();
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.jjs.ast;
+
+/**
+ * Base class for any Java literal expression.
+ */
+public abstract class JValueLiteral extends JLiteral {
+
+ public JValueLiteral(JProgram program) {
+ super(program);
+ }
+
+ public abstract Object getValueObj();
+
+}
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/AssertionRemover.java b/dev/core/src/com/google/gwt/dev/jjs/impl/AssertionRemover.java
index f030ea0..fd13b6d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/AssertionRemover.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/AssertionRemover.java
@@ -1,63 +1,63 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.jjs.impl;
-
-import com.google.gwt.dev.jjs.ast.Context;
-import com.google.gwt.dev.jjs.ast.JAssertStatement;
-import com.google.gwt.dev.jjs.ast.JBlock;
-import com.google.gwt.dev.jjs.ast.JModVisitor;
-import com.google.gwt.dev.jjs.ast.JProgram;
-import com.google.gwt.dev.jjs.ast.JStatement;
-
-/**
- * Removes all assertion statements from the AST.
- */
-public class AssertionRemover {
-
- /**
- * Removes all asserts.
- */
- public class AssertVisitor extends JModVisitor {
-
- public void endVisit(JAssertStatement x, Context ctx) {
- removeMe(x, ctx);
- }
-
- private void removeMe(JStatement stmt, Context ctx) {
- if (ctx.canRemove()) {
- ctx.removeMe();
- } else {
- // empty block statement
- ctx.replaceMe(new JBlock(program, stmt.getSourceInfo()));
- }
- }
- }
-
- public static void exec(JProgram program) {
- new AssertionRemover(program).execImpl();
- }
-
- private final JProgram program;
-
- public AssertionRemover(JProgram program) {
- this.program = program;
- }
-
- private void execImpl() {
- AssertVisitor assertVisitor = new AssertVisitor();
- assertVisitor.accept(program);
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.jjs.impl;
+
+import com.google.gwt.dev.jjs.ast.Context;
+import com.google.gwt.dev.jjs.ast.JAssertStatement;
+import com.google.gwt.dev.jjs.ast.JBlock;
+import com.google.gwt.dev.jjs.ast.JModVisitor;
+import com.google.gwt.dev.jjs.ast.JProgram;
+import com.google.gwt.dev.jjs.ast.JStatement;
+
+/**
+ * Removes all assertion statements from the AST.
+ */
+public class AssertionRemover {
+
+ /**
+ * Removes all asserts.
+ */
+ public class AssertVisitor extends JModVisitor {
+
+ public void endVisit(JAssertStatement x, Context ctx) {
+ removeMe(x, ctx);
+ }
+
+ private void removeMe(JStatement stmt, Context ctx) {
+ if (ctx.canRemove()) {
+ ctx.removeMe();
+ } else {
+ // empty block statement
+ ctx.replaceMe(new JBlock(program, stmt.getSourceInfo()));
+ }
+ }
+ }
+
+ public static void exec(JProgram program) {
+ new AssertionRemover(program).execImpl();
+ }
+
+ private final JProgram program;
+
+ public AssertionRemover(JProgram program) {
+ this.program = program;
+ }
+
+ private void execImpl() {
+ AssertVisitor assertVisitor = new AssertVisitor();
+ assertVisitor.accept(program);
+ }
+}
diff --git a/dev/core/src/com/google/gwt/dev/js/JsNormalizer.java b/dev/core/src/com/google/gwt/dev/js/JsNormalizer.java
index 0a72672..0756a2b 100644
--- a/dev/core/src/com/google/gwt/dev/js/JsNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/js/JsNormalizer.java
@@ -1,122 +1,122 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.js;
-
-import com.google.gwt.dev.js.ast.JsBinaryOperation;
-import com.google.gwt.dev.js.ast.JsBinaryOperator;
-import com.google.gwt.dev.js.ast.JsContext;
-import com.google.gwt.dev.js.ast.JsExpression;
-import com.google.gwt.dev.js.ast.JsModVisitor;
-import com.google.gwt.dev.js.ast.JsPostfixOperation;
-import com.google.gwt.dev.js.ast.JsPrefixOperation;
-import com.google.gwt.dev.js.ast.JsProgram;
-import com.google.gwt.dev.js.ast.JsUnaryOperation;
-import com.google.gwt.dev.js.ast.JsUnaryOperator;
-
-/**
- * Fixes any semantic errors introduced by JS AST gen.
- *
- * <ul>
- * <li> Creating clinit calls can put comma expressions as lvalues; the
- * modifying operation must be moved inside the comma expression to the last
- * argument. </li>
- * </ul>
- */
-public class JsNormalizer {
-
- /**
- * Resolves any unresolved JsNameRefs.
- */
- private class JsNormalizing extends JsModVisitor {
-
- public void endVisit(JsBinaryOperation x, JsContext ctx) {
- maybeShuffleModifyingBinary(x, ctx);
- }
-
- public void endVisit(JsPostfixOperation x, JsContext ctx) {
- maybeShuffleModifyingUnary(x, ctx);
- }
-
- public void endVisit(JsPrefixOperation x, JsContext ctx) {
- maybeShuffleModifyingUnary(x, ctx);
- }
-
- /**
- * Due to the way clinits are constructed, you can end up with a comma
- * operation as the argument to a modifying operation, which is illegal.
- * Juggle things to put the operator inside of the comma expression.
- */
- private void maybeShuffleModifyingBinary(JsBinaryOperation x, JsContext ctx) {
- JsBinaryOperator myOp = x.getOperator();
- JsExpression lhs = x.getArg1();
- JsExpression rhs = x.getArg2();
-
- if (myOp.isAssignment() && (lhs instanceof JsBinaryOperation)) {
- // Find the rightmost comma operation
- JsBinaryOperation curLhs = (JsBinaryOperation) lhs;
- assert (curLhs.getOperator() == JsBinaryOperator.COMMA);
- while (curLhs.getArg2() instanceof JsBinaryOperation) {
- curLhs = (JsBinaryOperation) curLhs.getArg2();
- assert (curLhs.getOperator() == JsBinaryOperator.COMMA);
- }
- // curLhs is now the rightmost comma operation; slide our operation in
- x.setArg1(curLhs.getArg2());
- curLhs.setArg2(x);
- // replace myself with the comma expression
- ctx.replaceMe(lhs);
- }
- }
-
- /**
- * Due to the way clinits are constructed, you can end up with a comma
- * operation as the argument to a modifying operation, which is illegal.
- * Juggle things to put the operator inside of the comma expression.
- */
- private void maybeShuffleModifyingUnary(JsUnaryOperation x, JsContext ctx) {
- JsUnaryOperator myOp = x.getOperator();
- JsExpression arg = x.getArg();
- if (myOp.isModifying() && (arg instanceof JsBinaryOperation)) {
- // Find the rightmost comma operation
- JsBinaryOperation curArg = (JsBinaryOperation) arg;
- assert (curArg.getOperator() == JsBinaryOperator.COMMA);
- while (curArg.getArg2() instanceof JsBinaryOperation) {
- curArg = (JsBinaryOperation) curArg.getArg2();
- assert (curArg.getOperator() == JsBinaryOperator.COMMA);
- }
- // curArg is now the rightmost comma operation; slide our operation in
- x.setArg(curArg.getArg2());
- curArg.setArg2(x);
- // replace myself with the comma expression
- ctx.replaceMe(arg);
- }
- }
- }
-
- public static void exec(JsProgram program) {
- new JsNormalizer(program).execImpl();
- }
-
- private final JsProgram program;
-
- private JsNormalizer(JsProgram program) {
- this.program = program;
- }
-
- private void execImpl() {
- JsNormalizing normalizer = new JsNormalizing();
- normalizer.accept(program);
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.js;
+
+import com.google.gwt.dev.js.ast.JsBinaryOperation;
+import com.google.gwt.dev.js.ast.JsBinaryOperator;
+import com.google.gwt.dev.js.ast.JsContext;
+import com.google.gwt.dev.js.ast.JsExpression;
+import com.google.gwt.dev.js.ast.JsModVisitor;
+import com.google.gwt.dev.js.ast.JsPostfixOperation;
+import com.google.gwt.dev.js.ast.JsPrefixOperation;
+import com.google.gwt.dev.js.ast.JsProgram;
+import com.google.gwt.dev.js.ast.JsUnaryOperation;
+import com.google.gwt.dev.js.ast.JsUnaryOperator;
+
+/**
+ * Fixes any semantic errors introduced by JS AST gen.
+ *
+ * <ul>
+ * <li> Creating clinit calls can put comma expressions as lvalues; the
+ * modifying operation must be moved inside the comma expression to the last
+ * argument. </li>
+ * </ul>
+ */
+public class JsNormalizer {
+
+ /**
+ * Resolves any unresolved JsNameRefs.
+ */
+ private class JsNormalizing extends JsModVisitor {
+
+ public void endVisit(JsBinaryOperation x, JsContext ctx) {
+ maybeShuffleModifyingBinary(x, ctx);
+ }
+
+ public void endVisit(JsPostfixOperation x, JsContext ctx) {
+ maybeShuffleModifyingUnary(x, ctx);
+ }
+
+ public void endVisit(JsPrefixOperation x, JsContext ctx) {
+ maybeShuffleModifyingUnary(x, ctx);
+ }
+
+ /**
+ * Due to the way clinits are constructed, you can end up with a comma
+ * operation as the argument to a modifying operation, which is illegal.
+ * Juggle things to put the operator inside of the comma expression.
+ */
+ private void maybeShuffleModifyingBinary(JsBinaryOperation x, JsContext ctx) {
+ JsBinaryOperator myOp = x.getOperator();
+ JsExpression lhs = x.getArg1();
+ JsExpression rhs = x.getArg2();
+
+ if (myOp.isAssignment() && (lhs instanceof JsBinaryOperation)) {
+ // Find the rightmost comma operation
+ JsBinaryOperation curLhs = (JsBinaryOperation) lhs;
+ assert (curLhs.getOperator() == JsBinaryOperator.COMMA);
+ while (curLhs.getArg2() instanceof JsBinaryOperation) {
+ curLhs = (JsBinaryOperation) curLhs.getArg2();
+ assert (curLhs.getOperator() == JsBinaryOperator.COMMA);
+ }
+ // curLhs is now the rightmost comma operation; slide our operation in
+ x.setArg1(curLhs.getArg2());
+ curLhs.setArg2(x);
+ // replace myself with the comma expression
+ ctx.replaceMe(lhs);
+ }
+ }
+
+ /**
+ * Due to the way clinits are constructed, you can end up with a comma
+ * operation as the argument to a modifying operation, which is illegal.
+ * Juggle things to put the operator inside of the comma expression.
+ */
+ private void maybeShuffleModifyingUnary(JsUnaryOperation x, JsContext ctx) {
+ JsUnaryOperator myOp = x.getOperator();
+ JsExpression arg = x.getArg();
+ if (myOp.isModifying() && (arg instanceof JsBinaryOperation)) {
+ // Find the rightmost comma operation
+ JsBinaryOperation curArg = (JsBinaryOperation) arg;
+ assert (curArg.getOperator() == JsBinaryOperator.COMMA);
+ while (curArg.getArg2() instanceof JsBinaryOperation) {
+ curArg = (JsBinaryOperation) curArg.getArg2();
+ assert (curArg.getOperator() == JsBinaryOperator.COMMA);
+ }
+ // curArg is now the rightmost comma operation; slide our operation in
+ x.setArg(curArg.getArg2());
+ curArg.setArg2(x);
+ // replace myself with the comma expression
+ ctx.replaceMe(arg);
+ }
+ }
+ }
+
+ public static void exec(JsProgram program) {
+ new JsNormalizer(program).execImpl();
+ }
+
+ private final JsProgram program;
+
+ private JsNormalizer(JsProgram program) {
+ this.program = program;
+ }
+
+ private void execImpl() {
+ JsNormalizing normalizer = new JsNormalizing();
+ normalizer.accept(program);
+ }
+}
diff --git a/dev/core/src/com/google/gwt/dev/js/ast/JsContext.java b/dev/core/src/com/google/gwt/dev/js/ast/JsContext.java
index aae37ed..a5c795e 100644
--- a/dev/core/src/com/google/gwt/dev/js/ast/JsContext.java
+++ b/dev/core/src/com/google/gwt/dev/js/ast/JsContext.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.js.ast;
-
-/**
- * The context in which a JsNode visitation occurs. This represents the set of
- * possible operations a JsVisitor subclass can perform on the currently visited
- * node.
- */
-public interface JsContext {
-
- boolean canInsert();
-
- boolean canRemove();
-
- void insertAfter(JsNode node);
-
- void insertBefore(JsNode node);
-
- void removeMe();
-
- void replaceMe(JsNode node);
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.js.ast;
+
+/**
+ * The context in which a JsNode visitation occurs. This represents the set of
+ * possible operations a JsVisitor subclass can perform on the currently visited
+ * node.
+ */
+public interface JsContext {
+
+ boolean canInsert();
+
+ boolean canRemove();
+
+ void insertAfter(JsNode node);
+
+ void insertBefore(JsNode node);
+
+ void removeMe();
+
+ void replaceMe(JsNode node);
+}
diff --git a/dev/core/src/com/google/gwt/dev/js/ast/JsDebugger.java b/dev/core/src/com/google/gwt/dev/js/ast/JsDebugger.java
index d1b2565..bd4b7f2 100644
--- a/dev/core/src/com/google/gwt/dev/js/ast/JsDebugger.java
+++ b/dev/core/src/com/google/gwt/dev/js/ast/JsDebugger.java
@@ -1,28 +1,28 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.js.ast;
-
-/**
- * Represents a JavaScript debugger statement.
- */
-public class JsDebugger extends JsStatement {
-
- public void traverse(JsVisitor v, JsContext ctx) {
- v.visit(this, ctx);
- v.endVisit(this, ctx);
- }
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.js.ast;
+
+/**
+ * Represents a JavaScript debugger statement.
+ */
+public class JsDebugger extends JsStatement {
+
+ public void traverse(JsVisitor v, JsContext ctx) {
+ v.visit(this, ctx);
+ v.endVisit(this, ctx);
+ }
+
+}
diff --git a/dev/core/src/com/google/gwt/dev/js/ast/JsModVisitor.java b/dev/core/src/com/google/gwt/dev/js/ast/JsModVisitor.java
index 05e7f0f..a701bd9 100644
--- a/dev/core/src/com/google/gwt/dev/js/ast/JsModVisitor.java
+++ b/dev/core/src/com/google/gwt/dev/js/ast/JsModVisitor.java
@@ -1,223 +1,223 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.js.ast;
-
-import com.google.gwt.dev.jjs.InternalCompilerException;
-
-import java.util.ArrayList;
-
-/**
- * A visitor for iterating through and modifying an AST.
- */
-public class JsModVisitor extends JsVisitor {
-
- private interface ContextFactory {
- JsContext create();
- }
-
- private class ContextPool extends ArrayList {
-
- private ContextFactory factory;
- private int pos = 0;
-
- public ContextPool(ContextFactory factory) {
- this.factory = factory;
- }
-
- public void release(JsContext ctx) {
- if (get(--pos) != ctx) {
- throw new InternalCompilerException(
- "Tried to release the wrong context");
- }
- }
-
- public JsContext take() {
- if (pos == size()) {
- add(factory.create());
- }
- return (JsContext) get(pos++);
- }
- }
-
- private class ListContext implements JsContext {
- private int index;
- private JsCollection collection;
- private boolean removed;
- private boolean replaced;
-
- public boolean canInsert() {
- return true;
- }
-
- public boolean canRemove() {
- return true;
- }
-
- public void insertAfter(JsNode node) {
- checkRemoved();
- collection.addNode(index + 1, node);
- didChange = true;
- }
-
- public void insertBefore(JsNode node) {
- checkRemoved();
- collection.addNode(index++, node);
- didChange = true;
- }
-
- public void removeMe() {
- checkState();
- collection.removeNode(index--);
- didChange = removed = true;
- }
-
- public void replaceMe(JsNode node) {
- checkState();
- checkReplacement(collection.getNode(index), node);
- collection.setNode(index, node);
- didChange = replaced = true;
- }
-
- protected void doReplace(Class targetClass, JsNode x) {
- checkState();
- checkReplacement(collection.getNode(index), x);
- collection.setNode(index, x);
- didChange = replaced = true;
- }
-
- protected void traverse(JsCollection collection) {
- this.collection = collection;
- for (index = 0; index < collection.size(); ++index) {
- removed = replaced = false;
- doTraverse(collection.getNode(index), this);
- }
- }
-
- private void checkRemoved() {
- if (removed) {
- throw new InternalCompilerException("Node was already removed");
- }
- }
-
- private void checkState() {
- checkRemoved();
- if (replaced) {
- throw new InternalCompilerException("Node was already replaced");
- }
- }
- }
-
- private class NodeContext implements JsContext {
- private JsNode node;
- private boolean replaced;
-
- public boolean canInsert() {
- return false;
- }
-
- public boolean canRemove() {
- return false;
- }
-
- public void insertAfter(JsNode node) {
- throw new UnsupportedOperationException();
- }
-
- public void insertBefore(JsNode node) {
- throw new UnsupportedOperationException();
- }
-
- public void removeMe() {
- throw new UnsupportedOperationException();
- }
-
- public void replaceMe(JsNode node) {
- if (replaced) {
- throw new InternalCompilerException("Node was already replaced");
- }
- checkReplacement(this.node, node);
- this.node = node;
- didChange = replaced = true;
- }
-
- protected JsNode traverse(JsNode node) {
- this.node = node;
- replaced = false;
- doTraverse(node, this);
- return this.node;
- }
- }
-
- protected static void checkReplacement(JsNode origNode, JsNode newNode) {
- if (newNode == null) {
- throw new InternalCompilerException("Cannot replace with null");
- }
- if (newNode == origNode) {
- throw new InternalCompilerException(
- "The replacement is the same as the original");
- }
- }
-
- protected boolean didChange = false;
-
- private final ContextPool listContextPool = new ContextPool(
- new ContextFactory() {
- public JsContext create() {
- return new ListContext();
- }
- });
-
- private final ContextPool nodeContextPool = new ContextPool(
- new ContextFactory() {
- public JsContext create() {
- return new NodeContext();
- }
- });
-
- public boolean didChange() {
- return didChange;
- }
-
- protected JsNode doAccept(JsNode node) {
- NodeContext ctx = (NodeContext) nodeContextPool.take();
- try {
- return ctx.traverse(node);
- } finally {
- nodeContextPool.release(ctx);
- }
- }
-
- protected void doAccept(JsCollection collection) {
- NodeContext ctx = (NodeContext) nodeContextPool.take();
- try {
- for (int i = 0, c = collection.size(); i < c; ++i) {
- collection.setNode(i, ctx.traverse(collection.getNode(i)));
- }
- } finally {
- nodeContextPool.release(ctx);
- }
- }
-
- protected void doAcceptWithInsertRemove(JsCollection collection) {
- ListContext ctx = (ListContext) listContextPool.take();
- try {
- ctx.traverse(collection);
- } finally {
- listContextPool.release(ctx);
- }
- }
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.js.ast;
+
+import com.google.gwt.dev.jjs.InternalCompilerException;
+
+import java.util.ArrayList;
+
+/**
+ * A visitor for iterating through and modifying an AST.
+ */
+public class JsModVisitor extends JsVisitor {
+
+ private interface ContextFactory {
+ JsContext create();
+ }
+
+ private class ContextPool extends ArrayList {
+
+ private ContextFactory factory;
+ private int pos = 0;
+
+ public ContextPool(ContextFactory factory) {
+ this.factory = factory;
+ }
+
+ public void release(JsContext ctx) {
+ if (get(--pos) != ctx) {
+ throw new InternalCompilerException(
+ "Tried to release the wrong context");
+ }
+ }
+
+ public JsContext take() {
+ if (pos == size()) {
+ add(factory.create());
+ }
+ return (JsContext) get(pos++);
+ }
+ }
+
+ private class ListContext implements JsContext {
+ private int index;
+ private JsCollection collection;
+ private boolean removed;
+ private boolean replaced;
+
+ public boolean canInsert() {
+ return true;
+ }
+
+ public boolean canRemove() {
+ return true;
+ }
+
+ public void insertAfter(JsNode node) {
+ checkRemoved();
+ collection.addNode(index + 1, node);
+ didChange = true;
+ }
+
+ public void insertBefore(JsNode node) {
+ checkRemoved();
+ collection.addNode(index++, node);
+ didChange = true;
+ }
+
+ public void removeMe() {
+ checkState();
+ collection.removeNode(index--);
+ didChange = removed = true;
+ }
+
+ public void replaceMe(JsNode node) {
+ checkState();
+ checkReplacement(collection.getNode(index), node);
+ collection.setNode(index, node);
+ didChange = replaced = true;
+ }
+
+ protected void doReplace(Class targetClass, JsNode x) {
+ checkState();
+ checkReplacement(collection.getNode(index), x);
+ collection.setNode(index, x);
+ didChange = replaced = true;
+ }
+
+ protected void traverse(JsCollection collection) {
+ this.collection = collection;
+ for (index = 0; index < collection.size(); ++index) {
+ removed = replaced = false;
+ doTraverse(collection.getNode(index), this);
+ }
+ }
+
+ private void checkRemoved() {
+ if (removed) {
+ throw new InternalCompilerException("Node was already removed");
+ }
+ }
+
+ private void checkState() {
+ checkRemoved();
+ if (replaced) {
+ throw new InternalCompilerException("Node was already replaced");
+ }
+ }
+ }
+
+ private class NodeContext implements JsContext {
+ private JsNode node;
+ private boolean replaced;
+
+ public boolean canInsert() {
+ return false;
+ }
+
+ public boolean canRemove() {
+ return false;
+ }
+
+ public void insertAfter(JsNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void insertBefore(JsNode node) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeMe() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void replaceMe(JsNode node) {
+ if (replaced) {
+ throw new InternalCompilerException("Node was already replaced");
+ }
+ checkReplacement(this.node, node);
+ this.node = node;
+ didChange = replaced = true;
+ }
+
+ protected JsNode traverse(JsNode node) {
+ this.node = node;
+ replaced = false;
+ doTraverse(node, this);
+ return this.node;
+ }
+ }
+
+ protected static void checkReplacement(JsNode origNode, JsNode newNode) {
+ if (newNode == null) {
+ throw new InternalCompilerException("Cannot replace with null");
+ }
+ if (newNode == origNode) {
+ throw new InternalCompilerException(
+ "The replacement is the same as the original");
+ }
+ }
+
+ protected boolean didChange = false;
+
+ private final ContextPool listContextPool = new ContextPool(
+ new ContextFactory() {
+ public JsContext create() {
+ return new ListContext();
+ }
+ });
+
+ private final ContextPool nodeContextPool = new ContextPool(
+ new ContextFactory() {
+ public JsContext create() {
+ return new NodeContext();
+ }
+ });
+
+ public boolean didChange() {
+ return didChange;
+ }
+
+ protected JsNode doAccept(JsNode node) {
+ NodeContext ctx = (NodeContext) nodeContextPool.take();
+ try {
+ return ctx.traverse(node);
+ } finally {
+ nodeContextPool.release(ctx);
+ }
+ }
+
+ protected void doAccept(JsCollection collection) {
+ NodeContext ctx = (NodeContext) nodeContextPool.take();
+ try {
+ for (int i = 0, c = collection.size(); i < c; ++i) {
+ collection.setNode(i, ctx.traverse(collection.getNode(i)));
+ }
+ } finally {
+ nodeContextPool.release(ctx);
+ }
+ }
+
+ protected void doAcceptWithInsertRemove(JsCollection collection) {
+ ListContext ctx = (ListContext) listContextPool.take();
+ try {
+ ctx.traverse(collection);
+ } finally {
+ listContextPool.release(ctx);
+ }
+ }
+
+}
diff --git a/dev/core/src/com/google/gwt/dev/js/ast/JsUnaryOperation.java b/dev/core/src/com/google/gwt/dev/js/ast/JsUnaryOperation.java
index a4978e5..1599428 100644
--- a/dev/core/src/com/google/gwt/dev/js/ast/JsUnaryOperation.java
+++ b/dev/core/src/com/google/gwt/dev/js/ast/JsUnaryOperation.java
@@ -1,51 +1,51 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.js.ast;
-
-/**
- * A JavaScript prefix or postfix operation.
- */
-public abstract class JsUnaryOperation extends JsExpression {
-
- private JsExpression arg;
-
- private final JsUnaryOperator op;
-
- public JsUnaryOperation(JsUnaryOperator op) {
- this(op, null);
- }
-
- public JsUnaryOperation(JsUnaryOperator op, JsExpression arg) {
- this.op = op;
- this.arg = arg;
- }
-
- public JsExpression getArg() {
- return arg;
- }
-
- public JsUnaryOperator getOperator() {
- return op;
- }
-
- public void setArg(JsExpression arg) {
- this.arg = arg;
- }
-
- public void traverse(JsVisitor v, JsContext ctx) {
- arg = v.accept(arg);
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.js.ast;
+
+/**
+ * A JavaScript prefix or postfix operation.
+ */
+public abstract class JsUnaryOperation extends JsExpression {
+
+ private JsExpression arg;
+
+ private final JsUnaryOperator op;
+
+ public JsUnaryOperation(JsUnaryOperator op) {
+ this(op, null);
+ }
+
+ public JsUnaryOperation(JsUnaryOperator op, JsExpression arg) {
+ this.op = op;
+ this.arg = arg;
+ }
+
+ public JsExpression getArg() {
+ return arg;
+ }
+
+ public JsUnaryOperator getOperator() {
+ return op;
+ }
+
+ public void setArg(JsExpression arg) {
+ this.arg = arg;
+ }
+
+ public void traverse(JsVisitor v, JsContext ctx) {
+ arg = v.accept(arg);
+ }
+}
diff --git a/dev/core/test/com/google/gwt/core/ext/typeinfo/JClassTypeTest.java b/dev/core/test/com/google/gwt/core/ext/typeinfo/JClassTypeTest.java
index 07c29a9..26a3cf8 100644
--- a/dev/core/test/com/google/gwt/core/ext/typeinfo/JClassTypeTest.java
+++ b/dev/core/test/com/google/gwt/core/ext/typeinfo/JClassTypeTest.java
@@ -1,354 +1,354 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.core.ext.typeinfo;
-
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.jdt.StaticCompilationUnitProvider;
-import com.google.gwt.dev.jdt.TypeOracleBuilder;
-import com.google.gwt.dev.jdt.URLCompilationUnitProvider;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-/**
- * Tests related to JClassType. See individual test methods to details.
- */
-public class JClassTypeTest extends TestCase {
-
- public void testGetOverridableMethods() throws UnableToCompleteException,
- TypeOracleException {
- TreeLogger logger = TreeLogger.NULL;
- TypeOracle typeOracle = buildOracleFromTestPackage(logger);
-
- String[] noParams = new String[0];
- String[] intObjectParams = new String[] {"int", "java.lang.Object"};
-
- // Verify IA.
- {
- JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IA");
- JMethod[] leafMethods = type.getOverridableMethods();
- assertEquals(3, leafMethods.length);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IA", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IA", "ia", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IA", "foo", noParams);
- }
-
- // Verify IB.
- {
- JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IB");
- JMethod[] leafMethods = type.getOverridableMethods();
- assertEquals(5, leafMethods.length);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IB", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IB", "ia", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.IB", "ib", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.IB", "ib", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.IB", "foo", noParams);
- }
-
- // Verify IC.
- {
- JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IC");
- JMethod[] leafMethods = type.getOverridableMethods();
- assertEquals(7, leafMethods.length);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ia", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ib", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ib", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ic", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.IC", "ic", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.IC", "foo", noParams);
- }
-
- // Both overloads of ia are only declared in IA, so all searches should find
- // them there.
- {
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CA", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CB", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ia", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CA", "ia", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CB", "ia", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IA",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ia", intObjectParams);
- }
-
- // Both overloads of ib are declared in both IB and IC, so
- // - searching for ib in CB will return IB
- // - searching for ib in CC will return IC
- {
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.CB", "ib", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ib", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.CB", "ib", intObjectParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ib", intObjectParams);
- }
-
- // Both overloads of ic are declared only in IC, but ic() is also declared
- // in CB, so
- // - searching for ic() in CB will return CB
- // - searching for ic() in CC will return CB
- // - searching for ic(int, Object) in CC will return IC
- {
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.CB",
- "com.google.gwt.core.ext.typeinfo.test.CB", "ic", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.CB",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ic", noParams);
-
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IC",
- "com.google.gwt.core.ext.typeinfo.test.CC", "ic", intObjectParams);
- }
-
- // Both IA and IB define foo(), and searching for foo() on IC should return
- // IB.foo(). This matters because IC also extends IA, so a naive algorithm
- // for getLeafMethods() might prefer IA.foo() to IB.foo().
- {
- assertMethodOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.IB",
- "com.google.gwt.core.ext.typeinfo.test.IC", "foo", noParams);
- }
-
- // Check that we aren't including methods that aren't actually overridable
- // because they are final and/or private.
- {
- assertMethodNotOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.CA",
- "com.google.gwt.core.ext.typeinfo.test.CA", "caNotOverridableFinal",
- noParams);
-
- assertMethodNotOverridable(typeOracle,
- "com.google.gwt.core.ext.typeinfo.test.CA",
- "com.google.gwt.core.ext.typeinfo.test.CA",
- "caNotOverridablePrivate", noParams);
- }
- }
-
- private void addCompilationUnitsInPath(TypeOracleBuilder builder,
- File sourcePathEntry, String pkgName) throws UnableToCompleteException,
- MalformedURLException {
- File pkgPath = new File(sourcePathEntry, pkgName.replace('.', '/'));
- File[] files = pkgPath.listFiles();
- if (files == null) {
- // No files found.
- return;
- }
-
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (file.isFile()) {
- // If it's a source file, slurp it in.
- if (file.getName().endsWith(".java")) {
- URL location = file.toURL();
- CompilationUnitProvider cup = new URLCompilationUnitProvider(
- location, pkgName);
- builder.addCompilationUnit(cup);
- }
- } else {
- // Recurse into subpackages.
- addCompilationUnitsInPath(builder, sourcePathEntry, pkgName
- + file.getName());
- }
- }
- }
-
- private void assertMethodNotOverridable(TypeOracle typeOracle,
- String expectedTypeName, String searchTypeName, String methodName,
- String[] paramTypeNames) throws TypeOracleException {
- assertOverridableMethodInclusion(false, typeOracle, expectedTypeName,
- searchTypeName, methodName, paramTypeNames);
- }
-
- private void assertMethodOverridable(TypeOracle typeOracle,
- String expectedTypeName, String searchTypeName, String methodName,
- String[] paramTypeNames) throws TypeOracleException {
- assertOverridableMethodInclusion(true, typeOracle, expectedTypeName,
- searchTypeName, methodName, paramTypeNames);
- }
-
- private void assertOverridableMethodInclusion(boolean shouldBeFound,
- TypeOracle oracle, String expectedTypeName, String searchTypeName,
- String methodName, String[] paramTypeNames) throws TypeOracleException {
-
- boolean wasFound = false;
-
- JClassType expectedType = oracle.getType(expectedTypeName);
- JClassType searchType = oracle.getType(searchTypeName);
- JType[] paramTypes = new JType[paramTypeNames.length];
- for (int i = 0; i < paramTypeNames.length; i++) {
- String paramTypeName = paramTypeNames[i];
- paramTypes[i] = oracle.parse(paramTypeName);
- }
-
- JMethod[] leafMethods = searchType.getOverridableMethods();
- for (int i = 0; i < leafMethods.length; i++) {
- JMethod method = leafMethods[i];
- if (method.getName().equals(methodName)) {
- if (method.hasParamTypes(paramTypes)) {
- String typeName = method.getEnclosingType().getQualifiedSourceName();
- assertEquals(expectedTypeName, typeName);
- wasFound = true;
- break;
- }
- }
- }
-
- if (shouldBeFound) {
- if (wasFound) {
- // Good. We wanted to find it and we did.
- } else {
- fail("Did not find expected method '" + methodName + "' on type '"
- + expectedTypeName + "'");
- }
- } else {
- // We want to *not* find it.
- if (wasFound) {
- fail("Did not expect to find method '" + methodName + "' on type '"
- + expectedTypeName + "'");
- } else {
- // Good. We didn't want to find it and didn't.
- }
- }
- }
-
- /**
- * Looks in the package containing this class and uses it as an anchor for
- * including all the classes under the "test" subpackage.
- *
- * TODO: This is not generalized yet, but it could be made reusable and put
- * into TypeOracleBuilder.
- *
- * @return
- * @throws URISyntaxException
- * @throws UnableToCompleteException
- * @throws MalformedURLException
- */
- private TypeOracle buildOracleFromTestPackage(TreeLogger logger)
- throws UnableToCompleteException {
- Throwable caught;
- try {
- // Find the source path using this class as an anchor.
- String className = getClass().getName();
- String resName = className.replace('.', '/') + ".java";
- URL location = getClass().getClassLoader().getResource(resName);
- assertNotNull("Ensure that source is in classpath for: " + resName,
- location);
- String absPath = new File(new URI(location.toString())).getAbsolutePath();
- int sourcePathEntryLen = absPath.length() - resName.length();
- File sourcePathEntry = new File(absPath.substring(0, sourcePathEntryLen));
-
- // Determine the starting package name.
- int lastDot = className.lastIndexOf('.');
- String pkgName = (lastDot < 0 ? "test" : className.substring(0, lastDot)
- + ".test");
-
- // Create the builder to be filled in.
- TypeOracleBuilder builder = new TypeOracleBuilder();
-
- // Add java.lang.Object.
- builder.addCompilationUnit(new StaticCompilationUnitProvider("java.lang",
- "Object", "package java.lang; public class Object { }".toCharArray()));
-
- // Recursively walk the directories.
- addCompilationUnitsInPath(builder, sourcePathEntry, pkgName);
- return builder.build(logger);
- } catch (URISyntaxException e) {
- caught = e;
- } catch (MalformedURLException e) {
- caught = e;
- }
- logger.log(TreeLogger.ERROR, "Failed to build type oracle", caught);
- throw new UnableToCompleteException();
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.core.ext.typeinfo;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.jdt.StaticCompilationUnitProvider;
+import com.google.gwt.dev.jdt.TypeOracleBuilder;
+import com.google.gwt.dev.jdt.URLCompilationUnitProvider;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+/**
+ * Tests related to JClassType. See individual test methods to details.
+ */
+public class JClassTypeTest extends TestCase {
+
+ public void testGetOverridableMethods() throws UnableToCompleteException,
+ TypeOracleException {
+ TreeLogger logger = TreeLogger.NULL;
+ TypeOracle typeOracle = buildOracleFromTestPackage(logger);
+
+ String[] noParams = new String[0];
+ String[] intObjectParams = new String[] {"int", "java.lang.Object"};
+
+ // Verify IA.
+ {
+ JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IA");
+ JMethod[] leafMethods = type.getOverridableMethods();
+ assertEquals(3, leafMethods.length);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IA", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IA", "ia", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IA", "foo", noParams);
+ }
+
+ // Verify IB.
+ {
+ JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IB");
+ JMethod[] leafMethods = type.getOverridableMethods();
+ assertEquals(5, leafMethods.length);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IB", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IB", "ia", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.IB", "ib", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.IB", "ib", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.IB", "foo", noParams);
+ }
+
+ // Verify IC.
+ {
+ JClassType type = typeOracle.getType("com.google.gwt.core.ext.typeinfo.test.IC");
+ JMethod[] leafMethods = type.getOverridableMethods();
+ assertEquals(7, leafMethods.length);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ia", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ib", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ib", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ic", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "ic", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "foo", noParams);
+ }
+
+ // Both overloads of ia are only declared in IA, so all searches should find
+ // them there.
+ {
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CA", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CB", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ia", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CA", "ia", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CB", "ia", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IA",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ia", intObjectParams);
+ }
+
+ // Both overloads of ib are declared in both IB and IC, so
+ // - searching for ib in CB will return IB
+ // - searching for ib in CC will return IC
+ {
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.CB", "ib", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ib", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.CB", "ib", intObjectParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ib", intObjectParams);
+ }
+
+ // Both overloads of ic are declared only in IC, but ic() is also declared
+ // in CB, so
+ // - searching for ic() in CB will return CB
+ // - searching for ic() in CC will return CB
+ // - searching for ic(int, Object) in CC will return IC
+ {
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.CB",
+ "com.google.gwt.core.ext.typeinfo.test.CB", "ic", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.CB",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ic", noParams);
+
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IC",
+ "com.google.gwt.core.ext.typeinfo.test.CC", "ic", intObjectParams);
+ }
+
+ // Both IA and IB define foo(), and searching for foo() on IC should return
+ // IB.foo(). This matters because IC also extends IA, so a naive algorithm
+ // for getLeafMethods() might prefer IA.foo() to IB.foo().
+ {
+ assertMethodOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.IB",
+ "com.google.gwt.core.ext.typeinfo.test.IC", "foo", noParams);
+ }
+
+ // Check that we aren't including methods that aren't actually overridable
+ // because they are final and/or private.
+ {
+ assertMethodNotOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.CA",
+ "com.google.gwt.core.ext.typeinfo.test.CA", "caNotOverridableFinal",
+ noParams);
+
+ assertMethodNotOverridable(typeOracle,
+ "com.google.gwt.core.ext.typeinfo.test.CA",
+ "com.google.gwt.core.ext.typeinfo.test.CA",
+ "caNotOverridablePrivate", noParams);
+ }
+ }
+
+ private void addCompilationUnitsInPath(TypeOracleBuilder builder,
+ File sourcePathEntry, String pkgName) throws UnableToCompleteException,
+ MalformedURLException {
+ File pkgPath = new File(sourcePathEntry, pkgName.replace('.', '/'));
+ File[] files = pkgPath.listFiles();
+ if (files == null) {
+ // No files found.
+ return;
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (file.isFile()) {
+ // If it's a source file, slurp it in.
+ if (file.getName().endsWith(".java")) {
+ URL location = file.toURL();
+ CompilationUnitProvider cup = new URLCompilationUnitProvider(
+ location, pkgName);
+ builder.addCompilationUnit(cup);
+ }
+ } else {
+ // Recurse into subpackages.
+ addCompilationUnitsInPath(builder, sourcePathEntry, pkgName
+ + file.getName());
+ }
+ }
+ }
+
+ private void assertMethodNotOverridable(TypeOracle typeOracle,
+ String expectedTypeName, String searchTypeName, String methodName,
+ String[] paramTypeNames) throws TypeOracleException {
+ assertOverridableMethodInclusion(false, typeOracle, expectedTypeName,
+ searchTypeName, methodName, paramTypeNames);
+ }
+
+ private void assertMethodOverridable(TypeOracle typeOracle,
+ String expectedTypeName, String searchTypeName, String methodName,
+ String[] paramTypeNames) throws TypeOracleException {
+ assertOverridableMethodInclusion(true, typeOracle, expectedTypeName,
+ searchTypeName, methodName, paramTypeNames);
+ }
+
+ private void assertOverridableMethodInclusion(boolean shouldBeFound,
+ TypeOracle oracle, String expectedTypeName, String searchTypeName,
+ String methodName, String[] paramTypeNames) throws TypeOracleException {
+
+ boolean wasFound = false;
+
+ JClassType expectedType = oracle.getType(expectedTypeName);
+ JClassType searchType = oracle.getType(searchTypeName);
+ JType[] paramTypes = new JType[paramTypeNames.length];
+ for (int i = 0; i < paramTypeNames.length; i++) {
+ String paramTypeName = paramTypeNames[i];
+ paramTypes[i] = oracle.parse(paramTypeName);
+ }
+
+ JMethod[] leafMethods = searchType.getOverridableMethods();
+ for (int i = 0; i < leafMethods.length; i++) {
+ JMethod method = leafMethods[i];
+ if (method.getName().equals(methodName)) {
+ if (method.hasParamTypes(paramTypes)) {
+ String typeName = method.getEnclosingType().getQualifiedSourceName();
+ assertEquals(expectedTypeName, typeName);
+ wasFound = true;
+ break;
+ }
+ }
+ }
+
+ if (shouldBeFound) {
+ if (wasFound) {
+ // Good. We wanted to find it and we did.
+ } else {
+ fail("Did not find expected method '" + methodName + "' on type '"
+ + expectedTypeName + "'");
+ }
+ } else {
+ // We want to *not* find it.
+ if (wasFound) {
+ fail("Did not expect to find method '" + methodName + "' on type '"
+ + expectedTypeName + "'");
+ } else {
+ // Good. We didn't want to find it and didn't.
+ }
+ }
+ }
+
+ /**
+ * Looks in the package containing this class and uses it as an anchor for
+ * including all the classes under the "test" subpackage.
+ *
+ * TODO: This is not generalized yet, but it could be made reusable and put
+ * into TypeOracleBuilder.
+ *
+ * @return
+ * @throws URISyntaxException
+ * @throws UnableToCompleteException
+ * @throws MalformedURLException
+ */
+ private TypeOracle buildOracleFromTestPackage(TreeLogger logger)
+ throws UnableToCompleteException {
+ Throwable caught;
+ try {
+ // Find the source path using this class as an anchor.
+ String className = getClass().getName();
+ String resName = className.replace('.', '/') + ".java";
+ URL location = getClass().getClassLoader().getResource(resName);
+ assertNotNull("Ensure that source is in classpath for: " + resName,
+ location);
+ String absPath = new File(new URI(location.toString())).getAbsolutePath();
+ int sourcePathEntryLen = absPath.length() - resName.length();
+ File sourcePathEntry = new File(absPath.substring(0, sourcePathEntryLen));
+
+ // Determine the starting package name.
+ int lastDot = className.lastIndexOf('.');
+ String pkgName = (lastDot < 0 ? "test" : className.substring(0, lastDot)
+ + ".test");
+
+ // Create the builder to be filled in.
+ TypeOracleBuilder builder = new TypeOracleBuilder();
+
+ // Add java.lang.Object.
+ builder.addCompilationUnit(new StaticCompilationUnitProvider("java.lang",
+ "Object", "package java.lang; public class Object { }".toCharArray()));
+
+ // Recursively walk the directories.
+ addCompilationUnitsInPath(builder, sourcePathEntry, pkgName);
+ return builder.build(logger);
+ } catch (URISyntaxException e) {
+ caught = e;
+ } catch (MalformedURLException e) {
+ caught = e;
+ }
+ logger.log(TreeLogger.ERROR, "Failed to build type oracle", caught);
+ throw new UnableToCompleteException();
+ }
+}
diff --git a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
index 48949bf..84aa23a 100644
--- a/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
+++ b/dev/core/test/com/google/gwt/dev/shell/StandardGeneratorContextTest.java
@@ -1,347 +1,347 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.shell;
-
-import com.google.gwt.core.ext.BadPropertyValueException;
-import com.google.gwt.core.ext.PropertyOracle;
-import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dev.jdt.CacheManager;
-import com.google.gwt.dev.util.Util;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A wide variety of tests on {@link StandardGeneratorContext}.
- */
-public class StandardGeneratorContextTest extends TestCase {
-
- private static class MockCacheManager extends CacheManager {
- }
-
- private static class MockPropertyOracle implements PropertyOracle {
- public String getPropertyValue(TreeLogger logger, String propertyName)
- throws BadPropertyValueException {
- return "";
- }
- }
-
- private static class MockTreeLogger implements TreeLogger {
-
- public TreeLogger branch(Type type, String msg, Throwable caught) {
- return this;
- }
-
- public boolean isLoggable(Type type) {
- return false;
- }
-
- public void log(Type type, String msg, Throwable caught) {
- }
- }
-
- private static class MockTypeOracle extends TypeOracle {
- }
-
- /**
- * Stores the File objects to delete in the order they were created. Delete
- * them in reverse order.
- */
- private final List toDelete = new ArrayList();
- private final TypeOracle mockTypeOracle = new MockTypeOracle();
- private final PropertyOracle mockPropOracle = new MockPropertyOracle();
- private final File tempGenDir;
- private final File tempOutDir;
- private final CacheManager mockCacheManager = new MockCacheManager();
- private final TreeLogger mockLogger = new MockTreeLogger();
- private final StandardGeneratorContext genCtx;
- private int tempFileCounter;
-
- public StandardGeneratorContextTest() {
- tempGenDir = createTempDir("gwt-gen-");
- tempOutDir = createTempDir("gwt-out-");
- genCtx = new StandardGeneratorContext(mockTypeOracle, mockPropOracle,
- tempGenDir, tempOutDir, mockCacheManager);
- }
-
- public void testTryCreateResource_badFileName() {
- try {
- genCtx.tryCreateResource(mockLogger, null);
- fail("The null filename in the previous statement should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
-
- try {
- genCtx.tryCreateResource(mockLogger, "");
- fail("The empty filename in the previous statement should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
-
- try {
- genCtx.tryCreateResource(mockLogger, " ");
- fail("The whitespace-only filename in the previous statement should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
-
- try {
- File absFile = new File("stuff.bin");
- String asbPath = absFile.getAbsolutePath();
- genCtx.tryCreateResource(mockLogger, asbPath);
- fail("The absolute path in the previous statement should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
-
- try {
- genCtx.tryCreateResource(mockLogger, "asdf\\stuff.bin");
- fail("The backslash in the path in the previous statement should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
- }
-
- /**
- * Tests that calling commit a second time on the same OutputStream throws an
- * exception. Note that this behavior should follow the same basic code path
- * attempting to commit an unknown OutputStream, as in
- * {@link #testTryCreateResource_commitWithUnknownStream()}.
- */
- public void testTryCreateResource_commitCalledTwice()
- throws UnableToCompleteException, IOException {
- String path = createTempOutFilename();
- OutputStream os = genCtx.tryCreateResource(mockLogger, path);
- os.write("going to call commit twice after this...".getBytes());
- genCtx.commitResource(mockLogger, os);
- File createdFile = new File(tempOutDir, path);
- assertTrue(createdFile.exists());
- rememberToDelete(createdFile);
- try {
- genCtx.commitResource(mockLogger, os);
- fail("Calling commit() again on the same stream object should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
- }
-
- public void testTryCreateResource_commitNotCalled()
- throws UnableToCompleteException, IOException {
- String path = createTempOutFilename();
- OutputStream os = genCtx.tryCreateResource(mockLogger, path);
- byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- os.write(arrayWritten);
-
- // Note that we're *not* committing before calling finish().
- genCtx.finish(mockLogger);
-
- File wouldBeCreatedFile = new File(tempOutDir, path);
- assertFalse(wouldBeCreatedFile.exists());
- }
-
- public void testTryCreateResource_commitWithBadStream() {
- try {
- genCtx.commitResource(mockLogger, (OutputStream) null);
- fail("Calling commit() on a null stream should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
-
- try {
- OutputStream os = new ByteArrayOutputStream();
- genCtx.commitResource(mockLogger, os);
- fail("Calling commit() on a stream not returned from tryCreateResource() should have caused an exception");
- } catch (UnableToCompleteException e) {
- // Success
- }
- }
-
- /**
- * Tests that finish() can be called before and after output file creation.
- *
- * @throws UnableToCompleteException
- * @throws IOException
- *
- */
- public void testTryCreateResource_creationWorksBetweenFinishes()
- throws UnableToCompleteException, IOException {
- genCtx.finish(mockLogger);
- testTryCreateResource_normalCompletionWithoutSubDir();
- genCtx.finish(mockLogger);
- testTryCreateResource_normalCompletionWithoutSubDir();
- genCtx.finish(mockLogger);
- }
-
- public void testTryCreateResource_duplicateCreationAttempt()
- throws UnableToCompleteException {
- String path = createTempOutFilename();
- OutputStream os1 = genCtx.tryCreateResource(mockLogger, path);
- assertNotNull(os1);
- OutputStream os2 = genCtx.tryCreateResource(mockLogger, path);
- assertNull(os2);
- }
-
- public void testTryCreateResource_finishCalledTwice()
- throws UnableToCompleteException, IOException {
- // Borrow impl.
- testTryCreateResource_commitNotCalled();
-
- // Now call finish() again to make sure nothing blows up.
- try {
- genCtx.finish(mockLogger);
- } catch (UnableToCompleteException e) {
- fail("finish() failed; it should support safely being called any number of times");
- }
- }
-
- public void testTryCreateResource_normalCompletionWithoutSubDir()
- throws UnableToCompleteException, IOException {
- String path = createTempOutFilename();
- testTryCreateResource_normalCompletion(null, path);
- }
-
- public void testTryCreateResource_normalCompletionWithSubDir()
- throws UnableToCompleteException, IOException {
- String subdir = createTempOutFilename();
- String filename = createTempOutFilename();
- testTryCreateResource_normalCompletion(subdir, filename);
- }
-
- /**
- * Tests that tryCreateResource() throws an exception when commit() is called
- * if the output exists. This situation should only happen if the file is
- * created externally between the time tryCreateResource() is called and
- * commit() is called. In the normal case of an existing file,
- * tryCreateResource() would return <code>null</code> so there would be
- * nothing to commit.
- *
- * @throws UnableToCompleteException
- * @throws IOException
- */
- public void testTryCreateResource_outputFileConflictAtCommit()
- throws UnableToCompleteException, IOException {
- String path = createTempOutFilename();
-
- OutputStream os = genCtx.tryCreateResource(mockLogger, path);
- assertNotNull(
- "This test requires that the file being created does not already exist at this point",
- os);
- byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- os.write(arrayWritten);
- try {
- // Manually create the file that would normally be created by commit().
- File existingFile = new File(tempOutDir, path);
- Util.writeStringAsFile(existingFile, "please don't clobber me");
- assertTrue(existingFile.exists());
- rememberToDelete(existingFile);
-
- genCtx.commitResource(mockLogger, os);
- fail("The previous statement should have caused an exception since writing the resource must have failed");
- } catch (UnableToCompleteException e) {
- // Success.
- }
- }
-
- /**
- * Tests that tryCreateResource() returns <code>null</code> when the
- * specified file already exists.
- *
- * @throws UnableToCompleteException
- * @throws IOException
- */
- public void testTryCreateResource_outputFileConflictAtCreation()
- throws UnableToCompleteException, IOException {
- String path = createTempOutFilename();
-
- // Manually create the file that would normally be created by commit().
- File existingFile = new File(tempOutDir, path);
- Util.writeStringAsFile(existingFile, "please don't clobber me");
- assertTrue(existingFile.exists());
- rememberToDelete(existingFile);
-
- OutputStream os = genCtx.tryCreateResource(mockLogger, path);
- assertNull(
- "tryCreateResource() should return null when the target file already exists",
- os);
- }
-
- protected void tearDown() throws Exception {
- for (int i = toDelete.size() - 1; i >= 0; --i) {
- File f = (File) toDelete.get(i);
- assertTrue(f.delete());
- }
- }
-
- private File createTempDir(String prefix) {
- String baseTempPath = System.getProperty("java.io.tmpdir");
- File baseTempDir = new File(baseTempPath);
- File newTempDir;
- do {
- newTempDir = new File(baseTempPath, prefix + System.currentTimeMillis());
- } while (!newTempDir.mkdirs());
- rememberToDelete(newTempDir);
- return newTempDir;
- }
-
- private String createTempOutFilename() {
- File tempFile;
- do {
- tempFile = new File(tempOutDir, System.currentTimeMillis() + "-" + (++tempFileCounter) + ".gwt.tmp");
- } while (tempFile.exists());
- return tempFile.getName();
- }
-
- private void rememberToDelete(File f) {
- toDelete.add(f);
- }
-
- private void testTryCreateResource_normalCompletion(String subdir, String name)
- throws UnableToCompleteException, IOException {
- if (subdir != null) {
- name = subdir + "/" + name;
- }
- OutputStream os = genCtx.tryCreateResource(mockLogger, name);
- assertNotNull(os);
- byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- os.write(arrayWritten);
- genCtx.commitResource(mockLogger, os);
-
- if (subdir != null) {
- File createdDir = new File(tempOutDir, subdir);
- assertTrue(createdDir.exists());
- rememberToDelete(createdDir);
- }
-
- File createdFile = new File(tempOutDir, name);
- assertTrue(createdFile.exists());
- rememberToDelete(createdFile);
-
- // Read the file.
- byte[] arrayRead = Util.readFileAsBytes(createdFile);
- assertTrue(Arrays.equals(arrayWritten, arrayRead));
- }
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.shell;
+
+import com.google.gwt.core.ext.BadPropertyValueException;
+import com.google.gwt.core.ext.PropertyOracle;
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.jdt.CacheManager;
+import com.google.gwt.dev.util.Util;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A wide variety of tests on {@link StandardGeneratorContext}.
+ */
+public class StandardGeneratorContextTest extends TestCase {
+
+ private static class MockCacheManager extends CacheManager {
+ }
+
+ private static class MockPropertyOracle implements PropertyOracle {
+ public String getPropertyValue(TreeLogger logger, String propertyName)
+ throws BadPropertyValueException {
+ return "";
+ }
+ }
+
+ private static class MockTreeLogger implements TreeLogger {
+
+ public TreeLogger branch(Type type, String msg, Throwable caught) {
+ return this;
+ }
+
+ public boolean isLoggable(Type type) {
+ return false;
+ }
+
+ public void log(Type type, String msg, Throwable caught) {
+ }
+ }
+
+ private static class MockTypeOracle extends TypeOracle {
+ }
+
+ /**
+ * Stores the File objects to delete in the order they were created. Delete
+ * them in reverse order.
+ */
+ private final List toDelete = new ArrayList();
+ private final TypeOracle mockTypeOracle = new MockTypeOracle();
+ private final PropertyOracle mockPropOracle = new MockPropertyOracle();
+ private final File tempGenDir;
+ private final File tempOutDir;
+ private final CacheManager mockCacheManager = new MockCacheManager();
+ private final TreeLogger mockLogger = new MockTreeLogger();
+ private final StandardGeneratorContext genCtx;
+ private int tempFileCounter;
+
+ public StandardGeneratorContextTest() {
+ tempGenDir = createTempDir("gwt-gen-");
+ tempOutDir = createTempDir("gwt-out-");
+ genCtx = new StandardGeneratorContext(mockTypeOracle, mockPropOracle,
+ tempGenDir, tempOutDir, mockCacheManager);
+ }
+
+ public void testTryCreateResource_badFileName() {
+ try {
+ genCtx.tryCreateResource(mockLogger, null);
+ fail("The null filename in the previous statement should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+
+ try {
+ genCtx.tryCreateResource(mockLogger, "");
+ fail("The empty filename in the previous statement should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+
+ try {
+ genCtx.tryCreateResource(mockLogger, " ");
+ fail("The whitespace-only filename in the previous statement should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+
+ try {
+ File absFile = new File("stuff.bin");
+ String asbPath = absFile.getAbsolutePath();
+ genCtx.tryCreateResource(mockLogger, asbPath);
+ fail("The absolute path in the previous statement should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+
+ try {
+ genCtx.tryCreateResource(mockLogger, "asdf\\stuff.bin");
+ fail("The backslash in the path in the previous statement should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Tests that calling commit a second time on the same OutputStream throws an
+ * exception. Note that this behavior should follow the same basic code path
+ * attempting to commit an unknown OutputStream, as in
+ * {@link #testTryCreateResource_commitWithUnknownStream()}.
+ */
+ public void testTryCreateResource_commitCalledTwice()
+ throws UnableToCompleteException, IOException {
+ String path = createTempOutFilename();
+ OutputStream os = genCtx.tryCreateResource(mockLogger, path);
+ os.write("going to call commit twice after this...".getBytes());
+ genCtx.commitResource(mockLogger, os);
+ File createdFile = new File(tempOutDir, path);
+ assertTrue(createdFile.exists());
+ rememberToDelete(createdFile);
+ try {
+ genCtx.commitResource(mockLogger, os);
+ fail("Calling commit() again on the same stream object should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+ }
+
+ public void testTryCreateResource_commitNotCalled()
+ throws UnableToCompleteException, IOException {
+ String path = createTempOutFilename();
+ OutputStream os = genCtx.tryCreateResource(mockLogger, path);
+ byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ os.write(arrayWritten);
+
+ // Note that we're *not* committing before calling finish().
+ genCtx.finish(mockLogger);
+
+ File wouldBeCreatedFile = new File(tempOutDir, path);
+ assertFalse(wouldBeCreatedFile.exists());
+ }
+
+ public void testTryCreateResource_commitWithBadStream() {
+ try {
+ genCtx.commitResource(mockLogger, (OutputStream) null);
+ fail("Calling commit() on a null stream should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+
+ try {
+ OutputStream os = new ByteArrayOutputStream();
+ genCtx.commitResource(mockLogger, os);
+ fail("Calling commit() on a stream not returned from tryCreateResource() should have caused an exception");
+ } catch (UnableToCompleteException e) {
+ // Success
+ }
+ }
+
+ /**
+ * Tests that finish() can be called before and after output file creation.
+ *
+ * @throws UnableToCompleteException
+ * @throws IOException
+ *
+ */
+ public void testTryCreateResource_creationWorksBetweenFinishes()
+ throws UnableToCompleteException, IOException {
+ genCtx.finish(mockLogger);
+ testTryCreateResource_normalCompletionWithoutSubDir();
+ genCtx.finish(mockLogger);
+ testTryCreateResource_normalCompletionWithoutSubDir();
+ genCtx.finish(mockLogger);
+ }
+
+ public void testTryCreateResource_duplicateCreationAttempt()
+ throws UnableToCompleteException {
+ String path = createTempOutFilename();
+ OutputStream os1 = genCtx.tryCreateResource(mockLogger, path);
+ assertNotNull(os1);
+ OutputStream os2 = genCtx.tryCreateResource(mockLogger, path);
+ assertNull(os2);
+ }
+
+ public void testTryCreateResource_finishCalledTwice()
+ throws UnableToCompleteException, IOException {
+ // Borrow impl.
+ testTryCreateResource_commitNotCalled();
+
+ // Now call finish() again to make sure nothing blows up.
+ try {
+ genCtx.finish(mockLogger);
+ } catch (UnableToCompleteException e) {
+ fail("finish() failed; it should support safely being called any number of times");
+ }
+ }
+
+ public void testTryCreateResource_normalCompletionWithoutSubDir()
+ throws UnableToCompleteException, IOException {
+ String path = createTempOutFilename();
+ testTryCreateResource_normalCompletion(null, path);
+ }
+
+ public void testTryCreateResource_normalCompletionWithSubDir()
+ throws UnableToCompleteException, IOException {
+ String subdir = createTempOutFilename();
+ String filename = createTempOutFilename();
+ testTryCreateResource_normalCompletion(subdir, filename);
+ }
+
+ /**
+ * Tests that tryCreateResource() throws an exception when commit() is called
+ * if the output exists. This situation should only happen if the file is
+ * created externally between the time tryCreateResource() is called and
+ * commit() is called. In the normal case of an existing file,
+ * tryCreateResource() would return <code>null</code> so there would be
+ * nothing to commit.
+ *
+ * @throws UnableToCompleteException
+ * @throws IOException
+ */
+ public void testTryCreateResource_outputFileConflictAtCommit()
+ throws UnableToCompleteException, IOException {
+ String path = createTempOutFilename();
+
+ OutputStream os = genCtx.tryCreateResource(mockLogger, path);
+ assertNotNull(
+ "This test requires that the file being created does not already exist at this point",
+ os);
+ byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ os.write(arrayWritten);
+ try {
+ // Manually create the file that would normally be created by commit().
+ File existingFile = new File(tempOutDir, path);
+ Util.writeStringAsFile(existingFile, "please don't clobber me");
+ assertTrue(existingFile.exists());
+ rememberToDelete(existingFile);
+
+ genCtx.commitResource(mockLogger, os);
+ fail("The previous statement should have caused an exception since writing the resource must have failed");
+ } catch (UnableToCompleteException e) {
+ // Success.
+ }
+ }
+
+ /**
+ * Tests that tryCreateResource() returns <code>null</code> when the
+ * specified file already exists.
+ *
+ * @throws UnableToCompleteException
+ * @throws IOException
+ */
+ public void testTryCreateResource_outputFileConflictAtCreation()
+ throws UnableToCompleteException, IOException {
+ String path = createTempOutFilename();
+
+ // Manually create the file that would normally be created by commit().
+ File existingFile = new File(tempOutDir, path);
+ Util.writeStringAsFile(existingFile, "please don't clobber me");
+ assertTrue(existingFile.exists());
+ rememberToDelete(existingFile);
+
+ OutputStream os = genCtx.tryCreateResource(mockLogger, path);
+ assertNull(
+ "tryCreateResource() should return null when the target file already exists",
+ os);
+ }
+
+ protected void tearDown() throws Exception {
+ for (int i = toDelete.size() - 1; i >= 0; --i) {
+ File f = (File) toDelete.get(i);
+ assertTrue(f.delete());
+ }
+ }
+
+ private File createTempDir(String prefix) {
+ String baseTempPath = System.getProperty("java.io.tmpdir");
+ File baseTempDir = new File(baseTempPath);
+ File newTempDir;
+ do {
+ newTempDir = new File(baseTempPath, prefix + System.currentTimeMillis());
+ } while (!newTempDir.mkdirs());
+ rememberToDelete(newTempDir);
+ return newTempDir;
+ }
+
+ private String createTempOutFilename() {
+ File tempFile;
+ do {
+ tempFile = new File(tempOutDir, System.currentTimeMillis() + "-" + (++tempFileCounter) + ".gwt.tmp");
+ } while (tempFile.exists());
+ return tempFile.getName();
+ }
+
+ private void rememberToDelete(File f) {
+ toDelete.add(f);
+ }
+
+ private void testTryCreateResource_normalCompletion(String subdir, String name)
+ throws UnableToCompleteException, IOException {
+ if (subdir != null) {
+ name = subdir + "/" + name;
+ }
+ OutputStream os = genCtx.tryCreateResource(mockLogger, name);
+ assertNotNull(os);
+ byte[] arrayWritten = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ os.write(arrayWritten);
+ genCtx.commitResource(mockLogger, os);
+
+ if (subdir != null) {
+ File createdDir = new File(tempOutDir, subdir);
+ assertTrue(createdDir.exists());
+ rememberToDelete(createdDir);
+ }
+
+ File createdFile = new File(tempOutDir, name);
+ assertTrue(createdFile.exists());
+ rememberToDelete(createdFile);
+
+ // Read the file.
+ byte[] arrayRead = Util.readFileAsBytes(createdFile);
+ assertTrue(Arrays.equals(arrayWritten, arrayRead));
+ }
+
+}
diff --git a/dev/core/test/com/google/gwt/dev/util/log/AbstractTreeLoggerTest.java b/dev/core/test/com/google/gwt/dev/util/log/AbstractTreeLoggerTest.java
index 8a01351..e77c817 100644
--- a/dev/core/test/com/google/gwt/dev/util/log/AbstractTreeLoggerTest.java
+++ b/dev/core/test/com/google/gwt/dev/util/log/AbstractTreeLoggerTest.java
@@ -1,93 +1,93 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.dev.util.log;
-
-import com.google.gwt.core.ext.TreeLogger;
-
-import junit.framework.TestCase;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-/**
- * Tests the <code>AbstractTreeLogger</code>.
- */
-public class AbstractTreeLoggerTest extends TestCase {
-
- /**
- * We handle out-of-memory conditions specially in the logger to provide more
- * useful log output. It does some slightly weird stuff like turning a regular
- * log() into a branch(), so this test makes sure that doesn't break anything.
- */
- public void testOutOfMemoryLoggerCommitOrderForLog() {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw, true);
- PrintWriterTreeLogger logger = new PrintWriterTreeLogger(pw);
- logger.setMaxDetail(TreeLogger.WARN);
-
- final String tstDbgStr = "TEST-DEBUG-STRING";
- final String tstErrStr = "TEST-ERROR-STRING";
-
- // Emit something that's low-priority and wouldn't show up normally unless
- // it had a higher-priority child log event.
- TreeLogger branch = logger.branch(TreeLogger.DEBUG, tstDbgStr, null);
- assertEquals(-1, sw.toString().indexOf(tstDbgStr));
-
- // Emit something that's low-priority but that also has a OOM.
- branch.log(TreeLogger.ERROR, tstErrStr, new OutOfMemoryError());
-
- // Make sure both are now there, in the right order.
- int posTstDbgStr = sw.toString().indexOf(tstDbgStr);
- int posTstErrStr = sw.toString().indexOf(tstErrStr);
- int posOutOfMemory = sw.toString().indexOf(
- AbstractTreeLogger.OUT_OF_MEMORY_MSG);
- assertTrue(posTstDbgStr != -1);
- assertTrue(posTstErrStr != -1);
- assertTrue(posOutOfMemory != -1);
- assertTrue(posTstDbgStr < posTstErrStr);
- assertTrue(posTstErrStr < posOutOfMemory);
- }
-
- /**
- * Low-priority branch points don't actually show low-priority messages unless
- * they (later) get a child that is loggable.
- */
- public void testLazyBranchCommit() {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw, true);
- PrintWriterTreeLogger logger = new PrintWriterTreeLogger(pw);
- logger.setMaxDetail(TreeLogger.WARN);
-
- final String tstDbgStr = "TEST-DEBUG-STRING";
- final String tstErrStr = "TEST-ERROR-STRING";
-
- // Emit something that's low-priority and wouldn't show up normally unless
- // it had a higher-priority child log event.
- TreeLogger branch = logger.branch(TreeLogger.DEBUG, tstDbgStr, null);
- assertEquals(-1, sw.toString().indexOf(tstDbgStr));
-
- // Emit something that's high-priority and will cause both to show up.
- branch.log(TreeLogger.ERROR, tstErrStr, null);
-
- // Make sure both are now there, in the right order.
- int posTstDbgStr = sw.toString().indexOf(tstDbgStr);
- int posTstErrStr = sw.toString().indexOf(tstErrStr);
- assertTrue(posTstDbgStr != -1);
- assertTrue(posTstErrStr != -1);
- assertTrue(posTstDbgStr < posTstErrStr);
- }
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dev.util.log;
+
+import com.google.gwt.core.ext.TreeLogger;
+
+import junit.framework.TestCase;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * Tests the <code>AbstractTreeLogger</code>.
+ */
+public class AbstractTreeLoggerTest extends TestCase {
+
+ /**
+ * We handle out-of-memory conditions specially in the logger to provide more
+ * useful log output. It does some slightly weird stuff like turning a regular
+ * log() into a branch(), so this test makes sure that doesn't break anything.
+ */
+ public void testOutOfMemoryLoggerCommitOrderForLog() {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw, true);
+ PrintWriterTreeLogger logger = new PrintWriterTreeLogger(pw);
+ logger.setMaxDetail(TreeLogger.WARN);
+
+ final String tstDbgStr = "TEST-DEBUG-STRING";
+ final String tstErrStr = "TEST-ERROR-STRING";
+
+ // Emit something that's low-priority and wouldn't show up normally unless
+ // it had a higher-priority child log event.
+ TreeLogger branch = logger.branch(TreeLogger.DEBUG, tstDbgStr, null);
+ assertEquals(-1, sw.toString().indexOf(tstDbgStr));
+
+ // Emit something that's low-priority but that also has a OOM.
+ branch.log(TreeLogger.ERROR, tstErrStr, new OutOfMemoryError());
+
+ // Make sure both are now there, in the right order.
+ int posTstDbgStr = sw.toString().indexOf(tstDbgStr);
+ int posTstErrStr = sw.toString().indexOf(tstErrStr);
+ int posOutOfMemory = sw.toString().indexOf(
+ AbstractTreeLogger.OUT_OF_MEMORY_MSG);
+ assertTrue(posTstDbgStr != -1);
+ assertTrue(posTstErrStr != -1);
+ assertTrue(posOutOfMemory != -1);
+ assertTrue(posTstDbgStr < posTstErrStr);
+ assertTrue(posTstErrStr < posOutOfMemory);
+ }
+
+ /**
+ * Low-priority branch points don't actually show low-priority messages unless
+ * they (later) get a child that is loggable.
+ */
+ public void testLazyBranchCommit() {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw, true);
+ PrintWriterTreeLogger logger = new PrintWriterTreeLogger(pw);
+ logger.setMaxDetail(TreeLogger.WARN);
+
+ final String tstDbgStr = "TEST-DEBUG-STRING";
+ final String tstErrStr = "TEST-ERROR-STRING";
+
+ // Emit something that's low-priority and wouldn't show up normally unless
+ // it had a higher-priority child log event.
+ TreeLogger branch = logger.branch(TreeLogger.DEBUG, tstDbgStr, null);
+ assertEquals(-1, sw.toString().indexOf(tstDbgStr));
+
+ // Emit something that's high-priority and will cause both to show up.
+ branch.log(TreeLogger.ERROR, tstErrStr, null);
+
+ // Make sure both are now there, in the right order.
+ int posTstDbgStr = sw.toString().indexOf(tstDbgStr);
+ int posTstErrStr = sw.toString().indexOf(tstErrStr);
+ assertTrue(posTstDbgStr != -1);
+ assertTrue(posTstErrStr != -1);
+ assertTrue(posTstDbgStr < posTstErrStr);
+ }
+
+}
diff --git a/samples/simplerpc/build.xml b/samples/simplerpc/build.xml
index 1a2cd86..f35f65e 100644
--- a/samples/simplerpc/build.xml
+++ b/samples/simplerpc/build.xml
@@ -1,5 +1,5 @@
-<project name="dynatable" default="build" basedir=".">
- <property name="sample.root" value="simplercp" />
- <property name="sample.module" value="SimpleRPC" />
- <import file="../common.ant.xml" />
-</project>
+<project name="dynatable" default="build" basedir=".">
+ <property name="sample.root" value="simplercp" />
+ <property name="sample.module" value="SimpleRPC" />
+ <import file="../common.ant.xml" />
+</project>
diff --git a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/SimpleRPC.gwt.xml b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/SimpleRPC.gwt.xml
index a80ff7c..76b3778 100644
--- a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/SimpleRPC.gwt.xml
+++ b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/SimpleRPC.gwt.xml
@@ -1,21 +1,21 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<module>
- <inherits name='com.google.gwt.user.User'/>
- <entry-point class='com.google.gwt.sample.simplerpc.client.SimpleRPC'/>
- <servlet path='/simpleRPC' class='com.google.gwt.sample.simplerpc.server.SimpleRPCServiceImpl'/>
-</module>
-
-
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<module>
+ <inherits name='com.google.gwt.user.User'/>
+ <entry-point class='com.google.gwt.sample.simplerpc.client.SimpleRPC'/>
+ <servlet path='/simpleRPC' class='com.google.gwt.sample.simplerpc.server.SimpleRPCServiceImpl'/>
+</module>
+
+
diff --git a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPCException.java b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPCException.java
index 59cddfe..941fa97 100644
--- a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPCException.java
+++ b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/client/SimpleRPCException.java
@@ -1,39 +1,39 @@
-/*
- * Copyright 2006 Google Inc.
- *
- * 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 com.google.gwt.sample.simplerpc.client;
-
-import com.google.gwt.user.client.rpc.SerializableException;
-
-/**
- * Simple RPC exception.
- */
-public class SimpleRPCException extends SerializableException {
-
- /**
- * Constructor for <code>SimpleRPCException</code>. Needed to support serialization.
- */
- public SimpleRPCException() {
- }
-
- /**
- * Constructor for <code>SimpleRPCException</code>.
- * @param message message for the <code>SimplePRCException</code>
- */
- public SimpleRPCException(String message) {
- super(message);
- }
-}
+/*
+ * Copyright 2006 Google Inc.
+ *
+ * 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 com.google.gwt.sample.simplerpc.client;
+
+import com.google.gwt.user.client.rpc.SerializableException;
+
+/**
+ * Simple RPC exception.
+ */
+public class SimpleRPCException extends SerializableException {
+
+ /**
+ * Constructor for <code>SimpleRPCException</code>. Needed to support serialization.
+ */
+ public SimpleRPCException() {
+ }
+
+ /**
+ * Constructor for <code>SimpleRPCException</code>.
+ * @param message message for the <code>SimplePRCException</code>
+ */
+ public SimpleRPCException(String message) {
+ super(message);
+ }
+}
diff --git a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/public/SimpleRPC.html b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/public/SimpleRPC.html
index 0fa249e..f02c6af 100644
--- a/samples/simplerpc/src/com/google/gwt/sample/simplerpc/public/SimpleRPC.html
+++ b/samples/simplerpc/src/com/google/gwt/sample/simplerpc/public/SimpleRPC.html
@@ -1,19 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta name='gwt:module'
- content='com.google.gwt.sample.simplerpc.SimpleRPC' />
- <link type="text/css" rel="stylesheet" href="SimpleRPC.css" />
- <title>SimpleRPC</title>
- </head>
- <body>
- <iframe src="javascript:''" id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
- <script type="text/javascript" language='javascript' src='gwt.js'>
- </script>
- <h1>
- Simple RPC
- </h1>
- Simple example of RPC, check out the DynaTable sample if you want to see real RPC coolness.
- </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta name='gwt:module'
+ content='com.google.gwt.sample.simplerpc.SimpleRPC' />
+ <link type="text/css" rel="stylesheet" href="SimpleRPC.css" />
+ <title>SimpleRPC</title>
+ </head>
+ <body>
+ <iframe src="javascript:''" id='__gwt_historyFrame' style='width:0;height:0;border:0'></iframe>
+ <script type="text/javascript" language='javascript' src='gwt.js'>
+ </script>
+ <h1>
+ Simple RPC
+ </h1>
+ Simple example of RPC, check out the DynaTable sample if you want to see real RPC coolness.
+ </body>
+</html>
diff --git a/user/src/com/google/gwt/user/ClippedImage.gwt.xml b/user/src/com/google/gwt/user/ClippedImage.gwt.xml
index 8262aab..d333d77 100644
--- a/user/src/com/google/gwt/user/ClippedImage.gwt.xml
+++ b/user/src/com/google/gwt/user/ClippedImage.gwt.xml
@@ -1,37 +1,37 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<!-- -->
-<!-- This module is required in order to use an Image in its clipped state, -->
-<!-- or an ImageBundle. -->
-<!-- -->
-<!-- The implementation differs between Internet Explorer and other -->
-<!-- browsers, so we use deferred binding to create the correct instance of -->
-<!-- the class based on the user's browser. -->
-<!-- -->
-<!-- This module is interited by the User module, so it will be available -->
-<!-- to all GWT applications. -->
-
-<module>
- <inherits name="com.google.gwt.core.Core" />
- <inherits name="com.google.gwt.user.UserAgent" />
-
- <!-- IE needs a different implementation -->
- <replace-with
- class="com.google.gwt.user.client.ui.impl.ClippedImageImplIE6">
- <when-type-is
- class="com.google.gwt.user.client.ui.impl.ClippedImageImpl" />
- <when-property-is name="user.agent" value="ie6" />
- </replace-with>
-</module>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<!-- -->
+<!-- This module is required in order to use an Image in its clipped state, -->
+<!-- or an ImageBundle. -->
+<!-- -->
+<!-- The implementation differs between Internet Explorer and other -->
+<!-- browsers, so we use deferred binding to create the correct instance of -->
+<!-- the class based on the user's browser. -->
+<!-- -->
+<!-- This module is interited by the User module, so it will be available -->
+<!-- to all GWT applications. -->
+
+<module>
+ <inherits name="com.google.gwt.core.Core" />
+ <inherits name="com.google.gwt.user.UserAgent" />
+
+ <!-- IE needs a different implementation -->
+ <replace-with
+ class="com.google.gwt.user.client.ui.impl.ClippedImageImplIE6">
+ <when-type-is
+ class="com.google.gwt.user.client.ui.impl.ClippedImageImpl" />
+ <when-property-is name="user.agent" value="ie6" />
+ </replace-with>
+</module>
diff --git a/user/src/com/google/gwt/user/ImageBundle.gwt.xml b/user/src/com/google/gwt/user/ImageBundle.gwt.xml
index d50e04e..13a6cf7 100644
--- a/user/src/com/google/gwt/user/ImageBundle.gwt.xml
+++ b/user/src/com/google/gwt/user/ImageBundle.gwt.xml
@@ -1,25 +1,25 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<!-- ImageBundle support. -->
-<!-- -->
-<module>
- <!-- Inherit ClippedImage, because ImageBundleGerator uses -->
- <!-- ClippedImagePrototype, which depends on ClippedImage -->
- <inherits name="com.google.gwt.user.ClippedImage" />
-
- <generate-with class="com.google.gwt.user.rebind.ui.ImageBundleGenerator">
- <when-type-assignable class="com.google.gwt.user.client.ui.ImageBundle" />
- </generate-with>
-</module>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<!-- ImageBundle support. -->
+<!-- -->
+<module>
+ <!-- Inherit ClippedImage, because ImageBundleGerator uses -->
+ <!-- ClippedImagePrototype, which depends on ClippedImage -->
+ <inherits name="com.google.gwt.user.ClippedImage" />
+
+ <generate-with class="com.google.gwt.user.rebind.ui.ImageBundleGenerator">
+ <when-type-assignable class="com.google.gwt.user.client.ui.ImageBundle" />
+ </generate-with>
+</module>
diff --git a/user/src/com/google/gwt/user/RichText.gwt.xml b/user/src/com/google/gwt/user/RichText.gwt.xml
index a3d6882..6569d22 100644
--- a/user/src/com/google/gwt/user/RichText.gwt.xml
+++ b/user/src/com/google/gwt/user/RichText.gwt.xml
@@ -1,60 +1,60 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<!-- Deferred binding rules for browser selection. -->
-<!-- -->
-<module>
- <inherits name="com.google.gwt.core.Core" />
- <inherits name="com.google.gwt.user.UserAgent" />
- <inherits name="com.google.gwt.i18n.I18N" />
-
- <!-- IE-specific implementation -->
- <replace-with
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImplIE6">
- <when-type-is
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
- <when-property-is name="user.agent" value="ie6" />
- </replace-with>
-
- <!-- Mozilla-specific implementation -->
- <replace-with
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImplMozilla">
- <when-type-is
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
- <any>
- <when-property-is name="user.agent" value="gecko1_8" />
- <when-property-is name="user.agent" value="gecko" />
- </any>
- </replace-with>
-
- <!-- Safari-specific implementation -->
- <replace-with
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImplSafari">
- <when-type-is
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
- <any>
- <when-property-is name="user.agent" value="safari" />
- </any>
- </replace-with>
-
- <!-- Opera-specific implementation -->
- <replace-with
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImplOpera">
- <when-type-is
- class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
- <any>
- <when-property-is name="user.agent" value="opera" />
- </any>
- </replace-with>
-</module>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<!-- Deferred binding rules for browser selection. -->
+<!-- -->
+<module>
+ <inherits name="com.google.gwt.core.Core" />
+ <inherits name="com.google.gwt.user.UserAgent" />
+ <inherits name="com.google.gwt.i18n.I18N" />
+
+ <!-- IE-specific implementation -->
+ <replace-with
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImplIE6">
+ <when-type-is
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
+ <when-property-is name="user.agent" value="ie6" />
+ </replace-with>
+
+ <!-- Mozilla-specific implementation -->
+ <replace-with
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImplMozilla">
+ <when-type-is
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
+ <any>
+ <when-property-is name="user.agent" value="gecko1_8" />
+ <when-property-is name="user.agent" value="gecko" />
+ </any>
+ </replace-with>
+
+ <!-- Safari-specific implementation -->
+ <replace-with
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImplSafari">
+ <when-type-is
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
+ <any>
+ <when-property-is name="user.agent" value="safari" />
+ </any>
+ </replace-with>
+
+ <!-- Opera-specific implementation -->
+ <replace-with
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImplOpera">
+ <when-type-is
+ class="com.google.gwt.user.client.ui.impl.RichTextAreaImpl" />
+ <any>
+ <when-property-is name="user.agent" value="opera" />
+ </any>
+ </replace-with>
+</module>
diff --git a/user/src/com/google/gwt/user/client/impl/HistoryImplFrame.java b/user/src/com/google/gwt/user/client/impl/HistoryImplFrame.java
index 48e9a65..fcde40b 100644
--- a/user/src/com/google/gwt/user/client/impl/HistoryImplFrame.java
+++ b/user/src/com/google/gwt/user/client/impl/HistoryImplFrame.java
@@ -1,77 +1,77 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.user.client.impl;
-
-import com.google.gwt.user.client.Element;
-
-/**
- * An IFRAME implementation of
- * {@link com.google.gwt.user.client.impl.HistoryImpl}.
- */
-abstract class HistoryImplFrame extends HistoryImpl {
-
- private static native Element findHistoryFrame() /*-{
- var historyFrame = $doc.getElementById('__gwt_historyFrame');
- return historyFrame || null;
- }-*/;
-
- private static native Element getTokenElement(Element historyFrame) /*-{
- // Initialize the history iframe. If '__gwt_historyToken' already exists, then
- // we're probably backing into the app, so _don't_ set the iframe's location.
- var tokenElement = null;
- if (historyFrame.contentWindow) {
- var doc = historyFrame.contentWindow.document;
- tokenElement = doc.getElementById('__gwt_historyToken') || null;
- }
- return tokenElement;
- }-*/;
-
- private Element historyFrame;
-
- public boolean init() {
- historyFrame = findHistoryFrame();
- if (historyFrame == null) {
- return false;
- }
-
- initHistoryToken();
-
- // Initialize the history iframe. If a token element already exists, then
- // we're probably backing into the app, so _don't_ create a new item.
- Element tokenElement = getTokenElement(historyFrame);
- if (tokenElement != null) {
- setToken(getTokenElementContent(tokenElement));
- } else {
- newItemImpl(historyFrame, getToken(), true);
- }
-
- injectGlobalHandler();
- return true;
- }
-
- public void newItem(String historyToken) {
- newItemImpl(historyFrame, historyToken, false);
- }
-
- protected abstract String getTokenElementContent(Element tokenElement);
-
- protected abstract void initHistoryToken();
-
- protected abstract void injectGlobalHandler();
-
- protected abstract void newItemImpl(Element historyFrame,
- String historyToken, boolean forceAdd);
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.impl;
+
+import com.google.gwt.user.client.Element;
+
+/**
+ * An IFRAME implementation of
+ * {@link com.google.gwt.user.client.impl.HistoryImpl}.
+ */
+abstract class HistoryImplFrame extends HistoryImpl {
+
+ private static native Element findHistoryFrame() /*-{
+ var historyFrame = $doc.getElementById('__gwt_historyFrame');
+ return historyFrame || null;
+ }-*/;
+
+ private static native Element getTokenElement(Element historyFrame) /*-{
+ // Initialize the history iframe. If '__gwt_historyToken' already exists, then
+ // we're probably backing into the app, so _don't_ set the iframe's location.
+ var tokenElement = null;
+ if (historyFrame.contentWindow) {
+ var doc = historyFrame.contentWindow.document;
+ tokenElement = doc.getElementById('__gwt_historyToken') || null;
+ }
+ return tokenElement;
+ }-*/;
+
+ private Element historyFrame;
+
+ public boolean init() {
+ historyFrame = findHistoryFrame();
+ if (historyFrame == null) {
+ return false;
+ }
+
+ initHistoryToken();
+
+ // Initialize the history iframe. If a token element already exists, then
+ // we're probably backing into the app, so _don't_ create a new item.
+ Element tokenElement = getTokenElement(historyFrame);
+ if (tokenElement != null) {
+ setToken(getTokenElementContent(tokenElement));
+ } else {
+ newItemImpl(historyFrame, getToken(), true);
+ }
+
+ injectGlobalHandler();
+ return true;
+ }
+
+ public void newItem(String historyToken) {
+ newItemImpl(historyFrame, historyToken, false);
+ }
+
+ protected abstract String getTokenElementContent(Element tokenElement);
+
+ protected abstract void initHistoryToken();
+
+ protected abstract void injectGlobalHandler();
+
+ protected abstract void newItemImpl(Element historyFrame,
+ String historyToken, boolean forceAdd);
+}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/FocusImplIE6.java b/user/src/com/google/gwt/user/client/ui/impl/FocusImplIE6.java
index 88c58d8..721d535 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/FocusImplIE6.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/FocusImplIE6.java
@@ -1,38 +1,38 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.user.client.ui.impl;
-
-import com.google.gwt.user.client.Element;
-
-/**
- * Implementation of {@link com.google.gwt.user.client.ui.impl.FocusImpl}
- * for IE that traps invalid focus attempts to match other browsers.
- */
-public class FocusImplIE6 extends FocusImpl {
-
- public native void focus(Element elem) /*-{
- try {
- elem.focus();
- } catch (e) {
- // Only trap the exception if the attempt was mostly legit
- if (!elem || !elem.focus) {
- // Rethrow the probable NPE or invalid type
- throw e;
- }
- }
- }-*/;
-
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.ui.impl;
+
+import com.google.gwt.user.client.Element;
+
+/**
+ * Implementation of {@link com.google.gwt.user.client.ui.impl.FocusImpl}
+ * for IE that traps invalid focus attempts to match other browsers.
+ */
+public class FocusImplIE6 extends FocusImpl {
+
+ public native void focus(Element elem) /*-{
+ try {
+ elem.focus();
+ } catch (e) {
+ // Only trap the exception if the attempt was mostly legit
+ if (!elem || !elem.focus) {
+ // Rethrow the probable NPE or invalid type
+ throw e;
+ }
+ }
+ }-*/;
+
+}
diff --git a/user/test/com/google/gwt/i18n/I18NTest_de.gwt.xml b/user/test/com/google/gwt/i18n/I18NTest_de.gwt.xml
index 90179ab..ffd4da5 100644
--- a/user/test/com/google/gwt/i18n/I18NTest_de.gwt.xml
+++ b/user/test/com/google/gwt/i18n/I18NTest_de.gwt.xml
@@ -1,23 +1,23 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<module>
- <!-- Inherit the JUnit support -->
- <inherits name='com.google.gwt.junit.JUnit'/>
- <inherits name = 'com.google.gwt.i18n.I18N'/>
- <!-- Include client-side source for the test cases -->
- <source path="client"/>
- <extend-property name="locale" values="de"/>
- <set-property name = "locale" value = "de"/>
-</module>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<module>
+ <!-- Inherit the JUnit support -->
+ <inherits name='com.google.gwt.junit.JUnit'/>
+ <inherits name = 'com.google.gwt.i18n.I18N'/>
+ <!-- Include client-side source for the test cases -->
+ <source path="client"/>
+ <extend-property name="locale" values="de"/>
+ <set-property name = "locale" value = "de"/>
+</module>
diff --git a/user/test/com/google/gwt/i18n/I18NTest_zh_CN.gwt.xml b/user/test/com/google/gwt/i18n/I18NTest_zh_CN.gwt.xml
index 5dc44f1..b6b7fb9 100644
--- a/user/test/com/google/gwt/i18n/I18NTest_zh_CN.gwt.xml
+++ b/user/test/com/google/gwt/i18n/I18NTest_zh_CN.gwt.xml
@@ -1,23 +1,23 @@
-<!-- -->
-<!-- Copyright 2007 Google Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
-<!-- may not use this file except in compliance with the License. You may -->
-<!-- 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. License for the specific language governing permissions and -->
-<!-- limitations under the License. -->
-
-<module>
- <!-- Inherit the JUnit support -->
- <inherits name='com.google.gwt.junit.JUnit'/>
- <inherits name = 'com.google.gwt.i18n.I18N'/>
- <!-- Include client-side source for the test cases -->
- <source path="client"/>
- <extend-property name="locale" values="zh_CN"/>
- <set-property name = "locale" value = "zh_CN"/>
-</module>
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<module>
+ <!-- Inherit the JUnit support -->
+ <inherits name='com.google.gwt.junit.JUnit'/>
+ <inherits name = 'com.google.gwt.i18n.I18N'/>
+ <!-- Include client-side source for the test cases -->
+ <source path="client"/>
+ <extend-property name="locale" values="zh_CN"/>
+ <set-property name = "locale" value = "zh_CN"/>
+</module>
diff --git a/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtype.java b/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtype.java
index 52fecd2..8ca1261 100644
--- a/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtype.java
+++ b/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtype.java
@@ -1,24 +1,24 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.user.client.rpc;
-
-/**
- */
-public interface InheritanceTestServiceSubtype extends InheritanceTestService {
- /**
- */
- void foo();
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.rpc;
+
+/**
+ */
+public interface InheritanceTestServiceSubtype extends InheritanceTestService {
+ /**
+ */
+ void foo();
+}
diff --git a/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtypeAsync.java b/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtypeAsync.java
index b377218..4757406 100644
--- a/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtypeAsync.java
+++ b/user/test/com/google/gwt/user/client/rpc/InheritanceTestServiceSubtypeAsync.java
@@ -1,24 +1,24 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.user.client.rpc;
-
-/**
- *
- */
-public interface InheritanceTestServiceSubtypeAsync extends
- InheritanceTestServiceAsync {
- public void foo(AsyncCallback callback);
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.rpc;
+
+/**
+ *
+ */
+public interface InheritanceTestServiceSubtypeAsync extends
+ InheritanceTestServiceAsync {
+ public void foo(AsyncCallback callback);
+}
diff --git a/user/test/com/google/gwt/user/client/ui/UIObjectTest.java b/user/test/com/google/gwt/user/client/ui/UIObjectTest.java
index febc9d7..f6f4c7e 100644
--- a/user/test/com/google/gwt/user/client/ui/UIObjectTest.java
+++ b/user/test/com/google/gwt/user/client/ui/UIObjectTest.java
@@ -1,180 +1,180 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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 com.google.gwt.user.client.ui;
-
-import com.google.gwt.junit.client.GWTTestCase;
-import com.google.gwt.user.client.DOM;
-
-/**
- * Tests UIObject. Currently, focuses on style name behaviors.
- */
-public class UIObjectTest extends GWTTestCase {
-
- public String getModuleName() {
- return "com.google.gwt.user.User";
- }
-
- static class MyObject extends UIObject {
- MyObject() {
- setElement(DOM.createDiv());
- }
- }
-
- public void testEmpty() {
- MyObject o = new MyObject();
-
- assertEquals("gwt-nostyle", o.getStyleName());
- doStuff(o);
- assertEquals("gwt-nostyle", o.getStyleName());
- }
-
- public void testNormal() {
- // Test the basic set/get case.
- MyObject o = new MyObject();
-
- o.setStyleName("baseStyle");
-
- assertEquals("baseStyle", o.getStyleName());
- doStuff(o);
- assertEquals("baseStyle", o.getStyleName());
- }
-
- public void testAddStyleBeforeSet() {
- MyObject o = new MyObject();
-
- // Test that adding a style name before calling setStyleName() causes the
- // gwt-nostyle class to get added.
- o.addStyleName("userStyle");
- assertStartsWithClass(o, "gwt-nostyle");
- assertContainsClass(o, "userStyle");
- o.removeStyleName("userStyle");
- assertDoesNotContainClass(o, "userStyle");
-
- // getStyleName() should still be "gwt-nostyle".
- assertEquals("gwt-nostyle", o.getStyleName());
-
- doStuff(o);
-
- assertStartsWithClass(o, "gwt-nostyle");
- assertEquals("gwt-nostyle", o.getStyleName());
- }
-
- public void testAddAndRemoveEmptyStyleName() {
- MyObject o = new MyObject();
-
- o.setStyleName("base");
- try {
- o.addStyleName("");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
-
- try {
- o.addStyleName(" ");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
-
- try {
- o.removeStyleName("");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
-
- try {
- o.removeStyleName(" ");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
-
- assertEquals("base", o.getStyleName());
- }
-
- public void testSetEmptyBaseStyleName() {
- MyObject o = new MyObject();
- try {
- o.setStyleName("");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
-
- try {
- o.setStyleName(" ");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
- }
-
- public void testRemoveBaseStyleName() {
- MyObject o = new MyObject();
- o.setStyleName("base");
-
- try {
- o.removeStyleName("base");
- fail();
- } catch (IllegalArgumentException e) {
- // This *should* throw.
- }
- }
-
- // doStuff() should leave MyObject's style in the same state it started in.
- private void doStuff(MyObject o) {
- // Test that the base style remains the first class, and that the dependent
- // style shows up.
- o.addStyleName(o.getStyleName() + "-dependent");
- assertContainsClass(o, o.getStyleName() + "-dependent");
-
- String oldBaseStyle = o.getStyleName();
-
- // Test that replacing the base style name works (and doesn't munge up the
- // user style).
- o.addStyleName("userStyle");
- o.setStyleName("newBaseStyle");
-
- assertEquals("newBaseStyle", o.getStyleName());
- assertStartsWithClass(o, "newBaseStyle");
- assertContainsClass(o, "newBaseStyle-dependent");
- assertContainsClass(o, "userStyle");
- assertDoesNotContainClass(o, oldBaseStyle);
- assertDoesNotContainClass(o, oldBaseStyle + "-dependent");
-
- // Clean up & return.
- o.setStyleName(oldBaseStyle);
- o.removeStyleName(oldBaseStyle + "-dependent");
- o.removeStyleName("userStyle");
- }
-
- private void assertContainsClass(UIObject o, String className) {
- String attr = DOM.getElementProperty(o.getElement(), "className");
- assertTrue(attr.indexOf(className) != -1);
- }
-
- private void assertDoesNotContainClass(UIObject o, String className) {
- String attr = DOM.getElementProperty(o.getElement(), "className");
- assertTrue(attr.indexOf(className) == -1);
- }
-
- private void assertStartsWithClass(UIObject o, String className) {
- String attr = DOM.getElementProperty(o.getElement(), "className");
- assertTrue(attr.indexOf(className) == 0);
- }
-}
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.user.client.ui;
+
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.user.client.DOM;
+
+/**
+ * Tests UIObject. Currently, focuses on style name behaviors.
+ */
+public class UIObjectTest extends GWTTestCase {
+
+ public String getModuleName() {
+ return "com.google.gwt.user.User";
+ }
+
+ static class MyObject extends UIObject {
+ MyObject() {
+ setElement(DOM.createDiv());
+ }
+ }
+
+ public void testEmpty() {
+ MyObject o = new MyObject();
+
+ assertEquals("gwt-nostyle", o.getStyleName());
+ doStuff(o);
+ assertEquals("gwt-nostyle", o.getStyleName());
+ }
+
+ public void testNormal() {
+ // Test the basic set/get case.
+ MyObject o = new MyObject();
+
+ o.setStyleName("baseStyle");
+
+ assertEquals("baseStyle", o.getStyleName());
+ doStuff(o);
+ assertEquals("baseStyle", o.getStyleName());
+ }
+
+ public void testAddStyleBeforeSet() {
+ MyObject o = new MyObject();
+
+ // Test that adding a style name before calling setStyleName() causes the
+ // gwt-nostyle class to get added.
+ o.addStyleName("userStyle");
+ assertStartsWithClass(o, "gwt-nostyle");
+ assertContainsClass(o, "userStyle");
+ o.removeStyleName("userStyle");
+ assertDoesNotContainClass(o, "userStyle");
+
+ // getStyleName() should still be "gwt-nostyle".
+ assertEquals("gwt-nostyle", o.getStyleName());
+
+ doStuff(o);
+
+ assertStartsWithClass(o, "gwt-nostyle");
+ assertEquals("gwt-nostyle", o.getStyleName());
+ }
+
+ public void testAddAndRemoveEmptyStyleName() {
+ MyObject o = new MyObject();
+
+ o.setStyleName("base");
+ try {
+ o.addStyleName("");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+
+ try {
+ o.addStyleName(" ");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+
+ try {
+ o.removeStyleName("");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+
+ try {
+ o.removeStyleName(" ");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+
+ assertEquals("base", o.getStyleName());
+ }
+
+ public void testSetEmptyBaseStyleName() {
+ MyObject o = new MyObject();
+ try {
+ o.setStyleName("");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+
+ try {
+ o.setStyleName(" ");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+ }
+
+ public void testRemoveBaseStyleName() {
+ MyObject o = new MyObject();
+ o.setStyleName("base");
+
+ try {
+ o.removeStyleName("base");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // This *should* throw.
+ }
+ }
+
+ // doStuff() should leave MyObject's style in the same state it started in.
+ private void doStuff(MyObject o) {
+ // Test that the base style remains the first class, and that the dependent
+ // style shows up.
+ o.addStyleName(o.getStyleName() + "-dependent");
+ assertContainsClass(o, o.getStyleName() + "-dependent");
+
+ String oldBaseStyle = o.getStyleName();
+
+ // Test that replacing the base style name works (and doesn't munge up the
+ // user style).
+ o.addStyleName("userStyle");
+ o.setStyleName("newBaseStyle");
+
+ assertEquals("newBaseStyle", o.getStyleName());
+ assertStartsWithClass(o, "newBaseStyle");
+ assertContainsClass(o, "newBaseStyle-dependent");
+ assertContainsClass(o, "userStyle");
+ assertDoesNotContainClass(o, oldBaseStyle);
+ assertDoesNotContainClass(o, oldBaseStyle + "-dependent");
+
+ // Clean up & return.
+ o.setStyleName(oldBaseStyle);
+ o.removeStyleName(oldBaseStyle + "-dependent");
+ o.removeStyleName("userStyle");
+ }
+
+ private void assertContainsClass(UIObject o, String className) {
+ String attr = DOM.getElementProperty(o.getElement(), "className");
+ assertTrue(attr.indexOf(className) != -1);
+ }
+
+ private void assertDoesNotContainClass(UIObject o, String className) {
+ String attr = DOM.getElementProperty(o.getElement(), "className");
+ assertTrue(attr.indexOf(className) == -1);
+ }
+
+ private void assertStartsWithClass(UIObject o, String className) {
+ String attr = DOM.getElementProperty(o.getElement(), "className");
+ assertTrue(attr.indexOf(className) == 0);
+ }
+}