01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2004 Jennifer Lhotak
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: package ca.mcgill.sable.soot.attributes;
21:
22: import java.util.ArrayList;
23:
24: import org.eclipse.core.resources.*;
25: import org.eclipse.core.runtime.IAdaptable;
26: import org.eclipse.ui.IEditorInput;
27: import org.eclipse.ui.texteditor.*;
28:
29: public class JimpleAttributesComputer extends
30: AbstractAttributesComputer {
31:
32: protected ArrayList computeNames(IFile file) {
33: return getNames();
34: }
35:
36: /* (non-Javadoc)
37: * @see ca.mcgill.sable.soot.attributes.AbstractAttributesComputer#computeNames(org.eclipse.ui.texteditor.AbstractTextEditor)
38: */
39: protected ArrayList computeNames(AbstractTextEditor editor) {
40: return getNames();
41: }
42:
43: private ArrayList getNames() {
44: ArrayList names = new ArrayList();
45: names.add(fileToNoExt(getRec().getName()));
46: return names;
47: }
48:
49: /* (non-Javadoc)
50: * @see ca.mcgill.sable.soot.attributes.AbstractAttributesComputer#init(org.eclipse.ui.texteditor.AbstractTextEditor)
51: */
52: protected void init(AbstractTextEditor editor) {
53: setRec(getResource(editor));
54: setProj(getRec().getProject());
55:
56: }
57:
58: public IResource getResource(AbstractTextEditor textEditor) {
59: IEditorInput input = textEditor.getEditorInput();
60: return (IResource) ((IAdaptable) input)
61: .getAdapter(IResource.class);
62: }
63:
64: public String fileToNoExt(String filename) {
65: return filename.substring(0, filename.lastIndexOf('.'));
66: }
67:
68: }
|