{"action":"created","issue":{"url":"https://api.github.com/repos/datathings/greycat/issues/45","repository_url":"https://api.github.com/repos/datathings/greycat","labels_url":"https://api.github.com/repos/datathings/greycat/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/datathings/greycat/issues/45/comments","events_url":"https://api.github.com/repos/datathings/greycat/issues/45/events","html_url":"https://github.com/datathings/greycat/issues/45","id":232806210,"number":45,"title":"ModelChecker: Check is a class is unique","user":{"login":"lmouline","id":2489384,"avatar_url":"https://avatars0.githubusercontent.com/u/2489384?v=3","gravatar_id":"","url":"https://api.github.com/users/lmouline","html_url":"https://github.com/lmouline","followers_url":"https://api.github.com/users/lmouline/followers","following_url":"https://api.github.com/users/lmouline/following{/other_user}","gists_url":"https://api.github.com/users/lmouline/gists{/gist_id}","starred_url":"https://api.github.com/users/lmouline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmouline/subscriptions","organizations_url":"https://api.github.com/users/lmouline/orgs","repos_url":"https://api.github.com/users/lmouline/repos","events_url":"https://api.github.com/users/lmouline/events{/privacy}","received_events_url":"https://api.github.com/users/lmouline/received_events","type":"User","site_admin":false},"labels":[{"id":586215367,"url":"https://api.github.com/repos/datathings/greycat/labels/Feature%20request","name":"Feature request","color":"c5def5","default":false},{"id":616960111,"url":"https://api.github.com/repos/datathings/greycat/labels/Modeling","name":"Modeling","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":{"login":"thomashartmann","id":5172497,"avatar_url":"https://avatars3.githubusercontent.com/u/5172497?v=3","gravatar_id":"","url":"https://api.github.com/users/thomashartmann","html_url":"https://github.com/thomashartmann","followers_url":"https://api.github.com/users/thomashartmann/followers","following_url":"https://api.github.com/users/thomashartmann/following{/other_user}","gists_url":"https://api.github.com/users/thomashartmann/gists{/gist_id}","starred_url":"https://api.github.com/users/thomashartmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomashartmann/subscriptions","organizations_url":"https://api.github.com/users/thomashartmann/orgs","repos_url":"https://api.github.com/users/thomashartmann/repos","events_url":"https://api.github.com/users/thomashartmann/events{/privacy}","received_events_url":"https://api.github.com/users/thomashartmann/received_events","type":"User","site_admin":false},"assignees":[{"login":"thomashartmann","id":5172497,"avatar_url":"https://avatars3.githubusercontent.com/u/5172497?v=3","gravatar_id":"","url":"https://api.github.com/users/thomashartmann","html_url":"https://github.com/thomashartmann","followers_url":"https://api.github.com/users/thomashartmann/followers","following_url":"https://api.github.com/users/thomashartmann/following{/other_user}","gists_url":"https://api.github.com/users/thomashartmann/gists{/gist_id}","starred_url":"https://api.github.com/users/thomashartmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomashartmann/subscriptions","organizations_url":"https://api.github.com/users/thomashartmann/orgs","repos_url":"https://api.github.com/users/thomashartmann/repos","events_url":"https://api.github.com/users/thomashartmann/events{/privacy}","received_events_url":"https://api.github.com/users/thomashartmann/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2017-06-01T08:43:59Z","updated_at":"2017-06-01T12:16:26Z","closed_at":"2017-06-01T12:08:03Z","body":"The model checker could check if a class is unique, i.e., there is no other class or enum with the same name\r\n\r\nBelow a first draft. It doesn't check that enum are also unique. Some optimizations should be possible by mixing both :)\r\n\r\n```java\r\nprivate static void checkUnicity(greycat.language.GreyCatModelParser.ModelDclContext modelDcl, greycat.language.GreyCatModelParser.ClassDclContext classDcl) throws RuntimeException{\r\n        int[] lines = new int[0];\r\n\r\n        String className = classDcl.IDENT().getText();\r\n        List<greycat.language.GreyCatModelParser.ClassDclContext> classes = modelDcl.classDcl();\r\n        for(int i=0;i<classes.size();i++) {\r\n            if(classes.get(i).IDENT().getText().equals(className)) {\r\n                int[] newLines = new int[lines.length + 1];\r\n                System.arraycopy(lines,0,newLines,0,lines.length);\r\n                lines = newLines;\r\n\r\n                lines[lines.length - 1] = classes.get(i).getStart().getLine();\r\n            }\r\n        }\r\n\r\n        if(lines.length > 1) {\r\n            StringBuilder message = new StringBuilder(64);\r\n            message.append(className)\r\n                    .append(\" is declared more than once. It is declared at\");\r\n            for(int i=0;i<lines.length;i++) {\r\n                message.append(\" line \" + lines[i]);\r\n                if(i<lines.length - 2) {\r\n                    message.append(\",\");\r\n                } else if(i<lines.length - 1){\r\n                    message.append(\" and\");\r\n                }\r\n            }\r\n            throw new RuntimeException(message.toString());\r\n        }\r\n\r\n        List<greycat.language.GreyCatModelParser.EnumDclContext> enums = modelDcl.enumDcl();\r\n        for(int i=0;i<enums.size();i++) {\r\n            if(enums.get(i).IDENT().getText().equals(className)) {\r\n                Token start = enums.get(i).getStart();\r\n                throw new RuntimeException(className + \" is also an enum name at line \" + start.getLine());\r\n            }\r\n        }\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/datathings/greycat/issues/comments/305476091","html_url":"https://github.com/datathings/greycat/issues/45#issuecomment-305476091","issue_url":"https://api.github.com/repos/datathings/greycat/issues/45","id":305476091,"user":{"login":"lmouline","id":2489384,"avatar_url":"https://avatars0.githubusercontent.com/u/2489384?v=3","gravatar_id":"","url":"https://api.github.com/users/lmouline","html_url":"https://github.com/lmouline","followers_url":"https://api.github.com/users/lmouline/followers","following_url":"https://api.github.com/users/lmouline/following{/other_user}","gists_url":"https://api.github.com/users/lmouline/gists{/gist_id}","starred_url":"https://api.github.com/users/lmouline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmouline/subscriptions","organizations_url":"https://api.github.com/users/lmouline/orgs","repos_url":"https://api.github.com/users/lmouline/repos","events_url":"https://api.github.com/users/lmouline/events{/privacy}","received_events_url":"https://api.github.com/users/lmouline/received_events","type":"User","site_admin":false},"created_at":"2017-06-01T12:16:26Z","updated_at":"2017-06-01T12:16:26Z","body":"yep, but when I see the code of some check, the complexity looks high for nothing ^^"}}
{"actor":{"display_login":"lmouline"}}