#12 -- Add some parsing of java files
parent
c5e1ad8f37
commit
2ee965a113
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||||
|
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ru.ulstu.extractor.heuristic.model;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class EntityUnit extends StructuralUnit {
|
||||||
|
|
||||||
|
public EntityUnit(File file) {
|
||||||
|
super(file);
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||||
|
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||||
|
*/
|
||||||
|
|
||||||
package ru.ulstu.extractor.heuristic.service;
|
package ru.ulstu.extractor.heuristic.service;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ru.ulstu.extractor.heuristic.api.StructuralUnitIdentifier;
|
import ru.ulstu.extractor.heuristic.api.StructuralUnitIdentifier;
|
||||||
import ru.ulstu.extractor.heuristic.model.StructuralUnit;
|
import ru.ulstu.extractor.heuristic.model.StructuralUnit;
|
||||||
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class StructuralUnitService {
|
public class StructuralUnitService {
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
private final DirectoryService directoryService;
|
||||||
private final List<StructuralUnitIdentifier> structuralUnitIdentifiers;
|
private final List<StructuralUnitIdentifier> structuralUnitIdentifiers;
|
||||||
|
|
||||||
public StructuralUnitService(List<StructuralUnitIdentifier> structuralUnitIdentifiers) {
|
public StructuralUnitService(GitRepositoryService gitRepositoryService,
|
||||||
|
DirectoryService directoryService,
|
||||||
|
List<StructuralUnitIdentifier> structuralUnitIdentifiers) {
|
||||||
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
this.directoryService = directoryService;
|
||||||
this.structuralUnitIdentifiers = structuralUnitIdentifiers;
|
this.structuralUnitIdentifiers = structuralUnitIdentifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StructuralUnit> getEntities() {
|
public List<StructuralUnit> getEntities(String repositoryUrl) throws IOException {
|
||||||
|
File rootPath = gitRepositoryService.getProjectDirectoryFile(repositoryUrl);
|
||||||
|
List<File> projectFiles = directoryService.getFilesRecursively(rootPath);
|
||||||
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
|
StructuralUnitIdentifier selectedIdentifier = structuralUnitIdentifiers.stream()
|
||||||
.filter(StructuralUnitIdentifier::canAppliedToProject)
|
.filter(structuralUnitIdentifier -> structuralUnitIdentifier.canAppliedToProject(projectFiles))
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
.orElseThrow(() -> new RuntimeException("Identifier not found"));
|
||||||
return selectedIdentifier.getEntityClasses();
|
return selectedIdentifier.getEntityClasses(projectFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package ru.ulstu.test;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
import ru.ulstu.extractor.heuristic.model.JavaProgrammingLanguage;
|
|
||||||
import ru.ulstu.extractor.heuristic.service.DetectorService;
|
|
||||||
import ru.ulstu.extractor.heuristic.service.JavaIdentifier;
|
|
||||||
|
|
||||||
public class HeuristicServiceTest {
|
|
||||||
private final JavaIdentifier javaIdentifier = new JavaIdentifier(new DetectorService());
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMainProgrammingLanguage() {
|
|
||||||
Assert.assertEquals(javaIdentifier.getMainProgrammingLanguage().orElse(null), new JavaProgrammingLanguage());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue