Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314027 - [formatter/matcher] Support before/after indentation -> problem with matcher remaining
Summary: [formatter/matcher] Support before/after indentation -> problem with matcher ...
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-22 18:02 EDT by Ed Willink CLA
Modified: 2016-07-21 04:26 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2010-05-22 18:02:47 EDT
As in: http://www.eclipse.org/forums/index.php?t=msg&goto=528455&

please support the ability to specify before/after for indentation elements so that e.g in

keyword expression

a line break can be specified after "keyword"
indentation can be specified to start before "expression"
indentation can be specified to stop after "expression"

ensuring that a substantial "expression" appears indented.
Comment 1 Moritz Eysholdt CLA 2010-05-26 04:35:24 EDT
Fixed in head. You can now specify indentation as follows:

cfg.incrementIndentation().after(f.getXAccess().getLeftCurlyBracketKeyword_1());
cfg.decrementIndentation().before(f.getXAccess().getRightCurlyBracketKeyword_3());
Comment 2 Ed Willink CLA 2010-05-26 16:52:12 EDT
Wow, that was quick, unfortunately it doesn't work.

The following manually formatted CompleteOCL 

context Transaction
inv invariant_Transaction1 :
	self.oclIsKindOf(Transaction) = true
inv invariant_Transaction3 :
	self.oclIsTypeOf(Burning) = false
inv invariant_Transaction2 :
	self.oclIsTypeOf(Transaction) = true
inv invariant_Transaction4 :
	self.oclIsKindOf(Burning) = false

context Transaction::program() : LoyaltyProgram

reformats as

context Transaction

inv invariant_Transaction1:
	self.oclIsKindOf(Transaction) = true

	inv invariant_Transaction3:
		self.oclIsTypeOf(Burning) = false

		inv invariant_Transaction2:
			self.oclIsTypeOf(Transaction) = true

			inv invariant_Transaction4:
				self.oclIsKindOf(Burning) = false

never decrementing. The formatting is:

{
InvCSElements a = f.getInvCSAccess();
		    c.setLinewrap(2).before(a.getInvKeyword_0());
			setNoSpaceLineWrap(c, a.getColonKeyword_2());
		    c.setIndentationIncrement().before(a.getExpressionAssignment_3());
		    c.setIndentationDecrement().after(a.getExpressionAssignment_3());
//		    c.setLinewrap().after(a.getExpressionAssignment_3());
	    }
Comment 3 Moritz Eysholdt CLA 2010-05-27 03:40:16 EDT
Hi Ed, could you post the involved grammar rules?
Comment 4 Ed Willink CLA 2010-05-27 04:30:50 EDT
It's all in CVS at /org.eclipse.ocl.examples.xtext.completeocl/src/org/eclipse/ocl/examples/xtext/completeocl/CompleteOCL.xtext.

A build (generated with RC1) against Xtext RC2a is at https://build.eclipse.org/hudson/job/cbi-mdt-ocl-3.0/251/artifact/build/N201005261618/

I suspect that the salient challenges are that a.getExpressionAssignment_3()

is a complex rule which terminates with backtracking after exhaustion of options

is inherited from /org.eclipse.ocl.examples.xtext.essentialocl/src/org/eclipse/ocl/examples/xtext/essentialocl/EssentialOCL.xtext
Comment 5 Sven Efftinge CLA 2010-05-30 17:17:32 EDT
we won't be able to solve this during the RC phase.
Comment 6 Moritz Eysholdt CLA 2016-07-21 04:26:07 EDT
won't fix because it affects the old formatter infrastructure