repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/persistance/CourseDAOImplTest.java | // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.model.Course;
import org.junit.Test;
import static org.junit.Assert.*; | package com.cloudcoders.gestaca.persistance;
public class CourseDAOImplTest {
@Test
public void shouldAddCourse() { | // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/test/java/com/cloudcoders/gestaca/persistance/CourseDAOImplTest.java
import com.cloudcoders.gestaca.model.Course;
import org.junit.Test;
import static org.junit.Assert.*;
package com.cloudcoders.gestaca.persistance;
public class CourseDAOImplTest {
@Test
public void shouldAddCourse() { | Course course = new Course("Prueba", "Prueba", 0); |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/taughtcourse/AddTaughtCourse.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.model.TaughtCourse; | package com.cloudcoders.gestaca.logic.taughtcourse;
public class AddTaughtCourse {
private ITaughtCourseDAO iTaughtCourseDAO;
public AddTaughtCourse(ITaughtCourseDAO iTaughtCourseDAO) {
this.iTaughtCourseDAO = iTaughtCourseDAO;
} | // Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/taughtcourse/AddTaughtCourse.java
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.model.TaughtCourse;
package com.cloudcoders.gestaca.logic.taughtcourse;
public class AddTaughtCourse {
private ITaughtCourseDAO iTaughtCourseDAO;
public AddTaughtCourse(ITaughtCourseDAO iTaughtCourseDAO) {
this.iTaughtCourseDAO = iTaughtCourseDAO;
} | public void add(TaughtCourse taughtCourse) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/ui/View.java | // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.Student;
import java.util.List; | package com.cloudcoders.gestaca.ui;
public interface View {
void showCourses(List<Course> courseList);
void showEmptyCourses();
Course askCourse();
String askDNI();
void showStudentNotFound();
void showStudentFoundAndEnrolled();
void showStudentEnrolled();
void showStudentFoundAndNotEnrolled();
| // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.Student;
import java.util.List;
package com.cloudcoders.gestaca.ui;
public interface View {
void showCourses(List<Course> courseList);
void showEmptyCourses();
Course askCourse();
String askDNI();
void showStudentNotFound();
void showStudentFoundAndEnrolled();
void showStudentEnrolled();
void showStudentFoundAndNotEnrolled();
| Student askStudent(); |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment; | package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO; | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO; | ITaughtCourseDAO iTaughtCourseDAO; |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment; | package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO; | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO; | IStudentDAO iStudentDAO; |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment; | package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment; | package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment; | package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
// public interface IEnrollmentDAO {
//
// Enrollment get(int id);
//
// List<Enrollment> getAll();
//
// void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse;
//
// Enrollment remove(Enrollment enrollment);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
import com.cloudcoders.gestaca.logic.IEnrollmentDAO;
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
package com.cloudcoders.gestaca.logic.enrollment;
public class AddEnrollment {
IEnrollmentDAO iEnrollmentDAO;
ITaughtCourseDAO iTaughtCourseDAO;
IStudentDAO iStudentDAO;
public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
this.iEnrollmentDAO = iEnrollmentDAO;
this.iTaughtCourseDAO = iTaughtCourseDAO;
this.iStudentDAO = iStudentDAO;
}
| public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/course/RemoveCourse.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course; | package com.cloudcoders.gestaca.logic.course;
public class RemoveCourse {
ICourseDAO iCourseDAO;
public RemoveCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/course/RemoveCourse.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
package com.cloudcoders.gestaca.logic.course;
public class RemoveCourse {
ICourseDAO iCourseDAO;
public RemoveCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| public Course remove(Course course) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/student/AddStudent.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student; | package com.cloudcoders.gestaca.logic.student;
public class AddStudent {
IStudentDAO iStudentDAO;
public AddStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/AddStudent.java
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student;
package com.cloudcoders.gestaca.logic.student;
public class AddStudent {
IStudentDAO iStudentDAO;
public AddStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| public void add(Student student) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/student/RemoveStudent.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student; | package com.cloudcoders.gestaca.logic.student;
public class RemoveStudent {
IStudentDAO iStudentDAO;
public RemoveStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/RemoveStudent.java
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student;
package com.cloudcoders.gestaca.logic.student;
public class RemoveStudent {
IStudentDAO iStudentDAO;
public RemoveStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| public Student remove(Student student) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/persistance/CourseDAOImpl.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.TaughtCourse;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; | package com.cloudcoders.gestaca.persistance;
public class CourseDAOImpl implements ICourseDAO{
private JsonParser parser;
public CourseDAOImpl(JsonParser parser) {
this.parser = parser;
}
@Override | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/persistance/CourseDAOImpl.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.TaughtCourse;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
package com.cloudcoders.gestaca.persistance;
public class CourseDAOImpl implements ICourseDAO{
private JsonParser parser;
public CourseDAOImpl(JsonParser parser) {
this.parser = parser;
}
@Override | public Course get(String name) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/persistance/CourseDAOImpl.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.TaughtCourse;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; | package com.cloudcoders.gestaca.persistance;
public class CourseDAOImpl implements ICourseDAO{
private JsonParser parser;
public CourseDAOImpl(JsonParser parser) {
this.parser = parser;
}
@Override
public Course get(String name) {
List<Course> courses = new ArrayList<>();
JSONArray jsonArray = null;
try {
jsonArray = parser.readFile("Course.json");
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Course res;
for (Object o : jsonArray) {
JSONObject aux = (JSONObject) o;
if (aux.get("name") == name) {
if (aux.get("taughtCourses") != null) {
res = new Course(
(String) aux.get("description"),
(String) aux.get("name"),
(int) aux.get("id"), | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/persistance/CourseDAOImpl.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.TaughtCourse;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
package com.cloudcoders.gestaca.persistance;
public class CourseDAOImpl implements ICourseDAO{
private JsonParser parser;
public CourseDAOImpl(JsonParser parser) {
this.parser = parser;
}
@Override
public Course get(String name) {
List<Course> courses = new ArrayList<>();
JSONArray jsonArray = null;
try {
jsonArray = parser.readFile("Course.json");
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Course res;
for (Object o : jsonArray) {
JSONObject aux = (JSONObject) o;
if (aux.get("name") == name) {
if (aux.get("taughtCourses") != null) {
res = new Course(
(String) aux.get("description"),
(String) aux.get("name"),
(int) aux.get("id"), | (List<TaughtCourse>) aux.get("taughtCourses")); |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/course/AddCourse.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course; | package com.cloudcoders.gestaca.logic.course;
public class AddCourse {
ICourseDAO iCourseDAO;
public AddCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/course/AddCourse.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
package com.cloudcoders.gestaca.logic.course;
public class AddCourse {
ICourseDAO iCourseDAO;
public AddCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| public void add(Course course) { |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/persistance/StudentDAOImplTest.java | // Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.model.Student;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.ArrayList;
import static org.junit.Assert.*; | package com.cloudcoders.gestaca.persistance;
public class StudentDAOImplTest {
@Test
public void addStudent() { | // Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/test/java/com/cloudcoders/gestaca/persistance/StudentDAOImplTest.java
import com.cloudcoders.gestaca.model.Student;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.ArrayList;
import static org.junit.Assert.*;
package com.cloudcoders.gestaca.persistance;
public class StudentDAOImplTest {
@Test
public void addStudent() { | Student st = new Student(03725, "C/Dtr 2", "554564m", "Alsx asdas", "45454sf"); |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/course/GetCourse.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course; | package com.cloudcoders.gestaca.logic.course;
public class GetCourse {
ICourseDAO iCourseDAO;
public GetCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetCourse.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
package com.cloudcoders.gestaca.logic.course;
public class GetCourse {
ICourseDAO iCourseDAO;
public GetCourse(ICourseDAO iCourseDAO) {
this.iCourseDAO = iCourseDAO;
}
| public Course get(String name) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/student/GetAllStudents.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student;
import java.util.List; | package com.cloudcoders.gestaca.logic.student;
public class GetAllStudents {
private IStudentDAO iStudentDAO;
public GetAllStudents(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetAllStudents.java
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student;
import java.util.List;
package com.cloudcoders.gestaca.logic.student;
public class GetAllStudents {
private IStudentDAO iStudentDAO;
public GetAllStudents(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| public List<Student> getStudents() { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/taughtcourse/RemoveTaughtCourse.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.model.TaughtCourse; | package com.cloudcoders.gestaca.logic.taughtcourse;
public class RemoveTaughtCourse {
private ITaughtCourseDAO iTaughtCourseDAO;
public RemoveTaughtCourse(ITaughtCourseDAO iTaughtCourseDAO) {
this.iTaughtCourseDAO = iTaughtCourseDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/ITaughtCourseDAO.java
// public interface ITaughtCourseDAO {
//
// void add(TaughtCourse taughtCourse);
//
// TaughtCourse remove(TaughtCourse taughtCourse);
//
// TaughtCourse get(int id);
//
// List<TaughtCourse> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/TaughtCourse.java
// public class TaughtCourse {
// private int quota;
// private int sessionDuration;
// private Date startDate;
// private int totalPrice;
// private String teachingday;
// private Date endDate;
// private int id;
// private Office office;
// private Teacher teacher;
// private List<Enrollment> enrollments;
// private Course course;
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.course = course;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public TaughtCourse(int quota,
// int sessionDuration,
// Date startDate,
// int totalPrice,
// String teachingday,
// Date endDate,
// int id,
// Office office,
// Teacher teacher,
// List<Enrollment> enrollments,
// Course course) {
// this.quota = quota;
// this.sessionDuration = sessionDuration;
// this.startDate = startDate;
// this.totalPrice = totalPrice;
// this.teachingday = teachingday;
// this.endDate = endDate;
// this.id = id;
// this.office = office;
// this.teacher = teacher;
// this.enrollments = enrollments;
// this.course = course;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public int getQuota() {
// return quota;
// }
//
// public int getSessionDuration() {
// return sessionDuration;
// }
//
// public Date getStartDate() {
// return startDate;
// }
//
// public int getTotalPrice() {
// return totalPrice;
// }
//
// public String getTeachingday() {
// return teachingday;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public int getId() {
// return id;
// }
//
// public Office getOffice() {
// return office;
// }
//
// public void setOffice(Office office) {
// this.office = office;
// }
//
// public Teacher getTeacher() {
// return teacher;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// public Course getCourse() {
// return course;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/taughtcourse/RemoveTaughtCourse.java
import com.cloudcoders.gestaca.logic.ITaughtCourseDAO;
import com.cloudcoders.gestaca.model.TaughtCourse;
package com.cloudcoders.gestaca.logic.taughtcourse;
public class RemoveTaughtCourse {
private ITaughtCourseDAO iTaughtCourseDAO;
public RemoveTaughtCourse(ITaughtCourseDAO iTaughtCourseDAO) {
this.iTaughtCourseDAO = iTaughtCourseDAO;
}
| public TaughtCourse remove(TaughtCourse taughtCourse) { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/ui/ExampleUi.java | // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.model.Course;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner; | package com.cloudcoders.gestaca.ui;
public class ExampleUi {
public static void main(String... args) {
Scanner scanner = new Scanner(System.in);
CommandLine cmd = new CommandLine(scanner);
String command;
| // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/ui/ExampleUi.java
import com.cloudcoders.gestaca.model.Course;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
package com.cloudcoders.gestaca.ui;
public class ExampleUi {
public static void main(String... args) {
Scanner scanner = new Scanner(System.in);
CommandLine cmd = new CommandLine(scanner);
String command;
| List<Course> courseList = new ArrayList<Course>(); |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/ui/CommandLine.java | // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.Student;
import java.util.List;
import java.util.Scanner; | } catch (NumberFormatException e) {
System.out.println("ERROR: Introduce un numero.");
}
} while (choice < 0 || choice > courseList.size());
Course course = this.courseList.get(choice);
return course;
}
public String askDNI() {
System.out.print("DNI alumno: ");
this.dni = scanner.nextLine();
return dni;
}
public void showStudentNotFound() {
System.out.println("Alumno no encontrado, introduce sus datos.");
}
public void showStudentFoundAndEnrolled() {
System.out.println("ERROR: Alumno ya escrito en el curso.");
}
public void showStudentFoundAndNotEnrolled() {
System.out.println("Alumno inscrito en el curso.");
}
public void showStudentEnrolled() {
System.out.println("Alumno matriculado y inscrito en el curso.");
}
| // Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/ui/CommandLine.java
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.model.Student;
import java.util.List;
import java.util.Scanner;
} catch (NumberFormatException e) {
System.out.println("ERROR: Introduce un numero.");
}
} while (choice < 0 || choice > courseList.size());
Course course = this.courseList.get(choice);
return course;
}
public String askDNI() {
System.out.print("DNI alumno: ");
this.dni = scanner.nextLine();
return dni;
}
public void showStudentNotFound() {
System.out.println("Alumno no encontrado, introduce sus datos.");
}
public void showStudentFoundAndEnrolled() {
System.out.println("ERROR: Alumno ya escrito en el curso.");
}
public void showStudentFoundAndNotEnrolled() {
System.out.println("Alumno inscrito en el curso.");
}
public void showStudentEnrolled() {
System.out.println("Alumno matriculado y inscrito en el curso.");
}
| public Student askStudent() { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
| import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import java.util.List; | package com.cloudcoders.gestaca.logic.course;
public class GetAllCourses {
ICourseDAO icourseDAO;
public GetAllCourses(ICourseDAO icourseDAO) {
this.icourseDAO = icourseDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/ICourseDAO.java
// public interface ICourseDAO {
//
// Course get(String name);
//
// List<Course> getAll();
//
// void add(Course course);
//
// Course remove(Course course);
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
import com.cloudcoders.gestaca.logic.ICourseDAO;
import com.cloudcoders.gestaca.model.Course;
import java.util.List;
package com.cloudcoders.gestaca.logic.course;
public class GetAllCourses {
ICourseDAO icourseDAO;
public GetAllCourses(ICourseDAO icourseDAO) {
this.icourseDAO = icourseDAO;
}
| public List<Course> getCourses() { |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
import java.util.List; | package com.cloudcoders.gestaca.logic;
public interface IEnrollmentDAO {
Enrollment get(int id);
List<Enrollment> getAll();
| // Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
import java.util.List;
package com.cloudcoders.gestaca.logic;
public interface IEnrollmentDAO {
Enrollment get(int id);
List<Enrollment> getAll();
| void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse; |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
| import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
import java.util.List; | package com.cloudcoders.gestaca.logic;
public interface IEnrollmentDAO {
Enrollment get(int id);
List<Enrollment> getAll();
| // Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidPersonException.java
// public class InvalidPersonException extends Exception {
// public InvalidPersonException(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/exceptions/InvalidTaughtCourse.java
// public class InvalidTaughtCourse extends Exception {
// public InvalidTaughtCourse(String message) {
// super(message);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Enrollment.java
// public class Enrollment {
// private Date cancellationDate;
// private Date enrollemntDate;
// private boolean uniquePayment;
// private List<Absence> absences;
// private TaughtCourse taughtCourse;
// private int id;
// private Student student;
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.taughtCourse = taughtCourse;
// this.student = student;
// this.absences = new ArrayList<Absence>();
// }
//
// public Enrollment(Date cancellationDate,
// Date enrollemntDate,
// boolean uniquePayment,
// int id, List<Absence> absences,
// TaughtCourse taughtCourse,
// Student student) {
// this.cancellationDate = cancellationDate;
// this.enrollemntDate = enrollemntDate;
// this.uniquePayment = uniquePayment;
// this.id = id;
// this.absences = absences;
// this.taughtCourse = taughtCourse;
// this.student = student;
// }
//
// public void addAbsences(Absence absence) {
// this.absences.add(absence);
// }
//
// public void removeAbsences(Absence absence) {
// this.absences.remove(absence);
// }
//
// public Student getStudent() {
// return student;
// }
//
// public Date getCancellationDate() {
// return cancellationDate;
// }
//
// public Date getEnrollemntDate() {
// return enrollemntDate;
// }
//
// public boolean isUniquePayment() {
// return uniquePayment;
// }
//
// public int getId() {
// return id;
// }
//
// public List<Absence> getAbsences() {
// return absences;
// }
//
// public TaughtCourse getTaughtCourse() {
// return taughtCourse;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/IEnrollmentDAO.java
import com.cloudcoders.gestaca.logic.exceptions.InvalidPersonException;
import com.cloudcoders.gestaca.logic.exceptions.InvalidTaughtCourse;
import com.cloudcoders.gestaca.model.Enrollment;
import java.util.List;
package com.cloudcoders.gestaca.logic;
public interface IEnrollmentDAO {
Enrollment get(int id);
List<Enrollment> getAll();
| void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse; |
CloudCoders/GestAca | src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
| import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student; | package com.cloudcoders.gestaca.logic.student;
public class GetStudent {
private IStudentDAO iStudentDAO;
public GetStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| // Path: src/main/java/com/cloudcoders/gestaca/logic/IStudentDAO.java
// public interface IStudentDAO {
//
// Student get(String id);
//
// void add(Student student);
//
// Student remove(Student student);
//
// List<Student> getAll();
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Student.java
// public class Student extends Person {
// private String iban;
// private List<Enrollment> enrollments;
//
// public Student(int zip, String address, String id, String name, String iban) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = new ArrayList<Enrollment>();
// }
//
// public Student(int zip, String address, String id, String name, String iban, List<Enrollment> enrollments) {
// super(zip, address, id, name);
// this.iban = iban;
// this.enrollments = enrollments;
// }
//
//
// public void addEnrollment(Enrollment enrollment) {
// this.enrollments.add(enrollment);
// }
//
// public void removeEnrollment(Enrollment enrollment) {
// this.enrollments.remove(enrollment);
// }
//
// public String getIban() {
// return iban;
// }
//
// public List<Enrollment> getEnrollments() {
// return enrollments;
// }
//
// }
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
import com.cloudcoders.gestaca.logic.IStudentDAO;
import com.cloudcoders.gestaca.model.Student;
package com.cloudcoders.gestaca.logic.student;
public class GetStudent {
private IStudentDAO iStudentDAO;
public GetStudent(IStudentDAO iStudentDAO) {
this.iStudentDAO = iStudentDAO;
}
| public Student getStudent(String dni) { |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
| import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() { | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
// Path: src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java
import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() { | View view = mock(View.class); |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
| import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) { | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
// Path: src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java
import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) { | GetStudent getStudent = mock(GetStudent.class); |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
| import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class); | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
// Path: src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java
import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class); | GetAllCourses getAllCourses = mock(GetAllCourses.class); |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
| import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class);
GetAllCourses getAllCourses = mock(GetAllCourses.class); | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
// Path: src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java
import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class);
GetAllCourses getAllCourses = mock(GetAllCourses.class); | given(getAllCourses.getCourses()).willReturn(Arrays.asList(new Course("", "", 0))); |
CloudCoders/GestAca | src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
| import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; | package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class);
GetAllCourses getAllCourses = mock(GetAllCourses.class);
given(getAllCourses.getCourses()).willReturn(Arrays.asList(new Course("", "", 0))); | // Path: src/main/java/com/cloudcoders/gestaca/logic/course/GetAllCourses.java
// public class GetAllCourses {
// ICourseDAO icourseDAO;
//
// public GetAllCourses(ICourseDAO icourseDAO) {
// this.icourseDAO = icourseDAO;
// }
//
// public List<Course> getCourses() {
// return icourseDAO.getAll();
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/enrollment/AddEnrollment.java
// public class AddEnrollment {
//
// IEnrollmentDAO iEnrollmentDAO;
// ITaughtCourseDAO iTaughtCourseDAO;
// IStudentDAO iStudentDAO;
//
// public AddEnrollment(IEnrollmentDAO iEnrollmentDAO, ITaughtCourseDAO iTaughtCourseDAO, IStudentDAO iStudentDAO) {
// this.iEnrollmentDAO = iEnrollmentDAO;
// this.iTaughtCourseDAO = iTaughtCourseDAO;
// this.iStudentDAO = iStudentDAO;
// }
//
// public void add(Enrollment enrollment) throws InvalidPersonException, InvalidTaughtCourse {
//
// if (iStudentDAO.get(enrollment.getStudent().getId()) == null) {
// throw new InvalidPersonException("Invalid person!");
// }
//
// if (iTaughtCourseDAO.get(enrollment.getTaughtCourse().getId()) == null) {
// throw new InvalidTaughtCourse("Invalid TaughtCourse Madafaka");
// }
//
// iEnrollmentDAO.add(enrollment);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/logic/student/GetStudent.java
// public class GetStudent {
//
// private IStudentDAO iStudentDAO;
//
// public GetStudent(IStudentDAO iStudentDAO) {
// this.iStudentDAO = iStudentDAO;
// }
//
// public Student getStudent(String dni) {
// return iStudentDAO.get(dni);
// }
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/model/Course.java
// public class Course {
// private String description;
// private String name;
// private int id;
// private List<TaughtCourse> taughtCourses;
//
// public Course(String description, String name, int id, List<TaughtCourse> taughtCourses) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = taughtCourses;
// }
//
// public Course(String description, String name, int id) {
// this.description = description;
// this.name = name;
// this.id = id;
// this.taughtCourses = new ArrayList<TaughtCourse>();
// }
//
// public void addTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.add(taughtCourse);
// }
//
// public void removeTaughtCourse(TaughtCourse taughtCourse) {
// this.taughtCourses.remove(taughtCourse);
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getName() {
// return name;
// }
//
// public int getId() {
// return id;
// }
//
// public List<TaughtCourse> getTaughtCourses() {
// return taughtCourses;
// }
//
// }
//
// Path: src/main/java/com/cloudcoders/gestaca/ui/View.java
// public interface View {
// void showCourses(List<Course> courseList);
//
// void showEmptyCourses();
//
// Course askCourse();
//
// String askDNI();
//
// void showStudentNotFound();
//
// void showStudentFoundAndEnrolled();
//
// void showStudentEnrolled();
//
// void showStudentFoundAndNotEnrolled();
//
// Student askStudent();
//
// void showStudent(Student student);
//
// Course askCreateCourse();
//
// void showCurseCreated();
//
// void showCurseAlreadyExists();
// }
// Path: src/test/java/com/cloudcoders/gestaca/ui/controller/EnrollmentCommandShould.java
import com.cloudcoders.gestaca.logic.course.GetAllCourses;
import com.cloudcoders.gestaca.logic.enrollment.AddEnrollment;
import com.cloudcoders.gestaca.logic.student.GetStudent;
import com.cloudcoders.gestaca.model.Course;
import com.cloudcoders.gestaca.ui.View;
import org.junit.Test;
import java.util.Arrays;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
package com.cloudcoders.gestaca.ui.controller;
public class EnrollmentCommandShould {
@Test
public void
call_to_show_all_courses() {
View view = mock(View.class);
getEnrollment(view);
verify(view).showCourses(anyObject());
}
private void getEnrollment(View view) {
GetStudent getStudent = mock(GetStudent.class);
GetAllCourses getAllCourses = mock(GetAllCourses.class);
given(getAllCourses.getCourses()).willReturn(Arrays.asList(new Course("", "", 0))); | AddEnrollment addEnrollment = mock(AddEnrollment.class); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleTest.java | // Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java
// public class TypedGraphModuleBuilder {
// private TypeRegistry typeRegistry = new TypeRegistry();
//
// public TypedGraphModuleBuilder() {
//
// }
//
// public TypedGraphModuleBuilder withClass(Class<?> type) {
// typeRegistry.add(type);
// return this;
// }
//
// public Module build() {
// final TypeManager manager = new TypeManager(typeRegistry);
// return new AbstractModule() {
//
// @Override
// public void doConfigure(FramedGraphConfiguration config) {
// config.addTypeResolver(manager);
// config.addFrameInitializer(manager);
// }
// };
// }
// }
| import com.tinkerpop.frames.*;
import junit.framework.TestCase;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import com.tinkerpop.frames.modules.typedgraph.TypeField;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
import com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder; | package com.tinkerpop.frames.modules.typedgraph;
public class TypedGraphModuleTest extends TestCase {
public static @TypeField("type")
interface Base {
@Property("label")
String getLabel();
};
public static @TypeValue("A")
interface A extends Base {
};
public static @TypeValue("B")
interface B extends Base {
};
public static @TypeValue("C")
interface C extends B {
@Property("label")
void setLabel(String label);
@InVertex
<T extends Base> T getInVertex();
};
public void testSerializeVertexType() {
Graph graph = new TinkerGraph(); | // Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java
// public class TypedGraphModuleBuilder {
// private TypeRegistry typeRegistry = new TypeRegistry();
//
// public TypedGraphModuleBuilder() {
//
// }
//
// public TypedGraphModuleBuilder withClass(Class<?> type) {
// typeRegistry.add(type);
// return this;
// }
//
// public Module build() {
// final TypeManager manager = new TypeManager(typeRegistry);
// return new AbstractModule() {
//
// @Override
// public void doConfigure(FramedGraphConfiguration config) {
// config.addTypeResolver(manager);
// config.addFrameInitializer(manager);
// }
// };
// }
// }
// Path: src/test/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleTest.java
import com.tinkerpop.frames.*;
import junit.framework.TestCase;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import com.tinkerpop.frames.modules.typedgraph.TypeField;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
import com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder;
package com.tinkerpop.frames.modules.typedgraph;
public class TypedGraphModuleTest extends TestCase {
public static @TypeField("type")
interface Base {
@Property("label")
String getLabel();
};
public static @TypeValue("A")
interface A extends Base {
};
public static @TypeValue("B")
interface B extends Base {
};
public static @TypeValue("C")
interface C extends B {
@Property("label")
void setLabel(String label);
@InVertex
<T extends Base> T getInVertex();
};
public void testSerializeVertexType() {
Graph graph = new TinkerGraph(); | FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class) |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
| import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module; | package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
| // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
// Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module;
package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
| public Module build() { |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
| import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module; | package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
public Module build() {
final TypeManager manager = new TypeManager(typeRegistry); | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
// Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module;
package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
public Module build() {
final TypeManager manager = new TypeManager(typeRegistry); | return new AbstractModule() { |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
| import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module; | package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
public Module build() {
final TypeManager manager = new TypeManager(typeRegistry);
return new AbstractModule() {
@Override | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
// Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypedGraphModuleBuilder.java
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
import com.tinkerpop.frames.modules.Module;
package com.tinkerpop.frames.modules.typedgraph;
/**
* TODO
*/
public class TypedGraphModuleBuilder {
private TypeRegistry typeRegistry = new TypeRegistry();
public TypedGraphModuleBuilder() {
}
public TypedGraphModuleBuilder withClass(Class<?> type) {
typeRegistry.add(type);
return this;
}
public Module build() {
final TypeManager manager = new TypeManager(typeRegistry);
return new AbstractModule() {
@Override | public void doConfigure(FramedGraphConfiguration config) { |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedElement.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
| import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.util.ElementHelper;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.MethodHandler;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map; | if (null == framedGraph) {
throw new IllegalArgumentException("FramedGraph can not be null");
}
if (null == element) {
throw new IllegalArgumentException("Element can not be null");
}
this.element = element;
this.framedGraph = framedGraph;
this.direction = direction;
}
public FramedElement(final FramedGraph framedGraph, final Element element) {
this(framedGraph, element, Direction.OUT);
}
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
if (method.equals(hashCodeMethod)) {
return this.element.hashCode();
} else if (method.equals(equalsMethod)) {
return this.proxyEquals(arguments[0]);
} else if (method.equals(toStringMethod)) {
return this.element.toString();
} else if (method.equals(asVertexMethod) || method.equals(asEdgeMethod)) {
return this.element;
}
final Annotation[] annotations = method.getAnnotations(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedElement.java
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.util.ElementHelper;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.MethodHandler;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map;
if (null == framedGraph) {
throw new IllegalArgumentException("FramedGraph can not be null");
}
if (null == element) {
throw new IllegalArgumentException("Element can not be null");
}
this.element = element;
this.framedGraph = framedGraph;
this.direction = direction;
}
public FramedElement(final FramedGraph framedGraph, final Element element) {
this(framedGraph, element, Direction.OUT);
}
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
if (method.equals(hashCodeMethod)) {
return this.element.hashCode();
} else if (method.equals(equalsMethod)) {
return this.proxyEquals(arguments[0]);
} else if (method.equals(toStringMethod)) {
return this.element.toString();
} else if (method.equals(asVertexMethod) || method.equals(asEdgeMethod)) {
return this.element;
}
final Annotation[] annotations = method.getAnnotations(); | Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = this.framedGraph.getConfig().getAnnotationHandlers(); |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedElement.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
| import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.util.ElementHelper;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.MethodHandler;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map; | throw new IllegalArgumentException("FramedGraph can not be null");
}
if (null == element) {
throw new IllegalArgumentException("Element can not be null");
}
this.element = element;
this.framedGraph = framedGraph;
this.direction = direction;
}
public FramedElement(final FramedGraph framedGraph, final Element element) {
this(framedGraph, element, Direction.OUT);
}
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
if (method.equals(hashCodeMethod)) {
return this.element.hashCode();
} else if (method.equals(equalsMethod)) {
return this.proxyEquals(arguments[0]);
} else if (method.equals(toStringMethod)) {
return this.element.toString();
} else if (method.equals(asVertexMethod) || method.equals(asEdgeMethod)) {
return this.element;
}
final Annotation[] annotations = method.getAnnotations();
Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = this.framedGraph.getConfig().getAnnotationHandlers(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedElement.java
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.blueprints.util.ElementHelper;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.MethodHandler;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map;
throw new IllegalArgumentException("FramedGraph can not be null");
}
if (null == element) {
throw new IllegalArgumentException("Element can not be null");
}
this.element = element;
this.framedGraph = framedGraph;
this.direction = direction;
}
public FramedElement(final FramedGraph framedGraph, final Element element) {
this(framedGraph, element, Direction.OUT);
}
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
if (method.equals(hashCodeMethod)) {
return this.element.hashCode();
} else if (method.equals(equalsMethod)) {
return this.proxyEquals(arguments[0]);
} else if (method.equals(toStringMethod)) {
return this.element.toString();
} else if (method.equals(asVertexMethod) || method.equals(asEdgeMethod)) {
return this.element;
}
final Annotation[] annotations = method.getAnnotations();
Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = this.framedGraph.getConfig().getAnnotationHandlers(); | Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = this.framedGraph.getConfig().getMethodHandlers(); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/domain/classes/Project.java | // Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedBy.java
// public interface CreatedBy {
//
// @Domain
// public Project getDomain();
//
// @Range
// public Person getRange();
//
// @Property("weight")
// public Float getWeight();
// }
//
// Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedInfo.java
// public interface CreatedInfo extends EdgeFrame {
// @OutVertex
// Person getPerson();
//
// @InVertex
// Project getProject();
//
// @Property("weight")
// public Float getWeight();
//
// @Property("weight")
// public void setWeight(float weight);
// }
| import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Incidence;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.domain.incidences.CreatedBy;
import com.tinkerpop.frames.domain.incidences.CreatedInfo;
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerClass; | package com.tinkerpop.frames.domain.classes;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@JavaHandlerClass(ProjectImpl.class)
public interface Project extends NamedObject {
@Property("lang")
public String getLanguage();
@Adjacency(label = "created", direction = Direction.IN)
public Iterable<Person> getCreatedByPeople();
@Incidence(label = "created", direction = Direction.IN) | // Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedBy.java
// public interface CreatedBy {
//
// @Domain
// public Project getDomain();
//
// @Range
// public Person getRange();
//
// @Property("weight")
// public Float getWeight();
// }
//
// Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedInfo.java
// public interface CreatedInfo extends EdgeFrame {
// @OutVertex
// Person getPerson();
//
// @InVertex
// Project getProject();
//
// @Property("weight")
// public Float getWeight();
//
// @Property("weight")
// public void setWeight(float weight);
// }
// Path: src/test/java/com/tinkerpop/frames/domain/classes/Project.java
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Incidence;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.domain.incidences.CreatedBy;
import com.tinkerpop.frames.domain.incidences.CreatedInfo;
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerClass;
package com.tinkerpop.frames.domain.classes;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@JavaHandlerClass(ProjectImpl.class)
public interface Project extends NamedObject {
@Property("lang")
public String getLanguage();
@Adjacency(label = "created", direction = Direction.IN)
public Iterable<Person> getCreatedByPeople();
@Incidence(label = "created", direction = Direction.IN) | public Iterable<CreatedBy> getCreatedBy(); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/domain/classes/Project.java | // Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedBy.java
// public interface CreatedBy {
//
// @Domain
// public Project getDomain();
//
// @Range
// public Person getRange();
//
// @Property("weight")
// public Float getWeight();
// }
//
// Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedInfo.java
// public interface CreatedInfo extends EdgeFrame {
// @OutVertex
// Person getPerson();
//
// @InVertex
// Project getProject();
//
// @Property("weight")
// public Float getWeight();
//
// @Property("weight")
// public void setWeight(float weight);
// }
| import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Incidence;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.domain.incidences.CreatedBy;
import com.tinkerpop.frames.domain.incidences.CreatedInfo;
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerClass; | package com.tinkerpop.frames.domain.classes;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@JavaHandlerClass(ProjectImpl.class)
public interface Project extends NamedObject {
@Property("lang")
public String getLanguage();
@Adjacency(label = "created", direction = Direction.IN)
public Iterable<Person> getCreatedByPeople();
@Incidence(label = "created", direction = Direction.IN)
public Iterable<CreatedBy> getCreatedBy();
@Incidence(label = "created", direction = Direction.IN) | // Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedBy.java
// public interface CreatedBy {
//
// @Domain
// public Project getDomain();
//
// @Range
// public Person getRange();
//
// @Property("weight")
// public Float getWeight();
// }
//
// Path: src/test/java/com/tinkerpop/frames/domain/incidences/CreatedInfo.java
// public interface CreatedInfo extends EdgeFrame {
// @OutVertex
// Person getPerson();
//
// @InVertex
// Project getProject();
//
// @Property("weight")
// public Float getWeight();
//
// @Property("weight")
// public void setWeight(float weight);
// }
// Path: src/test/java/com/tinkerpop/frames/domain/classes/Project.java
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Incidence;
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.domain.incidences.CreatedBy;
import com.tinkerpop.frames.domain.incidences.CreatedInfo;
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerClass;
package com.tinkerpop.frames.domain.classes;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
@JavaHandlerClass(ProjectImpl.class)
public interface Project extends NamedObject {
@Property("lang")
public String getLanguage();
@Adjacency(label = "created", direction = Direction.IN)
public Iterable<Person> getCreatedByPeople();
@Incidence(label = "created", direction = Direction.IN)
public Iterable<CreatedBy> getCreatedBy();
@Incidence(label = "created", direction = Direction.IN) | public Iterable<CreatedInfo> getCreatedInfo(); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/modules/typedgraph/TypeRegistryTest.java | // Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypeRegistry.java
// public class TypeRegistry {
// Map<Class<?>, Class<?>> typeFields = new HashMap<Class<?>, Class<?>>();
// Map<TypeDiscriminator, Class<?>> typeDiscriminators = new HashMap<TypeDiscriminator, Class<?>>();
//
//
//
// /**
// * @return The interface that has the {@link TypeField} annotation for this class. (Either the class itself, or a base class if the class was registered).
// */
// public Class<?> getTypeHoldingTypeField(Class<?> type) {
// if (type.getAnnotation(TypeField.class) != null)
// return type;
// return typeFields.get(type);
// }
//
// /**
// * @param typeHoldingTypeField The type that has the {@link TypeField} annotation for the Proxy class to be constructed.
// * @param typeValue The actual persisted value for a type field on an {@link Element} in the graph
// * @return The type that needs to be constructed, or null if there is no registered class that matches the input values.
// */
// public Class<?> getType(Class<?> typeHoldingTypeField, String typeValue) {
// Class<?> result = typeDiscriminators.get(new TypeDiscriminator(typeHoldingTypeField, typeValue));
// return result;
// }
//
// static final class TypeDiscriminator {
// private Class<?> typeHoldingTypeField;
// private String value;
//
// TypeDiscriminator(Class<?> typeHoldingTypeField, String value) {
// Validate.assertNotNull(typeHoldingTypeField, value);
// this.typeHoldingTypeField = typeHoldingTypeField;
// this.value = value;
// }
//
// @Override public int hashCode() {
// return 31 * (31 + typeHoldingTypeField.hashCode()) + value.hashCode();
// }
//
// @Override public boolean equals(Object obj) {
// if (obj instanceof TypeDiscriminator) {
// TypeDiscriminator other = (TypeDiscriminator)obj;
// //fields are never null:
// return typeHoldingTypeField.equals(other.typeHoldingTypeField) && value.equals(other.value);
// }
// return false;
// }
// }
//
// /**
// * @param Add the interface to the registry. The interface should have a {@link TypeValue} annotation, and there should be a {@link TypeField} annotation
// * on the interface or its parents.
// */
// public TypeRegistry add(Class<?> type) {
// Validate.assertArgument(type.isInterface(), "Not an interface: %s", type.getName());
// if (!typeFields.containsKey(type)) {
// Class<?> typeHoldingTypeField = findTypeHoldingTypeField(type);
// Validate.assertArgument(typeHoldingTypeField != null, "The type and its supertypes don't have a @TypeField annotation: %s", type.getName());
// typeFields.put(type, typeHoldingTypeField);
// registerTypeValue(type, typeHoldingTypeField);
// }
// return this;
// }
//
//
//
//
// private Class<?> findTypeHoldingTypeField(Class<?> type) {
// Class<?> typeHoldingTypeField = type.getAnnotation(TypeField.class) == null ? null : type;
// for (Class<?> parentType: type.getInterfaces()) {
// Class<?> parentTypeHoldingTypeField = findTypeHoldingTypeField(parentType);
// Validate.assertArgument(parentTypeHoldingTypeField == null || typeHoldingTypeField == null || parentTypeHoldingTypeField == typeHoldingTypeField, "You have multiple TypeField annotations in your class-hierarchy for %s", type.getName());
// if (typeHoldingTypeField == null)
// typeHoldingTypeField = parentTypeHoldingTypeField;
// }
// return typeHoldingTypeField;
// }
//
// private void registerTypeValue(Class<?> type, Class<?> typeHoldingTypeField) {
// TypeValue typeValue = type.getAnnotation(TypeValue.class);
// Validate.assertArgument(typeValue != null, "The type does not have a @TypeValue annotation: %s", type.getName());
// typeDiscriminators.put(new TypeRegistry.TypeDiscriminator(typeHoldingTypeField, typeValue.value()), type);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.tinkerpop.frames.modules.typedgraph.TypeField;
import com.tinkerpop.frames.modules.typedgraph.TypeRegistry;
import com.tinkerpop.frames.modules.typedgraph.TypeValue; | package com.tinkerpop.frames.modules.typedgraph;
public class TypeRegistryTest {
@Test(expected = IllegalArgumentException.class) public void noAnotations() {
//You can't register interfaces when there is no @TypeField on it or on any of the parents: | // Path: src/main/java/com/tinkerpop/frames/modules/typedgraph/TypeRegistry.java
// public class TypeRegistry {
// Map<Class<?>, Class<?>> typeFields = new HashMap<Class<?>, Class<?>>();
// Map<TypeDiscriminator, Class<?>> typeDiscriminators = new HashMap<TypeDiscriminator, Class<?>>();
//
//
//
// /**
// * @return The interface that has the {@link TypeField} annotation for this class. (Either the class itself, or a base class if the class was registered).
// */
// public Class<?> getTypeHoldingTypeField(Class<?> type) {
// if (type.getAnnotation(TypeField.class) != null)
// return type;
// return typeFields.get(type);
// }
//
// /**
// * @param typeHoldingTypeField The type that has the {@link TypeField} annotation for the Proxy class to be constructed.
// * @param typeValue The actual persisted value for a type field on an {@link Element} in the graph
// * @return The type that needs to be constructed, or null if there is no registered class that matches the input values.
// */
// public Class<?> getType(Class<?> typeHoldingTypeField, String typeValue) {
// Class<?> result = typeDiscriminators.get(new TypeDiscriminator(typeHoldingTypeField, typeValue));
// return result;
// }
//
// static final class TypeDiscriminator {
// private Class<?> typeHoldingTypeField;
// private String value;
//
// TypeDiscriminator(Class<?> typeHoldingTypeField, String value) {
// Validate.assertNotNull(typeHoldingTypeField, value);
// this.typeHoldingTypeField = typeHoldingTypeField;
// this.value = value;
// }
//
// @Override public int hashCode() {
// return 31 * (31 + typeHoldingTypeField.hashCode()) + value.hashCode();
// }
//
// @Override public boolean equals(Object obj) {
// if (obj instanceof TypeDiscriminator) {
// TypeDiscriminator other = (TypeDiscriminator)obj;
// //fields are never null:
// return typeHoldingTypeField.equals(other.typeHoldingTypeField) && value.equals(other.value);
// }
// return false;
// }
// }
//
// /**
// * @param Add the interface to the registry. The interface should have a {@link TypeValue} annotation, and there should be a {@link TypeField} annotation
// * on the interface or its parents.
// */
// public TypeRegistry add(Class<?> type) {
// Validate.assertArgument(type.isInterface(), "Not an interface: %s", type.getName());
// if (!typeFields.containsKey(type)) {
// Class<?> typeHoldingTypeField = findTypeHoldingTypeField(type);
// Validate.assertArgument(typeHoldingTypeField != null, "The type and its supertypes don't have a @TypeField annotation: %s", type.getName());
// typeFields.put(type, typeHoldingTypeField);
// registerTypeValue(type, typeHoldingTypeField);
// }
// return this;
// }
//
//
//
//
// private Class<?> findTypeHoldingTypeField(Class<?> type) {
// Class<?> typeHoldingTypeField = type.getAnnotation(TypeField.class) == null ? null : type;
// for (Class<?> parentType: type.getInterfaces()) {
// Class<?> parentTypeHoldingTypeField = findTypeHoldingTypeField(parentType);
// Validate.assertArgument(parentTypeHoldingTypeField == null || typeHoldingTypeField == null || parentTypeHoldingTypeField == typeHoldingTypeField, "You have multiple TypeField annotations in your class-hierarchy for %s", type.getName());
// if (typeHoldingTypeField == null)
// typeHoldingTypeField = parentTypeHoldingTypeField;
// }
// return typeHoldingTypeField;
// }
//
// private void registerTypeValue(Class<?> type, Class<?> typeHoldingTypeField) {
// TypeValue typeValue = type.getAnnotation(TypeValue.class);
// Validate.assertArgument(typeValue != null, "The type does not have a @TypeValue annotation: %s", type.getName());
// typeDiscriminators.put(new TypeRegistry.TypeDiscriminator(typeHoldingTypeField, typeValue.value()), type);
// }
// }
// Path: src/test/java/com/tinkerpop/frames/modules/typedgraph/TypeRegistryTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import com.tinkerpop.frames.modules.typedgraph.TypeField;
import com.tinkerpop.frames.modules.typedgraph.TypeRegistry;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
package com.tinkerpop.frames.modules.typedgraph;
public class TypeRegistryTest {
@Test(expected = IllegalArgumentException.class) public void noAnotations() {
//You can't register interfaces when there is no @TypeField on it or on any of the parents: | new TypeRegistry().add(Empty.class); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/modules/AbstractModuleTest.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
| import junit.framework.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule; | package com.tinkerpop.frames.modules;
public class AbstractModuleTest {
@Test
public void testNoWrapping() {
Graph baseGraph = Mockito.mock(Graph.class);
TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
| // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
// Path: src/test/java/com/tinkerpop/frames/modules/AbstractModuleTest.java
import junit.framework.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
package com.tinkerpop.frames.modules;
public class AbstractModuleTest {
@Test
public void testNoWrapping() {
Graph baseGraph = Mockito.mock(Graph.class);
TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
| FramedGraphConfiguration config = new FramedGraphConfiguration(); |
tinkerpop/frames | src/test/java/com/tinkerpop/frames/modules/AbstractModuleTest.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
| import junit.framework.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule; | package com.tinkerpop.frames.modules;
public class AbstractModuleTest {
@Test
public void testNoWrapping() {
Graph baseGraph = Mockito.mock(Graph.class);
TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
FramedGraphConfiguration config = new FramedGraphConfiguration(); | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
// public class AbstractModule implements Module {
//
// @Override
// public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) {
// if(baseGraph instanceof TransactionalGraph) {
// baseGraph = doConfigure((TransactionalGraph)baseGraph, config);
// }
// else {
// baseGraph = doConfigure(baseGraph, config);
// }
// doConfigure(config);
// return baseGraph;
// }
//
//
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected Graph doConfigure(Graph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform configuration
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// protected TransactionalGraph doConfigure(TransactionalGraph baseGraph, FramedGraphConfiguration config) {
// return baseGraph;
// }
//
// /**
// * Perform common configuration across all graph types.
// * @param config
// */
// protected void doConfigure(FramedGraphConfiguration config) {
//
// }
//
// }
// Path: src/test/java/com/tinkerpop/frames/modules/AbstractModuleTest.java
import junit.framework.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration;
import com.tinkerpop.frames.modules.AbstractModule;
package com.tinkerpop.frames.modules;
public class AbstractModuleTest {
@Test
public void testNoWrapping() {
Graph baseGraph = Mockito.mock(Graph.class);
TransactionalGraph baseTransactionalGraph = Mockito.mock(TransactionalGraph.class);
FramedGraphConfiguration config = new FramedGraphConfiguration(); | AbstractModule module = Mockito.mock(AbstractModule.class); |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/modules/AbstractModule.java | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
| import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration; | package com.tinkerpop.frames.modules;
/**
* Helper base module to simplify configuring different types of graph. Override doConfigure for the appropriate type of graph.
* @author Bryn Cooke
*
*/
public class AbstractModule implements Module {
@Override | // Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
// public class FramedGraphConfiguration {
// private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
// private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
// private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
// private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>();
// private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver();
// private Graph configuredGraph;
//
//
//
// /**
// * @param annotationHandler
// * The {@link AnnotationHandler} to add to the
// * {@link FramedGraph}.
// */
// void addAnnotationHandler(AnnotationHandler<?> annotationHandler) {
// annotationHandlers.put(annotationHandler.getAnnotationType(), annotationHandler);
// }
//
//
// /**
// * @param methodHandler
// * The {@link MethodHandler} to add to the
// * {@link FramedGraph}.
// */
// public void addMethodHandler(MethodHandler<?> methodHandler) {
// methodHandlers.put(methodHandler.getAnnotationType(), methodHandler);
// }
//
// /**
// * @param frameInitializer
// * The {@link FrameInitializer} to add to the {@link FramedGraph}
// * .
// */
// public void addFrameInitializer(FrameInitializer frameInitializer) {
// frameInitializers.add(frameInitializer);
// }
//
// /**
// * @param typeResolver
// * The {@link TypeResolver} to add to the {@link FramedGraph}.
// */
// public void addTypeResolver(TypeResolver typeResolver) {
// typeResolvers.add(typeResolver);
// }
//
// public void setFrameClassLoaderResolver(FrameClassLoaderResolver frameClassLoaderResolver) {
// this.frameClassLoaderResolver = frameClassLoaderResolver;
// }
//
// List<FrameInitializer> getFrameInitializers() {
// return frameInitializers;
// }
//
// Map<Class<? extends Annotation>, AnnotationHandler<?>> getAnnotationHandlers() {
// return annotationHandlers;
// }
//
// List<TypeResolver> getTypeResolvers() {
// return typeResolvers;
// }
//
// FrameClassLoaderResolver getFrameClassLoaderResolver() {
// return frameClassLoaderResolver;
// }
//
// public void setConfiguredGraph(Graph configuredGraph) {
// this.configuredGraph = configuredGraph;
// }
//
// Graph getConfiguredGraph() {
// return configuredGraph;
// }
//
// Map<Class<? extends Annotation>, MethodHandler<?>> getMethodHandlers() {
// return methodHandlers;
// }
// }
// Path: src/main/java/com/tinkerpop/frames/modules/AbstractModule.java
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.frames.FramedGraphConfiguration;
package com.tinkerpop.frames.modules;
/**
* Helper base module to simplify configuring different types of graph. Override doConfigure for the appropriate type of graph.
* @author Bryn Cooke
*
*/
public class AbstractModule implements Module {
@Override | public final Graph configure(Graph baseGraph, FramedGraphConfiguration config) { |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
| import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver; | package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver;
package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>(); | private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>(); |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
| import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver; | package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver;
package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>(); | private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>(); |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
| import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver; | package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver;
package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>(); | private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver(); |
tinkerpop/frames | src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
| import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver; | package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>(); | // Path: src/main/java/com/tinkerpop/frames/annotations/AnnotationHandler.java
// public interface AnnotationHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param annotation The annotation
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @param direction The direction of the edge.
// * @return A return value for the method.
// */
// public Object processElement(final T annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/DefaultClassLoaderResolver.java
// public class DefaultClassLoaderResolver implements FrameClassLoaderResolver {
// @Override
// public ClassLoader resolveClassLoader(Class<?> frameType) {
// return frameType.getClassLoader();
// }
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/FrameClassLoaderResolver.java
// public interface FrameClassLoaderResolver {
// public ClassLoader resolveClassLoader(Class<?> frameType);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/MethodHandler.java
// public interface MethodHandler<T extends Annotation> {
// /**
// * @return The annotation type that this handler responds to.
// */
// public Class<T> getAnnotationType();
//
// /**
// * @param frame The frame upon which the method is being called.
// * @param method The method being called on the frame.
// * @param arguments The arguments to the method.
// * @param annotation The annotation
// * @param framedGraph The graph being called.
// * @param element The underlying element.
// * @return A return value for the method.
// */
// public Object processElement(final Object frame, final Method method, final Object[] arguments, final T annotation, final FramedGraph<?> framedGraph, final Element element);
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/Module.java
// public interface Module {
// /**
// * @param baseGraph The graph being framed.
// * @param config The configuration for the new FramedGraph.
// * @return The graph being framed.
// */
// Graph configure(Graph baseGraph, FramedGraphConfiguration config);
//
//
//
// }
//
// Path: src/main/java/com/tinkerpop/frames/modules/TypeResolver.java
// public interface TypeResolver {
//
// /**
// * @param v The vertex being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Vertex v, Class<?> defaultType);
// /**
// * @param e The edge being framed.
// * @param defaultType The default as passed in to the framing method.
// * @return Any additional interfaces that the frame should implement.
// */
// Class<?>[] resolveTypes(Edge e, Class<?> defaultType);
// }
// Path: src/main/java/com/tinkerpop/frames/FramedGraphConfiguration.java
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.frames.annotations.AnnotationHandler;
import com.tinkerpop.frames.modules.DefaultClassLoaderResolver;
import com.tinkerpop.frames.modules.FrameClassLoaderResolver;
import com.tinkerpop.frames.modules.MethodHandler;
import com.tinkerpop.frames.modules.Module;
import com.tinkerpop.frames.modules.TypeResolver;
package com.tinkerpop.frames;
/**
* A configuration for a {@link FramedGraph}. These are supplied to
* {@link Module}s for each {@link FramedGraph} being create by a
* {@link FramedGraphFactory}.
*
* Allows registration of {@link AnnotationHandler}s, {@link FrameInitializer}s
* and {@link TypeResolver}s.
*
* @author Bryn Cooke
*
*/
public class FramedGraphConfiguration {
private Map<Class<? extends Annotation>, AnnotationHandler<?>> annotationHandlers = new HashMap<Class<? extends Annotation>, AnnotationHandler<?>>();
private Map<Class<? extends Annotation>, MethodHandler<?>> methodHandlers = new HashMap<Class<? extends Annotation>, MethodHandler<?>>();
private List<FrameInitializer> frameInitializers = new ArrayList<FrameInitializer>();
private List<TypeResolver> typeResolvers = new ArrayList<TypeResolver>(); | private FrameClassLoaderResolver frameClassLoaderResolver = new DefaultClassLoaderResolver(); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/docker/DockerComposeYamlVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLFileType;
import org.jetbrains.yaml.psi.YAMLFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.docker;
public class DockerComposeYamlVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/docker/DockerComposeYamlVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLFileType;
import org.jetbrains.yaml.psi.YAMLFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.docker;
public class DockerComposeYamlVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | public FileAcceptResult acceptFile(VirtualFile file) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/docker/DockerComposeYamlVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLFileType;
import org.jetbrains.yaml.psi.YAMLFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.docker;
public class DockerComposeYamlVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if (file.getName().equals("docker-compose.yml") || file.getName().equals("docker-compose.yaml")) {
return file.getFileType().equals(YAMLFileType.YML) ? FileAcceptResult.ACCEPTED : FileAcceptResult.NOT_ACCEPTED;
}
return FileAcceptResult.NOT_ACCEPTED;
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/docker/DockerComposeYamlVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLFileType;
import org.jetbrains.yaml.psi.YAMLFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.docker;
public class DockerComposeYamlVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if (file.getName().equals("docker-compose.yml") || file.getName().equals("docker-compose.yaml")) {
return file.getFileType().equals(YAMLFileType.YML) ? FileAcceptResult.ACCEPTED : FileAcceptResult.NOT_ACCEPTED;
}
return FileAcceptResult.NOT_ACCEPTED;
}
@NotNull
@Override | public Collection<KeyValuePsiElement> getElements(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvKeyGotoHandler.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
| import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import ru.adelf.idea.dotenv.psi.DotEnvKey; | package ru.adelf.idea.dotenv.extension;
public class DotEnvKeyGotoHandler implements GotoDeclarationHandler {
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
if(psiElement == null || psiElement.getParent() == null) {
return PsiElement.EMPTY_ARRAY;
}
psiElement = psiElement.getParent();
| // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvKeyGotoHandler.java
import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import ru.adelf.idea.dotenv.psi.DotEnvKey;
package ru.adelf.idea.dotenv.extension;
public class DotEnvKeyGotoHandler implements GotoDeclarationHandler {
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
if(psiElement == null || psiElement.getParent() == null) {
return PsiElement.EMPTY_ARRAY;
}
psiElement = psiElement.getParent();
| if(!(psiElement instanceof DotEnvKey)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvKeyGotoHandler.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
| import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import ru.adelf.idea.dotenv.psi.DotEnvKey; | package ru.adelf.idea.dotenv.extension;
public class DotEnvKeyGotoHandler implements GotoDeclarationHandler {
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
if(psiElement == null || psiElement.getParent() == null) {
return PsiElement.EMPTY_ARRAY;
}
psiElement = psiElement.getParent();
if(!(psiElement instanceof DotEnvKey)) {
return PsiElement.EMPTY_ARRAY;
}
| // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvKeyGotoHandler.java
import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import ru.adelf.idea.dotenv.psi.DotEnvKey;
package ru.adelf.idea.dotenv.extension;
public class DotEnvKeyGotoHandler implements GotoDeclarationHandler {
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement psiElement, int i, Editor editor) {
if(psiElement == null || psiElement.getParent() == null) {
return PsiElement.EMPTY_ARRAY;
}
psiElement = psiElement.getParent();
if(!(psiElement instanceof DotEnvKey)) {
return PsiElement.EMPTY_ARRAY;
}
| return EnvironmentVariablesApi.getKeyUsages(psiElement.getProject(), psiElement.getText()); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*; | package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*;
package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | if(!(file instanceof DotEnvFile)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*; | package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if(!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*;
package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if(!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor(); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*; | package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if(!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
file.acceptChildren(visitor);
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
Map<String, PsiElement> existingKeys = new HashMap<>();
Set<PsiElement> markedElements = new HashSet<>(); | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvPsiElementsVisitor.java
// public class DotEnvPsiElementsVisitor extends DotEnvVisitor {
// private final Collection<KeyValuePsiElement> collectedItems = new HashSet<>();
//
// @Override
// public void visitProperty(@NotNull DotEnvProperty property) {
// collectedItems.add(new KeyValuePsiElement(
// property.getKeyText(),
// property.getValueText(),
// property)
// );
// }
//
// public Collection<KeyValuePsiElement> getCollectedItems() {
// return collectedItems;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvPsiElementsVisitor;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*;
package ru.adelf.idea.dotenv.inspections;
public class DuplicateKeyInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Duplicate key";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if(!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
file.acceptChildren(visitor);
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
Map<String, PsiElement> existingKeys = new HashMap<>();
Set<PsiElement> markedElements = new HashSet<>(); | for(KeyValuePsiElement keyValue : visitor.getCollectedItems()) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/ruby/RubyEnvironmentVariablesUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ruby.ruby.lang.RubyFileType;
import org.jetbrains.plugins.ruby.ruby.lang.psi.RFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.ruby;
public class RubyEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(RubyFileType.RUBY);
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/ruby/RubyEnvironmentVariablesUsagesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.ruby.ruby.lang.RubyFileType;
import org.jetbrains.plugins.ruby.ruby.lang.psi.RFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.ruby;
public class RubyEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(RubyFileType.RUBY);
}
@NotNull
@Override | public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java | // Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvVisitor.java
// public class DotEnvVisitor extends PsiElementVisitor {
//
// public void visitKey(@NotNull DotEnvKey o) {
// visitPsiElement(o);
// }
//
// public void visitProperty(@NotNull DotEnvProperty o) {
// visitNamedElement(o);
// }
//
// public void visitValue(@NotNull DotEnvValue o) {
// visitPsiElement(o);
// }
//
// public void visitNamedElement(@NotNull DotEnvNamedElement o) {
// visitPsiElement(o);
// }
//
// public void visitPsiElement(@NotNull PsiElement o) {
// visitElement(o);
// }
//
// }
| import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.psi.DotEnvKey;
import ru.adelf.idea.dotenv.psi.DotEnvVisitor; | // This is a generated file. Not intended for manual editing.
package ru.adelf.idea.dotenv.psi.impl;
public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
public DotEnvKeyImpl(@NotNull ASTNode node) {
super(node);
}
| // Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvKey.java
// public interface DotEnvKey extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvVisitor.java
// public class DotEnvVisitor extends PsiElementVisitor {
//
// public void visitKey(@NotNull DotEnvKey o) {
// visitPsiElement(o);
// }
//
// public void visitProperty(@NotNull DotEnvProperty o) {
// visitNamedElement(o);
// }
//
// public void visitValue(@NotNull DotEnvValue o) {
// visitPsiElement(o);
// }
//
// public void visitNamedElement(@NotNull DotEnvNamedElement o) {
// visitPsiElement(o);
// }
//
// public void visitPsiElement(@NotNull PsiElement o) {
// visitElement(o);
// }
//
// }
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.psi.DotEnvKey;
import ru.adelf.idea.dotenv.psi.DotEnvVisitor;
// This is a generated file. Not intended for manual editing.
package ru.adelf.idea.dotenv.psi.impl;
public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
public DotEnvKeyImpl(@NotNull ASTNode node) {
super(node);
}
| public void accept(@NotNull DotEnvVisitor visitor) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl; | package ru.adelf.idea.dotenv.inspections;
public class IncorrectDelimiterInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Incorrect delimiter";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl;
package ru.adelf.idea.dotenv.inspections;
public class IncorrectDelimiterInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Incorrect delimiter";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | if (!(file instanceof DotEnvFile)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl; | package ru.adelf.idea.dotenv.inspections;
public class IncorrectDelimiterInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Incorrect delimiter";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl;
package ru.adelf.idea.dotenv.inspections;
public class IncorrectDelimiterInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Incorrect delimiter";
}
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl; | }
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> {
if (key.getText().contains("-")) {
problemsHolder.registerProblem(key, "Expected: '_' Found: '-'"/*, new ReplaceDelimiterQuickFix()*/);
}
});
return problemsHolder;
}
private static class ReplaceDelimiterQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Replace delimiter";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> {
if (key.getText().contains("-")) {
problemsHolder.registerProblem(key, "Expected: '_' Found: '-'"/*, new ReplaceDelimiterQuickFix()*/);
}
});
return problemsHolder;
}
private static class ReplaceDelimiterQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Replace delimiter";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| PsiElement newPsiElement = DotEnvFactory.createFromText(project, DotEnvTypes.KEY, |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl; | }
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> {
if (key.getText().contains("-")) {
problemsHolder.registerProblem(key, "Expected: '_' Found: '-'"/*, new ReplaceDelimiterQuickFix()*/);
}
});
return problemsHolder;
}
private static class ReplaceDelimiterQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Replace delimiter";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvKeyImpl.java
// public class DotEnvKeyImpl extends ASTWrapperPsiElement implements DotEnvKey {
//
// public DotEnvKeyImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitKey(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> {
if (key.getText().contains("-")) {
problemsHolder.registerProblem(key, "Expected: '_' Found: '-'"/*, new ReplaceDelimiterQuickFix()*/);
}
});
return problemsHolder;
}
private static class ReplaceDelimiterQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Replace delimiter";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| PsiElement newPsiElement = DotEnvFactory.createFromText(project, DotEnvTypes.KEY, |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | public FileAcceptResult acceptFile(VirtualFile file) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if(!file.getFileType().equals(DotEnvFileType.INSTANCE)) {
return FileAcceptResult.NOT_ACCEPTED;
}
// .env.dist , .env.example files are secondary
return file.getName().equals(".env") ? FileAcceptResult.ACCEPTED : FileAcceptResult.ACCEPTED_SECONDARY;
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if(!file.getFileType().equals(DotEnvFileType.INSTANCE)) {
return FileAcceptResult.NOT_ACCEPTED;
}
// .env.dist , .env.example files are secondary
return file.getName().equals(".env") ? FileAcceptResult.ACCEPTED : FileAcceptResult.ACCEPTED_SECONDARY;
}
@NotNull
@Override | public Collection<KeyValuePsiElement> getElements(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if(!file.getFileType().equals(DotEnvFileType.INSTANCE)) {
return FileAcceptResult.NOT_ACCEPTED;
}
// .env.dist , .env.example files are secondary
return file.getName().equals(".env") ? FileAcceptResult.ACCEPTED : FileAcceptResult.ACCEPTED_SECONDARY;
}
@NotNull
@Override
public Collection<KeyValuePsiElement> getElements(PsiFile psiFile) { | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/DotEnvVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv;
public class DotEnvVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
if(!file.getFileType().equals(DotEnvFileType.INSTANCE)) {
return FileAcceptResult.NOT_ACCEPTED;
}
// .env.dist , .env.example files are secondary
return file.getName().equals(".env") ? FileAcceptResult.ACCEPTED : FileAcceptResult.ACCEPTED_SECONDARY;
}
@NotNull
@Override
public Collection<KeyValuePsiElement> getElements(PsiFile psiFile) { | if(psiFile instanceof DotEnvFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/psi/DotEnvTokenType.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvLanguage.java
// public class DotEnvLanguage extends Language {
// public static final DotEnvLanguage INSTANCE = new DotEnvLanguage();
//
// private DotEnvLanguage() {
// super("DotEnv");
// }
// }
| import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvLanguage; | package ru.adelf.idea.dotenv.psi;
public class DotEnvTokenType extends IElementType {
public DotEnvTokenType(@NotNull @NonNls String debugName) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvLanguage.java
// public class DotEnvLanguage extends Language {
// public static final DotEnvLanguage INSTANCE = new DotEnvLanguage();
//
// private DotEnvLanguage() {
// super("DotEnv");
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvTokenType.java
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvLanguage;
package ru.adelf.idea.dotenv.psi;
public class DotEnvTokenType extends IElementType {
public DotEnvTokenType(@NotNull @NonNls String debugName) { | super(debugName, DotEnvLanguage.INSTANCE); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinPsiHelper.java | // Path: src/main/java/ru/adelf/idea/dotenv/java/JavaEnvironmentClasses.java
// public class JavaEnvironmentClasses {
// public static boolean isDirectMethodCall(String methodName) {
// return methodName.equals("getenv") || methodName.equals("getEnv");
// }
//
// @Nullable
// public static List<String> getClassNames(String methodName) {
// switch (methodName) {
// case "get":
// return Arrays.asList("Dotenv", "DotEnv");
// case "getProperty":
// return Collections.singletonList("System");
// }
//
// return null;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.*;
import ru.adelf.idea.dotenv.java.JavaEnvironmentClasses;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Arrays;
import java.util.List; | PsiElement methodCall = valueArgumentList.getParent();
if (!(methodCall instanceof KtCallExpression)) return false;
return isEnvMethodCall((KtCallExpression) methodCall);
}
private static boolean isArrayAccessLiteral(KtContainerNode containerNode) {
if (!(containerNode.getParent() instanceof KtArrayAccessExpression)) {
return false;
}
return isEnvArrayAccess((KtArrayAccessExpression) containerNode.getParent());
}
/**
* Checks whether this function reference is reference for env functions, like env or getenv
*
* @param methodCallExpression Checking reference
* @return true if condition filled
*/
static boolean isEnvMethodCall(KtCallExpression methodCallExpression) {
PsiElement nameElement = methodCallExpression.getCalleeExpression();
if (!(nameElement instanceof KtNameReferenceExpression)) {
return false;
}
String methodName = ((KtNameReferenceExpression) nameElement).getReferencedName();
| // Path: src/main/java/ru/adelf/idea/dotenv/java/JavaEnvironmentClasses.java
// public class JavaEnvironmentClasses {
// public static boolean isDirectMethodCall(String methodName) {
// return methodName.equals("getenv") || methodName.equals("getEnv");
// }
//
// @Nullable
// public static List<String> getClassNames(String methodName) {
// switch (methodName) {
// case "get":
// return Arrays.asList("Dotenv", "DotEnv");
// case "getProperty":
// return Collections.singletonList("System");
// }
//
// return null;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinPsiHelper.java
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.*;
import ru.adelf.idea.dotenv.java.JavaEnvironmentClasses;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Arrays;
import java.util.List;
PsiElement methodCall = valueArgumentList.getParent();
if (!(methodCall instanceof KtCallExpression)) return false;
return isEnvMethodCall((KtCallExpression) methodCall);
}
private static boolean isArrayAccessLiteral(KtContainerNode containerNode) {
if (!(containerNode.getParent() instanceof KtArrayAccessExpression)) {
return false;
}
return isEnvArrayAccess((KtArrayAccessExpression) containerNode.getParent());
}
/**
* Checks whether this function reference is reference for env functions, like env or getenv
*
* @param methodCallExpression Checking reference
* @return true if condition filled
*/
static boolean isEnvMethodCall(KtCallExpression methodCallExpression) {
PsiElement nameElement = methodCallExpression.getCalleeExpression();
if (!(nameElement instanceof KtNameReferenceExpression)) {
return false;
}
String methodName = ((KtNameReferenceExpression) nameElement).getReferencedName();
| if (JavaEnvironmentClasses.isDirectMethodCall(methodName)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinPsiHelper.java | // Path: src/main/java/ru/adelf/idea/dotenv/java/JavaEnvironmentClasses.java
// public class JavaEnvironmentClasses {
// public static boolean isDirectMethodCall(String methodName) {
// return methodName.equals("getenv") || methodName.equals("getEnv");
// }
//
// @Nullable
// public static List<String> getClassNames(String methodName) {
// switch (methodName) {
// case "get":
// return Arrays.asList("Dotenv", "DotEnv");
// case "getProperty":
// return Collections.singletonList("System");
// }
//
// return null;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.*;
import ru.adelf.idea.dotenv.java.JavaEnvironmentClasses;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Arrays;
import java.util.List; |
/**
* Checks whether this function reference is reference for env functions, like env or getenv
*
* @param methodCallExpression Checking reference
* @return true if condition filled
*/
static boolean isEnvMethodCall(KtCallExpression methodCallExpression) {
PsiElement nameElement = methodCallExpression.getCalleeExpression();
if (!(nameElement instanceof KtNameReferenceExpression)) {
return false;
}
String methodName = ((KtNameReferenceExpression) nameElement).getReferencedName();
if (JavaEnvironmentClasses.isDirectMethodCall(methodName)) {
return true;
}
List<String> classNames = JavaEnvironmentClasses.getClassNames(methodName);
if (classNames == null) {
return false;
}
return checkReferences(methodCallExpression.getCalleeExpression(), classNames);
}
@Nullable | // Path: src/main/java/ru/adelf/idea/dotenv/java/JavaEnvironmentClasses.java
// public class JavaEnvironmentClasses {
// public static boolean isDirectMethodCall(String methodName) {
// return methodName.equals("getenv") || methodName.equals("getEnv");
// }
//
// @Nullable
// public static List<String> getClassNames(String methodName) {
// switch (methodName) {
// case "get":
// return Arrays.asList("Dotenv", "DotEnv");
// case "getProperty":
// return Collections.singletonList("System");
// }
//
// return null;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinPsiHelper.java
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.*;
import ru.adelf.idea.dotenv.java.JavaEnvironmentClasses;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Arrays;
import java.util.List;
/**
* Checks whether this function reference is reference for env functions, like env or getenv
*
* @param methodCallExpression Checking reference
* @return true if condition filled
*/
static boolean isEnvMethodCall(KtCallExpression methodCallExpression) {
PsiElement nameElement = methodCallExpression.getCalleeExpression();
if (!(nameElement instanceof KtNameReferenceExpression)) {
return false;
}
String methodName = ((KtNameReferenceExpression) nameElement).getReferencedName();
if (JavaEnvironmentClasses.isDirectMethodCall(methodName)) {
return true;
}
List<String> classNames = JavaEnvironmentClasses.getClassNames(methodName);
if (classNames == null) {
return false;
}
return checkReferences(methodCallExpression.getCalleeExpression(), classNames);
}
@Nullable | static KeyUsagePsiElement getKeyUsageFromCall(@NotNull KtCallExpression expression) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/psi/DotEnvElementType.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvLanguage.java
// public class DotEnvLanguage extends Language {
// public static final DotEnvLanguage INSTANCE = new DotEnvLanguage();
//
// private DotEnvLanguage() {
// super("DotEnv");
// }
// }
| import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.*;
import ru.adelf.idea.dotenv.DotEnvLanguage; | package ru.adelf.idea.dotenv.psi;
public class DotEnvElementType extends IElementType {
public DotEnvElementType(@NotNull @NonNls String debugName) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvLanguage.java
// public class DotEnvLanguage extends Language {
// public static final DotEnvLanguage INSTANCE = new DotEnvLanguage();
//
// private DotEnvLanguage() {
// super("DotEnv");
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvElementType.java
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.*;
import ru.adelf.idea.dotenv.DotEnvLanguage;
package ru.adelf.idea.dotenv.psi;
public class DotEnvElementType extends IElementType {
public DotEnvElementType(@NotNull @NonNls String debugName) { | super(debugName, DotEnvLanguage.INSTANCE); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/DotEnvSyntaxHighlighter.java | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; | package ru.adelf.idea.dotenv;
class DotEnvSyntaxHighlighter extends SyntaxHighlighterBase {
private static final TextAttributesKey SEPARATOR =
createTextAttributesKey("DOTENV_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
private static final TextAttributesKey KEY =
createTextAttributesKey("DOTENV_KEY", DefaultLanguageHighlighterColors.KEYWORD);
private static final TextAttributesKey VALUE =
createTextAttributesKey("DOTENV_VALUE", DefaultLanguageHighlighterColors.STRING);
private static final TextAttributesKey COMMENT =
createTextAttributesKey("DOTENV_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
private static final TextAttributesKey BAD_CHARACTER =
createTextAttributesKey("DOTENV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
@NotNull
@Override
public Lexer getHighlightingLexer() { | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSyntaxHighlighter.java
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
package ru.adelf.idea.dotenv;
class DotEnvSyntaxHighlighter extends SyntaxHighlighterBase {
private static final TextAttributesKey SEPARATOR =
createTextAttributesKey("DOTENV_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
private static final TextAttributesKey KEY =
createTextAttributesKey("DOTENV_KEY", DefaultLanguageHighlighterColors.KEYWORD);
private static final TextAttributesKey VALUE =
createTextAttributesKey("DOTENV_VALUE", DefaultLanguageHighlighterColors.STRING);
private static final TextAttributesKey COMMENT =
createTextAttributesKey("DOTENV_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
private static final TextAttributesKey BAD_CHARACTER =
createTextAttributesKey("DOTENV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
@NotNull
@Override
public Lexer getHighlightingLexer() { | return new DotEnvLexerAdapter(); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/DotEnvSyntaxHighlighter.java | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; | package ru.adelf.idea.dotenv;
class DotEnvSyntaxHighlighter extends SyntaxHighlighterBase {
private static final TextAttributesKey SEPARATOR =
createTextAttributesKey("DOTENV_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
private static final TextAttributesKey KEY =
createTextAttributesKey("DOTENV_KEY", DefaultLanguageHighlighterColors.KEYWORD);
private static final TextAttributesKey VALUE =
createTextAttributesKey("DOTENV_VALUE", DefaultLanguageHighlighterColors.STRING);
private static final TextAttributesKey COMMENT =
createTextAttributesKey("DOTENV_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
private static final TextAttributesKey BAD_CHARACTER =
createTextAttributesKey("DOTENV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
@NotNull
@Override
public Lexer getHighlightingLexer() {
return new DotEnvLexerAdapter();
}
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSyntaxHighlighter.java
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
package ru.adelf.idea.dotenv;
class DotEnvSyntaxHighlighter extends SyntaxHighlighterBase {
private static final TextAttributesKey SEPARATOR =
createTextAttributesKey("DOTENV_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
private static final TextAttributesKey KEY =
createTextAttributesKey("DOTENV_KEY", DefaultLanguageHighlighterColors.KEYWORD);
private static final TextAttributesKey VALUE =
createTextAttributesKey("DOTENV_VALUE", DefaultLanguageHighlighterColors.STRING);
private static final TextAttributesKey COMMENT =
createTextAttributesKey("DOTENV_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
private static final TextAttributesKey BAD_CHARACTER =
createTextAttributesKey("DOTENV_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
@NotNull
@Override
public Lexer getHighlightingLexer() {
return new DotEnvLexerAdapter();
}
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { | if (tokenType.equals(DotEnvTypes.SEPARATOR)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection; | package ru.adelf.idea.dotenv.api;
public interface EnvironmentVariablesProvider {
@NotNull
FileAcceptResult acceptFile(VirtualFile file);
@NotNull | // Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
package ru.adelf.idea.dotenv.api;
public interface EnvironmentVariablesProvider {
@NotNull
FileAcceptResult acceptFile(VirtualFile file);
@NotNull | Collection<KeyValuePsiElement> getElements(PsiFile psiFile); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java | // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*; | package ru.adelf.idea.dotenv.api;
public class EnvironmentVariablesApi {
@NotNull
public static Map<String, String> getAllKeyValues(Project project) {
FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
Map<String, String> keyValues = new HashMap<>();
Map<String, String> secondaryKeyValues = new HashMap<>();
Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
GlobalSearchScope scope = GlobalSearchScope.allScope(project);
| // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*;
package ru.adelf.idea.dotenv.api;
public class EnvironmentVariablesApi {
@NotNull
public static Map<String, String> getAllKeyValues(Project project) {
FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
Map<String, String> keyValues = new HashMap<>();
Map<String, String> secondaryKeyValues = new HashMap<>();
Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
GlobalSearchScope scope = GlobalSearchScope.allScope(project);
| fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java | // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*; | }
return true;
}), scope);
}
return true;
}, project);
secondaryKeyValues.putAll(keyValues);
return secondaryKeyValues;
}
/**
* @param project project
* @param key environment variable key
* @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
*/
@NotNull
public static PsiElement[] getKeyDeclarations(Project project, String key) {
List<PsiElement> targets = new ArrayList<>();
List<PsiElement> secondaryTargets = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFileTarget == null) {
return true;
}
| // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*;
}
return true;
}), scope);
}
return true;
}, project);
secondaryKeyValues.putAll(keyValues);
return secondaryKeyValues;
}
/**
* @param project project
* @param key environment variable key
* @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
*/
@NotNull
public static PsiElement[] getKeyDeclarations(Project project, String key) {
List<PsiElement> targets = new ArrayList<>();
List<PsiElement> secondaryTargets = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFileTarget == null) {
return true;
}
| for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java | // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*; | return true;
}, project);
secondaryKeyValues.putAll(keyValues);
return secondaryKeyValues;
}
/**
* @param project project
* @param key environment variable key
* @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
*/
@NotNull
public static PsiElement[] getKeyDeclarations(Project project, String key) {
List<PsiElement> targets = new ArrayList<>();
List<PsiElement> secondaryTargets = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFileTarget == null) {
return true;
}
for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
if (!fileAcceptResult.isAccepted()) {
continue;
}
| // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesUtil.java
// public class EnvironmentVariablesUtil {
// @NotNull
// public static EnvironmentKeyValue getKeyValueFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return new EnvironmentKeyValue(s.trim(), "");
// } else {
// return new EnvironmentKeyValue(s.substring(0, pos).trim(), s.substring(pos + 1).trim());
// }
// }
//
// @NotNull
// public static String getKeyFromString(@NotNull String s) {
// int pos = s.indexOf("=");
//
// if(pos == -1) {
// return s.trim();
// } else {
// return s.substring(0, pos).trim();
// }
// }
//
// @NotNull
// public static Set<PsiElement> getElementsByKey(String key, Collection<KeyValuePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyValuePsiElement::getElement).collect(Collectors.toSet());
// }
//
// @NotNull
// public static Set<PsiElement> getUsagesElementsByKey(String key, Collection<KeyUsagePsiElement> items) {
// return items.stream().filter(item -> item.getKey().equals(key)).map(KeyUsagePsiElement::getElement).collect(Collectors.toSet());
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.util.Processor;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesUtil;
import java.util.*;
return true;
}, project);
secondaryKeyValues.putAll(keyValues);
return secondaryKeyValues;
}
/**
* @param project project
* @param key environment variable key
* @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
*/
@NotNull
public static PsiElement[] getKeyDeclarations(Project project, String key) {
List<PsiElement> targets = new ArrayList<>();
List<PsiElement> secondaryTargets = new ArrayList<>();
FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFileTarget == null) {
return true;
}
for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
if (!fileAcceptResult.isAccepted()) {
continue;
}
| (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget))); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern; | package ru.adelf.idea.dotenv.inspections;
public class SpaceAroundSeparatorInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Extra spaces surrounding '='";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern;
package ru.adelf.idea.dotenv.inspections;
public class SpaceAroundSeparatorInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Extra spaces surrounding '='";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | if (!(file instanceof DotEnvFile)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern; | package ru.adelf.idea.dotenv.inspections;
public class SpaceAroundSeparatorInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Extra spaces surrounding '='";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern;
package ru.adelf.idea.dotenv.inspections;
public class SpaceAroundSeparatorInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Extra spaces surrounding '='";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| PsiTreeUtil.findChildrenOfType(file, DotEnvProperty.class).forEach(dotEnvProperty -> { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern; | if (separator.matches("([ \t]+=.*)|(.*=[ \t]+)")) {
problemsHolder.registerProblem(dotEnvProperty,
new TextRange(
dotEnvProperty.getKey().getText().length(),
dotEnvProperty.getKey().getText().length() + separator.length()
),
"Extra spaces surrounding '='",
new RemoveSpaceAroundSeparatorQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveSpaceAroundSeparatorQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove spaces surrounding '='";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
DotEnvProperty dotEnvProperty = (DotEnvProperty) descriptor.getPsiElement();
String key = dotEnvProperty.getKey().getText();
String value = dotEnvProperty.getValue() != null ? dotEnvProperty.getValue().getText() : "";
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern;
if (separator.matches("([ \t]+=.*)|(.*=[ \t]+)")) {
problemsHolder.registerProblem(dotEnvProperty,
new TextRange(
dotEnvProperty.getKey().getText().length(),
dotEnvProperty.getKey().getText().length() + separator.length()
),
"Extra spaces surrounding '='",
new RemoveSpaceAroundSeparatorQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveSpaceAroundSeparatorQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove spaces surrounding '='";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
DotEnvProperty dotEnvProperty = (DotEnvProperty) descriptor.getPsiElement();
String key = dotEnvProperty.getKey().getText();
String value = dotEnvProperty.getValue() != null ? dotEnvProperty.getValue().getText() : "";
| PsiElement newPsiElement = DotEnvFactory.createFromText( |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern; | new TextRange(
dotEnvProperty.getKey().getText().length(),
dotEnvProperty.getKey().getText().length() + separator.length()
),
"Extra spaces surrounding '='",
new RemoveSpaceAroundSeparatorQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveSpaceAroundSeparatorQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove spaces surrounding '='";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
DotEnvProperty dotEnvProperty = (DotEnvProperty) descriptor.getPsiElement();
String key = dotEnvProperty.getKey().getText();
String value = dotEnvProperty.getValue() != null ? dotEnvProperty.getValue().getText() : "";
PsiElement newPsiElement = DotEnvFactory.createFromText(
project, | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceAroundSeparatorInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import java.util.regex.Pattern;
new TextRange(
dotEnvProperty.getKey().getText().length(),
dotEnvProperty.getKey().getText().length() + separator.length()
),
"Extra spaces surrounding '='",
new RemoveSpaceAroundSeparatorQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveSpaceAroundSeparatorQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove spaces surrounding '='";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
DotEnvProperty dotEnvProperty = (DotEnvProperty) descriptor.getPsiElement();
String key = dotEnvProperty.getKey().getText();
String value = dotEnvProperty.getValue() != null ? dotEnvProperty.getValue().getText() : "";
PsiElement newPsiElement = DotEnvFactory.createFromText(
project, | DotEnvTypes.PROPERTY, |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/python/PythonEnvironmentVariablesUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.psi.PyFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.python;
public class PythonEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(PythonFileType.INSTANCE);
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/python/PythonEnvironmentVariablesUsagesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.psi.PyFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.python;
public class PythonEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(PythonFileType.INSTANCE);
}
@NotNull
@Override | public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes; | package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() { | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() { | return new DefaultWordsScanner(new DotEnvLexerAdapter(), |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes; | package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() {
return new DefaultWordsScanner(new DotEnvLexerAdapter(), | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() {
return new DefaultWordsScanner(new DotEnvLexerAdapter(), | TokenSet.create(DotEnvTypes.PROPERTY), |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
| import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes; | package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() {
return new DefaultWordsScanner(new DotEnvLexerAdapter(),
TokenSet.create(DotEnvTypes.PROPERTY),
TokenSet.create(DotEnvTypes.COMMENT),
TokenSet.EMPTY);
}
@Override
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return psiElement instanceof PsiNamedElement;
}
@Nullable
@Override
public String getHelpId(@NotNull PsiElement psiElement) {
return null;
}
@NotNull
@Override
public String getType(@NotNull PsiElement element) { | // Path: src/main/java/ru/adelf/idea/dotenv/grammars/DotEnvLexerAdapter.java
// public class DotEnvLexerAdapter extends FlexAdapter {
// public DotEnvLexerAdapter() {
// super(new _DotEnvLexer(null));
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvProperty.java
// public interface DotEnvProperty extends DotEnvNamedElement {
//
// @NotNull
// DotEnvKey getKey();
//
// @Nullable
// DotEnvValue getValue();
//
// String getKeyText();
//
// String getValueText();
//
// String getName();
//
// PsiElement setName(@NotNull String newName);
//
// PsiElement getNameIdentifier();
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvFindUsagesProvider.java
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.grammars.DotEnvLexerAdapter;
import ru.adelf.idea.dotenv.psi.DotEnvProperty;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
package ru.adelf.idea.dotenv.extension;
public class DotEnvFindUsagesProvider implements FindUsagesProvider {
@Nullable
@Override
public WordsScanner getWordsScanner() {
return new DefaultWordsScanner(new DotEnvLexerAdapter(),
TokenSet.create(DotEnvTypes.PROPERTY),
TokenSet.create(DotEnvTypes.COMMENT),
TokenSet.EMPTY);
}
@Override
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return psiElement instanceof PsiNamedElement;
}
@Nullable
@Override
public String getHelpId(@NotNull PsiElement psiElement) {
return null;
}
@NotNull
@Override
public String getType(@NotNull PsiElement element) { | if (element instanceof DotEnvProperty) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
| import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map; | package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map;
package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
| boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues; |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
| import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map; | package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map;
package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
| for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
| import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map; | package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map;
package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
| for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
| import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map; | package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
// public class EnvironmentVariablesProviderUtil {
// public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
//
// public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders();
//
// private static EnvironmentVariablesProvider[] getEnvVariablesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesProvider");
// }
//
// private static EnvironmentVariablesUsagesProvider[] getEnvVariablesUsagesProviders() {
// return getExtensions("ru.adelf.idea.dotenv.environmentVariablesUsagesProvider");
// }
//
// private static <T> T[] getExtensions(@NotNull String name) {
// ExtensionPointName<T> pointName = new ExtensionPointName<>(name);
//
// return pointName.getExtensions();
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.DotEnvSettings;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import ru.adelf.idea.dotenv.util.EnvironmentVariablesProviderUtil;
import java.util.HashMap;
import java.util.Map;
package ru.adelf.idea.dotenv.indexing;
public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
@NotNull
@Override
public ID<String, String> getName() {
return KEY;
}
@NotNull
@Override
public DataIndexer<String, String, FileContent> getIndexer() {
return fileContent -> {
final Map<String, String> map = new HashMap<>();
boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) { | for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl; | package ru.adelf.idea.dotenv.inspections;
public class TrailingWhitespaceInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Value has trailing whitespace";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl;
package ru.adelf.idea.dotenv.inspections;
public class TrailingWhitespaceInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Value has trailing whitespace";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | if (!(file instanceof DotEnvFile)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl; | package ru.adelf.idea.dotenv.inspections;
public class TrailingWhitespaceInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Value has trailing whitespace";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl;
package ru.adelf.idea.dotenv.inspections;
public class TrailingWhitespaceInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Value has trailing whitespace";
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| PsiTreeUtil.findChildrenOfType(file, DotEnvValue.class).forEach(dotEnvValue -> { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl; | "Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl;
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
| if (psiElement instanceof DotEnvValueImpl) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl; | new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement instanceof DotEnvValueImpl) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl;
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement instanceof DotEnvValueImpl) { | PsiElement newPsiElement = DotEnvFactory.createFromText(project, DotEnvTypes.VALUE, |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl; | new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement instanceof DotEnvValueImpl) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
// public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
//
// public DotEnvValueImpl(@NotNull ASTNode node) {
// super(node);
// }
//
// public void accept(@NotNull DotEnvVisitor visitor) {
// visitor.visitValue(this);
// }
//
// @Override
// public void accept(@NotNull PsiElementVisitor visitor) {
// if (visitor instanceof DotEnvVisitor) accept((DotEnvVisitor)visitor);
// else super.accept(visitor);
// }
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/TrailingWhitespaceInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.impl.DotEnvValueImpl;
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
if (whiteSpace.getText().matches("\\s*[ \\t]\\n\\s*")) {
problemsHolder.registerProblem(whiteSpace,
"Line has trailing whitespace.",
new TrailingWhitespaceInspection.RemoveTrailingWhitespaceQuickFix()
);
}
});
return problemsHolder;
}
private static class RemoveTrailingWhitespaceQuickFix implements LocalQuickFix {
@NotNull
@Override
public String getName() {
return "Remove trailing whitespace";
}
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
try {
PsiElement psiElement = descriptor.getPsiElement();
if (psiElement instanceof DotEnvValueImpl) { | PsiElement newPsiElement = DotEnvFactory.createFromText(project, DotEnvTypes.VALUE, |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/go/GoEnvironmentVariablesUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.goide.GoFileType;
import com.goide.psi.GoFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.go;
public class GoEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(GoFileType.INSTANCE);
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/go/GoEnvironmentVariablesUsagesProvider.java
import com.goide.GoFileType;
import com.goide.psi.GoFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.go;
public class GoEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(GoFileType.INSTANCE);
}
@NotNull
@Override | public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/test/java/ru/adelf/idea/dotenv/tests/dotenv/DotEnvFileTest.java | // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/test/java/ru/adelf/idea/dotenv/tests/DotEnvLightCodeInsightFixtureTestCase.java
// @RunWith(JUnit4.class)
// public abstract class DotEnvLightCodeInsightFixtureTestCase extends BasePlatformTestCase {
//
// protected String basePath = "src/test/java/ru/adelf/idea/dotenv/tests/";
//
// protected void assertCompletion(String... shouldContain) {
// myFixture.completeBasic();
//
// List<String> strings = myFixture.getLookupElementStrings();
//
// if (strings == null) {
// fail("Null completion");
// return;
// }
//
// assertContainsElements(strings, shouldContain);
// }
//
// protected void assertIndexContains(@NotNull ID<String, ?> id, @NotNull String... keys) {
// assertIndex(id, false, keys);
// }
//
// protected void assertIndexNotContains(@NotNull ID<String, ?> id, @NotNull String... keys) {
// assertIndex(id, true, keys);
// }
//
// private void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) {
// for (String key : keys) {
// final Collection<VirtualFile> virtualFiles = new ArrayList<>();
//
// FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// virtualFiles.add(virtualFile);
// return true;
// }, GlobalSearchScope.allScope(getProject()));
//
// if (notCondition && virtualFiles.size() > 0) {
// fail(String.format("Fail that ID '%s' not contains '%s'", id, key));
// } else if (!notCondition && virtualFiles.size() == 0) {
// fail(String.format("Fail that ID '%s' contains '%s'", id, key));
// }
// }
// }
//
// protected void assertUsagesContains(@NotNull String... keys) {
// for (String key : keys) {
// PsiElement[] usages = EnvironmentVariablesApi.getKeyUsages(this.myFixture.getProject(), key);
// if (usages.length == 0) {
// fail(String.format("Fail that usages contains '%s'", key));
// }
// }
// }
//
// protected void assertContainsKeyAndValue(@NotNull String key, @NotNull String value) {
// assertIndexContains(DotEnvKeyValuesIndex.KEY, key);
//
// final AtomicBoolean found = new AtomicBoolean(false);
// Set<String> variants = new HashSet<>();
//
// FileBasedIndexImpl.getInstance().processValues(DotEnvKeyValuesIndex.KEY, key, null, (virtualFile, s) -> {
// variants.add(s);
//
// if (s.equals(value)) {
// found.set(true);
// }
// return false;
// }, GlobalSearchScope.allScope(myFixture.getProject()));
//
// if (!found.get()) {
// fail(String.format("Fail that index contains pair '%s' => '%s'. Variants: '%s'", key, value, String.join("', '", variants)));
// }
// }
// }
| import org.junit.Test;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.tests.DotEnvLightCodeInsightFixtureTestCase; | package ru.adelf.idea.dotenv.tests.dotenv;
public class DotEnvFileTest extends DotEnvLightCodeInsightFixtureTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.configureFromExistingVirtualFile(myFixture.copyFileToProject(".env"));
}
protected String getTestDataPath() {
return basePath + "dotenv/fixtures";
}
@Test
public void testEnvKeys() { | // Path: src/main/java/ru/adelf/idea/dotenv/indexing/DotEnvKeyValuesIndex.java
// public class DotEnvKeyValuesIndex extends FileBasedIndexExtension<String, String> {
//
// public static final ID<String, String> KEY = ID.create("ru.adelf.idea.php.dotenv.keyValues");
//
// @NotNull
// @Override
// public ID<String, String> getName() {
// return KEY;
// }
//
// @NotNull
// @Override
// public DataIndexer<String, String, FileContent> getIndexer() {
// return fileContent -> {
// final Map<String, String> map = new HashMap<>();
//
// boolean storeValues = DotEnvSettings.getInstance(fileContent.getProject()).storeValues;
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// for (KeyValuePsiElement keyValueElement : provider.getElements(fileContent.getPsiFile())) {
// if (storeValues) {
// map.put(keyValueElement.getKey(), keyValueElement.getShortValue());
// } else {
// map.put(keyValueElement.getKey(), "");
// }
// }
// }
//
// return map;
// };
// }
//
// @NotNull
// @Override
// public KeyDescriptor<String> getKeyDescriptor() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public DataExternalizer<String> getValueExternalizer() {
// return EnumeratorStringDescriptor.INSTANCE;
// }
//
// @NotNull
// @Override
// public FileBasedIndex.InputFilter getInputFilter() {
// return file -> {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// if (provider.acceptFile(file).isAccepted()) return true;
// }
//
// return false;
// };
// }
//
// @Override
// public boolean dependsOnFileContent() {
// return true;
// }
//
// @Override
// public int getVersion() {
// return 7;
// }
// }
//
// Path: src/test/java/ru/adelf/idea/dotenv/tests/DotEnvLightCodeInsightFixtureTestCase.java
// @RunWith(JUnit4.class)
// public abstract class DotEnvLightCodeInsightFixtureTestCase extends BasePlatformTestCase {
//
// protected String basePath = "src/test/java/ru/adelf/idea/dotenv/tests/";
//
// protected void assertCompletion(String... shouldContain) {
// myFixture.completeBasic();
//
// List<String> strings = myFixture.getLookupElementStrings();
//
// if (strings == null) {
// fail("Null completion");
// return;
// }
//
// assertContainsElements(strings, shouldContain);
// }
//
// protected void assertIndexContains(@NotNull ID<String, ?> id, @NotNull String... keys) {
// assertIndex(id, false, keys);
// }
//
// protected void assertIndexNotContains(@NotNull ID<String, ?> id, @NotNull String... keys) {
// assertIndex(id, true, keys);
// }
//
// private void assertIndex(@NotNull ID<String, ?> id, boolean notCondition, @NotNull String... keys) {
// for (String key : keys) {
// final Collection<VirtualFile> virtualFiles = new ArrayList<>();
//
// FileBasedIndexImpl.getInstance().getFilesWithKey(id, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// virtualFiles.add(virtualFile);
// return true;
// }, GlobalSearchScope.allScope(getProject()));
//
// if (notCondition && virtualFiles.size() > 0) {
// fail(String.format("Fail that ID '%s' not contains '%s'", id, key));
// } else if (!notCondition && virtualFiles.size() == 0) {
// fail(String.format("Fail that ID '%s' contains '%s'", id, key));
// }
// }
// }
//
// protected void assertUsagesContains(@NotNull String... keys) {
// for (String key : keys) {
// PsiElement[] usages = EnvironmentVariablesApi.getKeyUsages(this.myFixture.getProject(), key);
// if (usages.length == 0) {
// fail(String.format("Fail that usages contains '%s'", key));
// }
// }
// }
//
// protected void assertContainsKeyAndValue(@NotNull String key, @NotNull String value) {
// assertIndexContains(DotEnvKeyValuesIndex.KEY, key);
//
// final AtomicBoolean found = new AtomicBoolean(false);
// Set<String> variants = new HashSet<>();
//
// FileBasedIndexImpl.getInstance().processValues(DotEnvKeyValuesIndex.KEY, key, null, (virtualFile, s) -> {
// variants.add(s);
//
// if (s.equals(value)) {
// found.set(true);
// }
// return false;
// }, GlobalSearchScope.allScope(myFixture.getProject()));
//
// if (!found.get()) {
// fail(String.format("Fail that index contains pair '%s' => '%s'. Variants: '%s'", key, value, String.join("', '", variants)));
// }
// }
// }
// Path: src/test/java/ru/adelf/idea/dotenv/tests/dotenv/DotEnvFileTest.java
import org.junit.Test;
import ru.adelf.idea.dotenv.indexing.DotEnvKeyValuesIndex;
import ru.adelf.idea.dotenv.tests.DotEnvLightCodeInsightFixtureTestCase;
package ru.adelf.idea.dotenv.tests.dotenv;
public class DotEnvFileTest extends DotEnvLightCodeInsightFixtureTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
myFixture.configureFromExistingVirtualFile(myFixture.copyFileToProject(".env"));
}
protected String getTestDataPath() {
return basePath + "dotenv/fixtures";
}
@Test
public void testEnvKeys() { | assertIndexContains(DotEnvKeyValuesIndex.KEY, "TEST", "TEST2", "TEST3", "EMPTY_KEY", "OFFSET_KEY"); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/php/PhpunitEnvironmentVariablesUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; | package ru.adelf.idea.dotenv.php;
public class PhpunitEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(XmlFileType.INSTANCE) && file.getName().equals("phpunit.xml");
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/php/PhpunitEnvironmentVariablesUsagesProvider.java
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
package ru.adelf.idea.dotenv.php;
public class PhpunitEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(XmlFileType.INSTANCE) && file.getName().equals("phpunit.xml");
}
@NotNull
@Override | public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/ui/DotEnvSettingsConfigurable.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
| import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvSettings;
import javax.swing.*;
import javax.swing.border.Border; | package ru.adelf.idea.dotenv.ui;
public class DotEnvSettingsConfigurable implements Configurable {
private final Project project;
public DotEnvSettingsConfigurable(@NotNull final Project project) {
this.project = project;
}
private JCheckBox completionEnabledCheckbox;
private JCheckBox storeValuesCheckbox;
@Nls
@Override
public String getDisplayName() {
return "DotEnv";
}
@Nullable
@Override
public JComponent createComponent() { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvSettings.java
// @State(name = "DotEnvSettings", storages = {@Storage("dot-env.xml")})
// public class DotEnvSettings implements PersistentStateComponent<DotEnvSettings> {
// public boolean completionEnabled = true;
// public boolean storeValues = true;
//
// @Nullable
// @Override
// public DotEnvSettings getState() {
// return this;
// }
//
// @Override
// public void loadState(@NotNull DotEnvSettings state) {
// XmlSerializerUtil.copyBean(state, this);
// }
//
// public static DotEnvSettings getInstance(Project project) {
// return project.getService(DotEnvSettings.class);
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/ui/DotEnvSettingsConfigurable.java
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvSettings;
import javax.swing.*;
import javax.swing.border.Border;
package ru.adelf.idea.dotenv.ui;
public class DotEnvSettingsConfigurable implements Configurable {
private final Project project;
public DotEnvSettingsConfigurable(@NotNull final Project project) {
this.project = project;
}
private JCheckBox completionEnabledCheckbox;
private JCheckBox storeValuesCheckbox;
@Nls
@Override
public String getDisplayName() {
return "DotEnv";
}
@Nullable
@Override
public JComponent createComponent() { | DotEnvSettings settings = getSettings(); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
| import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider; | package ru.adelf.idea.dotenv.util;
public class EnvironmentVariablesProviderUtil {
public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
| // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
// Path: src/main/java/ru/adelf/idea/dotenv/util/EnvironmentVariablesProviderUtil.java
import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
package ru.adelf.idea.dotenv.util;
public class EnvironmentVariablesProviderUtil {
public static final EnvironmentVariablesProvider[] PROVIDERS = getEnvVariablesProviders();
| public static final EnvironmentVariablesUsagesProvider[] USAGES_PROVIDERS = getEnvVariablesUsagesProviders(); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/docker/DockerfileVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.docker.dockerFile.DockerFileType;
import com.intellij.docker.dockerFile.DockerPsiFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.docker;
public class DockerfileVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/docker/DockerfileVariablesProvider.java
import com.intellij.docker.dockerFile.DockerFileType;
import com.intellij.docker.dockerFile.DockerPsiFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.docker;
public class DockerfileVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override | public FileAcceptResult acceptFile(VirtualFile file) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/docker/DockerfileVariablesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.docker.dockerFile.DockerFileType;
import com.intellij.docker.dockerFile.DockerPsiFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections; | package ru.adelf.idea.dotenv.docker;
public class DockerfileVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
return file.getFileType().equals(DockerFileType.DOCKER_FILE_TYPE) ? FileAcceptResult.ACCEPTED : FileAcceptResult.NOT_ACCEPTED;
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesProvider.java
// public interface EnvironmentVariablesProvider {
// @NotNull
// FileAcceptResult acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyValuePsiElement> getElements(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/api/FileAcceptResult.java
// public class FileAcceptResult {
// public final static FileAcceptResult ACCEPTED = new FileAcceptResult(true, true);
// public final static FileAcceptResult NOT_ACCEPTED = new FileAcceptResult(false, true);
// public final static FileAcceptResult ACCEPTED_SECONDARY = new FileAcceptResult(true, false);
//
// private final boolean accepted;
// private final boolean primary;
//
// private FileAcceptResult(boolean accepted, boolean primary) {
// this.accepted = accepted;
// this.primary = primary;
// }
//
// public boolean isAccepted() {
// return accepted;
// }
//
// public boolean isPrimary() {
// return primary;
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyValuePsiElement.java
// public class KeyValuePsiElement {
//
// private final String key;
// private final String value;
// private final PsiElement element;
//
// public KeyValuePsiElement(String key, String value, PsiElement element) {
// this.key = key;
// this.value = value;
// this.element = element;
// }
//
// public String getKey() {
// return key.trim();
// }
//
// public String getShortValue() {
// if (value.indexOf('\n') != -1) {
// return clearString(value.substring(0, value.indexOf('\n'))) + "...";
// }
//
// return value.trim();
// }
//
// private String clearString(String s) {
// return StringUtil.trim(s.trim(), ch -> ch != '\\').trim();
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/docker/DockerfileVariablesProvider.java
import com.intellij.docker.dockerFile.DockerFileType;
import com.intellij.docker.dockerFile.DockerPsiFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesProvider;
import ru.adelf.idea.dotenv.api.FileAcceptResult;
import ru.adelf.idea.dotenv.models.KeyValuePsiElement;
import java.util.Collection;
import java.util.Collections;
package ru.adelf.idea.dotenv.docker;
public class DockerfileVariablesProvider implements EnvironmentVariablesProvider {
@NotNull
@Override
public FileAcceptResult acceptFile(VirtualFile file) {
return file.getFileType().equals(DockerFileType.DOCKER_FILE_TYPE) ? FileAcceptResult.ACCEPTED : FileAcceptResult.NOT_ACCEPTED;
}
@NotNull
@Override | public Collection<KeyValuePsiElement> getElements(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinEnvironmentVariablesUsagesProvider.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
| import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.psi.KtFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; | package ru.adelf.idea.dotenv.kotlin;
public class KotlinEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(KotlinFileType.INSTANCE);
}
@NotNull
@Override | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesUsagesProvider.java
// public interface EnvironmentVariablesUsagesProvider {
// boolean acceptFile(VirtualFile file);
//
// @NotNull
// Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile);
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/models/KeyUsagePsiElement.java
// public class KeyUsagePsiElement {
//
// private final String key;
// private final PsiElement element;
//
// public KeyUsagePsiElement(String key, PsiElement element) {
// this.key = key;
// this.element = element;
// }
//
// public String getKey() {
// return key;
// }
//
// public PsiElement getElement() {
// return element;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/kotlin/KotlinEnvironmentVariablesUsagesProvider.java
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.psi.KtFile;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesUsagesProvider;
import ru.adelf.idea.dotenv.models.KeyUsagePsiElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
package ru.adelf.idea.dotenv.kotlin;
public class KotlinEnvironmentVariablesUsagesProvider implements EnvironmentVariablesUsagesProvider {
@Override
public boolean acceptFile(VirtualFile file) {
return file.getFileType().equals(KotlinFileType.INSTANCE);
}
@NotNull
@Override | public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) { |
adelf/idea-php-dotenv-plugin | src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java | // Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvVisitor.java
// public class DotEnvVisitor extends PsiElementVisitor {
//
// public void visitKey(@NotNull DotEnvKey o) {
// visitPsiElement(o);
// }
//
// public void visitProperty(@NotNull DotEnvProperty o) {
// visitNamedElement(o);
// }
//
// public void visitValue(@NotNull DotEnvValue o) {
// visitPsiElement(o);
// }
//
// public void visitNamedElement(@NotNull DotEnvNamedElement o) {
// visitPsiElement(o);
// }
//
// public void visitPsiElement(@NotNull PsiElement o) {
// visitElement(o);
// }
//
// }
| import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.DotEnvVisitor; | // This is a generated file. Not intended for manual editing.
package ru.adelf.idea.dotenv.psi.impl;
public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
public DotEnvValueImpl(@NotNull ASTNode node) {
super(node);
}
| // Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvVisitor.java
// public class DotEnvVisitor extends PsiElementVisitor {
//
// public void visitKey(@NotNull DotEnvKey o) {
// visitPsiElement(o);
// }
//
// public void visitProperty(@NotNull DotEnvProperty o) {
// visitNamedElement(o);
// }
//
// public void visitValue(@NotNull DotEnvValue o) {
// visitPsiElement(o);
// }
//
// public void visitNamedElement(@NotNull DotEnvNamedElement o) {
// visitPsiElement(o);
// }
//
// public void visitPsiElement(@NotNull PsiElement o) {
// visitElement(o);
// }
//
// }
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/impl/DotEnvValueImpl.java
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import ru.adelf.idea.dotenv.psi.DotEnvVisitor;
// This is a generated file. Not intended for manual editing.
package ru.adelf.idea.dotenv.psi.impl;
public class DotEnvValueImpl extends ASTWrapperPsiElement implements DotEnvValue {
public DotEnvValueImpl(@NotNull ASTNode node) {
super(node);
}
| public void accept(@NotNull DotEnvVisitor visitor) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/extension/DotEnvReference.java | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
| import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import java.util.Arrays; | package ru.adelf.idea.dotenv.extension;
public class DotEnvReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private final String key;
public DotEnvReference(@NotNull PsiElement element, TextRange textRange) {
super(element, textRange);
key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
}
public DotEnvReference(@NotNull PsiElement element, TextRange textRange, String key) {
super(element, textRange);
this.key = key;
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) { | // Path: src/main/java/ru/adelf/idea/dotenv/api/EnvironmentVariablesApi.java
// public class EnvironmentVariablesApi {
//
// @NotNull
// public static Map<String, String> getAllKeyValues(Project project) {
// FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
// Map<String, String> keyValues = new HashMap<>();
// Map<String, String> secondaryKeyValues = new HashMap<>();
// Map<VirtualFile, FileAcceptResult> resultsCache = new HashMap<>();
//
// GlobalSearchScope scope = GlobalSearchScope.allScope(project);
//
// fileBasedIndex.processAllKeys(DotEnvKeyValuesIndex.KEY, key -> {
// for (VirtualFile virtualFile : fileBasedIndex.getContainingFiles(DotEnvKeyValuesIndex.KEY, key, scope)) {
//
// FileAcceptResult fileAcceptResult;
//
// if (resultsCache.containsKey(virtualFile)) {
// fileAcceptResult = resultsCache.get(virtualFile);
// } else {
// fileAcceptResult = getFileAcceptResult(virtualFile);
// resultsCache.put(virtualFile, fileAcceptResult);
// }
//
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// fileBasedIndex.processValues(DotEnvKeyValuesIndex.KEY, key, virtualFile, ((file, val) -> {
// if (fileAcceptResult.isPrimary()) {
// keyValues.putIfAbsent(key, val);
// } else {
// secondaryKeyValues.putIfAbsent(key, val);
// }
//
// return true;
// }), scope);
// }
//
// return true;
// }, project);
//
// secondaryKeyValues.putAll(keyValues);
//
// return secondaryKeyValues;
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key declarations, in .env files, Dockerfile, docker-compose.yml, etc
// */
// @NotNull
// public static PsiElement[] getKeyDeclarations(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
// List<PsiElement> secondaryTargets = new ArrayList<>();
//
// FileBasedIndex.getInstance().getFilesWithKey(DotEnvKeyValuesIndex.KEY, new HashSet<>(Collections.singletonList(key)), virtualFile -> {
// PsiFile psiFileTarget = PsiManager.getInstance(project).findFile(virtualFile);
// if (psiFileTarget == null) {
// return true;
// }
//
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// (fileAcceptResult.isPrimary() ? targets : secondaryTargets).addAll(EnvironmentVariablesUtil.getElementsByKey(key, provider.getElements(psiFileTarget)));
// }
//
// return true;
// }, GlobalSearchScope.allScope(project));
//
// return (targets.size() > 0 ? targets : secondaryTargets).toArray(PsiElement.EMPTY_ARRAY);
// }
//
// /**
// * @param project project
// * @param key environment variable key
// * @return All key usages, like getenv('KEY')
// */
// @NotNull
// public static PsiElement[] getKeyUsages(Project project, String key) {
// List<PsiElement> targets = new ArrayList<>();
//
// PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(project);
//
// Processor<PsiFile> psiFileProcessor = psiFile -> {
// for (EnvironmentVariablesUsagesProvider provider : EnvironmentVariablesProviderUtil.USAGES_PROVIDERS) {
// targets.addAll(EnvironmentVariablesUtil.getUsagesElementsByKey(key, provider.getUsages(psiFile)));
// }
//
// return true;
// };
//
// searchHelper.processAllFilesWithWord(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
// searchHelper.processAllFilesWithWordInLiterals(key, GlobalSearchScope.allScope(project), psiFileProcessor);
// searchHelper.processAllFilesWithWordInText(key, GlobalSearchScope.allScope(project), psiFileProcessor, true);
//
// return targets.toArray(PsiElement.EMPTY_ARRAY);
// }
//
// private static FileAcceptResult getFileAcceptResult(VirtualFile virtualFile) {
// for (EnvironmentVariablesProvider provider : EnvironmentVariablesProviderUtil.PROVIDERS) {
// FileAcceptResult fileAcceptResult = provider.acceptFile(virtualFile);
// if (!fileAcceptResult.isAccepted()) {
// continue;
// }
//
// return fileAcceptResult;
// }
//
// return FileAcceptResult.NOT_ACCEPTED;
// }
// }
// Path: src/main/java/ru/adelf/idea/dotenv/extension/DotEnvReference.java
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.api.EnvironmentVariablesApi;
import java.util.Arrays;
package ru.adelf.idea.dotenv.extension;
public class DotEnvReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private final String key;
public DotEnvReference(@NotNull PsiElement element, TextRange textRange) {
super(element, textRange);
key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
}
public DotEnvReference(@NotNull PsiElement element, TextRange textRange, String key) {
super(element, textRange);
this.key = key;
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) { | final PsiElement[] elements = EnvironmentVariablesApi.getKeyDeclarations(myElement.getProject(), key); |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import java.util.function.Supplier;
import java.util.stream.Stream; | package ru.adelf.idea.dotenv.inspections;
public class SpaceInsideNonQuotedInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Space inside non-quoted value";
}
private AddQuotesQuickFix addQuotesQuickFix = new AddQuotesQuickFix();
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import java.util.function.Supplier;
import java.util.stream.Stream;
package ru.adelf.idea.dotenv.inspections;
public class SpaceInsideNonQuotedInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Space inside non-quoted value";
}
private AddQuotesQuickFix addQuotesQuickFix = new AddQuotesQuickFix();
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { | if (!(file instanceof DotEnvFile)) { |
adelf/idea-php-dotenv-plugin | src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java | // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
| import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import java.util.function.Supplier;
import java.util.stream.Stream; | package ru.adelf.idea.dotenv.inspections;
public class SpaceInsideNonQuotedInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Space inside non-quoted value";
}
private AddQuotesQuickFix addQuotesQuickFix = new AddQuotesQuickFix();
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| // Path: src/main/java/ru/adelf/idea/dotenv/DotEnvFactory.java
// public class DotEnvFactory {
// public static PsiElement createFromText(@NotNull Project project, @NotNull IElementType type, @NotNull String text) {
// final Ref<PsiElement> ret = new Ref<>();
// PsiFile dummyFile = createDummyFile(project, text);
// dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
// public void visitElement(@NotNull PsiElement element) {
// ASTNode node = element.getNode();
// if (node != null && node.getElementType() == type) {
// ret.set(element);
// stopWalking();
// } else {
// super.visitElement(element);
// }
// }
// });
//
// assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
//
// return ret.get();
// }
//
// @NotNull
// private static PsiFile createDummyFile(Project project, String fileText) {
// return PsiFileFactory.getInstance(project).createFileFromText("DUMMY__.env", DotEnvFileType.INSTANCE, fileText, System.currentTimeMillis(), false);
// }
// }
//
// Path: src/main/java/ru/adelf/idea/dotenv/psi/DotEnvFile.java
// public class DotEnvFile extends PsiFileBase {
// public DotEnvFile(@NotNull FileViewProvider viewProvider) {
// super(viewProvider, DotEnvLanguage.INSTANCE);
// }
//
// @NotNull
// @Override
// public FileType getFileType() {
// return DotEnvFileType.INSTANCE;
// }
//
// @Override
// public String toString() {
// return ".env file";
// }
//
// @Override
// public Icon getIcon(int flags) {
// return super.getIcon(flags);
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvTypes.java
// public interface DotEnvTypes {
//
// IElementType KEY = new DotEnvElementType("KEY");
// IElementType PROPERTY = new DotEnvElementType("PROPERTY");
// IElementType VALUE = new DotEnvElementType("VALUE");
//
// IElementType COMMENT = new DotEnvTokenType("COMMENT");
// IElementType CRLF = new DotEnvTokenType("CRLF");
// IElementType EXPORT = new DotEnvTokenType("EXPORT");
// IElementType KEY_CHARS = new DotEnvTokenType("KEY_CHARS");
// IElementType QUOTE = new DotEnvTokenType("QUOTE");
// IElementType SEPARATOR = new DotEnvTokenType("SEPARATOR");
// IElementType VALUE_CHARS = new DotEnvTokenType("VALUE_CHARS");
//
// class Factory {
// public static PsiElement createElement(ASTNode node) {
// IElementType type = node.getElementType();
// if (type == KEY) {
// return new DotEnvKeyImpl(node);
// }
// else if (type == PROPERTY) {
// return new DotEnvPropertyImpl(node);
// }
// else if (type == VALUE) {
// return new DotEnvValueImpl(node);
// }
// throw new AssertionError("Unknown element type: " + type);
// }
// }
// }
//
// Path: src/main/gen/ru/adelf/idea/dotenv/psi/DotEnvValue.java
// public interface DotEnvValue extends PsiElement {
//
// }
// Path: src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java
import com.intellij.codeInspection.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import ru.adelf.idea.dotenv.DotEnvFactory;
import ru.adelf.idea.dotenv.psi.DotEnvFile;
import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
import java.util.function.Supplier;
import java.util.stream.Stream;
package ru.adelf.idea.dotenv.inspections;
public class SpaceInsideNonQuotedInspection extends LocalInspectionTool {
// Change the display name within the plugin.xml
// This needs to be here as otherwise the tests will throw errors.
@NotNull
@Override
public String getDisplayName() {
return "Space inside non-quoted value";
}
private AddQuotesQuickFix addQuotesQuickFix = new AddQuotesQuickFix();
@Override
public boolean runForWholeFile() {
return true;
}
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (!(file instanceof DotEnvFile)) {
return null;
}
return analyzeFile(file, manager, isOnTheFly).getResultsArray();
}
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
| PsiTreeUtil.findChildrenOfType(file, DotEnvValue.class).forEach(dotEnvValue -> { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.