KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > attributes > JimpleAttributesComputer


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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
21 package ca.mcgill.sable.soot.attributes;
22
23 import java.util.ArrayList JavaDoc;
24
25 import org.eclipse.core.resources.*;
26 import org.eclipse.core.runtime.IAdaptable;
27 import org.eclipse.ui.IEditorInput;
28 import org.eclipse.ui.texteditor.*;
29
30 public class JimpleAttributesComputer extends AbstractAttributesComputer {
31
32     protected ArrayList JavaDoc 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 JavaDoc computeNames(AbstractTextEditor editor) {
40         return getNames();
41     }
42     
43     private ArrayList JavaDoc getNames(){
44         ArrayList JavaDoc names = new ArrayList JavaDoc();
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).getAdapter(IResource.class);
61     }
62     
63     public String JavaDoc fileToNoExt(String JavaDoc filename) {
64         return filename.substring(0, filename.lastIndexOf('.'));
65     }
66
67
68     
69
70 }
71
Popular Tags