02-Editing/05-Rearranging_code.cs [1:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
using System;
namespace JetBrains.ReSharper.Koans.Editing
{
// Rearrange Code
//
// Move code up/down/left/right/in/out
//
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
public class RearrangingCode
{
public void RearrangeLines()
{
// 1. Place caret on one of the line below
// use
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
Console.WriteLine("One");
Console.WriteLine("Two");
Console.WriteLine("Three");
Console.WriteLine("Four");
Console.WriteLine("Five");
}
public void RearrangeExpressionOrder()
{
var value = 42;
var newValue = 34;
newValue++;
// 2. Place caret on newValue
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
value = newValue;
Console.WriteLine(value);
}
public void RearrangeParameterOrder()
{
const string hello = "hello";
const string world = "world";
const string foo = "foo";
const string bar = "bar";
// 3. Place caret on hello
// rearrange parameter order
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
MethodWithParameters(hello, world, foo, bar);
}
public void RearrangeInAndOut()
{
if (true)
{
// 4. Place caret on WriteLine
// Rearrange within the if statement
// Move out of if statement
// Move above and below if statement
// Move into the if statement
Console.WriteLine("Hello");
Console.WriteLine("World");
}
}
// 5. Rearrange the comment
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
public void RearrangeComment()
{
// Move me
Console.WriteLine("Hello");
Console.WriteLine("World");
}
public void ExtendBlockWithGreedyBraces()
{
// 5. Place caret on outside of closing brace
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
//
// Move block to include next statement
// move up block to exclude current last statement
if (true)
{
Console.WriteLine("Hello");
}
Console.WriteLine("World");
}
private void MethodWithParameters(string p1, string p2, string p3, string p4)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
localized/ja/02-Editing/05-Rearranging_code.cs [1:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
using System;
namespace JetBrains.ReSharper.Koans.Editing
{
// Rearrange Code
//
// Move code up/down/left/right/in/out
//
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
public class RearrangingCode
{
public void RearrangeLines()
{
// 1. Place caret on one of the line below
// use
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
Console.WriteLine("One");
Console.WriteLine("Two");
Console.WriteLine("Three");
Console.WriteLine("Four");
Console.WriteLine("Five");
}
public void RearrangeExpressionOrder()
{
var value = 42;
var newValue = 34;
newValue++;
// 2. Place caret on newValue
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
value = newValue;
Console.WriteLine(value);
}
public void RearrangeParameterOrder()
{
const string hello = "hello";
const string world = "world";
const string foo = "foo";
const string bar = "bar";
// 3. Place caret on hello
// rearrange parameter order
// Left - Ctrl+Shift+Alt+Left
// Right - Ctrl+Shift+Alt+Right
MethodWithParameters(hello, world, foo, bar);
}
public void RearrangeInAndOut()
{
if (true)
{
// 4. Place caret on WriteLine
// Rearrange within the if statement
// Move out of if statement
// Move above and below if statement
// Move into the if statement
Console.WriteLine("Hello");
Console.WriteLine("World");
}
}
// 5. Rearrange the comment
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
public void RearrangeComment()
{
// Move me
Console.WriteLine("Hello");
Console.WriteLine("World");
}
public void ExtendBlockWithGreedyBraces()
{
// 5. Place caret on outside of closing brace
// Up - Ctrl+Shift+Alt+Up
// Down - Ctrl+Shift+Alt+Down
//
// Move block to include next statement
// move up block to exclude current last statement
if (true)
{
Console.WriteLine("Hello");
}
Console.WriteLine("World");
}
private void MethodWithParameters(string p1, string p2, string p3, string p4)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -