AS6 how to collapse functions

Go To Last Post
29 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm playing with AS6.
I have made a new project in AS6 and copied a number of 'old' files to the project.

What I see is that when I write new functions these are collapsible. But the existing functions are not.

How can I import files (run some sort of check tool on them) such that they all have the ability to collapse the function contents?

as a side question I have seen a thread about the way studio 4 reports the used flas/ram & eeprom space. and how to also have this same method of displaying in AS6 but I cannot find back that thread. Where is this thread located?

regards

Marcel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, playing some more with the studio...

to be a bit clearer on what I'm looking for.

If I select the function contents
Then right click my mouse and get the pop-up window
Then select 'Outlining'
and the Hide selection I get the same result.

ofcoarse I can do that for every file and avery function, but I would epect this to automatically be done when I open a file in AS.

I have also looked in the "Tools -> Option"
and can only find under "text edittor" a reference to outlining under the XML section (that is enabled)

I had expected also a "Miscellaneous" section under "All Languages"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still not really clear..

Are you having some functions that are not collapsible at all (i.e. lacking the plus-sign in the left margin)?

Or are you looking for having all the contents of a file collapsed when opening it?

Also note: I've encountered at least one bug in the outlining in Atmel Studio 6. This seems to be an effect of the language module for studio (not the compiler, but the thing that parses the code to do highlighting, "go to def" etc) gets confused for some code. I have yet to investigate this more to get a solid enough bug report to file with Atmel.

It seems to involve nested if-statements and comments, and the net effect is that there is a part of the function that is not foldable (the C language module thinks it ends before it actually does).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not having 'some' functions that are not collapsible I have entire files that are not collapsible.

I have been working on one file in that project that was collapsible, but that was only at the precompiler level. ( I think). It has an #ifdef statement that lets me choose for the uart to be interrupt driven or to be bitbang. There I can collapse on that level, but not on the function level below that.
I also have a file with main and 2 other functions and non of them are collapsible.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you saying you cannot make the thing on the left look like the thing on the right?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Correct Cliff,

the + and - are missing in front of the function headers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have seen the IDE confused by nested #ifdefs so #ifdefs may be the reason for your problems.

Try temporarily commenting out the #ifdefs to find out if that's the case.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I said above, there are cases (not involving #IFDEFs as far as I can tell, where the folding does not work. I have an ambition to file a bug report re this, but not without having enough info to make it a decent report (i.e. the "minimal repeatable case" that I always nag about when people post 1K lines of code and asks "Why is my LED not blinking?").

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
As I said above, there are cases (not involving #IFDEFs as far as I can tell, where the folding does not work. I have an ambition to file a bug report re this, but not without having enough info to make it a decent report (i.e. the "minimal repeatable case" that I always nag about when people post 1K lines of code and asks "Why is my LED not blinking?").

I'm looking forward to read that bug report...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morten!

I should have left this to later, but it actually took just a few minutes to create a few screen dumps in a minimal demonstrator. Due to CSDL (complex screen-dump logistics) it might take a few minutes more before I can attach them to a post here.

EDIT: OK, here goes..

Attachment(s): 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Mon. Dec 3, 2012 - 02:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What I was referring to is not a folding problem, it's something else. But in that case, the IDE is definitely confused by #ifdefs.

It turns out they don't even have to be nested.

It's not entirely off topic, as the IDE gets confused by the source code in this case too, so I'll post a short example to illustrate.

#define Y

typedef enum
{
    #ifdef X
        AA,
    #endif
    #ifdef Y
        BB,
    #endif
} E;

int main(void)
{
    E e = BB;
}

Click between the two Bs in main(). The strip just above the text editor now states "enum BB = 1". That is obviously not correct.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But I'm hardly using #ifdefs and for sure not nested as I would definitely confuse myself more then the IDE doing so.

Also If the IDe is confused I would expect it to be in a single file, but it is confused then over an entire project....
in my 'main.c' there are no #ifdefs so there I would not expect it to fail.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I should have left this to later, but it actually took just a few minutes to create a few screen dumps in a minimal demonstrator. Due to CSDL (complex screen-dump logistics) it might take a few minutes more before I can attach them to a post here.

Nice pics... You are going to post a bug also I hope?

The thin vertical line besides the main function clearly indicates that some parser thinks the while loop is outside main. I do however not have any constructive hints regarding this at the top of my head...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meolsen wrote:
I do however not have any constructive hints regarding this at the top of my head...

In Johan's case, the IDE is confused by the comment following the opening brace. Put a linefeed between the opening brace and the comment and the problem is gone.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The thin vertical line besides the main function clearly indicates that some parser thinks the while loop is outside main. I do however not have any constructive hints regarding this at the top of my head...

I believe it is somehow related to the way the if-clause is written. I played around with this a few weeks ago. The small isolated case is an extreme cut-down and rewrite of code from Atmels "Lightweight Mesh". If Alex used AS6 he would have spotted it.. :wink:

I'll poke at it and see if I can spot more specifically what makes this happen, but I have a strong feeling the opening gull-wing followed by a comment on the same line is involved. It has little or nothing to do with the while-clause.

When I have something substantial I'll file a bug report.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
I believe it is somehow related to the way the if-clause is written.

Like I said above, it's the opening brace followed by a comment on the same line that is causing this in the case you posted.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is my main.c

it does not have a single collapsible part in the project I have.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just checked all of my project C files and there are some that do have the collapsing possibility. Also a number off collapses have the opening brace + comment issue as described above. when I indeed add a crlf behind the opening brace the collapse indication goes to the right point.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

another interesting thing happened with the following code:

void LCD_WriteString(uint8_t x, uint8_t y, char *text)
{
   	uint8_t l_Cnt;
   	
	l_Cnt = strlen( (const char *)text);		// find length of the string

		// check if x value is valid
	if (x> LCDCOLS)
	{
		x = LCDCOLS;
	}		
		
		// find out if string has to be truncated
   	if (l_Cnt > (LCDCOLS - x))
   	{	// truncate the string to the max length
      	l_Cnt = (LCDCOLS - x);
    }

	LCD_SetCursor(x,y);
      
   	while ((*text != 0) && (l_Cnt > 0))
   	{  
       	--l_Cnt;

		LCD_WriteData(*text++);
   	}
} // LCD_WriteString

the collapse originally goes to the closing bracket after "truncte the string...."
If I add an enter to that line the entire collapse disappears.....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp wrote:
This is my main.c

it does not have a single collapsible part in the project I have.


Add a newline between any brace and the comment after it, and it will start working.

This applies to closing braces as well as opening braces.

In other words, change this:

} //blah blah blah

to this:

}
//blah blah blah

And this:

{ //blah blah blah

to this:

{
//blah blah blah

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Side notes now: I must say that the habit of having a comment after an opening gull-wing looks ugly to me. E.g. the comment could well get detached from the code it comments on if there is new code lines inserted just after the line with the gull-wing. I must say that I have not seen this very often, but there is code out tere that does it.

The case of commenting on a line with a closing gull-wing is more frequent, but any modern editor or IDE will
- either allow you to quick jump to the opening gull-wing and back (so that you can see what ends)
- or actually tell you e.g. the function name as soon as the caret is inside the block (like AS6 does)
- or both

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd also try to resist:

//*

use either:

//

or

/* ... */

but not a combination with half of one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChaunceyGardiner wrote:

Add a newline between any brace and the comment after it, and it will start working.

This applies to closing braces as well as opening braces.

That is really to bad.
I would expect that the program that interprets the code would see the opening/closing gull wing and then act accordingly. to bad it gets confused by this.

In addition I will try to resist using //***** for header comment blocks, but what are then generally good alternatives?
use

// ##########

or

/*
 * 
 *
 *
 */

or are there other generally accepted methods.
What I like in my case is that the comment blocks are clearly visible. I have a feeling that when I change to the /* the commented code is no longer sticking out (if I say that correctly)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have another issue wiht the collapsing of functions I would like to know what I do wrong. if I take the code below:

	for(;;)
	{
		if (Event_Get(&l_CurrentEvent)==TRUE)
		{
			switch (l_CurrentEvent.Event)
			{
				case UART_SYSTEM_SEGMENT_RECEIVED_EVENT:
				{
					for(l_Cnt=0;l_Cnt  to state 
							
						}
					}
				}				
				break ; 
				//UART_SYSTEM_SEGMENT_RECEIVED_EVENT

				case UART_SPECIAL_BYTE_RECEIVED_EVENT:
				{
					switch(l_CurrentEvent.Data)
					{
						case '?':
						{
							TransmitHelpMenu();
						}
						break;
					}						
				}
				break;
				
				case KB_KEYPRESSED_EVENT:
				{
					KB_HandleMainMenuKeyPres(KB_KeyScan(l_CurrentEvent.Data));

				}
				break; // KB_KEYPRESSED_EVENT

				case EXECUTE_SIGNAL_EVENT:
				{

				}
				break; // EXECUTE_SIGNAL_EVENT
			}
			//switch to event
		}
		//Check for new event
	}

then there is the posibility to collapse the "case '#':
but that is collapsing to text "//Check for new event"

I really wonder what I do wrong here for the collapsing to select this entire function rather then the case part.

Hope someone can explain

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems to be a totally "generic bug", i.e. it is nothing special like how comments are placed or anything like that. When you try to collapse the first case in a switch statement the complete switch statement collapses. This is the test I made:

/*
 * foldingbug2.c
 *
 * Created: 2012-12-17 22:18:36
 *  Author: johan
 */ 


#include 

int main(void)
{
  switch (PINC)
  {
    case 1:
    {
      PORTD = 2;
    }
    break;
    
    case 2:
    {
      PORTD = 1;
    }
    break;
    
    case 3:
    {
      PORTD = 0xFF;
    }
    break;
  }
}

Slam that into a newly created project. Then try to collapse each of the case's in order - you'll see what I mean.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are obviously many ways to confuse the collapser, with or without comments.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

phewwwww.....

I was already starting to thing I was doing something simple and stupid wrong.

Hope then that Atmel still is around, they now have a nice example of not working collapse....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
meslomp, this does not make sense ?? 

 case UART_SYSTEM_SEGMENT_RECEIVED_EVENT:
				{
					for(l_Cnt=0;l_Cnt  to state 
							
						} 
					}
				}				
				break ;  
                              

 

by the way, acording to the collapse issue, i have a bad habit with doing this

void slipknapper(void){
		char a=1;
		_delay_ms(2);
		while(a==1){
			a=0;
			if (bit_is_clear(PINB,enter)){a=1;	}
			if (bit_is_clear(PINB,esc)){a=1;	}
			if (bit_is_clear(PINB,up)){a=1;	}
			if (bit_is_clear(PINB,down)){a=1;	}}
	}

the duble curly brackets prevents collapsing.

 

Does anyone know if it's possible to setup the AS6 to collapse all on startup ? 

 

If you can´t fix it... try harder.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not even Visual Studio does this IIRC. It once had that option but it was removed, methinks. For VS2008 (or was it 2010) I located a 3rd party plugin that did the trick.

 

Best you can do is probably to memorize the keyboard shortcut for it.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]