Bring code into the fold

aotte

Member³
Hi,

In the old days, when I was mucking about on an Atari ST, I had an editor that allowed me to "fold" code out of sight, like you would with a piece of paper.

It worked then with specific comments, similar to HTML , but I think it would work miracles with Function / Procedure / Loop / Case / IfThenElse structures. It could act as a natural extension of the code contents browser, in concert with the code beautifier.

You would expand/collapse pieces of code as necessary. The line number gutter could hold the [+] [-] buttons to expand or collapse for the mouse, and provide visual feedback, while ALT-Left, and ALT-Right are possible keyboard alternatives.

It really enhanced the overview of code, you get a quick feel of what is happening, without getting bogged down in 100's of lines of listed columns etc.

Here is an example that goes from completely collapsed to fully expanded:

DISCLAIMER: Code not fit for production use. For one, it is not closing the cursor.

Completely collapsed
Code:
FUNCTION ut_tbl (cu_crrnt_test_src cu_test_src)
   RETURN t_tbl
   PIPELINED
   PARALLEL_ENABLE (PARTITION cu_crrnt_test_src BY ANY)
END ut_tbl;

Expand once:
Code:
FUNCTION ut_tbl (cu_crrnt_test_src cu_test_src)
   RETURN t_tbl
   PIPELINED
   PARALLEL_ENABLE (PARTITION cu_crrnt_test_src BY ANY)
IS
   v_test_src_id unit_test_src.src_id%TYPE;
   vr_tbl r_tbl;
   vr_empty_tbl r_tbl;
BEGIN
   <<test_src_loop>>
   LOOP
   END LOOP test_src_loop;

   RETURN;
END ut_tbl;

Expand twice:
Code:
FUNCTION ut_tbl (cu_crrnt_test_src cu_test_src)
   RETURN t_tbl
   PIPELINED
   PARALLEL_ENABLE (PARTITION cu_crrnt_test_src BY ANY)
IS
   v_test_src_id unit_test_src.src_id%TYPE;
   vr_tbl r_tbl;
   vr_empty_tbl r_tbl;
BEGIN
   <<test_src_loop>>
   LOOP
      -- Get next source data item
      FETCH cu_crrnt_test_src INTO v_test_src_id;

      -- Is there more source data to be processed?
      IF cu_crrnt_test_src%NOTFOUND THEN
      ELSE -- cu_crrnt_test_src%NOTFOUND
      END IF;  -- cu_crrnt_test_src%NOTFOUND

   END LOOP test_src_loop;

   RETURN;
END ut_tbl;

Expand three times:
Code:
FUNCTION ut_tbl (cu_crrnt_test_src cu_test_src)
   RETURN t_tbl
   PIPELINED
   PARALLEL_ENABLE (PARTITION cu_crrnt_test_src BY ANY)
IS
   v_test_src_id unit_test_src.src_id%TYPE;
   vr_tbl r_tbl;
   vr_empty_tbl r_tbl;
BEGIN
   <<test_src_loop>>
   LOOP
      -- Get next source data item
      FETCH cu_crrnt_test_src INTO v_test_src_id;

      -- Is there more source data to be processed?
      IF cu_crrnt_test_src%NOTFOUND THEN
         -- No more source data
         EXIT test_src_loop;

      ELSE -- cu_crrnt_test_src%NOTFOUND
         -- Ensure an empty record
         vr_tbl := vr_empty_tbl;
         -- Assume record will be populated
         v_populated := TRUE;

         CASE v_test_src_id
            WHEN 1 THEN
            ELSE
         END CASE; -- v_test_src_id

         IF v_populated THEN
         END IF; -- v_populated

      END IF;  -- cu_crrnt_test_src%NOTFOUND

   END LOOP test_src_loop;

   RETURN;
END ut_tbl;

Fully Expanded:
Code:
FUNCTION ut_tbl (cu_crrnt_test_src cu_test_src)
   RETURN t_tbl
   PIPELINED
   PARALLEL_ENABLE (PARTITION cu_crrnt_test_src BY ANY)
IS
   v_test_src_id unit_test_src.src_id%TYPE;
   vr_tbl r_tbl;
   vr_empty_tbl r_tbl;
BEGIN
   <<test_src_loop>>
   LOOP
      -- Get next source data item
      FETCH cu_crrnt_test_src INTO v_test_src_id;

      -- Is there more source data to be processed?
      IF cu_crrnt_test_src%NOTFOUND THEN
         -- No more source data
         EXIT test_src_loop;

      ELSE -- cu_crrnt_test_src%NOTFOUND
         -- Ensure an empty record
         vr_tbl := vr_empty_tbl;
         -- Assume record will be populated
         v_populated := TRUE;

         CASE v_test_src_id
         -- Populate the record with data associated with this test case
            WHEN 1 THEN
               -- Populate appropriate columns only
               vr_tbl.column1 := 'Something';
            ELSE
               -- Unrelated test case, no population
               v_populated := FALSE;
         END CASE; -- v_test_src_id

         IF v_populated THEN
            PIPE ROW (vr_tbl);
         END IF; -- v_populated

      END IF;  -- cu_crrnt_test_src%NOTFOUND

   END LOOP test_src_loop;

   RETURN;
END ut_tbl;

------------------
Hakuna Matata,

Arnoud.

[This message has been edited by aotte (edited 03 June 2003).]
 
I agree that this is a good idea. I have added this to the list of enhancement requests.

------------------
Marco Kalter
Allround Automations
 
I just want to add that the expanding and collapsing, in the example, is based on nesting levels. That is just one scenario of course. The status of expanded or collapsed would be determined per individual, collapsable, statement.

I guess that any block-based statement would then become collapsable: Package definitions, type definitions, etc.

------------------
Hakuna Matata,

Arnoud.

[This message has been edited by aotte (edited 04 June 2003).]
 
Back
Top