aboutsummaryrefslogtreecommitdiffstats
path: root/ajde.core
diff options
context:
space:
mode:
authoraclement <aclement>2010-07-08 20:50:01 +0000
committeraclement <aclement>2010-07-08 20:50:01 +0000
commit75467d52b8c68812895b437ec2d2e41fe95adf43 (patch)
treea8adc199b2f364bd9a6b57ac096ffbd04d182ee6 /ajde.core
parent2bcdbacf5f2278ad559d186935f3e9529e5412ff (diff)
downloadaspectj-75467d52b8c68812895b437ec2d2e41fe95adf43.tar.gz
aspectj-75467d52b8c68812895b437ec2d2e41fe95adf43.zip
generics
Diffstat (limited to 'ajde.core')
-rw-r--r--ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java
index 1b475ae89..07c1497a4 100644
--- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java
+++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/SavedModelConsistencyTests.java
@@ -72,8 +72,9 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
IProgramElement nodePostBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);
- assertTrue("Nodes should be identical: Prebuild kind = " + nodePreBuild.getKind() + " Postbuild kind = "
- + nodePostBuild.getKind(), nodePreBuild.getKind().equals(nodePostBuild.getKind()));
+ assertTrue(
+ "Nodes should be identical: Prebuild kind = " + nodePreBuild.getKind() + " Postbuild kind = "
+ + nodePostBuild.getKind(), nodePreBuild.getKind().equals(nodePostBuild.getKind()));
}
@@ -84,7 +85,7 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
IHierarchy model = asm.getHierarchy();
assertTrue("model exists", model != null);
- final List preBuildKinds = new ArrayList();
+ final List<IProgramElement.Kind> preBuildKinds = new ArrayList<IProgramElement.Kind>();
HierarchyWalker walker = new HierarchyWalker() {
public void preProcess(IProgramElement node) {
preBuildKinds.add(node.getKind());
@@ -96,7 +97,7 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
doBuild();
assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty());
- final List postBuildKinds = new ArrayList();
+ final List<IProgramElement.Kind> postBuildKinds = new ArrayList<IProgramElement.Kind>();
HierarchyWalker walker2 = new HierarchyWalker() {
public void preProcess(IProgramElement node) {
postBuildKinds.add(node.getKind());
@@ -105,8 +106,8 @@ public class SavedModelConsistencyTests extends AjdeCoreTestCase {
asm.getHierarchy().getRoot().walk(walker2);
assertFalse("Expected there to be build kinds but didn't " + "find any", preBuildKinds.isEmpty());
- assertTrue("Lists should be the same: PRE" + preBuildKinds.toString() + " POST" + postBuildKinds.toString(), preBuildKinds
- .equals(postBuildKinds));
+ assertTrue("Lists should be the same: PRE" + preBuildKinds.toString() + " POST" + postBuildKinds.toString(),
+ preBuildKinds.equals(postBuildKinds));
}
ass="s">"code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "xorm.io/builder" ) // GetRepositoriesByForkID returns all repositories with given fork ID. func GetRepositoriesByForkID(ctx context.Context, forkID int64) ([]*Repository, error) { repos := make([]*Repository, 0, 10) return repos, db.GetEngine(ctx). Where("fork_id=?", forkID). Find(&repos) } // GetForkedRepo checks if given user has already forked a repository with given ID. func GetForkedRepo(ownerID, repoID int64) *Repository { repo := new(Repository) has, _ := db.GetEngine(db.DefaultContext). Where("owner_id=? AND fork_id=?", ownerID, repoID). Get(repo) if has { return repo } return nil } // HasForkedRepo checks if given user has already forked a repository with given ID. func HasForkedRepo(ownerID, repoID int64) bool { has, _ := db.GetEngine(db.DefaultContext). Table("repository"). Where("owner_id=? AND fork_id=?", ownerID, repoID). Exist() return has } // GetUserFork return user forked repository from this repository, if not forked return nil func GetUserFork(ctx context.Context, repoID, userID int64) (*Repository, error) { var forkedRepo Repository has, err := db.GetEngine(ctx).Where("fork_id = ?", repoID).And("owner_id = ?", userID).Get(&forkedRepo) if err != nil { return nil, err } if !has { return nil, nil } return &forkedRepo, nil } // GetForks returns all the forks of the repository func GetForks(repo *Repository, listOptions db.ListOptions) ([]*Repository, error) { if listOptions.Page == 0 { forks := make([]*Repository, 0, repo.NumForks) return forks, db.GetEngine(db.DefaultContext).Find(&forks, &Repository{ForkID: repo.ID}) } sess := db.GetPaginatedSession(&listOptions) forks := make([]*Repository, 0, listOptions.PageSize) return forks, sess.Find(&forks, &Repository{ForkID: repo.ID}) } // IncrementRepoForkNum increment repository fork number func IncrementRepoForkNum(ctx context.Context, repoID int64) error { _, err := db.GetEngine(ctx).Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", repoID) return err } // DecrementRepoForkNum decrement repository fork number func DecrementRepoForkNum(ctx context.Context, repoID int64) error { _, err := db.GetEngine(ctx).Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repoID) return err } // FindUserOrgForks returns the forked repositories for one user from a repository func FindUserOrgForks(ctx context.Context, repoID, userID int64) ([]*Repository, error) { cond := builder.And( builder.Eq{"fork_id": repoID}, builder.In("owner_id", builder.Select("org_id"). From("org_user"). Where(builder.Eq{"uid": userID}), ), ) var repos []*Repository return repos, db.GetEngine(ctx).Table("repository").Where(cond).Find(&repos) } // GetForksByUserAndOrgs return forked repos of the user and owned orgs func GetForksByUserAndOrgs(ctx context.Context, user *user_model.User, repo *Repository) ([]*Repository, error) { var repoList []*Repository if user == nil { return repoList, nil } forkedRepo, err := GetUserFork(ctx, repo.ID, user.ID) if err != nil { return repoList, err } if forkedRepo != nil { repoList = append(repoList, forkedRepo) } orgForks, err := FindUserOrgForks(ctx, repo.ID, user.ID) if err != nil { return nil, err } repoList = append(repoList, orgForks...) return repoList, nil }