package ru.yandex.qatools.allure.aspects;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import ru.yandex.qatools.allure.Allure;
import ru.yandex.qatools.allure.annotations.Attach;
import ru.yandex.qatools.allure.events.MakeAttachEvent;

/**
 * @author Dmitry Baev charlie@yandex-team.ru
 *         Date: 24.10.13
 */

@Aspect
public class AllureAttachAspects {

	@Pointcut("@annotation(ru.yandex.qatools.allure.annotations.Attach)")
	public void withAttachAnnotation() {
        //pointcut body, should be empty
	}

	@Pointcut("execution(* *(..))")
	public void anyMethod() {
        //pointcut body, should be empty
	}

	@AfterReturning(pointcut = "anyMethod() && withAttachAnnotation()", returning = "result")
	public void attach(JoinPoint joinPoint, Object result) {
		MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
		Attach attach = methodSignature.getMethod().getAnnotation(Attach.class);
		String attachTitle = AllureAspectUtils.getTitle(attach.name(), methodSignature.getName(), joinPoint.getArgs());
        Allure.LIFECYCLE.fire(new MakeAttachEvent(attachTitle, attach.type(), result));
	}
}

@@ -533,17 +533,20 @@
 ects %7B%0A%0A
-%09
+    
 @Pointcu
@@ -603,25 +603,28 @@
 s.Attach)%22)%0A
-%09
+    
 public void 
@@ -689,21 +689,27 @@
 e empty%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Pointcu
@@ -732,17 +732,20 @@
 (..))%22)%0A
-%09
+    
 public v
@@ -807,13 +807,19 @@
 pty%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Aft
@@ -904,17 +904,20 @@
 esult%22)%0A
-%09
+    
 public v
@@ -965,18 +965,24 @@
 sult) %7B%0A
-%09%09
+        
 MethodSi
@@ -1051,18 +1051,24 @@
 ture();%0A
-%09%09
+        
 Attach a
@@ -1136,10 +1136,16 @@
 s);%0A
-%09%09
+        
 Stri
@@ -1344,9 +1344,12 @@
 ));%0A
-%09
+    
 %7D%0A%7D%0A

Replace tab with sequence of spaces