1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Follow up on 174597

This commit is contained in:
Anton Leherbauer 2008-01-24 12:08:37 +00:00
parent 571e7a6a7c
commit 80613b3223
3 changed files with 20 additions and 16 deletions

View file

@ -97,7 +97,8 @@ int MyI = 0,j = 0;
puts("tryagain");
} while (0);
if (MyI==0) {
if (MyI==0)
{
return 1;
}
return 0;

View file

@ -216,7 +216,7 @@ public class FoldingTest extends TestCase {
createPosition(57, 59),
createPosition(61, 63),
createPosition(65, 67),
createPosition(70, 103, 71),
createPosition(70, 104, 71),
createPosition(75, 76),
createPosition(77, 79),
createPosition(80, 82),
@ -226,10 +226,10 @@ public class FoldingTest extends TestCase {
createPosition(90, 91),
createPosition(92, 93),
createPosition(95, 97),
createPosition(99, 101),
createPosition(105, 109),
createPosition(99, 102),
createPosition(106, 110),
};
// assertEquals(toString(expected), toString(actual));
assertEquals(toString(expected), toString(actual));
assertEqualPositions(expected, actual);
}
@ -251,7 +251,7 @@ public class FoldingTest extends TestCase {
createPosition(57, 59),
createPosition(61, 63),
createPosition(65, 67),
createPosition(70, 103, 71),
createPosition(70, 104, 71),
createPosition(75, 76),
createPosition(77, 79),
createPosition(80, 82),
@ -261,10 +261,10 @@ public class FoldingTest extends TestCase {
createPosition(90, 91),
createPosition(92, 93),
createPosition(95, 97),
createPosition(99, 101),
createPosition(105, 109),
createPosition(99, 102),
createPosition(106, 110),
};
// assertEquals(toString(expected), toString(actual));
assertEquals(toString(expected), toString(actual));
assertEqualPositions(expected, actual);
}

View file

@ -51,7 +51,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
@ -1127,13 +1126,16 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
IASTFileLocation fl;
if (statement instanceof IASTIfStatement) {
IASTIfStatement ifstmt = (IASTIfStatement) statement;
fl = ifstmt.getFileLocation();
if (fl==null) return PROCESS_CONTINUE;
int ifOffset= fl.getNodeOffset();
IASTStatement tmp;
mr = new ModifiableRegionExtra();
tmp = ifstmt.getThenClause();
if (tmp==null) return PROCESS_CONTINUE;
fl = tmp.getFileLocation();
mr.setLength(fl.getNodeLength());
mr.setOffset(fl.getNodeOffset());
mr.setLength(fl.getNodeOffset() + fl.getNodeLength() - ifOffset);
mr.setOffset(ifOffset);
mr.inclusive = false;
tmp = ifstmt.getElseClause();
if (tmp==null) {
@ -1148,6 +1150,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
mr.setOffset(fl.getNodeOffset());
mr.inclusive = true;
iral.push(mr);
return PROCESS_CONTINUE;
}
mr = new ModifiableRegionExtra();
mr.inclusive = true;
@ -1186,7 +1189,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
iral.push(tmpmr);
pushedMR = true;
}
}
}
}
if (statement instanceof IASTForStatement ||
statement instanceof IASTWhileStatement ||
@ -1198,9 +1201,9 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
iral.push(mr);
}
return PROCESS_CONTINUE;
} catch (Throwable e) {
CCorePlugin.log(e);
return PROCESS_CONTINUE;
} catch (Exception e) {
CUIPlugin.getDefault().log(e);
return PROCESS_ABORT;
}
}
});