Skip to content

Commit

Permalink
Merge pull request #14 from k--kato/fix/#13
Browse files Browse the repository at this point in the history
fixed #13
  • Loading branch information
Keisuke KATO authored Jul 10, 2016
2 parents 56e5d64 + 3a2f462 commit acf62e4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ script:
- npm test --silent
- npm run-script coverage_travis
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

language: node_js
node_js:
- "6"
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "docomment",
"version": "0.0.6",
"version": "0.0.7",
"publisher": "k--kato",
"engines": {
"vscode": "^1.2.x"
"vscode": "^1.3.x"
},
"displayName": "C# XML Documentation Comments",
"description": "Generate C# XML documentation comments for ///",
Expand Down Expand Up @@ -46,8 +46,8 @@
},
"devDependencies": {
"typescript": "^1.8.10",
"vscode": "^0.11.13",
"tslint": "^3.11.0",
"vscode": "^0.11.14",
"tslint": "^3.13.0",
"istanbul": "^0.4.4",
"coveralls": "^2.11.9",
"mocha": "^2.5.3",
Expand Down
15 changes: 14 additions & 1 deletion src/Utility/StringUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ export class StringUtil {

public static IsCodeBlockStart(line: string): boolean {
if (line === null) return false;
return (line.indexOf('{') !== -1) || (line.indexOf(';') !== -1);

const isAttribute: boolean = line.trim().startsWith('['); // SKIP Attribute: [foo="bar"]
if (isAttribute) return false;

const isCodeBlockStart: boolean = (line.indexOf('{') !== -1);
if (isCodeBlockStart) return true;

const isInterface: boolean = (line.indexOf(';') !== -1)
if (isInterface) return true;

const isEndMethod: boolean = (line.trim().endsWith(')'))
if (isEndMethod) return true;

return isCodeBlockStart;
}

public static RemoveComment(line: string): string {
Expand Down
3 changes: 3 additions & 0 deletions test/TestData/X.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@ public class Nested{} // "T:N.X.Nested"
int Generate(int level);
public void Save(string data, Action<AchievementSavedResponse> onComplete = null);
Func<string, bool> FirstClassFunction(Func<bool, int> func);
[Route("{time}/{location}")]
[HttpGet]
public async Task<string> GetInfoForTime(string location, double time)
}
}
37 changes: 37 additions & 0 deletions test/Utility/StringUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,43 @@ suite('Utility.StringUtil.IsCodeBlockStart Tests', () => {
// assert
assert.equal(actual, true);
});

test(`
Category: Black-box testing
Class : Utility.StringUtil
Method : IsCodeBlockStart
STATE : -
IN : '[Route("{time}/{location}")]'
OUT : false
`, () => {
// arrange
const code = '[Route("{time}/{location}")]';

// act
const actual: boolean = StringUtil.IsCodeBlockStart(code);

// assert
assert.equal(actual, false);
});

test(`
Category: Black-box testing
Class : Utility.StringUtil
Method : IsCodeBlockStart
STATE : -
IN : 'public async Task<string> GetInfoForTime(string location, double time)'
OUT : true
`, () => {
// arrange
const code = 'public async Task<string> GetInfoForTime(string location, double time)';

// act
const actual: boolean = StringUtil.IsCodeBlockStart(code);

// assert
assert.equal(actual, true);
});

});


Expand Down

0 comments on commit acf62e4

Please sign in to comment.