• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java AliasTransformation类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.google.javascript.jscomp.CompilerOptions.AliasTransformation的典型用法代码示例。如果您正苦于以下问题:Java AliasTransformation类的具体用法?Java AliasTransformation怎么用?Java AliasTransformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

AliasTransformation类属于com.google.javascript.jscomp.CompilerOptions包,在下文中一共展示了AliasTransformation类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSourceRegion

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
private SourcePosition<AliasTransformation> getSourceRegion(Node n) {
  Node testNode = n;
  Node next = null;
  for (; next != null || testNode.isScript();) {
    next = testNode.getNext();
    testNode = testNode.getParent();
  }

  int endLine = next == null ? Integer.MAX_VALUE : next.getLineno();
  int endChar = next == null ? Integer.MAX_VALUE : next.getCharno();
  SourcePosition<AliasTransformation> pos =
      new SourcePosition<AliasTransformation>() {};
  pos.setPositionInformation(
      n.getLineno(), n.getCharno(), endLine, endChar);
  return pos;
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:17,
代码来源:ScopedAliases.java

示例2: testRecordOneAlias

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordOneAlias() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g = goog;\n g.dom.createElement(g.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertTrue(spy.observedPositions.containsKey("testcode"));
  List<SourcePosition<AliasTransformation>> positions =
      spy.observedPositions.get("testcode");
  assertEquals(1, positions.size());
  verifyAliasTransformationPosition(1, 0, 2, 1, positions.get(0));

  assertEquals(1, spy.constructedAliases.size());
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertEquals("goog", aliasSpy.observedDefinitions.get("g"));
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:21,
代码来源:ScopedAliasesTest.java

示例3: testRecordMultipleAliases

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordMultipleAliases() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g = goog;\n var b= g.bar;\n var f = goog.something.foo;"
      + "g.dom.createElement(g.dom.TagName.DIV);\n b.foo();"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode =
      "goog.dom.createElement(goog.dom.TagName.DIV);\n goog.bar.foo();";
  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertTrue(spy.observedPositions.containsKey("testcode"));
  List<SourcePosition<AliasTransformation>> positions =
      spy.observedPositions.get("testcode");
  assertEquals(1, positions.size());
  verifyAliasTransformationPosition(1, 0, 3, 1, positions.get(0));

  assertEquals(1, spy.constructedAliases.size());
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertEquals("goog", aliasSpy.observedDefinitions.get("g"));
  assertEquals("g.bar", aliasSpy.observedDefinitions.get("b"));
  assertEquals("goog.something.foo", aliasSpy.observedDefinitions.get("f"));
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:24,
代码来源:ScopedAliasesTest.java

示例4: testRecordOneAlias

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordOneAlias() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g = goog;\n g.dom.createElement(g.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertThat(spy.observedPositions).containsKey("testcode");
  List<SourcePosition<AliasTransformation>> positions = spy.observedPositions.get("testcode");
  assertThat(positions).hasSize(1);
  verifyAliasTransformationPosition(1, 0, 2, 1, positions.get(0));

  assertThat(spy.constructedAliases).hasSize(1);
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertThat(aliasSpy.observedDefinitions).containsEntry("g", "goog");
}
 

开发者ID:google,
项目名称:closure-compiler,
代码行数:20,
代码来源:ScopedAliasesTest.java

示例5: testRecordOneAlias2

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordOneAlias2() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g$1 = goog;\n g$1.dom.createElement(g$1.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertThat(spy.observedPositions).containsKey("testcode");
  List<SourcePosition<AliasTransformation>> positions = spy.observedPositions.get("testcode");
  assertThat(positions).hasSize(1);
  verifyAliasTransformationPosition(1, 0, 2, 1, positions.get(0));

  assertThat(spy.constructedAliases).hasSize(1);
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertThat(aliasSpy.observedDefinitions).containsEntry("g$1", "goog");
}
 

开发者ID:google,
项目名称:closure-compiler,
代码行数:20,
代码来源:ScopedAliasesTest.java

示例6: testRecordMultipleAliases

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordMultipleAliases() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g = goog;\n var b= g.bar;\n var f = goog.something.foo;"
      + "g.dom.createElement(g.dom.TagName.DIV);\n b.foo();"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode =
      "goog.dom.createElement(goog.dom.TagName.DIV);\n goog.bar.foo();";
  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertThat(spy.observedPositions).containsKey("testcode");
  List<SourcePosition<AliasTransformation>> positions = spy.observedPositions.get("testcode");
  assertThat(positions).hasSize(1);
  verifyAliasTransformationPosition(1, 0, 3, 1, positions.get(0));

  assertThat(spy.constructedAliases).hasSize(1);
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertThat(aliasSpy.observedDefinitions).containsEntry("g", "goog");
  assertThat(aliasSpy.observedDefinitions).containsEntry("b", "g.bar");
  assertThat(aliasSpy.observedDefinitions).containsEntry("f", "goog.something.foo");
}
 

开发者ID:google,
项目名称:closure-compiler,
代码行数:23,
代码来源:ScopedAliasesTest.java

示例7: testRecordOneAlias2

点赞 3

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordOneAlias2() {
  String fullJsCode = GOOG_SCOPE_START_BLOCK
      + "var g$1 = goog;\n g$1.dom.createElement(g$1.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);

  assertTrue(spy.observedPositions.containsKey("testcode"));
  List<SourcePosition<AliasTransformation>> positions =
      spy.observedPositions.get("testcode");
  assertEquals(1, positions.size());
  verifyAliasTransformationPosition(1, 0, 2, 1, positions.get(0));

  assertEquals(1, spy.constructedAliases.size());
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertEquals("goog", aliasSpy.observedDefinitions.get("g$1"));
}
 

开发者ID:nicks,
项目名称:closure-compiler-old,
代码行数:21,
代码来源:ScopedAliasesTest.java

示例8: testRecordAliasFromMultipleGoogScope

点赞 2

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordAliasFromMultipleGoogScope() {
  String firstGoogScopeBlock = GOOG_SCOPE_START_BLOCK
      + "\n var g = goog;\n g.dom.createElement(g.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String fullJsCode = firstGoogScopeBlock + "\n\nvar l = abc.def;\n\n"
      + GOOG_SCOPE_START_BLOCK
      + "\n var z = namespace.Zoo;\n z.getAnimals(l);\n"
      + GOOG_SCOPE_END_BLOCK;

  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n"
      + "\n\nvar l = abc.def;\n\n" + "\n namespace.Zoo.getAnimals(l);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);


  assertTrue(spy.observedPositions.containsKey("testcode"));
  List<SourcePosition<AliasTransformation>> positions =
      spy.observedPositions.get("testcode");
  assertEquals(2, positions.size());

  verifyAliasTransformationPosition(1, 0, 6, 0, positions.get(0));

  verifyAliasTransformationPosition(8, 0, 11, 4, positions.get(1));

  assertEquals(2, spy.constructedAliases.size());
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertEquals("goog", aliasSpy.observedDefinitions.get("g"));

  aliasSpy = (AliasSpy) spy.constructedAliases.get(1);
  assertEquals("namespace.Zoo", aliasSpy.observedDefinitions.get("z"));
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:34,
代码来源:ScopedAliasesTest.java

示例9: verifyAliasTransformationPosition

点赞 2

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
private void verifyAliasTransformationPosition(int startLine, int startChar,
    int endLine, int endChar, SourcePosition<AliasTransformation> pos) {
  assertEquals(startLine, pos.getStartLine());
  assertEquals(startChar, pos.getPositionOnStartLine());
  assertTrue(
      "expected endline >= " + endLine + ".  Found " + pos.getEndLine(),
      pos.getEndLine() >= endLine);
  assertTrue("expected endChar >= " + endChar + ".  Found "
      + pos.getPositionOnEndLine(), pos.getPositionOnEndLine() >= endChar);
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:11,
代码来源:ScopedAliasesTest.java

示例10: logAliasTransformation

点赞 2

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
@Override
public AliasTransformation logAliasTransformation(
    String sourceFile, SourcePosition<AliasTransformation> position) {
  if(!observedPositions.containsKey(sourceFile)) {
    observedPositions.put(sourceFile,
        Lists.<SourcePosition<AliasTransformation>> newArrayList());
  }
  observedPositions.get(sourceFile).add(position);
  AliasTransformation spy = new AliasSpy();
  constructedAliases.add(spy);
  return spy;
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:13,
代码来源:ScopedAliasesTest.java

示例11: testRecordAliasFromMultipleGoogScope

点赞 2

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
public void testRecordAliasFromMultipleGoogScope() {
  String firstGoogScopeBlock = GOOG_SCOPE_START_BLOCK
      + "\n var g = goog;\n g.dom.createElement(g.dom.TagName.DIV);\n"
      + GOOG_SCOPE_END_BLOCK;
  String fullJsCode = firstGoogScopeBlock + "\n\nvar l = abc.def;\n\n"
      + GOOG_SCOPE_START_BLOCK
      + "\n var z = namespace.Zoo;\n z.getAnimals(l);\n"
      + GOOG_SCOPE_END_BLOCK;

  String expectedJsCode = "goog.dom.createElement(goog.dom.TagName.DIV);\n"
      + "\n\nvar l = abc.def;\n\n" + "\n namespace.Zoo.getAnimals(l);\n";

  TransformationHandlerSpy spy = new TransformationHandlerSpy();
  transformationHandler = spy;
  test(fullJsCode, expectedJsCode);


  assertThat(spy.observedPositions).containsKey("testcode");
  List<SourcePosition<AliasTransformation>> positions = spy.observedPositions.get("testcode");
  assertThat(positions).hasSize(2);

  verifyAliasTransformationPosition(1, 0, 6, 0, positions.get(0));

  verifyAliasTransformationPosition(8, 0, 11, 4, positions.get(1));

  assertThat(spy.constructedAliases).hasSize(2);
  AliasSpy aliasSpy = (AliasSpy) spy.constructedAliases.get(0);
  assertThat(aliasSpy.observedDefinitions).containsEntry("g", "goog");

  aliasSpy = (AliasSpy) spy.constructedAliases.get(1);
  assertThat(aliasSpy.observedDefinitions).containsEntry("z", "namespace.Zoo");
}
 

开发者ID:google,
项目名称:closure-compiler,
代码行数:33,
代码来源:ScopedAliasesTest.java

示例12: logAliasTransformation

点赞 2

import com.google.javascript.jscomp.CompilerOptions.AliasTransformation; //导入依赖的package包/类
@Override
public AliasTransformation logAliasTransformation(
    String sourceFile, SourcePosition<AliasTransformation> position) {
  if (!observedPositions.containsKey(sourceFile)) {
    observedPositions.put(sourceFile,
         new ArrayList<SourcePosition<AliasTransformation>>());
  }
  observedPositions.get(sourceFile).add(position);
  AliasTransformation spy = new AliasSpy();
  constructedAliases.add(spy);
  return spy;
}
 

开发者ID:google,
项目名称:closure-compiler,
代码行数:13,
代码来源:ScopedAliasesTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)