[MonoDevelop] Re: Reformat source file

Jacob Ilsø Christensen jacobilsoe at gmail.com
Fri Jun 10 16:30:55 EDT 2005


I am not sure what you mean about interfaces...

And about formatting, I cannot see how it could be language
non-specific. Each language has its own contructs which need to be
structured differently.
Is it the visitor you would like to generalize?

/Jacob

On 6/10/05, Todd Berman <tberman at off.net> wrote:
> Just as a question, the only issue I see with this approach is the
> requirement of every parser to implement these interfaces so they can
> all use it.
> 
> I would like to see the formatting be as language non-specific as
> possible, at least in the implementation details.
> 
> What other pieces do you see requiring per-language implementations?
> 
> --Todd
> 
> On Fri, 2005-06-10 at 22:01 +0200, Jacob Ilsø Christensen wrote:
> > Hi.
> >
> > I have attached a first attempt of the reformat file functionality.
> > The file contains a visitor that will visit the AST of the file to be
> > formatted.
> > The output is a hashtable which contains line numbers as keys and for
> > each key the value is the level of indention.
> > >From the SourceEditorView this hashtable is used to traverse the
> > lines. If a line is represented in the hashtable it is TrimStart()'ed
> > and prefixed with the number of tabs specified for that line in the
> > hashtable.
> >
> > I tried it out on some sample source file and it works pretty well.
> > The visitor needs to be completed and some stuff on the parser needs
> > to be done too.
> >
> > Seems like the way to go?
> >
> > /Jacob
> >
> >
> >
> > On 6/10/05, Jacob Ilsø Christensen <jacobilsoe at gmail.com> wrote:
> > > Hi.
> > >
> > > I am starting out with just coding reformat file. Then I will do the
> > > other stuff.
> > > I have run into an issue though.
> > >
> > > Suppose you have the following:
> > >
> > > 1: namespace NS
> > > 2:    {
> > > 3:
> > > 4:                    }
> > >
> > > This should be (depending on how you have configured MD) formatted to:
> > >
> > > 1: namespace NS
> > > 2: {
> > > 3:
> > > 4: }
> > >
> > > The problem is that the AST only contains information about where a
> > > namespace declaration begins and ends (lines 1 and 4) not where the
> > > contents of it begins and ends (line 2 and 4).
> > >
> > > I would like to extend the NamespaceDeclaration class with this
> > > information. But this class resides in the ICSharpCode.SharpRefactory
> > > namespace. Is it ok to change stuff there or is there still some
> > > collaboration going on with SharpDevelop?
> > >
> > > /Jacob
> > >
> > >
> > >
> > > On 6/9/05, John Luke <john.luke at gmail.com> wrote:
> > > >
> > > > Jacob Ilsø Christensen wrote:
> > > >
> > > > >Hi.
> > > > >
> > > > >Ok, here is what I plan to do:
> > > > >
> > > > >1) Parse the file currently viewing.
> > > > >2) Traverse the built AST in parallel with traversing the file.
> > > > >3) Indent a specific line according to what level and what item is
> > > > >currently looked at in the AST.
> > > > >
> > > > >Does this sound like a way to do it?
> > > > >
> > > > It sounds like _a_ way, but there are many.  You might want to take a
> > > > look at one of the editors that does
> > > > this already vim, emacs, eclipse, etc.  Have you looked at the existing
> > > > FormattingStrategy stuff in the various language bindings?
> > > > Also, consider multiline pasting and probably more little corner cases I
> > > > can't think of right now.
> > > >
> > > > >Do we want such a feature in MD?
> > > > >
> > > > >
> > > > I think we do.  Perhaps starting with "format a file on ctl+shift+f" and
> > > > make sure it works right (without changing/losing information) would be
> > > > a smaller first step.  Then format as you go can come later after you
> > > > know all the issues.
> > > >
> > >
> > _______________________________________________
> > Monodevelop-list mailing list
> > Monodevelop-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/monodevelop-list
> 
>


More information about the Monodevelop-list mailing list