Java 类org.eclipse.xtext.formatting2.regionaccess.ISemanticRegionsFinder 实例源码

项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForFeatureContainmentReference() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo) action");
  final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  try {
    finder.feature(RegionaccesstestlanguagePackage.Literals.ASSIGNED_ACTION__CHILD);
    Assert.fail();
  } catch (final Throwable _t) {
    if (_t instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  try {
    finder.features(RegionaccesstestlanguagePackage.Literals.ASSIGNED_ACTION__CHILD);
    Assert.fail();
  } catch (final Throwable _t_1) {
    if (_t_1 instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t_1);
    }
  }
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallEObjectParserRule() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (child (foo))");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  try {
    finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getEobjMixedParserRuleCall_2_2_1_1_0());
    Assert.fail();
  } catch (final Throwable _t) {
    if (_t instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  try {
    finder.ruleCalls(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getEobjMixedParserRuleCall_2_2_1_1_0());
    Assert.fail();
  } catch (final Throwable _t_1) {
    if (_t_1 instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t_1);
    }
  }
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToEObjectParserRule() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (child (foo))");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  try {
    finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule());
    Assert.fail();
  } catch (final Throwable _t) {
    if (_t instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  try {
    finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getMixedRule());
    Assert.fail();
  } catch (final Throwable _t_1) {
    if (_t_1 instanceof IllegalStateException) {
    } else {
      throw Exceptions.sneakyThrow(_t_1);
    }
  }
}
项目:xtext-core    文件:AbstractRegionAccess.java   
@Override
public ISemanticRegionsFinder allRegionsFor(EObject object) {
    AbstractEObjectRegion region = regionForEObject(object);
    if (region == null)
        return SemanticRegionNullFinder.INSTANCE;
    return region.getAllRegionsFor();
}
项目:xtext-core    文件:AbstractRegionAccess.java   
@Override
public ISemanticRegionsFinder regionFor(EObject object) {
    AbstractEObjectRegion region = regionForEObject(object);
    if (region != null)
        return region.getRegionFor();
    else
        return SemanticRegionNullFinder.INSTANCE;
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForFeatureAttribute() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.feature(RegionaccesstestlanguagePackage.Literals.MIXED__NAME);
  final List<ISemanticRegion> actuals = finder.features(RegionaccesstestlanguagePackage.Literals.MIXED__NAME);
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallUnassignedTerminal() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (unassigned foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getIDTerminalRuleCall_1_1_0());
  final List<ISemanticRegion> actuals = finder.ruleCalls(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getIDTerminalRuleCall_1_1_0());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToUnassignedTerminal() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (unassigned foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  final List<ISemanticRegion> actuals = finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallUnassignedDataType() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (unassigned datatype foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeParserRuleCall_1_1_1());
  final List<ISemanticRegion> actuals = finder.ruleCalls(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeParserRuleCall_1_1_1());
  this.assertEquals("datatype foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToUnassignedDataType() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (unassigned datatype foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getDatatypeRule());
  final List<ISemanticRegion> actuals = finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getDatatypeRule());
  this.assertEquals("datatype foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallAssignedTerminal() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameIDTerminalRuleCall_2_2_0_0());
  final ISemanticRegion actuals = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameIDTerminalRuleCall_2_2_0_0());
  Assert.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToAssignedTerminal() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  final ISemanticRegion actuals = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  Assert.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallAssignedDataType() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (datatype foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeDatatypeParserRuleCall_2_2_2_0());
  final ISemanticRegion actuals = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getDatatypeDatatypeParserRuleCall_2_2_2_0());
  Assert.assertEquals("datatype foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToAssignedDataType() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (datatype foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getDatatypeRule());
  final ISemanticRegion actuals = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getDatatypeRule());
  Assert.assertEquals("datatype foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallCrossReference() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (ref foo) action (foo) end");
  final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
  final ISemanticRegion actual = finder.ruleCall(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
  final List<ISemanticRegion> actuals = finder.ruleCalls(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedIDTerminalRuleCall_2_2_3_1_0_1());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForRuleCallToCrossReference() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (ref foo) action (foo) end");
  final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
  final ISemanticRegion actual = finder.ruleCallTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  final List<ISemanticRegion> actuals = finder.ruleCallsTo(this._regionAccessTestLanguageGrammarAccess.getIDRule());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForKeywordString() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.keyword("(");
  final List<ISemanticRegion> actuals = finder.keywords("(");
  this.assertEquals("(", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForKeyword() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.keyword(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getLeftParenthesisKeyword_0());
  final List<ISemanticRegion> actuals = finder.keywords(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getLeftParenthesisKeyword_0());
  this.assertEquals("(", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForCrossReference() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (ref foo) action (foo) end");
  final AssignedAction mixed = this.<AssignedAction>parseAs(_builder, AssignedAction.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed.getChild()).getRegionFor();
  final ISemanticRegion actual = finder.crossRef(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedCrossReference_2_2_3_1_0());
  final List<ISemanticRegion> actuals = finder.crossRefs(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getRefMixedCrossReference_2_2_3_1_0());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForAssignment() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("6 (foo)");
  final Mixed mixed = this.<Mixed>parseAs(_builder, Mixed.class);
  final ISemanticRegionsFinder finder = this.toAccess(mixed).regionForEObject(mixed).getRegionFor();
  final ISemanticRegion actual = finder.assignment(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameAssignment_2_2_0());
  final List<ISemanticRegion> actuals = finder.assignments(this._regionAccessTestLanguageGrammarAccess.getMixedAccess().getNameAssignment_2_2_0());
  this.assertEquals("foo", actual, actuals);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForKeywordPairs() {
  @Extension
  final RegionAccessTestLanguageGrammarAccess.ParenthesizedElements rule = this._regionAccessTestLanguageGrammarAccess.getParenthesizedAccess();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("5 (foo)");
  final Expression expr = this.<Expression>parseAs(_builder, Expression.class);
  final ISemanticRegionsFinder finder = this.toAccess(expr).regionForEObject(expr).getRegionFor();
  final String actual1 = this.pairsToString(finder.keywordPairs("(", ")"));
  final String actual2 = this.pairsToString(finder.keywordPairs(rule.getLeftParenthesisKeyword_0(), rule.getRightParenthesisKeyword_2()));
  final String expected = "(foo)";
  Assert.assertEquals(expected, actual1);
  Assert.assertEquals(expected, actual2);
}
项目:xtext-core    文件:SemanticRegionFinderTest.java   
@Test
public void regionForKeywordPairs2() {
  @Extension
  final RegionAccessTestLanguageGrammarAccess.ParenthesizedElements rule = this._regionAccessTestLanguageGrammarAccess.getParenthesizedAccess();
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("5 (a + ((b) + c) + d)");
  final Expression expr = this.<Expression>parseAs(_builder, Expression.class);
  final ISemanticRegionsFinder finder = this.toAccess(expr).regionForRootEObject().getAllRegionsFor();
  final String actual1 = this.pairsToString(finder.keywordPairs("(", ")"));
  final String actual2 = this.pairsToString(finder.keywordPairs(rule.getLeftParenthesisKeyword_0(), rule.getRightParenthesisKeyword_2()));
  final String expected = "(b); ((b) + c); (a + ((b) + c) + d)";
  Assert.assertEquals(expected, actual1);
  Assert.assertEquals(expected, actual2);
}
项目:xtext-gef    文件:StatemachineFormatter.java   
protected void _format(final StatePropertyExpression expression, @Extension final IFormattableDocument document) {
  ISemanticRegionsFinder _regionFor = this.textRegionExtensions.regionFor(expression);
  ISemanticRegion _keyword = _regionFor.keyword(".");
  final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
    @Override
    public void apply(final IHiddenRegionFormatter it) {
      it.noSpace();
    }
  };
  document.surround(_keyword, _function);
}
项目:xtext-core    文件:AbstractEObjectRegion.java   
@Override
public ISemanticRegionsFinder getAllRegionsFor() {
    return new SemanticRegionInIterableFinder(getAllSemanticRegions());
}
项目:xtext-core    文件:AbstractEObjectRegion.java   
@Override
public ISemanticRegionsFinder getRegionFor() {
    return new SemanticRegionInIterableFinder(getSemanticRegions());
}