src/eu/inmite/android/plugin/butterknifezelezny/common/Utils.java
public static PsiFile findLayoutResource(PsiElement element) {
		if (element == null) {
			return null; // nothing to be used
		}
		if (!(element instanceof PsiIdentifier)) {
			return null; // nothing to be used
		}

		PsiElement layout = element.getParent().getFirstChild();
		if (layout == null) {
			return null; // no file to process
		}
		if (!"R.layout".equals(layout.getText())) {
			return null; // not layout file
		}

		Project project = element.getProject();
		String name = String.format("%s.xml", element.getText());
		PsiFile[] files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
		if (files.length <= 0) {
			return null; //no matching files
		}

		return files[0];
	}
/**
	 * Try to find layout XML file in selected element
	 *
	 * @param element
	 * @return
	 */
Try to find layout XML file in selected element
@param element
@return
Try to find layout XML file in selected element @param element @return
public static PsiFile findLayoutResource(PsiElement element) {
		if (element == null) {
			return null; 
		}
		if (!(element instanceof PsiIdentifier)) {
			return null; 
		}
		PsiElement layout = element.getParent().getFirstChild();
		if (layout == null) {
			return null; 
		}
		if (!"R.layout".equals(layout.getText())) {
			return null; 
		}
		Project project = element.getProject();
		String name = String.format("%s.xml", element.getText());
		PsiFile[] files = FilenameIndex.getFilesByName(project, name, new EverythingGlobalScope(project));
		if (files.length <= 0) {
			return null; 
		}
		return files[0];
	}
public static PsiFile findLayoutResource ( PsiElement element ) { if ( element == null ) { return null ; } if ( ! ( element instanceof PsiIdentifier ) ) { return null ; } PsiElement layout = element . getParent ( ) . getFirstChild ( ) ; if ( layout == null ) { return null ; } if ( ! "R.layout" . equals ( layout . getText ( ) ) ) { return null ; } Project project = element . getProject ( ) ; String name = String . format ( "%s.xml" , element . getText ( ) ) ; PsiFile [ ] files = FilenameIndex . getFilesByName ( project , name , new EverythingGlobalScope ( project ) ) ; if ( files . length <= 0 ) { return null ; } return files [ 0 ] ; }
Try to find layout XML file in selected element
 @param element
 @return
Try to find layout XML file in selected element @param element @return
// nothing to be used // nothing to be used // no file to process // not layout file //no matching files