declaration.getMethodReceiver().getType() == null) {
visitElement(declaration);
return;
}
blockNameStack.push(new HashSet<String>());
GoLiteralIdentifier id = declaration.getMethodReceiver().getIdentifier();
nameCheck(id, result);
for (GoFunctionParameter parameter : declaration.getParameters()) {
for (GoLiteralIdentifier paramterId : parameter.getIdentifiers()) {
nameCheck(paramterId, result);
}
}
for (GoFunctionParameter parameter : declaration.getResults()) {
for (GoLiteralIdentifier paramterId : parameter.getIdentifiers()) {
nameCheck(paramterId, result);
}
}
visitElement(declaration);
blockNameStack.pop();
String name = declaration.getMethodReceiver().getType().getText() + "." + declaration.getName();
if (name.startsWith("*")) {
name = name.substring(1);
}
if (methodNameSet.contains(name)) {
result.addProblem(declaration.getNameIdentifier(), GoBundle.message("error.redeclare"),
ProblemHighlightType.GENERIC_ERROR);
return;
}
methodNameSet.add(name);
}
@Override
public void visitFunctionDeclaration(GoFunctionDeclaration declaration) {
blockNameStack.push(new HashSet<String>());
for (GoFunctionParameter parameter : declaration.getParameters()) {
for (GoLiteralIdentifier parameterIdentifier : parameter.getIdentifiers()) {
nameCheck(parameterIdentifier, result);
}
}
for (GoFunctionParameter parameter : declaration.getResults()) {
for (GoLiteralIdentifier parameterIdentifier : parameter.getIdentifiers()) {
nameCheck(parameterIdentifier, result);
}
}
visitElement(declaration);
blockNameStack.pop();
if (!declaration.isInit())
nameCheck(declaration.getNameIdentifier(), declaration.getName(), result);
}
@Override
public void visitFunctionLiteral(GoLiteralFunction declaration) {
blockNameStack.push(new HashSet<String>());
for (GoFunctionParameter parameter : declaration.getParameters()) {
for (GoLiteralIdentifier parameterIdentifier : parameter.getIdentifiers()) {
nameCheck(parameterIdentifier, result);
}
}
for (GoFunctionParameter parameter : declaration.getResults()) {
for (GoLiteralIdentifier parameterIdentifier : parameter.getIdentifiers()) {
nameCheck(parameterIdentifier, result);
}
}
visitElement(declaration);
blockNameStack.pop();
}
@Override
public void visitTypeNameDeclaration(GoTypeNameDeclaration declaration) {
nameCheck(declaration, declaration.getName(), result);
visitElement(declaration);
}
@Override
public void visitConstDeclaration(GoConstDeclaration declaration) {
GoLiteralIdentifier[] ids = declaration.getIdentifiers();
for (GoLiteralIdentifier id : ids) {
nameCheck(id, result);
}
visitElement(declaration);
}
@Override
public void visitVarDeclaration(GoVarDeclaration declaration) {
GoLiteralIdentifier[] ids = declaration.getIdentifiers();
for (GoLiteralIdentifier id : ids) {
nameCheck(id, result);
}
visitElement(declaration);
}
@Override
public void visitShortVarDeclaration(GoShortVarDeclaration declaration) {
GoLiteralIdentifier[] ids = declaration.getIdentifiers();
boolean isAllRepeat = true;
for (GoLiteralIdentifier id : ids) {
if (id.isBlank()) {
continue;
}
String idName = id.getName();
if (!blockNameStack.peek().contains(idName)) {
isAllRepeat = false;
blockNameStack.peek().add(idName);
}
}