Skip to content

Commit

Permalink
Merge pull request #87 from kasecato/#86/identifer
Browse files Browse the repository at this point in the history
Fixed #86 when using @ prefixed identifiers, the prefix should be rem…
  • Loading branch information
kasecato committed May 19, 2020
2 parents 58a69e8 + 47b2628 commit 2394b17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,11 @@
# Change Log

## 0.1.9 (May 26, 2020)
## 0.1.10 (May 19, 2020)

* bug fix - When using @ prefixed identifiers, the prefix should be removed in the generated param name. See [#86](https://github.com/kasecato/vscode-docomment/issues/86).
* upgrade libs

## 0.1.9 (March 26, 2020)

* upgrade libs

Expand Down
12 changes: 8 additions & 4 deletions src/SyntacticAnalysis/SyntacticAnalysisCSharp.ts
Expand Up @@ -153,7 +153,7 @@ export class SyntacticAnalysisCSharp {
}

const generics: RegExpMatchArray = code.match(/<([^<>]*)>/);

const isUnMatched = (generics === null || generics.length !== 2);
if (isUnMatched) return null;

Expand Down Expand Up @@ -194,7 +194,7 @@ export class SyntacticAnalysisCSharp {
const isMatched = (params === null || params.length !== 2);
if (isMatched) return null;

let paramName: Array<string> = new Array<string>();
let paramNames: Array<string> = new Array<string>();
params[1].split(',').forEach(param => {
const hasOptionalParam: boolean = param.match(/\S+\s+\S+\s*=/) !== null;
const hasTypeInfo: boolean = param.match(/[\w\W]+\s+[\w\W]+/) !== null;
Expand All @@ -207,11 +207,15 @@ export class SyntacticAnalysisCSharp {
name = param.match(/(\S+)\s*$/);
}
if (name !== null && name.length === 2) {
paramName.push(name[1]);
const hasIdentifer = name[1].startsWith('@');
const paramName = (hasIdentifer)
? name[1].replace('@', '')
: name[1];
paramNames.push(paramName);
}
});

return paramName;
return paramNames;
}

public static HasMethodReturn(code: string): boolean {
Expand Down
2 changes: 2 additions & 0 deletions test/TestData/X.cs
Expand Up @@ -74,4 +74,6 @@ class SampleClass2<T> : IBaseInterface2<T, string> { }
public delegate List<T> StackEventHandler<T, U>(T sender, U eventArgs);

public class Foo : Bar<string> { }

void DoSomething(bool @checked) { }
}

0 comments on commit 2394b17

Please sign in to comment.