our algorithm can't deal with recursive prefixes. that's not a huge
problem though since ANTLR uses LL(*) which can't deal with these
constructs either.
solution for the moment: if the minimal path difference analysis errors
out check if more than 2 path are recursive. if so, throw an exception
possible improvement for later: just consider predicates and not tokens
- similar to ANTLR which falls back to LL(1)
use path in grammar as key for caching elements; using the elements
itself doesn't work because the reference will be different for the
content assist grammar run.
this does not work for generated elements; the only place that generated
elements are necessary is when dealing with nested identical paths, in
this case caching is disabled.
the benchmark test case does not validate the result since we are only
interested in the runtime.
- added test case of recursive rules (with start rule) and optional
context
- disable cardinalities (and repetitions in unordered groups) in context
analysis if the current element was already seen and there was no
progress this recursion - the element itself will not be returned by
getNextElementsInContext()
- changed isStartRule() and findAllRuleCalls() in GrammarUtils to only
compare the name of the rule. otherwise constructed paths cause problems
(since the rule object is not the same and the alternatives-attribute
might (very probably) not be equal in the constructed rule object).
- changed findGuardForOptionalCardinalityWithoutContext() in
HoistingProcessor to avoid the construction of virtual elements and
instead provide the virtual cardinality to the token analysis via a new
parameter.
- fixed testCardinalityQuestionmarkWithExternalContext_expectContextCheck()
test case (context analysis is not possible if the context equals the
remainder of the prefixed alternative; changed context to be different)
nested prefix alternatives analysis
now flattenPaths() considers following repetitions
new problem: unordered groups and non-trivial cardinalities without
non-optional elements causes explosion of generated alternatives, which
in turn cause the identity analysis to go out of control
example: S: ('a'? | 'b'?)+
with a token limit of 10 the nested prefix alternatives analysis would
generate over 1300 alternatives
current quick fix: limit of alternatives
after minimal path difference analysis failed, flatten paths (limited by
token limit; justification: identity check would error out if paths are
not distinguishable within the limit) and recompute alternative guard.
now nested prefixes will be collapsed with all corresponding guard
conditions
This change introduces an explicit validation context that is used by the INamesAreUniqueValidationHelper. This allows to fine tune the scope of the validation in various ways. Default contexts are available to validation uniqueness in the current container, along the chain of visible containers or local to the current resource (the default).
Local unique name validation can be implemented now based on the LocalUniqueNameContext.
closes#1466
- Modify the FormattingConfigBasedStream to handle the different line
endings properly.
- Implement corresponding XtextFormatterTest and
GrammarAccessExtensions2Test test cases.
Signed-off-by: Tamas Miklossy <miklossy@itemis.de>
- Improve the serializeReplacement implementation by modifying the
ReplaceRegion length calculation so that it takes not only the
ICompositeNode.getTotalLength() into account, but considers if the new
text contains additional whitespaces and the old text is also followed
by white spaces, than the whitespaces contained by the original document
is also consumed by the quickfix.
- Implement corresponding SerializerReplacementCalculationTest test case
based on the NoJdtTestLanguage.
Signed-off-by: Tamas Miklossy <miklossy@itemis.de>
Don't call a value converter if nothing was matched. Also don't assign naively true for boolean values without checking if there was a token consumed.
closes#1462