Package: AcceleoSourceLookupParticipant

AcceleoSourceLookupParticipant

nameinstructionbranchcomplexitylinemethod
AcceleoSourceLookupParticipant()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
findSourceElements(Object)
M: 61 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
getSourceName(Object)
M: 11 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2012 Obeo.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Obeo - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.acceleo.internal.ide.ui.launching;
12:
13: import org.eclipse.acceleo.common.IAcceleoConstants;
14: import org.eclipse.acceleo.ide.ui.resources.AcceleoProject;
15: import org.eclipse.acceleo.internal.ide.ui.debug.model.AcceleoStackFrame;
16: import org.eclipse.core.resources.IFile;
17: import org.eclipse.core.resources.ResourcesPlugin;
18: import org.eclipse.core.runtime.CoreException;
19: import org.eclipse.core.runtime.IPath;
20: import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
21:
22: /**
23: * A source lookup participant that searches for an Acceleo source code.
24: *
25: * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
26: */
27: public class AcceleoSourceLookupParticipant extends JavaSourceLookupParticipant {
28:
29:         /**
30:          * Returns the source name associated with the given object, or <code>null</code> if none.
31:          *
32:          * @param object
33:          * is an Acceleo debug model element
34:          * @return the source name associated with the given object, or <code>null</code> if none
35:          * @exception CoreException
36:          * if unable to retrieve the source name
37:          */
38:         @Override
39:         public String getSourceName(Object object) throws CoreException {
40:•                if (object instanceof AcceleoStackFrame) {
41:                         return ((AcceleoStackFrame)object).getSourceName();
42:                 }
43:                 return super.getSourceName(object);
44:         }
45:
46:         /**
47:          * {@inheritDoc}
48:          *
49:          * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
50:          */
51:         @Override
52:         public Object[] findSourceElements(Object object) throws CoreException {
53:                 Object[] result = super.findSourceElements(object);
54:•                for (int i = 0; i < result.length; i++) {
55:•                        if (result[i] instanceof IFile
56:•                                        && IAcceleoConstants.MTL_FILE_EXTENSION.equals(((IFile)result[i]).getFileExtension())) {
57:                                 IFile file = (IFile)result[i];
58:                                 AcceleoProject acceleoProject = new AcceleoProject(file.getProject());
59:                                 IPath realFilePath = acceleoProject.getInputFilePath(file.getFullPath());
60:•                                if (realFilePath != null && realFilePath.segmentCount() > 1) {
61:                                         IFile realFile = ResourcesPlugin.getWorkspace().getRoot().getFile(realFilePath);
62:•                                        if (realFile.exists()) {
63:                                                 result[i] = realFile;
64:                                         }
65:                                 }
66:                         }
67:                 }
68:                 return result;
69:         }
70: }