issue_id
int64 2.03k
426k
| title
stringlengths 9
251
| body
stringlengths 1
32.8k
⌀ | status
stringclasses 6
values | after_fix_sha
stringlengths 7
7
| project_name
stringclasses 6
values | repo_url
stringclasses 6
values | repo_name
stringclasses 6
values | language
stringclasses 1
value | issue_url
null | before_fix_sha
null | pull_url
null | commit_datetime
timestamp[us, tz=UTC] | report_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 2
187
| file_content
stringlengths 0
368k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.Frame;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.BuildListener;
import org.aspectj.ajde.BuildProgressMonitor;
import org.aspectj.ajde.EditorAdapter;
import org.aspectj.ajde.ErrorHandler;
import org.aspectj.ajde.ProjectPropertiesAdapter;
import org.aspectj.ajde.TaskListManager;
import org.aspectj.ajde.ui.FileStructureView;
import org.aspectj.ajde.ui.IdeUIAdapter;
import org.aspectj.ajde.ui.UserPreferencesAdapter;
import org.aspectj.ajde.ui.internal.AjcBuildOptions;
/**
* @author Mik Kersten
*/
public class AjdeUIManager {
protected static final AjdeUIManager INSTANCE = new AjdeUIManager();
private BrowserViewManager viewManager = null;
private BuildProgressMonitor buildProgressMonitor = null;
private ErrorHandler errorHandler = null;
private UserPreferencesAdapter userPreferencesAdapter = null;
private AjcBuildOptions buildOptionsAdapter = null;
private IdeUIAdapter ideUIAdapter = null;
private TreeViewBuildConfigEditor buildConfigEditor = null;
private IconRegistry iconRegistry;
private OptionsFrame optionsFrame = null;
private Frame rootFrame = null;
private StructureViewPanel fileStructurePanel = null;
/**
* Order of initialization is critical here.
*/
public void init(
EditorAdapter editorAdapter,
TaskListManager taskListManager,
ProjectPropertiesAdapter projectProperties,
UserPreferencesAdapter userPreferencesAdapter,
IdeUIAdapter ideUIAdapter,
IconRegistry iconRegistry,
Frame rootFrame,
boolean useFileView) {
try {
BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame);
ErrorHandler errorHandler = new AjdeErrorHandler();
this.iconRegistry = iconRegistry;
//ConfigurationManager configManager = new LstConfigurationManager();
this.ideUIAdapter = ideUIAdapter;
this.userPreferencesAdapter = userPreferencesAdapter;
this.buildOptionsAdapter = new AjcBuildOptions(userPreferencesAdapter);
this.buildConfigEditor = new TreeViewBuildConfigEditor();
this.rootFrame = rootFrame;
Ajde.init(
editorAdapter,
taskListManager,
compileProgress,
projectProperties,
buildOptionsAdapter,
new SwingTreeViewNodeFactory(iconRegistry),
ideUIAdapter,
errorHandler);
Ajde.getDefault().getBuildManager().addListener(STATUS_TEXT_UPDATER);
//Ajde.getDefault().setConfigurationManager(configManager);
if (useFileView) {
FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(
Ajde.getDefault().getEditorManager().getCurrFile(),
Ajde.getDefault().getStructureViewManager().getDefaultViewProperties()
);
Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView);
fileStructurePanel = new StructureViewPanel(structureView);
}
viewManager = new BrowserViewManager();
optionsFrame = new OptionsFrame(iconRegistry);
//Ajde.getDefault().getStructureViewManager().refreshView(
// Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
//);
//viewManager.updateView();
} catch (Throwable t) {
Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t);
}
}
public static AjdeUIManager getDefault() {
return INSTANCE;
}
public BrowserViewManager getViewManager() {
return viewManager;
}
public Frame getRootFrame() {
return rootFrame;
}
public OptionsFrame getOptionsFrame() {
return optionsFrame;
}
public void showOptionsFrame() {
int x = (rootFrame.getWidth()/2) + rootFrame.getX() - optionsFrame.getWidth()/2;
int y = (rootFrame.getHeight()/2) + rootFrame.getY() - optionsFrame.getHeight()/2;
optionsFrame.setLocation(x, y);
optionsFrame.show();
}
public AjcBuildOptions getBuildOptions() {
return buildOptionsAdapter;
}
private final BuildListener STATUS_TEXT_UPDATER = new BuildListener() {
public void compileStarted(String buildConfigFile) {
ideUIAdapter.displayStatusInformation(" Building: " + buildConfigFile + "...");
}
public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) {
int timeInSeconds = buildTime/1000;
if (succeeded) {
ideUIAdapter.displayStatusInformation(" Build succeeded in " + timeInSeconds + " second(s).");
//hideMessages();
} else {
ideUIAdapter.displayStatusInformation(" Build failed in " + timeInSeconds + " second(s)");
//showMessages();
}
}
public void compileAborted(String buildConfigFile, String message) {
ideUIAdapter.displayStatusInformation("Compile aborted: " + message);
}
};
public IdeUIAdapter getIdeUIAdapter() {
return ideUIAdapter;
}
public TreeViewBuildConfigEditor getBuildConfigEditor() {
return buildConfigEditor;
}
public StructureViewPanel getFileStructurePanel() {
return fileStructurePanel;
}
public IconRegistry getIconRegistry() {
return iconRegistry;
}
}
//public abstract class AjdeAction {
// public abstract void actionPerformed(ActionEvent e);
//
// public abstract String getName();
//
// public abstract ImageIcon getIcon();
//}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/BasicEditor.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.EditorAdapter;
import org.aspectj.bridge.ISourceLocation;
/**
* Bare-bones editor implementation used when the framework is being used
* standalone.
*
* @author Mik Kersten
*/
public class BasicEditor implements EditorAdapter {
private String NO_FILE = "<no file selected>";
private String filePath = NO_FILE;
private JPanel editor_panel = new JPanel();
// @todo get rid of these
private int currHighlightStart = 0;
private int currHighlightEnd = 0;
private BorderLayout borderLayout1 = new BorderLayout();
private JScrollPane jScrollPane1 = new JScrollPane();
private JEditorPane editorPane = new JEditorPane();
public BasicEditor() {
try {
editorPane.setEditable(true);
editorPane.setContentType("text/plain");
editorPane.setFont(new Font("Monospaced", 0, 11));
editor_panel.add(editorPane);
jbInit();
}
catch(Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
}
public String getCurrFile() {
return filePath;
}
public void showSourceLine(ISourceLocation sourceLocation, boolean highlight) {
showSourceLine(sourceLocation.getSourceFile().getAbsolutePath(), sourceLocation.getLine(), highlight);
}
public void showSourceLine(int lineNumber, boolean highlight) {
showSourceLine(filePath, lineNumber, highlight);
}
public void pasteToCaretPos(String text) {
if (currHighlightEnd < 1) return;
String contents = editorPane.getText();
String pasted = contents.substring(0, currHighlightEnd) +
text + contents.substring(currHighlightEnd, contents.length());
editorPane.setText(pasted);
}
public void showSourceLine(String filePath, int lineNumber, boolean highlight) {
//AjdeUIManager.getDefault().getIdeUIAdapter().resetEditor();
String oldPath = this.filePath;
this.filePath = filePath;
// if (oldPath != filePath && !Ajde.INSTANCE.BROWSER_MANAGER.isGlobalMode()) {
// Ajde.INSTANCE.BROWSER_MANAGER.updateView();
// }
// Ajde.IDE_MANAGER.setEditorStatusText(filePath);
currHighlightStart = 0;
currHighlightEnd = 0;
editorPane.setText(readFile(filePath, lineNumber));
try {
editorPane.getHighlighter().addHighlight(currHighlightStart, currHighlightEnd, DefaultHighlighter.DefaultPainter);
editorPane.setCaretPosition(currHighlightStart);
} catch (BadLocationException ble) {
Ajde.getDefault().getErrorHandler().handleError("Could not highlight location.", ble);
}
Ajde.getDefault().getEditorManager().notifyCurrentFileChanged(filePath);
}
/**
* Not implemented.
*/
public void showSourcelineAnnotation(String filePath, int lineNumber, java.util.List items) { }
public void addEditorViewForSourceLine(String filePath, int lineNumber) {
}
public void saveContents() throws IOException {
if (filePath != NO_FILE && filePath != "" && editorPane.getText() != "") {
BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
writer.write(editorPane.getText());
writer.flush();
}
}
public JPanel getPanel() {
return editor_panel;
}
public void showSourceForFile(String filePath) { }
public void showSourceForLine(int lineNumber, boolean highlight) { }
public void showSourceForSourceLine(String filePath, int lineNumber, boolean highlight) { }
public String getCurrSourceFilePath() { return null; }
public void setBreakpointRequest(String filePath, int lineNumber, boolean isDeferred) { }
public void clearBreakpointRequest(String filePath, int lineNumber) { }
private String readFile(String filePath, int lineNumber) {
try {
URL url = ClassLoader.getSystemResource(filePath);
File file = new File(filePath);
if (!file.exists()) {
return "ERROR: file \"" + filePath + "\" does not exist.";
}
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuffer contents = new StringBuffer();
String line = reader.readLine();
int numChars = 0;
int numLines = 0;
while (line != null) {
numLines++;
if (numLines < lineNumber) {
currHighlightStart += line.length()+1;
}
if (numLines == lineNumber) {
currHighlightEnd = currHighlightStart + line.length();
}
contents.append(line);
contents.append('\n');
line = reader.readLine();
}
return contents.toString();
} catch (IOException ioe) {
return "ERROR: could not read file \"" + filePath + "\", make sure that you have mounted /project/aop on X:\\";
}
}
private void jbInit() throws Exception {
editor_panel.setFont(new java.awt.Font("DialogInput", 1, 12));
editor_panel.setLayout(borderLayout1);
editor_panel.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(editorPane, null);
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Stack;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.GlobalStructureView;
import org.aspectj.ajde.ui.GlobalViewProperties;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.AdviceAssociation;
import org.aspectj.asm.InheritanceAssociation;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.ISourceLocation;
/**
* Responsible for displaying and controlling the configuration and output of a
* master and slave structure view.
*
* @author Mik Kersten
*/
public class BrowserViewManager {
private StructureViewPanel browserPanel = null;
private boolean globalMode = true;
private boolean splitViewMode = false;
private IconRegistry icons;
private Stack backHistory = new Stack();
private Stack forwardHistory = new Stack();
private ProgramElementNode currNode = null;
private final GlobalStructureView DECLARATION_VIEW;
private final GlobalStructureView CROSSCUTTING_VIEW;
private final GlobalStructureView INHERITANCE_VIEW;
private final GlobalViewProperties DECLARATION_VIEW_PROPERTIES;
private final GlobalViewProperties CROSSCUTTING_VIEW_PROPERTIES;
private final GlobalViewProperties INHERITANCE_VIEW_PROPERTIES;
public BrowserViewManager() {
java.util.List views = new ArrayList();
views.add(DECLARATION_VIEW);
views.add(CROSSCUTTING_VIEW);
views.add(INHERITANCE_VIEW);
browserPanel = new StructureViewPanel(views);
}
public StructureViewPanel getBrowserPanel() {
return browserPanel;
}
public void showSourcesNodes(java.util.List nodes) {
for (Iterator it = nodes.iterator(); it.hasNext(); ) {
ProgramElementNode currNode = null;
StructureNode structureNode = (StructureNode)it.next();
if (structureNode instanceof LinkNode) {
currNode = ((LinkNode)structureNode).getProgramElementNode();
} else {
currNode = (ProgramElementNode)structureNode;
}
ISourceLocation sourceLoc = currNode.getSourceLocation();
if (null != sourceLoc) {
Ajde.getDefault().getEditorManager().addViewForSourceLine(
sourceLoc.getSourceFile().getAbsolutePath(),
sourceLoc.getLine());
}
}
}
public void extractAndInsertSignatures(java.util.List signatures, boolean calls) {
PointcutWizard pointcutWizard = new PointcutWizard(signatures);
pointcutWizard.setVisible(true);
pointcutWizard.setLocation(AjdeUIManager.getDefault().getRootFrame().getX()+100, AjdeUIManager.getDefault().getRootFrame().getY()+100);
}
{
DECLARATION_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.DECLARATION);
CROSSCUTTING_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.CROSSCUTTING);
INHERITANCE_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_CALL_SITE_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.HANDLER_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.INITIALIZER_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.FIELD_ACCESS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.IMPLEMENTS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_MEMBERS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_RELATION);
DECLARATION_VIEW_PROPERTIES.setRelations(Ajde.getDefault().getStructureViewManager().getAvailableRelations());
CROSSCUTTING_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(CROSSCUTTING_VIEW_PROPERTIES);
INHERITANCE_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(INHERITANCE_VIEW_PROPERTIES);
DECLARATION_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(DECLARATION_VIEW_PROPERTIES);
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
class BrowserViewTreeListener implements TreeSelectionListener, MouseListener {
private StructureTree tree = null;
public BrowserViewTreeListener(StructureTree tree) {
this.tree = tree;
}
public void valueChanged(TreeSelectionEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseClicked(MouseEvent e) {
singleClickNavigation(e);
//doubleClickNavigation(e);
maybeShowPopup(e);
}
public void singleClickNavigation(MouseEvent e) {
SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
if (treeNode != null && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) {
StructureNode currNode = (StructureNode)treeNode.getUserObject();
if (currNode instanceof ProgramElementNode && !e.isControlDown()
&& !e.isShiftDown() && e.getModifiers() != 4) {
//AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((ProgramElementNode)currNode);
//if (AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) {
// AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView((ProgramElementNode)currNode);
//}
} else if (currNode instanceof LinkNode) {
//if (!AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) {
// AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((LinkNode)currNode);
//} else {
// AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode());
//}
}
}
}
public void doubleClickNavigation(MouseEvent e) {
int clickCount = e.getClickCount();
SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
if (treeNode != null) {
StructureNode currNode = (StructureNode)treeNode.getUserObject();
if (currNode instanceof ProgramElementNode && !e.isControlDown() && !e.isShiftDown()
&& e.getModifiers() != 4) {
//AjdeUIManager.getDefault().getViewManager().showNodeInMasterView(((LinkNode)currNode).getProgramElementNode());
//AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode());
} else if (currNode instanceof LinkNode) {
if (clickCount == 1) {
//AjdeUIManager.getDefault().getViewManager().showLink((LinkNode)currNode);
} else if (clickCount == 2) {
//navigationAction((ProgramElementNode)((LinkNode)currNode).getProgramElementNode(), true, true);
}
}
}
}
/**
* @todo this should probably use <CODE>e.isPopupTrigger()</CODE> but that
* doesn't work for some reason, so we just check if the right mouse button
* has been clicked.
*/
private void maybeShowPopup(MouseEvent e) {
if (e.getModifiers() == InputEvent.BUTTON3_MASK && tree.getSelectionCount() > 0) {
TreePath[] selectionPaths = tree.getSelectionPaths();
final List signatures = new ArrayList();
for (int i = 0; i < selectionPaths.length; i++) {
StructureNode currNode = (StructureNode)((SwingTreeViewNode)selectionPaths[i].getLastPathComponent()).getUserObject();
if (currNode instanceof LinkNode || currNode instanceof ProgramElementNode) {
signatures.add(currNode);
}
}
JPopupMenu popup = new JPopupMenu();
JMenuItem showSourcesItem = new JMenuItem("Display sources", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.CODE));
showSourcesItem.setFont(new java.awt.Font("Dialog", 0, 11));
showSourcesItem.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//AjdeUIManager.getDefault().getViewManager().showSourcesNodes(signatures);
}
});
popup.add(showSourcesItem);
popup.addSeparator();
JMenuItem generatePCD = new JMenuItem("Pointcut Wizard (alpha)...", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT));
generatePCD.setFont(new java.awt.Font("Dialog", 0, 11));
generatePCD.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AjdeUIManager.getDefault().getViewManager().extractAndInsertSignatures(signatures, true);
}
});
popup.add(generatePCD);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.EditorManager;
import org.aspectj.asm.ProgramElementNode;
public class BuildConfigPopupMenu extends JPopupMenu {
public BuildConfigPopupMenu(final AbstractAction action) {
java.util.List configFiles = Ajde.getDefault().getProjectProperties().getBuildConfigFiles();
for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
final String buildConfig = (String)it.next();
JMenuItem buildItem = new JMenuItem(buildConfig);
buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
buildItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(buildConfig);
if (EditorManager.isShiftDown(e.getModifiers())) {
Ajde.getDefault().getBuildManager().buildFresh();
} else {
Ajde.getDefault().getBuildManager().build();
}
action.actionPerformed(e);
}
});
buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.FILE_LST).getIconResource());
this.add(buildItem);
}
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.GlobalViewProperties;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.InheritanceAssociation;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
class PointcutWizard extends JFrame {
private BrowserViewPanel typeTreeView = null;
private java.util.List signatures = null;
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel4 = new JPanel();
JLabel jLabel1 = new JLabel();
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
JLabel jLabel4 = new JLabel();
JPanel jPanel3 = new JPanel();
JCheckBox jCheckBox5 = new JCheckBox();
JCheckBox jCheckBox4 = new JCheckBox();
JCheckBox jCheckBox3 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
JCheckBox jCheckBox1 = new JCheckBox();
JButton cancel_button = new JButton();
JButton ok_button = new JButton();
JPanel jPanel5 = new JPanel();
public PointcutWizard(java.util.List signatures) {
this.signatures = signatures;
ArrayList views = new ArrayList();
views.add(StructureViewProperties.Hierarchy.INHERITANCE);
typeTreeView = new BrowserViewPanel(AjdeUIManager.getDefault().getIconRegistry(), views, StructureViewProperties.Hierarchy.INHERITANCE);
typeTreeView.updateTree(Ajde.getDefault().getEditorManager().getCurrFile());
try {
jbInit();
}
catch(Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
this.setSize(400, 400);
this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)).getImage());
}
private Map getViewProperties() {
Map views = new HashMap();
GlobalViewProperties INHERITANCE_VIEW = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE);
INHERITANCE_VIEW.addRelation(InheritanceAssociation.INHERITS_RELATION);
views.put(INHERITANCE_VIEW.toString(), INHERITANCE_VIEW);
return views;
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel1.setText("Generate pointcut designator for corresponding joinpoints:");
jPanel1.setLayout(borderLayout1);
jPanel4.setLayout(borderLayout2);
jPanel2.setLayout(borderLayout3);
jLabel4.setText("Select the target type that will host the generated pointcut:");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel4.setToolTipText("");
jPanel3.setMaximumSize(new Dimension(32767, 34));
jCheckBox5.setEnabled(false);
jCheckBox5.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox5.setSelected(true);
jCheckBox5.setText("call");
jCheckBox4.setEnabled(false);
jCheckBox4.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox4.setText("execution");
jCheckBox3.setEnabled(false);
jCheckBox3.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox3.setText("initialization");
jCheckBox2.setEnabled(false);
jCheckBox2.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox2.setText("static initialization");
jCheckBox1.setEnabled(false);
jCheckBox1.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox1.setText("field get/set");
cancel_button.setFont(new java.awt.Font("Dialog", 0, 11));
cancel_button.setText("Cancel");
cancel_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancel_button_actionPerformed(e);
}
});
ok_button.setText("OK");
ok_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
ok_button_actionPerformed(e);
}
});
ok_button.setFont(new java.awt.Font("Dialog", 0, 11));
this.setTitle("Pointcut Wizard");
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jPanel4, BorderLayout.NORTH);
jPanel4.add(jLabel1, BorderLayout.NORTH);
jPanel4.add(jPanel3, BorderLayout.CENTER);
jPanel3.add(jCheckBox5, null);
jPanel3.add(jCheckBox4, null);
jPanel3.add(jCheckBox3, null);
jPanel3.add(jCheckBox2, null);
jPanel3.add(jCheckBox1, null);
jPanel1.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jLabel4, BorderLayout.NORTH);
jPanel2.add(typeTreeView, BorderLayout.CENTER);
jPanel1.add(jPanel5, BorderLayout.SOUTH);
jPanel5.add(ok_button, null);
jPanel5.add(cancel_button, null);
}
private void ok_button_actionPerformed(ActionEvent e) {
Ajde.getDefault().getEditorManager().pasteToCaretPos(generatePcd());
this.dispose();
}
private void cancel_button_actionPerformed(ActionEvent e) {
this.dispose();
}
private String generatePcd() {
String pcd = "\n\n" +
" pointcut temp(): \n";
for (Iterator it = signatures.iterator(); it.hasNext(); ) {
pcd += " call(* " + it.next() + ")";
if (it.hasNext()) {
pcd += " ||";
} else {
pcd += ";";
}
pcd += "\n";
}
return pcd;
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.FileStructureView;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewNode;
import org.aspectj.ajde.ui.StructureViewRenderer;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureNode;
/**
* Represents the configuration of a structure view of the system, rendered
* by the <CODE>StructureTreeManager</CODE>.
*
* @author Mik Kersten
*/
public class StructureViewPanel extends JPanel implements StructureViewRenderer {
protected StructureTreeManager treeManager = new StructureTreeManager();
protected StructureView currentView = null;
private java.util.List structureViews = null;
protected Border border1;
protected Border border2;
JScrollPane tree_ScrollPane = new JScrollPane();
JPanel structureToolBar_panel = null;
BorderLayout borderLayout1 = new BorderLayout();
public StructureViewPanel(FileStructureView structureView) {
currentView = structureView;
initView(structureView);
structureToolBar_panel = new SimpleStructureViewToolPanel(currentView);
init();
}
public StructureViewPanel(java.util.List structureViews) {
this.structureViews = structureViews;
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
initView((StructureView)it.next());
}
currentView = (StructureView)structureViews.get(0);
structureToolBar_panel = new BrowserStructureViewToolPanel(structureViews, currentView, this);
init();
}
private void init() {
try {
jbInit();
} catch (Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize view panel.", e);
}
updateView(currentView);
}
public void setCurrentView(StructureView view) {
currentView = view;
treeManager.updateTree(view);
}
public void updateView(StructureView structureView) {
if (structureView == currentView) {
treeManager.updateTree(structureView);
}
}
private void initView(StructureView view) {
view.setRenderer(this);
}
public void setActiveNode(StructureViewNode node) {
setActiveNode(node, 0);
}
public void setActiveNode(StructureViewNode node, int lineOffset) {
if (node == null) return;
if (!(node.getStructureNode() instanceof ProgramElementNode)) return;
ProgramElementNode pNode = (ProgramElementNode)node.getStructureNode();
treeManager.highlightNode(pNode);
if (pNode.getSourceLocation() != null) {
Ajde.getDefault().getEditorManager().showSourceLine(
pNode.getSourceLocation().getSourceFile().getAbsolutePath(),
pNode.getSourceLocation().getLine() + lineOffset,
true
);
}
}
public void highlightActiveNode() {
if (currentView.getActiveNode() == null) return;
StructureNode node = currentView.getActiveNode().getStructureNode();
if (node instanceof ProgramElementNode) {
treeManager.highlightNode((ProgramElementNode)node);
}
}
protected void jbInit() {
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(156, 156, 158),new Color(109, 109, 110));
border2 = BorderFactory.createEmptyBorder(0,1,0,0);
this.setLayout(borderLayout1);
this.add(tree_ScrollPane, BorderLayout.CENTER);
this.add(structureToolBar_panel, BorderLayout.NORTH);
tree_ScrollPane.getViewport().add(treeManager.getStructureTree(), null);
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/testsrc/AjdeModuleTests.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
// default package
import junit.framework.*;
public class AjdeModuleTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AjdeModuleTests.class.getName());
suite.addTest(org.aspectj.ajde.AjdeTests.suite());
suite.addTest(org.aspectj.ajde.internal.AjdeInternalTests.suite());
suite.addTest(org.aspectj.ajde.ui.AjdeUiTests.suite());
return suite;
}
public AjdeModuleTests(String name) { super(name); }
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java
|
/* *******************************************************************
* Copyright (c) 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* AMC 2003 initial version
* ******************************************************************/
package org.aspectj.ajde;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/**
* @author colyer
*
* To change this generated comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class CompilerMessagesTest extends AjdeTestCase {
private final String CONFIG_FILE_PATH = "../examples/declare-warning/all.lst";
/**
* Constructor for CompilerMessagesTest.
* @param name
*/
public CompilerMessagesTest(String name) {
super(name);
}
public void testMessages() {
// bug 33474
// The build has happened, what messages did the compiler give, and do they
// contain the information we expect?
List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
if (2 != msgs.size()) {
assertTrue("not two messages: " + msgs, false);
}
assertEquals("Two warning messages should be produced",2,msgs.size());
NullIdeTaskListManager.SourceLineTask task =
(NullIdeTaskListManager.SourceLineTask) msgs.get(0);
assertEquals( 8, task.location.getLine());
assertEquals( "Please don't call init methods", task.message);
try {
String fullyQualifiedFile = task.location.getSourceFile().getCanonicalPath();
// this name has a tester specific prefix, followed by the location of the file.
// we can validate the ending.
fullyQualifiedFile = fullyQualifiedFile.replace('\\','/'); // ignore platform differences in slashes
assertTrue( "Fully-qualified source file location returned",
fullyQualifiedFile.endsWith("testdata/examples/declare-warning/apackage/SomeClass.java"));
} catch (IOException ex) {
assertTrue( "Unable to convert source file location: " + task.location.getSourceFile(), false);
}
}
public void testDeclareMessageContents() {
List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
assertEquals( "Please don't call setters" , ((NullIdeTaskListManager.SourceLineTask) msgs.get(1)).message);
}
/*
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp("examples");
doSynchronousBuild(CONFIG_FILE_PATH);
}
/*
* @see AjdeTestCase#tearDown()
*/
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java
| |
40,771
|
Bug 40771 ajde apis are unnecessariy coupled to swing
|
The AJDE APIs are coupled to javax.swing by org.aspectj.ajde.EditorManager. The EditorManager needs to be refactored, have swing specific parts moved to org.aspectj.ajde.ui.swing and org.aspectj.ajbrowser.
|
resolved fixed
|
bbd832b
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-25T15:07:57Z
| 2003-07-25T13:33:20Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* AMC 03.27.2003 changed to allow access to NullIdeManager
* as a singleton - needed for verifying
* compiler warning and error messages.
* ******************************************************************/
package org.aspectj.ajde;
import java.util.List;
import javax.swing.JFrame;
import org.aspectj.ajde.ui.IdeUIAdapter;
import org.aspectj.ajde.ui.UserPreferencesAdapter;
import org.aspectj.ajde.ui.internal.UserPreferencesStore;
import org.aspectj.ajde.ui.swing.*;
/**
* @author Mik Kersten
*/
public class NullIdeManager {
private static NullIdeManager ideManager = null;
private NullIdeTaskListManager taskListManager = null;
public static NullIdeManager getIdeManager() {
if ( null == ideManager ) {
ideManager = new NullIdeManager();
}
return ideManager;
}
public void init(String testProjectPath) {
try {
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false);
ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath);
taskListManager = new NullIdeTaskListManager();
BasicEditor ajdeEditor = new BasicEditor();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
JFrame nullFrame = new JFrame();
//configurationManager.setConfigFiles(getConfigFilesList(configFiles));
AjdeUIManager.getDefault().init(
ajdeEditor,
taskListManager,
browserProjectProperties,
preferencesAdapter,
uiAdapter,
new IconRegistry(),
nullFrame,
true);
//Ajde.getDefault().enableLogging( System.out );
} catch (Throwable t) {
t.printStackTrace();
Ajde.getDefault().getErrorHandler().handleError(
"Null IDE failed to initialize.",
t);
}
}
public List getCompilationSourceLineTasks() {
return taskListManager.getSourceLineTasks();
}
}
|
39,842
|
Bug 39842 allow use of an environment variable to set compiler arguments
|
I'm trying to create a special jsp compilation servlet in Tomcat 4.x that uses the aspectj compiler. I can plug in the compiler adapter, but I don't have control of the ant code they use to invoke the compiler, so I'd like to use an environment variable to do this (apparently the only mechanism they do support). I'm doing this so I can pass an aspectpath in to weave aspects into the compiled jsp servlet.
|
resolved fixed
|
2502ee5
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-26T04:13:54Z
| 2003-07-09T22:33:20Z
|
taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
|
/* *******************************************************************
* Copyright (c) 2001-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC)
* 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.tools.ant.taskdefs;
import java.io.*;
import java.util.*;
import org.apache.tools.ant.*;
import org.apache.tools.ant.taskdefs.*;
import org.apache.tools.ant.types.*;
import org.aspectj.bridge.*;
import org.aspectj.tools.ajc.Main;
import org.aspectj.tools.ajc.Main.MessagePrinter;
import org.aspectj.util.*;
/**
* This runs the AspectJ 1.1 compiler,
* supporting all the command-line options.
* It can also complete the output in
* the destination directory or output jar
* by copying non-.class files from all input jars
* or copying resources from source root directories.
* When copying anything to the output jar,
* this will pass the AspectJ
* compiler a path to a different temporary output jar file,
* the contents of which will be copied along with any
* resources to the actual output jar.
* When not forking, things will be copied as needed
* for each iterative compile,
* but when forking things are only copied at the
* completion of a successful compile.
* <p>
* See the development environment guide for
* usage documentation.
*
* @since AspectJ 1.1, Ant 1.5
*/
public class AjcTask extends MatchingTask {
/*
* This task mainly converts ant specification for ajc,
* verbosely ignoring improper input.
* It also has some special features for non-obvious clients:
* (1) Javac compiler adapter supported in
* <code>setupAjc(AjcTask, Javac, File)</code>
* and
* <code>readArguments(String[])</code>;
* (2) testing is supported by
* (a) permitting the same specification to be re-run
* with added flags (settings once made cannot be
* removed); and
* (b) permitting recycling the task with
* <code>reset()</code> (untested).
*
* The parts that do more than convert ant specs are
* (a) code for forking;
* (b) code for copying resources.
*
* If you maintain/upgrade this task, keep in mind:
* (1) changes to the semantics of ajc (new options, new
* values permitted, etc.) will have to be reflected here.
* (2) the clients:
* the iajc ant script, Javac compiler adapter,
* maven clients of iajc, and testing code.
*/
// XXX move static methods after static initializer
/**
* This method extracts javac arguments to ajc,
* and add arguments to make ajc behave more like javac
* in copying resources.
* <p>
* Pass ajc-specific options using compilerarg sub-element:
* <pre>
* <javac srcdir="src">
* <compilerarg compiler="..." line="-argfile src/args.lst"/>
* <javac>
* </pre>
* Some javac arguments are not supported in this component (yet):
* <pre>
* String memoryInitialSize;
* boolean includeAntRuntime = true;
* boolean includeJavaRuntime = false;
* </pre>
* Other javac arguments are not supported in ajc 1.1:
* <pre>
* boolean optimize;
* String forkedExecutable;
* FacadeTaskHelper facade;
* boolean depend;
* String debugLevel;
* Path compileSourcepath;
* </pre>
* @param javac the Javac command to implement (not null)
* @param ajc the AjcTask to adapt (not null)
* @param destDir the File class destination directory (may be null)
* @return null if no error, or String error otherwise
*/
public static String setupAjc(AjcTask ajc, Javac javac, File destDir) {
if (null == ajc) {
return "null ajc";
} else if (null == javac) {
return "null javac";
} else if (null == destDir) {
destDir = javac.getDestdir();
if (null == destDir) {
destDir = new File(".");
}
}
// no null checks b/c AjcTask handles null input gracefully
ajc.setProject(javac.getProject());
ajc.setLocation(javac.getLocation());
ajc.setTaskName("javac-iajc");
ajc.setDebug(javac.getDebug());
ajc.setDeprecation(javac.getDeprecation());
ajc.setFailonerror(javac.getFailonerror());
final boolean fork = javac.isForkedJavac();
ajc.setFork(fork);
if (fork) {
ajc.setMaxmem(javac.getMemoryMaximumSize());
}
ajc.setNowarn(javac.getNowarn());
ajc.setListFileArgs(javac.getListfiles());
ajc.setVerbose(javac.getVerbose());
ajc.setTarget(javac.getTarget());
ajc.setSource(javac.getSource());
ajc.setEncoding(javac.getEncoding());
ajc.setDestdir(destDir);
ajc.setBootclasspath(javac.getBootclasspath());
ajc.setExtdirs(javac.getExtdirs());
ajc.setClasspath(javac.getClasspath());
// ignore srcDir -- all files picked up in recalculated file list
// ajc.setSrcDir(javac.getSrcdir());
ajc.addFiles(javac.getFileList());
// mimic javac's behavior in copying resources,
ajc.setSourceRootCopyFilter("**/CVS/*,**/*.java,**/*.aj");
// arguments can override the filter, add to paths, override options
ajc.readArguments(javac.getCurrentCompilerArgs());
return null;
}
/**
* Find aspectjtools.jar on the task or system classpath.
* Accept <code>aspectj{-}tools{...}.jar</code>
* mainly to support build systems using maven-style
* re-naming
* (e.g., <code>aspectj-tools-1.1.0.jar</code>.
* Note that we search the task classpath first,
* though an entry on the system classpath would be loaded first,
* because it seems more correct as the more specific one.
* @return readable File for aspectjtools.jar, or null if not found.
*/
public static File findAspectjtoolsJar() {
File result = null;
ClassLoader loader = AjcTask.class.getClassLoader();
if (loader instanceof AntClassLoader) {
AntClassLoader taskLoader = (AntClassLoader) loader;
String cp = taskLoader.getClasspath();
String[] cps = LangUtil.splitClasspath(cp);
for (int i = 0; (i < cps.length) && (null == result); i++) {
result = isAspectjtoolsjar(cps[i]);
}
}
if (null == result) {
final Path classpath = Path.systemClasspath;
final String[] paths = classpath.list();
for (int i = 0; (i < paths.length) && (null == result); i++) {
result = isAspectjtoolsjar(paths[i]);
}
}
return (null == result? null : result.getAbsoluteFile());
}
/** @return File if readable jar with aspectj tools name, or null */
private static File isAspectjtoolsjar(String path) {
if (null == path) {
return null;
}
final String prefix = "aspectj";
final String infix = "tools";
final String altInfix = "-tools";
final String suffix = ".jar";
final int prefixLength = 7; // prefix.length();
final int minLength = 16;
// prefixLength + infix.length() + suffix.length();
if (!path.endsWith(suffix)) {
return null;
}
int loc = path.lastIndexOf(prefix);
if ((-1 != loc) && ((loc + minLength) <= path.length())) {
String rest = path.substring(loc+prefixLength);
if (-1 != rest.indexOf(File.pathSeparator)) {
return null;
}
if (rest.startsWith(infix)
|| rest.startsWith(altInfix)) {
File result = new File(path);
if (result.canRead() && result.isFile()) {
return result;
}
}
}
return null;
}
/**
* Maximum length (in chars) of command line
* before converting to an argfile when forking
*/
private static final int MAX_COMMANDLINE = 4096;
private static final File DEFAULT_DESTDIR = new File(".");
/** do not throw BuildException on fail/abort message with usage */
private static final String USAGE_SUBSTRING = "AspectJ-specific options";
/** valid -X[...] options other than -Xlint variants */
private static final List VALID_XOPTIONS;
/** valid warning (-warn:[...]) variants */
private static final List VALID_WARNINGS;
/** valid debugging (-g:[...]) variants */
private static final List VALID_DEBUG;
/**
* -Xlint variants (error, warning, ignore)
* @see org.aspectj.weaver.Lint
*/
private static final List VALID_XLINT;
static {
String[] xs = new String[]
{ "serializableAspects", "incrementalFile"
//, "targetNearSource", "OcodeSize",
};
VALID_XOPTIONS = Collections.unmodifiableList(Arrays.asList(xs));
xs = new String[]
{"constructorName", "packageDefaultMethod", "deprecation",
"maskedCatchBlocks", "unusedLocals", "unusedArguments",
"unusedImports", "syntheticAccess", "assertIdentifier", "none" };
VALID_WARNINGS = Collections.unmodifiableList(Arrays.asList(xs));
xs = new String[] {"none", "lines", "vars", "source" };
VALID_DEBUG = Collections.unmodifiableList(Arrays.asList(xs));
xs = new String[] { "error", "warning", "ignore"};
VALID_XLINT = Collections.unmodifiableList(Arrays.asList(xs));
}
// ---------------------------- state and Ant interface thereto
private boolean verbose;
private boolean listFileArgs;
private boolean failonerror;
private boolean fork;
private String maxMem;
// ------- single entries dumped into cmd
protected GuardedCommand cmd;
// ------- lists resolved in addListArgs() at execute() time
private Path srcdir;
private Path injars;
private Path classpath;
private Path bootclasspath;
private Path forkclasspath;
private Path extdirs;
private Path aspectpath;
private Path argfiles;
private List ignored;
private Path sourceRoots;
// ----- added by adapter - integrate better?
private List /* File */ adapterFiles;
private String[] adapterArguments;
private IMessageHolder messageHolder;
// -------- resource-copying
/** true if copying injar non-.class files to the output jar */
private boolean copyInjars;
/** non-null if copying all source root files but the filtered ones */
private String sourceRootCopyFilter;
/** directory sink for classes */
private File destDir;
/** zip file sink for classes */
private File outjar;
/** track whether we've supplied any temp outjar */
private boolean outjarFixedup;
/**
* When possibly copying resources to the output jar,
* pass ajc a fake output jar to copy from,
* so we don't change the modification time of the output jar
* when copying injars into the actual outjar.
*/
private File tmpOutjar;
private boolean executing;
/** non-null only while executing in same vm */
private Main main;
/** true only when executing in other vm */
private boolean executingInOtherVM;
/** true if -incremental */
private boolean inIncrementalMode;
/** true if -XincrementalFile (i.e, setTagFile)*/
private boolean inIncrementalFileMode;
// also note MatchingTask grabs source files...
public AjcTask() {
reset();
}
/** to use this same Task more than once (testing) */
public void reset() { // XXX possible to reset MatchingTask?
// need declare for "all fields initialized in ..."
adapterArguments = null;
adapterFiles = new ArrayList();
argfiles = null;
executing = false;
aspectpath = null;
bootclasspath = null;
classpath = null;
cmd = new GuardedCommand();
copyInjars = false;
destDir = DEFAULT_DESTDIR;
executing = false;
executingInOtherVM = false;
extdirs = null;
failonerror = true; // non-standard default
forkclasspath = null;
inIncrementalMode = false;
inIncrementalFileMode = false;
ignored = new ArrayList();
injars = null;
listFileArgs = false;
maxMem = null;
messageHolder = null;
outjar = null;
sourceRootCopyFilter = null;
sourceRoots = null;
srcdir = null;
tmpOutjar = null;
verbose = false;
}
protected void ignore(String ignored) {
this.ignored.add(ignored + " at " + getLocation());
}
//---------------------- option values
// used by entries with internal commas
protected String validCommaList(String list, List valid, String label) {
return validCommaList(list, valid, label, valid.size());
}
protected String validCommaList(String list, List valid, String label, int max) {
StringBuffer result = new StringBuffer();
StringTokenizer st = new StringTokenizer(list, ",");
int num = 0;
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
num++;
if (num > max) {
ignore("too many entries for -"
+ label
+ ": "
+ token);
break;
}
if (!valid.contains(token)) {
ignore("bad commaList entry for -"
+ label
+ ": "
+ token);
} else {
if (0 < result.length()) {
result.append(",");
}
result.append(token);
}
}
return (0 == result.length() ? null : result.toString());
}
public void setIncremental(boolean incremental) {
cmd.addFlag("-incremental", incremental);
inIncrementalMode = incremental;
}
public void setHelp(boolean help) {
cmd.addFlag("-help", help);
}
public void setVersion(boolean version) {
cmd.addFlag("-version", version);
}
public void setXNoweave(boolean noweave) {
cmd.addFlag("-XnoWeave", noweave);
}
public void setNowarn(boolean nowarn) {
cmd.addFlag("-nowarn", nowarn);
}
public void setDeprecation(boolean deprecation) {
cmd.addFlag("-deprecation", deprecation);
}
public void setWarn(String warnings) {
warnings = validCommaList(warnings, VALID_WARNINGS, "warn");
cmd.addFlag("-warn:" + warnings, (null != warnings));
}
public void setDebug(boolean debug) {
cmd.addFlag("-g", debug);
}
public void setDebugLevel(String level) {
level = validCommaList(level, VALID_DEBUG, "g");
cmd.addFlag("-g:" + level, (null != level));
}
public void setEmacssym(boolean emacssym) {
cmd.addFlag("-emacssym", emacssym);
}
/**
* -Xlint - set default level of -Xlint messages to warning
* (same as </code>-Xlint:warning</code>)
*/
public void setXlintwarnings(boolean xlintwarnings) {
cmd.addFlag("-Xlint", xlintwarnings);
}
/** -Xlint:{error|warning|info} - set default level for -Xlint messages
* @param xlint the String with one of error, warning, ignored
*/
public void setXlint(String xlint) {
xlint = validCommaList(xlint, VALID_XLINT, "Xlint", 1);
cmd.addFlag("-Xlint:" + xlint, (null != xlint));
}
/**
* -Xlintfile {lint.properties} - enable or disable specific forms
* of -Xlint messages based on a lint properties file
* (default is
* <code>org/aspectj/weaver/XLintDefault.properties</code>)
* @param xlintFile the File with lint properties
*/
public void setXlintfile(File xlintFile) {
cmd.addFlagged("-Xlintfile", xlintFile.getAbsolutePath());
}
public void setPreserveAllLocals(boolean preserveAllLocals) {
cmd.addFlag("-preserveAllLocals", preserveAllLocals);
}
public void setNoImportError(boolean noImportError) {
cmd.addFlag("-noImportError", noImportError);
}
public void setEncoding(String encoding) {
cmd.addFlagged("-encoding", encoding);
}
public void setLog(File file) {
cmd.addFlagged("-log", file.getAbsolutePath());
}
public void setProceedOnError(boolean proceedOnError) {
cmd.addFlag("-proceedOnError", proceedOnError);
}
public void setVerbose(boolean verbose) {
cmd.addFlag("-verbose", verbose);
this.verbose = verbose;
}
public void setListFileArgs(boolean listFileArgs) {
this.listFileArgs = listFileArgs;
}
public void setReferenceInfo(boolean referenceInfo) {
cmd.addFlag("-referenceInfo", referenceInfo);
}
public void setProgress(boolean progress) {
cmd.addFlag("-progress", progress);
}
public void setTime(boolean time) {
cmd.addFlag("-time", time);
}
public void setNoExit(boolean noExit) {
cmd.addFlag("-noExit", noExit);
}
public void setFailonerror(boolean failonerror) {
this.failonerror = failonerror;
}
public void setFork(boolean fork) {
this.fork = fork;
}
public void setMaxmem(String maxMem) {
this.maxMem = maxMem;
}
// ----------------
public void setTagFile(File file) {
inIncrementalMode = true;
cmd.addFlagged(Main.CommandController.TAG_FILE_OPTION,
file.getAbsolutePath());
inIncrementalFileMode = true;
}
public void setOutjar(File file) {
if (DEFAULT_DESTDIR != destDir) {
String e = "specifying both output jar ("
+ file
+ ") and destination dir ("
+ destDir
+ ")";
throw new BuildException(e);
}
outjar = file;
outjarFixedup = false;
tmpOutjar = null;
}
public void setDestdir(File dir) {
if (null != outjar) {
String e = "specifying both output jar ("
+ outjar
+ ") and destination dir ("
+ dir
+ ")";
throw new BuildException(e);
}
cmd.addFlagged("-d", dir.getAbsolutePath());
destDir = dir;
}
public void setTarget(String either11or12) {
if ("1.1".equals(either11or12)) {
cmd.addFlagged("-target", "1.1");
} else if ("1.2".equals(either11or12)) {
cmd.addFlagged("-target", "1.2");
} else if (null != either11or12){
ignore("-target " + either11or12);
}
}
/**
* Language compliance level.
* If not set explicitly, eclipse default holds.
* @param either13or14 either "1.3" or "1.4"
*/
public void setCompliance(String either13or14) {
if ("1.3".equals(either13or14)) {
cmd.addFlag("-1.3", true);
} else if ("1.4".equals(either13or14)) {
cmd.addFlag("-1.4", true);
// } else if ("1.5".equals(either13or14)) {
// cmd.addFlag("-1.5", true);
} else if (null != either13or14) {
ignore(either13or14 + "[compliance]");
}
}
/**
* Source compliance level.
* If not set explicitly, eclipse default holds.
* @param either13or14 either "1.3" or "1.4"
*/
public void setSource(String either13or14) {
if ("1.3".equals(either13or14)) {
cmd.addFlagged("-source", "1.3");
} else if ("1.4".equals(either13or14)) {
cmd.addFlagged("-source", "1.4");
} else if (null != either13or14) {
ignore("-source " + either13or14);
}
}
/**
* Flag to copy all non-.class contents of injars
* to outjar after compile completes.
* Requires both injars and outjar.
* @param doCopy
*/
public void setCopyInjars(boolean doCopy){
this.copyInjars = doCopy;
}
/**
* Option to copy all files from
* all source root directories
* except those specified here.
* If this is specified and sourceroots are specified,
* then this will copy all files except
* those specified in the filter pattern.
* Requires sourceroots.
*
* @param filter a String acceptable as an excludes
* filter for an Ant Zip fileset.
*/
public void setSourceRootCopyFilter(String filter){
this.sourceRootCopyFilter = filter;
}
public void setX(String input) { // ajc-only eajc-also docDone
StringTokenizer tokens = new StringTokenizer(input, ",", false);
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
if (1 < token.length()) {
if (VALID_XOPTIONS.contains(token)) {
cmd.addFlag("-X" + token, true);
} else {
ignore("-X" + token);
}
}
}
}
/** direct API for testing */
public void setMessageHolder(IMessageHolder holder) {
this.messageHolder = holder;
}
/**
* Setup custom message handling.
* @param className the String fully-qualified-name of a class
* reachable from this object's class loader,
* implementing IMessageHolder, and
* having a public no-argument constructor.
* @throws BuildException if unable to create instance of className
*/
public void setMessageHolderClass(String className) {
try {
Class mclass = Class.forName(className);
IMessageHolder holder = (IMessageHolder) mclass.newInstance();
setMessageHolder(holder);
} catch (Throwable t) {
String m = "unable to instantiate message holder: " + className;
throw new BuildException(m, t);
}
}
//---------------------- Path lists
/**
* Add path elements to source path and return result.
* Elements are added even if they do not exist.
* @param source the Path to add to - may be null
* @param toAdd the Path to add - may be null
* @return the (never-null) Path that results
*/
protected Path incPath(Path source, Path toAdd) {
if (null == source) {
source = new Path(project);
}
if (null != toAdd) {
source.append(toAdd);
}
return source;
}
public void setSourcerootsref(Reference ref) {
createSourceRoots().setRefid(ref);
}
public void setSourceRoots(Path roots) {
sourceRoots = incPath(sourceRoots, roots);
}
public Path createSourceRoots() {
if (sourceRoots == null) {
sourceRoots = new Path(project);
}
return sourceRoots.createPath();
}
public void setInjarsref(Reference ref) {
createInjars().setRefid(ref);
}
public void setInjars(Path path) {
injars = incPath(injars, path);
}
public Path createInjars() {
if (injars == null) {
injars = new Path(project);
}
return injars.createPath();
}
public void setClasspath(Path path) {
classpath = incPath(classpath, path);
}
public void setClasspathref(Reference classpathref) {
createClasspath().setRefid(classpathref);
}
public Path createClasspath() {
if (classpath == null) {
classpath = new Path(project);
}
return classpath.createPath();
}
public void setBootclasspath(Path path) {
bootclasspath = incPath(bootclasspath, path);
}
public void setBootclasspathref(Reference bootclasspathref) {
createBootclasspath().setRefid(bootclasspathref);
}
public Path createBootclasspath() {
if (bootclasspath == null) {
bootclasspath = new Path(project);
}
return bootclasspath.createPath();
}
public void setForkclasspath(Path path) {
forkclasspath = incPath(forkclasspath, path);
}
public void setForkclasspathref(Reference forkclasspathref) {
createForkclasspath().setRefid(forkclasspathref);
}
public Path createForkclasspath() {
if (forkclasspath == null) {
forkclasspath = new Path(project);
}
return forkclasspath.createPath();
}
public void setExtdirs(Path path) {
extdirs = incPath(extdirs, path);
}
public void setExtdirsref(Reference ref) {
createExtdirs().setRefid(ref);
}
public Path createExtdirs() {
if (extdirs == null) {
extdirs = new Path(project);
}
return extdirs.createPath();
}
public void setAspectpathref(Reference ref) {
createAspectpath().setRefid(ref);
}
public void setAspectpath(Path path) {
aspectpath = incPath(aspectpath, path);
}
public Path createAspectpath() {
if (aspectpath == null) {
aspectpath = new Path(project);
}
return aspectpath.createPath();
}
public void setSrcDir(Path path) {
srcdir = incPath(srcdir, path);
}
public Path createSrc() {
return createSrcdir();
}
public Path createSrcdir() {
if (srcdir == null) {
srcdir = new Path(project);
}
return srcdir.createPath();
}
/** @return true if in incremental mode (command-line or file) */
public boolean isInIncrementalMode() {
return inIncrementalMode;
}
/** @return true if in incremental file mode */
public boolean isInIncrementalFileMode() {
return inIncrementalFileMode;
}
public void setArgfilesref(Reference ref) {
createArgfiles().setRefid(ref);
}
public void setArgfiles(Path path) { // ajc-only eajc-also docDone
argfiles = incPath(argfiles, path);
}
public Path createArgfiles() {
if (argfiles == null) {
argfiles = new Path(project);
}
return argfiles.createPath();
}
// ------------------------------ run
/**
* Compile using ajc per settings.
* @exception BuildException if the compilation has problems
* or if there were compiler errors and failonerror is true.
*/
public void execute() throws BuildException {
if (executing) {
throw new IllegalStateException("already executing");
} else {
executing = true;
}
verifyOptions();
try {
String[] args = makeCommand();
if (verbose || listFileArgs) { // XXX if listFileArgs, only do that
log("ajc " + Arrays.asList(args), Project.MSG_VERBOSE);
}
if (!fork) {
executeInSameVM(args);
} else { // when forking, Adapter handles failonerror
executeInOtherVM(args);
}
} catch (BuildException e) {
throw e;
} catch (Throwable x) {
System.err.println(Main.renderExceptionForUser(x));
throw new BuildException("IGNORE -- See "
+ LangUtil.unqualifiedClassName(x)
+ " rendered to System.err");
} finally {
executing = false;
if (null != tmpOutjar) {
tmpOutjar.delete();
}
}
}
/**
* Halt processing.
* This tells main in the same vm to quit.
* It fails when running in forked mode.
* @return true if not in forked mode
* and main has quit or been told to quit
*/
public boolean quit() {
if (executingInOtherVM) {
return false;
}
Main me = main;
if (null != me) {
me.quit();
}
return true;
}
// package-private for testing
String[] makeCommand() {
ArrayList result = new ArrayList();
if (0 < ignored.size()) {
for (Iterator iter = ignored.iterator(); iter.hasNext();) {
log("ignored: " + iter.next(), Project.MSG_INFO);
}
}
// when copying resources, use temp jar for class output
// then copy temp jar contents and resources to output jar
if ((null != outjar) && !outjarFixedup) {
if (copyInjars || (null != sourceRootCopyFilter)) {
String path = outjar.getAbsolutePath();
int len = FileUtil.zipSuffixLength(path);
if (len < 1) {
log("not copying injars - weird outjar: " + path);
} else {
path = path.substring(0, path.length()-len) + ".tmp.jar";
tmpOutjar = new File(path);
}
}
if (null == tmpOutjar) {
cmd.addFlagged("-outjar", outjar.getAbsolutePath());
} else {
cmd.addFlagged("-outjar", tmpOutjar.getAbsolutePath());
}
outjarFixedup = true;
}
result.addAll(cmd.extractArguments());
addListArgs(result);
return (String[]) result.toArray(new String[0]);
}
/**
* @throw BuildException if options conflict
*/
protected void verifyOptions() {
if (fork && isInIncrementalMode() && !isInIncrementalFileMode()) {
String m = "can fork incremental only using tag file";
throw new BuildException(m);
}
}
/**
* Run the compile in the same VM by
* loading the compiler (Main),
* setting up any message holders,
* doing the compile,
* and converting abort/failure and error messages
* to BuildException, as appropriate.
* @throws BuildException if abort or failure messages
* or if errors and failonerror.
*
*/
protected void executeInSameVM(String[] args) {
if (null != maxMem) {
log("maxMem ignored unless forked: " + maxMem, Project.MSG_WARN);
}
IMessageHolder holder = messageHolder;
int numPreviousErrors;
if (null == holder) {
MessageHandler mhandler = new MessageHandler(true);
final IMessageHandler delegate
= verbose ? MessagePrinter.VERBOSE: MessagePrinter.TERSE;
mhandler.setInterceptor(delegate);
if (!verbose) {
mhandler.ignore(IMessage.INFO);
}
holder = mhandler;
numPreviousErrors = 0;
} else {
numPreviousErrors = holder.numMessages(IMessage.ERROR, true);
}
{
Main newmain = new Main();
newmain.setHolder(holder);
newmain.setCompletionRunner(new Runnable() {
public void run() {
doCompletionTasks();
}
});
if (null != main) {
MessageUtil.fail(holder, "still running prior main");
return;
}
main = newmain;
}
try {
main.runMain(args, false);
} finally {
main = null;
}
if (failonerror) {
int errs = holder.numMessages(IMessage.ERROR, false);
errs -= numPreviousErrors;
if (0 < errs) {
// errors should already be printed by interceptor
throw new BuildException(errs + " errors");
}
}
// Throw BuildException if there are any fail or abort
// messages.
// The BuildException message text has a list of class names
// for the exceptions found in the messages, or the
// number of fail/abort messages found if there were
// no exceptions for any of the fail/abort messages.
// The interceptor message handler should have already
// printed the messages, including any stack traces.
// HACK: this ignores the Usage message
{
IMessage[] fails = holder.getMessages(IMessage.FAIL, true);
if (!LangUtil.isEmpty(fails)) {
StringBuffer sb = new StringBuffer();
String prefix = "fail due to ";
int numThrown = 0;
for (int i = 0; i < fails.length; i++) {
String message = fails[i].getMessage();
if (LangUtil.isEmpty(message)) {
message = "<no message>";
} else if (-1 != message.indexOf(USAGE_SUBSTRING)) {
continue;
}
Throwable t = fails[i].getThrown();
if (null != t) {
numThrown++;
sb.append(prefix);
sb.append(LangUtil.unqualifiedClassName(t.getClass()));
String thrownMessage = t.getMessage();
if (!LangUtil.isEmpty(thrownMessage)) {
sb.append(" \"" + thrownMessage + "\"");
}
}
sb.append("\"" + message + "\"");
prefix = ", ";
}
if (0 < sb.length()) {
sb.append(" (" + numThrown + " exceptions)");
throw new BuildException(sb.toString());
}
}
}
}
/**
* Execute in a separate VM.
* Differences from normal same-VM execution:
* <ul>
* <li>ignores any message holder {class} set</li>
* <li>No resource-copying between interative runs</li>
* <li>failonerror fails when process interface fails
* to return negative values</li>
* </ul>
* @param args String[] of the complete compiler command to execute
*
* @see DefaultCompilerAdapter#executeExternalCompile(String[], int)
* @throws BuildException if ajc aborts (negative value)
* or if failonerror and there were compile errors.
*/
protected void executeInOtherVM(String[] args) {
if (null != messageHolder) {
log("message holder ignored when forking: "
+ messageHolder.getClass().getName(), Project.MSG_WARN);
}
CommandlineJava javaCmd = new CommandlineJava();
javaCmd.setClassname(org.aspectj.tools.ajc.Main.class.getName());
final Path vmClasspath = javaCmd.createClasspath(getProject());
{
File aspectjtools = null;
int vmClasspathSize = vmClasspath.size();
if ((null != forkclasspath)
&& (0 != forkclasspath.size())) {
vmClasspath.addExisting(forkclasspath);
} else {
aspectjtools = findAspectjtoolsJar();
if (null != aspectjtools) {
vmClasspath.createPathElement().setLocation(aspectjtools);
}
}
int newVmClasspathSize = vmClasspath.size();
if (vmClasspathSize == newVmClasspathSize) {
String m = "unable to find aspectjtools to fork - ";
if (null != aspectjtools) {
m += "tried " + aspectjtools.toString();
} else if (null != forkclasspath) {
m += "tried " + forkclasspath.toString();
} else {
m += "define forkclasspath or put aspectjtools on classpath";
}
throw new BuildException(m);
}
}
if (null != maxMem) {
javaCmd.setMaxmemory(maxMem);
}
File tempFile = null;
int numArgs = args.length;
args = GuardedCommand.limitTo(args, MAX_COMMANDLINE, getLocation());
if (args.length != numArgs) {
tempFile = new File(args[1]);
}
try {
String[] javaArgs = javaCmd.getCommandline();
String[] both = new String[javaArgs.length + args.length];
System.arraycopy(javaArgs,0,both,0,javaArgs.length);
System.arraycopy(args,0,both,javaArgs.length,args.length);
// try to use javaw instead on windows
if (both[0].endsWith("java.exe")) {
String path = both[0];
path = path.substring(0, path.length()-4);
path = path + "w.exe";
File javaw = new File(path);
if (javaw.canRead() && javaw.isFile()) {
both[0] = path;
}
}
if (verbose) { // XXX also when ant is verbose...
log("forking " + Arrays.asList(both));
}
int result = execInOtherVM(both);
if (0 > result) {
throw new BuildException("failure[" + result + "] running ajc");
} else if (failonerror && (0 < result)) {
throw new BuildException("compile errors: " + result);
}
// when forking, do completion only at end and when successful
doCompletionTasks();
} finally {
if (null != tempFile) {
tempFile.delete();
}
}
}
/**
* Execute in another process using the same JDK
* and the base directory of the project. XXX correct?
* @param args
* @return
*/
protected int execInOtherVM(String[] args) {
try {
Project project = getProject();
LogStreamHandler handler = new LogStreamHandler(this,
Project.MSG_INFO, Project.MSG_WARN);
Execute exe = new Execute(handler);
exe.setAntRun(project);
exe.setWorkingDirectory(project.getBaseDir());
exe.setCommandline(args);
try {
if (executingInOtherVM) {
String s = "already running in other vm?";
throw new BuildException(s, location);
}
executingInOtherVM = true;
exe.execute();
} finally {
executingInOtherVM = false;
}
return exe.getExitValue();
} catch (IOException e) {
String m = "Error executing command " + Arrays.asList(args);
throw new BuildException(m, e, location);
}
}
// ------------------------------ setup and reporting
/** @return null if path null or empty, String rendition otherwise */
protected static void addFlaggedPath(String flag, Path path, List list) {
if (!LangUtil.isEmpty(flag)
&& ((null != path) && (0 < path.size()))) {
list.add(flag);
list.add(path.toString());
}
}
/**
* Add to list any path or plural arguments.
*/
protected void addListArgs(List list) throws BuildException {
addFlaggedPath("-classpath", classpath, list);
addFlaggedPath("-bootclasspath", bootclasspath, list);
addFlaggedPath("-extdirs", extdirs, list);
addFlaggedPath("-aspectpath", aspectpath, list);
addFlaggedPath("-injars", injars, list);
addFlaggedPath("-sourceroots", sourceRoots, list);
if (argfiles != null) {
String[] files = argfiles.list();
for (int i = 0; i < files.length; i++) {
File argfile = project.resolveFile(files[i]);
if (check(argfile, files[i], false, location)) {
list.add("-argfile");
list.add(argfile.getAbsolutePath());
}
}
}
if (srcdir != null) {
// todo: ignore any srcdir if any argfiles and no explicit includes
String[] dirs = srcdir.list();
for (int i = 0; i < dirs.length; i++) {
File dir = project.resolveFile(dirs[i]);
check(dir, dirs[i], true, location);
// relies on compiler to prune non-source files
String[] files = getDirectoryScanner(dir).getIncludedFiles();
for (int j = 0; j < files.length; j++) {
File file = new File(dir, files[j]);
if (FileUtil.hasSourceSuffix(file)) {
list.add(file.getAbsolutePath());
}
}
}
}
if (0 < adapterFiles.size()) {
for (Iterator iter = adapterFiles.iterator(); iter.hasNext();) {
File file = (File) iter.next();
if (file.canRead() && FileUtil.hasSourceSuffix(file)) {
list.add(file.getAbsolutePath());
} else {
log("skipping file: " + file, Project.MSG_WARN);
}
}
}
}
/**
* Throw BuildException unless file is valid.
* @param file the File to check
* @param name the symbolic name to print on error
* @param isDir if true, verify file is a directory
* @param loc the Location used to create sensible BuildException
* @return
* @throws BuildException unless file valid
*/
protected final boolean check(File file, String name,
boolean isDir, Location loc) {
loc = loc != null ? loc : location;
if (file == null) {
throw new BuildException(name + " is null!", loc);
}
if (!file.exists()) {
throw new BuildException(file + " doesn't exist!", loc);
}
if (isDir ^ file.isDirectory()) {
String e = file + " should" + (isDir ? "" : "n't") +
" be a directory!";
throw new BuildException(e, loc);
}
return true;
}
/**
* Called when compile or incremental compile is completing,
* this completes the output jar or directory
* by copying resources if requested.
* Note: this is a callback run synchronously by the compiler.
* That means exceptions thrown here are caught by Main.run(..)
* and passed to the message handler.
*/
protected void doCompletionTasks() {
if (!executing) {
throw new IllegalStateException("should be executing");
}
if (null != outjar) {
completeOutjar();
} else {
completeDestdir();
}
}
/**
* Complete the destination directory
* by copying resources from the source root directories
* (if the filter is specified)
* and non-.class files from the input jars
* (if XCopyInjars is enabled).
*/
private void completeDestdir() {
if (!copyInjars && (null == sourceRootCopyFilter)) {
return;
} else if (!destDir.canWrite()) {
String s = "unable to copy resources to destDir: " + destDir;
throw new BuildException(s);
}
final Project project = getProject();
if (copyInjars) {
String taskName = getTaskName() + " - unzip";
String[] paths = injars.list();
if (!LangUtil.isEmpty(paths)) {
PatternSet patternSet = new PatternSet();
patternSet.setProject(project);
patternSet.setIncludes("**/*");
patternSet.setExcludes("**/*.class");
for (int i = 0; i < paths.length; i++) {
Expand unzip = new Expand();
unzip.setProject(project);
unzip.setTaskName(taskName);
unzip.setDest(destDir);
unzip.setSrc(new File(paths[i]));
unzip.addPatternset(patternSet);
unzip.execute();
}
}
}
if ((null != sourceRootCopyFilter) && (null != sourceRoots)) {
String[] paths = sourceRoots.list();
if (!LangUtil.isEmpty(paths)) {
Copy copy = new Copy();
copy.setProject(project);
copy.setTodir(destDir);
for (int i = 0; i < paths.length; i++) {
FileSet fileSet = new FileSet();
fileSet.setDir(new File(paths[i]));
fileSet.setIncludes("**/*");
fileSet.setExcludes(sourceRootCopyFilter);
copy.addFileset(fileSet);
}
copy.execute();
}
}
}
/**
* Complete the output jar
* by copying resources from the source root directories
* if the filter is specified.
* and non-.class files from the input jars if enabled.
*/
private void completeOutjar() {
if (((null == tmpOutjar) || !tmpOutjar.canRead())
|| (!copyInjars && (null == sourceRootCopyFilter))) {
return;
}
Zip zip = new Zip();
Project project = getProject();
zip.setProject(project);
zip.setTaskName(getTaskName() + " - zip");
zip.setDestFile(outjar);
ZipFileSet zipfileset = new ZipFileSet();
zipfileset.setProject(project);
zipfileset.setSrc(tmpOutjar);
zipfileset.setIncludes("**/*.class");
zip.addZipfileset(zipfileset);
if (copyInjars) {
String[] paths = injars.list();
if (!LangUtil.isEmpty(paths)) {
for (int i = 0; i < paths.length; i++) {
File jarFile = new File(paths[i]);
zipfileset = new ZipFileSet();
zipfileset.setProject(project);
zipfileset.setSrc(jarFile);
zipfileset.setIncludes("**/*");
zipfileset.setExcludes("**/*.class");
zip.addZipfileset(zipfileset);
}
}
}
if ((null != sourceRootCopyFilter) && (null != sourceRoots)) {
String[] paths = sourceRoots.list();
if (!LangUtil.isEmpty(paths)) {
for (int i = 0; i < paths.length; i++) {
File srcRoot = new File(paths[i]);
FileSet fileset = new FileSet();
fileset.setProject(project);
fileset.setDir(srcRoot);
fileset.setIncludes("**/*");
fileset.setExcludes(sourceRootCopyFilter);
zip.addFileset(fileset);
}
}
}
zip.execute();
}
// -------------------------- compiler adapter interface extras
/**
* Add specified source files.
*/
void addFiles(File[] paths) {
for (int i = 0; i < paths.length; i++) {
addFile(paths[i]);
}
}
/**
* Add specified source file.
*/
void addFile(File path) {
if (null != path) {
adapterFiles.add(path);
}
}
/**
* Read arguments in as if from a command line,
* mainly to support compiler adapter compilerarg subelement.
*
* @param args the String[] of arguments to read
*/
public void readArguments(String[] args) { // XXX slow, stupid, unmaintainable
if ((null == args) || (0 == args.length)) {
return;
}
/** String[] wrapper with increment, error reporting */
class Args {
final String[] args;
int index = 0;
Args(String[] args) {
this.args = args; // not null or empty
}
boolean hasNext() {
return index < args.length;
}
String next() {
String err = null;
if (!hasNext()) {
err = "need arg for flag " + args[args.length-1];
} else {
String s = args[index++];
if (null == s) {
err = "null value";
} else {
s = s.trim();
if (0 == s.trim().length()) {
err = "no value";
} else {
return s;
}
}
}
err += " at [" + index + "] of " + Arrays.asList(args);
throw new BuildException(err);
}
} // class Args
Args in = new Args(args);
String flag;
while (in.hasNext()) {
flag = in.next();
if ("-1.3".equals(flag)) {
setCompliance("1.3");
} else if ("-1.4".equals(flag)) {
setCompliance("1.4");
// } else if ("-1.5".equals(flag)) {
// setCompliance("1.5");
} else if ("-argfile".equals(flag)) {
setArgfiles(new Path(project, in.next()));
} else if ("-aspectpath".equals(flag)) {
setAspectpath(new Path(project, in.next()));
} else if ("-classpath".equals(flag)) {
setClasspath(new Path(project, in.next()));
} else if ("-Xcopyinjars".equals(flag)) {
setCopyInjars(true);
} else if ("-g".equals(flag)) {
setDebug(true);
} else if (flag.startsWith("-g:")) {
setDebugLevel(flag.substring(2));
} else if ("-deprecation".equals(flag)) {
setDeprecation(true);
} else if ("-d".equals(flag)) {
setDestdir(new File(in.next()));
} else if ("-emacssym".equals(flag)) {
setEmacssym(true);
} else if ("-encoding".equals(flag)) {
setEncoding(in.next());
} else if ("-Xfailonerror".equals(flag)) {
setFailonerror(true);
} else if ("-fork".equals(flag)) {
setFork(true);
} else if ("-forkclasspath".equals(flag)) {
setForkclasspath(new Path(project, in.next()));
} else if ("-help".equals(flag)) {
setHelp(true);
} else if ("-incremental".equals(flag)) {
setIncremental(true);
} else if ("-injars".equals(flag)) {
setInjars(new Path(project, in.next()));
} else if ("-Xlistfileargs".equals(flag)) {
setListFileArgs(true);
} else if ("-Xmaxmem".equals(flag)) {
setMaxmem(in.next());
} else if ("-Xmessageholderclass".equals(flag)) {
setMessageHolderClass(in.next());
} else if ("-noexit".equals(flag)) {
setNoExit(true);
} else if ("-noimport".equals(flag)) {
setNoExit(true);
} else if ("-noExit".equals(flag)) {
setNoExit(true);
} else if ("-noImportError".equals(flag)) {
setNoImportError(true);
} else if ("-noWarn".equals(flag)) {
setNowarn(true);
} else if ("-noexit".equals(flag)) {
setNoExit(true);
} else if ("-outjar".equals(flag)) {
setOutjar(new File(in.next()));
} else if ("-preserveAllLocals".equals(flag)) {
setPreserveAllLocals(true);
} else if ("-proceedOnError".equals(flag)) {
setProceedOnError(true);
} else if ("-progress".equals(flag)) {
setProgress(true);
} else if ("-referenceInfo".equals(flag)) {
setReferenceInfo(true);
} else if ("-source".equals(flag)) {
setSource(in.next());
} else if ("-Xsourcerootcopyfilter".equals(flag)) {
setSourceRootCopyFilter(in.next());
} else if ("-sourceroots".equals(flag)) {
setSourceRoots(new Path(project, in.next()));
} else if ("-Xsrcdir".equals(flag)) {
setSrcDir(new Path(project, in.next()));
} else if ("-Xtagfile".equals(flag)) {
setTagFile(new File(in.next()));
} else if ("-target".equals(flag)) {
setTarget(in.next());
} else if ("-time".equals(flag)) {
setTime(true);
} else if ("-time".equals(flag)) {
setTime(true);
} else if ("-verbose".equals(flag)) {
setVerbose(true);
} else if ("-version".equals(flag)) {
setVersion(true);
} else if ("-warn".equals(flag)) {
setWarn(in.next());
} else if (flag.startsWith("-warn:")) {
setWarn(flag.substring(6));
} else if ("-Xlint".equals(flag)) {
setXlintwarnings(true);
} else if (flag.startsWith("-Xlint:")) {
setXlint(flag.substring(7));
} else if ("-Xlintfile".equals(flag)) {
setXlintfile(new File(in.next()));
} else if ("-Xnoweave".equals(flag)) {
setXNoweave(true);
} else if (flag.startsWith("@")) {
File file = new File(flag.substring(1));
if (file.canRead()) {
setArgfiles(new Path(project, file.getPath()));
} else {
ignore(flag);
}
} else {
File file = new File(flag);
if (file.isFile()
&& file.canRead()
&& FileUtil.hasSourceSuffix(file)) {
addFile(file);
} else {
ignore(flag);
}
}
}
}
/**
* Commandline wrapper that
* only permits addition of non-empty values
* and converts to argfile form if necessary.
*/
public static class GuardedCommand {
Commandline command;
//int size;
static boolean isEmpty(String s) {
return ((null == s) || (0 == s.trim().length()));
}
GuardedCommand() {
command = new Commandline();
}
void addFlag(String flag, boolean doAdd) {
if (doAdd && !isEmpty(flag)) {
command.createArgument().setValue(flag);
//size += 1 + flag.length();
}
}
void addFlagged(String flag, String argument) {
if (!isEmpty(flag) && !isEmpty(argument)) {
command.addArguments(new String[] {flag, argument});
//size += 1 + flag.length() + argument.length();
}
}
private void addFile(File file) {
if (null != file) {
String path = file.getAbsolutePath();
addFlag(path, true);
}
}
List extractArguments() {
ArrayList result = new ArrayList();
String[] cmds = command.getArguments();
if (!LangUtil.isEmpty(cmds)) {
result.addAll(Arrays.asList(cmds));
}
return result;
}
/**
* Adjust args for size if necessary by creating
* an argument file, which should be deleted by the client
* after the compiler run has completed.
* @param max the int maximum length of the command line (in char)
* @return the temp File for the arguments (if generated),
* for deletion when done.
* @throws IllegalArgumentException if max is negative
*/
static String[] limitTo(String[] args, int max,
Location location) {
if (max < 0) {
throw new IllegalArgumentException("negative max: " + max);
}
// sigh - have to count anyway for now
int size = 0;
for (int i = 0; (i < args.length) && (size < max); i++) {
size += 1 + (null == args[i] ? 0 : args[i].length());
}
if (size <= max) {
return args;
}
File tmpFile = null;
PrintWriter out = null;
// adapted from DefaultCompilerAdapter.executeExternalCompile
try {
String userDirName = System.getProperty("user.dir");
File userDir = new File(userDirName);
tmpFile = File.createTempFile("argfile", "", userDir);
out = new PrintWriter(new FileWriter(tmpFile));
for (int i = 0; i < args.length; i++) {
out.println(args[i]);
}
out.flush();
return new String[] {"-argfile", tmpFile.getAbsolutePath()};
} catch (IOException e) {
throw new BuildException("Error creating temporary file",
e, location);
} finally {
if (out != null) {
try {out.close();} catch (Throwable t) {}
}
}
}
}
}
|
39,842
|
Bug 39842 allow use of an environment variable to set compiler arguments
|
I'm trying to create a special jsp compilation servlet in Tomcat 4.x that uses the aspectj compiler. I can plug in the compiler adapter, but I don't have control of the ant code they use to invoke the compiler, so I'd like to use an environment variable to do this (apparently the only mechanism they do support). I'm doing this so I can pass an aspectpath in to weave aspects into the compiled jsp servlet.
|
resolved fixed
|
2502ee5
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-26T04:13:54Z
| 2003-07-09T22:33:20Z
|
taskdefs/src/org/aspectj/tools/ant/taskdefs/ICommandEditor.java
| |
39,842
|
Bug 39842 allow use of an environment variable to set compiler arguments
|
I'm trying to create a special jsp compilation servlet in Tomcat 4.x that uses the aspectj compiler. I can plug in the compiler adapter, but I don't have control of the ant code they use to invoke the compiler, so I'd like to use an environment variable to do this (apparently the only mechanism they do support). I'm doing this so I can pass an aspectpath in to weave aspects into the compiled jsp servlet.
|
resolved fixed
|
2502ee5
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-26T04:13:54Z
| 2003-07-09T22:33:20Z
|
taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC)
* 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.tools.ant.taskdefs;
import org.apache.tools.ant.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.selectors.FilenameSelector;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHolder;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
import java.io.*;
import java.io.File;
import java.util.Arrays;
import junit.framework.TestCase;
/**
* Some API tests, but mostly functional tests driving
* the task execute using data in ../taskdefs/testdata.
* This will re-run in forked mode for any nonfailing
* compile if aspectjtools-dist is built into
* ../aj-build/dist/tools/lib/aspectjtools.jar.
*/
public class AjcTaskTest extends TestCase {
private static final Class NO_EXCEPTION = null;
private static final String NOFILE = "NOFILE";
private static final File tempDir;
private static final String aspectjtoolsJar;
private static final String testdataDir;
private static final StringBuffer MESSAGES = new StringBuffer();
static {
tempDir = new File("IncrementalAjcTaskTest-temp");
String toolsPath = "../aj-build/dist/tools/lib/aspectjtools.jar";
File toolsjar = new File(toolsPath);
if (toolsjar.canRead()) {
aspectjtoolsJar = toolsjar.getAbsolutePath();
} else {
aspectjtoolsJar = null;
String s =
"AjcTaskTest not forking - build aspectjtools-dist to get "
+ toolsPath;
System.out.println(s);
}
File dir = new File("../taskdefs/testdata");
if (dir.canRead() && dir.isDirectory()) {
testdataDir = dir.getAbsolutePath();
} else {
testdataDir = null;
}
}
/**
* Check that aspectjtools are found on the classpath,
* reporting any errors to System.err.
*
* Run multiple times with different classpaths.
* This should find variants
* aspectjtools.jar,
* aspectj-tools.jar,
* aspectj-tools-1.1.jar, and
* aspectjtools-1.0.6.jar
* but not
* aspectjrt.jar or
* aspectj/tools.jar.
* XXX use testing aspect to stub out
* <code>System.getProperty("java.class.path")</code>
* @param args a String[], first is expected path, if any
*/
public static void main(String[] args) {
java.io.File toolsjar = AjcTask.findAspectjtoolsJar();
if ((null == args) || (0 == args.length)) {
if (null != toolsjar) {
System.err.println("FAIL - not expected: " + toolsjar);
}
} else if ("-help".equals(args[0])) {
System.out.println("java " + AjcTaskTest.class.getName()
+ " <expectedPathToAspectjtoolsJar>");
} else if (null == toolsjar) {
System.err.println("FAIL - expected: " + args[0]);
} else {
String path = toolsjar.getAbsolutePath();
if (!path.equals(args[0])) {
System.err.println("FAIL - expected: "
+ args[0]
+ " actual: "
+ path
);
}
}
}
public static void collectMessage(String s) {
MESSAGES.append(s);
}
private static void deleteTempDir() {
if ((null != tempDir) && tempDir.exists()) {
FileUtil.deleteContents(tempDir);
tempDir.delete();
}
}
private static final File getTempDir() {
return tempDir;
}
public AjcTaskTest(String name) {
super(name);
}
public void tearDown() {
deleteTempDir();
MESSAGES.setLength(0);
}
public void testLimitTo() {
int numArgs = 100;
String arg = "123456789";
String[] args = new String[numArgs];
for (int i = 0; i < args.length; i++) {
args[i] = arg;
}
// no limit
int max = numArgs*(arg.length() + 1);
Location location = new Location("AjcTaskTest.java");
String[] newArgs = AjcTask.GuardedCommand.limitTo(args, max, location);
assertTrue("same", args == newArgs);
// limited - read file and verify arguments
max--;
newArgs = AjcTask.GuardedCommand.limitTo(args, max, location);
assertTrue("not same", args != newArgs);
assertTrue("not null", null != newArgs);
String label = "newArgs " + Arrays.asList(newArgs);
assertTrue("size 2" + label, 2 == newArgs.length);
assertEquals("-argfile", newArgs[0]);
File file = new File(newArgs[1]);
assertTrue("readable newArgs[1]" + label, file.canRead());
FileReader fin = null;
try {
fin = new FileReader(file);
BufferedReader reader = new BufferedReader(fin);
String line;
int i = 0;
while (null != (line = reader.readLine())) {
assertEquals(i + ": ", args[i++], line);
}
assertEquals("num entries", i, args.length);
} catch (IOException e) {
assertTrue("IOException " + e.getMessage(), false);
} finally {
if (null != fin) {
try {
fin.close();
} catch (IOException e) {
// ignore
}
}
file.delete();
}
}
public void testFindAspectjtoolsJar() {
File toolsJar = AjcTask.findAspectjtoolsJar();
if (null != toolsJar) {
assertNull("tools jar found?: " + toolsJar, toolsJar);
}
// not found when unit testing b/c not on system classpath
// so just checking for exceptions.
// XXX need aspect to stub out System.getProperty(..)
}
protected AjcTask getTask(String input) {
AjcTask task = new AjcTask();
Project p = new Project();
task.setProject(p);
task.setDestdir(getTempDir());
if (NOFILE.equals(input)) {
// add nothing
} else if (input.endsWith(".lst")) {
if (-1 != input.indexOf(",")) {
throw new IllegalArgumentException("lists not supported: " + input);
} else if (null == testdataDir) {
throw new Error("testdata not found - run in ../taskdefs");
} else {
String path = testdataDir + File.separator + input;
task.setArgfiles(new Path(task.getProject(), path));
}
} else if ((input.endsWith(".java") || input.endsWith(".aj"))) {
// not working
FilenameSelector fns = new FilenameSelector();
fns.setName(input);
task.addFilename(fns);
} else {
File dir = new File(input);
if (dir.canRead() && dir.isDirectory()) {
task.setSourceRoots(new Path(task.getProject(), input));
}
}
task.setClasspath(new Path(p, "../lib/test/aspectjrt.jar"));
task.setVerbose(true); // XXX
return task;
}
/** used in testMessageHolderClassName */
public static class Holder extends MessageHandler {
public Holder() {}
public boolean handleMessage(IMessage message) {
IMessage.Kind kind = message.getKind();
if (IMessage.ERROR.isSameOrLessThan(kind)) {
String m = kind.toString();
AjcTaskTest.collectMessage(m.substring(0,1));
}
return true;
}
}
public void testMessageHolderClassName() {
AjcTask task = getTask("compileError.lst");
task.setFailonerror(false);
MESSAGES.setLength(0);
runTest(task, null, MessageHolderChecker.ONE_ERROR,
Holder.class.getName());
String result = MESSAGES.toString();
MESSAGES.setLength(0);
assertEquals("messages", "e", result);
}
public void testDefaultListForkedNoTools() {
AjcTask task = getTask("default.lst");
task.setFork(true);
boolean passed = false;
try {
runTest(task, BuildException.class, MessageHolderChecker.NONE);
passed = true;
} finally {
if (!passed) {
String m = "AjcTaskTest.testDefaultListForkedNoTools()"
+ " fails if aspectjtools.jar is on the classpath";
System.err.println(m);
}
}
}
public void testDefaultListForkedIncremental() {
AjcTask task = getTask("default.lst");
task.setFork(true);
task.setIncremental(true);
runTest(task, BuildException.class, MessageHolderChecker.NONE);
}
/** failonerror should default to true, unlike other booleans */
public void testCompileErrorFailOnErrorDefault() {
AjcTask task = getTask("compileError.lst");
runTest(task, BuildException.class, MessageHolderChecker.ONE_ERROR);
}
public void testDefaultList() {
AjcTask task = getTask("default.lst");
runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
}
public void testCompileErrorList() {
AjcTask task = getTask("compileError.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR);
}
public void testCompileWarningList() {
AjcTask task = getTask("compileWarning.lst");
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_WARNING);
}
public void testNoSuchFileList() {
AjcTask task = getTask("NoSuchFile.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR_ONE_ABORT);
}
public void testClasspath() {
AjcTask task = getTask(NOFILE);
String[] cmd = task.makeCommand();
String classpath = null;
String bootclasspath = null;
for (int i = 0; i < cmd.length; i++) {
if ("-classpath".equals(cmd[i])) {
classpath = cmd[i+1];
} else if ("-bootclasspath".equals(cmd[i])) {
bootclasspath = cmd[i+1];
}
}
assertTrue("not expecting bootclasspath",
null == bootclasspath);
assertTrue("expecting aspectj in classpath",
(-1 != classpath.indexOf("aspectjrt.jar")));
}
// ---------------------------------------- sourcefile
// XXX need to figure out how to specify files directly programmatically
// public void testDefaultFile() {
// AjcTask task = getTask("testdata/Default.java");
// runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
// }
public void testNoFile() {
AjcTask task = getTask(NOFILE);
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR_ONE_ABORT);
}
public void testCompileErrorFile() {
AjcTask task = getTask("compileError.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR);
}
public void testCompileWarningFile() {
AjcTask task = getTask("compileWarning.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_WARNING);
}
public void testNoSuchFile() {
AjcTask task = getTask("NoSuchFile.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR_ONE_ABORT);
}
public void testDefaultFileComplete() {
AjcTask task = getTask("default.lst");
task.setDebugLevel("none");
task.setDeprecation(true);
task.setFailonerror(false);
task.setNoExit(true); // ok to override Ant?
task.setNoImportError(true);
task.setNowarn(true);
task.setXNoweave(true);
task.setPreserveAllLocals(true);
task.setProceedOnError(true);
task.setReferenceInfo(true);
task.setSource("1.3");
task.setTarget("1.1");
task.setTime(true);
task.setVerbose(true);
task.setXlint("info");
runTest(task, NO_EXCEPTION, MessageHolderChecker.INFOS);
}
protected void runTest(
AjcTask task,
Class exceptionType,
MessageHolderChecker checker,
String messageHolderClass) {
task.setMessageHolderClass(messageHolderClass);
runTest(task, exceptionType, checker, (MessageHandler) null);
}
protected void runTest(
AjcTask task,
Class exceptionType,
MessageHolderChecker checker) {
MessageHandler holder = new MessageHandler();
task.setMessageHolder(holder);
runTest(task, exceptionType, checker, holder);
}
protected void runTest(
AjcTask task,
Class exceptionType,
MessageHolderChecker checker,
MessageHandler holder) {
Throwable thrown = null;
// re-run forked iff tools.jar and expect to pass
boolean rerunForked
= ((null != aspectjtoolsJar)
&& (null == exceptionType)
&& ((null == checker) || !checker.expectFail()));
String label = "same-vm ";
while (true) { // same vm, then perhaps forked
try {
task.execute();
} catch (Throwable t) {
thrown = t;
} finally {
deleteTempDir();
}
if (null == exceptionType) {
if (null != thrown) {
assertTrue(label + "thrown: " + render(thrown), false);
}
} else if (null == thrown) {
assertTrue(label + "expected " + exceptionType.getName(), false);
} else if (!(exceptionType.isAssignableFrom(thrown.getClass()))) {
assertTrue(label + "expected " + exceptionType.getName()
+ " got " + render(thrown), false);
}
if (null != holder) {
if (null == checker) {
checker = MessageHolderChecker.NONE;
}
checker.check(holder, label);
}
if (!rerunForked) {
break;
} else {
label = "other-vm ";
rerunForked = false;
// can't reset without losing values...
task.setFork(true);
task.setFailonerror(true);
task.setForkclasspath(new Path(task.getProject(),
aspectjtoolsJar));
}
}
}
protected String render(Throwable thrown) {
return LangUtil.renderException(thrown);
}
static class MessageHolderChecker { // XXX export to testing-utils
/** use as value to ignore results */
static int IGNORE = Integer.MIN_VALUE;
static MessageHolderChecker NONE =
new MessageHolderChecker(0,0,0,0,0);
/** any number (0+) of info messages */
static MessageHolderChecker INFOS =
new MessageHolderChecker(0,0,0,0,IGNORE);
/** one error, any number of info messages */
static MessageHolderChecker ONE_ERROR=
new MessageHolderChecker(0,0,1,0,IGNORE);
static MessageHolderChecker ONE_ERROR_ONE_ABORT =
new MessageHolderChecker(1,0,1,0,IGNORE);
/** one warning, any number of info messages */
static MessageHolderChecker ONE_WARNING =
new MessageHolderChecker(0,0,0,1,IGNORE);
int aborts, fails, errors, warnings, infos;
public MessageHolderChecker(int aborts, int fails, int errors, int warnings, int infos) {
this.aborts = aborts;
this.fails = fails;
this.errors = errors;
this.warnings = warnings;
this.infos = infos;
}
public boolean expectFail() {
return (0 < (aborts + fails + errors));
}
public void check(IMessageHolder holder, String label) {
boolean failed = true;
try {
check(holder, aborts, IMessage.ABORT);
check(holder, fails, IMessage.FAIL);
check(holder, errors, IMessage.ERROR);
check(holder, warnings,IMessage.WARNING);
check(holder, infos, IMessage.INFO);
failed = false;
} finally {
if (failed) {
MessageUtil.print(System.err, holder, label + "failed?");
}
}
}
private void check(IMessageHolder holder, int num, IMessage.Kind kind) {
if (num != IGNORE) {
int actual = holder.numMessages(kind, false);
if (num != actual) {
if (actual > 0) {
MessageUtil.print(System.err, holder, kind + " expected " + num + " got " + actual);
}
assertEquals(kind.toString(), num, actual);
}
}
}
}
}
|
40,824
|
Bug 40824 asm treats "declare parents" as methods
|
"declare parents" member declarations report their kind as "method" instead of what they are.
|
resolved fixed
|
58e3cb2
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-29T10:55:25Z
| 2003-07-28T11:00:00Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Stack;
import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelManager;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.Member;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
import org.eclipse.jdt.internal.compiler.ast.LocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MemberTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
public static void build(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
new AsmBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
private AsmBuilder(CompilationResult result) {
LangUtil.throwIaxIfNull(result, "result");
currCompilationResult = result;
stack = new Stack();
}
/**
* Called only by
* build(CompilationUnitDeclaration unit, StructureModel structureModel)
*/
private void internalBuild(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
}
// ---- summary
// add unit to package (or root if no package),
// first removing any duplicate (XXX? removes children if 3 classes in same file?)
// push the node on the stack
// and traverse
// -- create node to add
final File file = new File(new String(unit.getFileName()));
final ProgramElementNode cuNode;
{
// AMC - use the source start and end from the compilation unit decl
int startLine = getStartLine(unit);
int endLine = getEndLine(unit);
ISourceLocation sourceLocation
= new SourceLocation(file, startLine, endLine);
cuNode = new ProgramElementNode(
new String(file.getName()),
ProgramElementNode.Kind.FILE_JAVA,
sourceLocation,
0,
"",
new ArrayList());
}
// -- get node (package or root) to add to
final StructureNode addToNode;
{
ImportReference currentPackage = unit.currentPackage;
if (null == currentPackage) {
addToNode = structureModel.getRoot();
} else {
String pkgName;
{
StringBuffer nameBuffer = new StringBuffer();
final char[][] importName = currentPackage.getImportName();
final int last = importName.length-1;
for (int i = 0; i < importName.length; i++) {
nameBuffer.append(new String(importName[i]));
if (i < last) {
nameBuffer.append('.');
}
}
pkgName = nameBuffer.toString();
}
ProgramElementNode pkgNode = null;
for (Iterator it = structureModel.getRoot().getChildren().iterator();
it.hasNext(); ) {
ProgramElementNode currNode = (ProgramElementNode)it.next();
if (pkgName.equals(currNode.getName())) {
pkgNode = currNode;
break; // any reason not to quit when found?
}
}
if (pkgNode == null) {
// note packages themselves have no source location
pkgNode = new ProgramElementNode(
pkgName,
ProgramElementNode.Kind.PACKAGE,
new ArrayList());
structureModel.getRoot().addChild(pkgNode);
}
addToNode = pkgNode;
}
}
// -- remove duplicates before adding (XXX use them instead?)
for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext(); ) {
ProgramElementNode child = (ProgramElementNode)itt.next();
ISourceLocation childLoc = child.getSourceLocation();
if (null == childLoc) {
// XXX ok, packages have null source locations
// signal others?
} else if (childLoc.getSourceFile().equals(file)) {
itt.remove();
}
}
// -- add and traverse
addToNode.addChild(cuNode);
stack.push(cuNode);
unit.traverse(this, unit.scope);
// -- update file map (XXX do this before traversal?)
try {
structureModel.addToFileMap(file.getCanonicalPath(), cuNode);
} catch (IOException e) {
System.err.println("IOException " + e.getMessage()
+ " creating path for " + file );
// XXX signal IOException when canonicalizing file path
}
}
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
String name = new String(typeDeclaration.name);
//System.err.println("type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (typeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (typeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(typeDeclaration),
typeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
stack.pop();
}
// ??? share impl with visit(TypeDeclaration, ..) ?
public boolean visit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
String name = new String(memberTypeDeclaration.name);
//System.err.println("member type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
String name = new String(memberTypeDeclaration.name);
String fullName = new String(memberTypeDeclaration.binding.constantPoolName());
int dollar = fullName.indexOf('$');
fullName = fullName.substring(dollar+1);
//
// System.err.println("member type with name: " + name + ", " +
// new String(fullName));
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
fullName,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
//??? we add this to the compilation unit
findEnclosingClass(stack).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
public boolean visit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
return visit((LocalTypeDeclaration)memberTypeDeclaration, scope);
}
public void endVisit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
private StructureNode findEnclosingClass(Stack stack) {
for (int i = stack.size()-1; i >= 0; i--) {
ProgramElementNode pe = (ProgramElementNode)stack.get(i);
if (pe.getProgramElementKind() == ProgramElementNode.Kind.CLASS) {
return pe;
}
}
return (StructureNode)stack.peek();
}
// !!! improve name and type generation
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
ProgramElementNode.Kind kind = ProgramElementNode.Kind.METHOD;
String label = new String(methodDeclaration.selector);
if (methodDeclaration instanceof AdviceDeclaration) {
kind = ProgramElementNode.Kind.ADVICE;
label = translateAdviceName(label);
} else if (methodDeclaration instanceof PointcutDeclaration) {
kind = ProgramElementNode.Kind.POINTCUT;
label = translatePointcutName(label);
} else if (methodDeclaration instanceof DeclareDeclaration) {
DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
label = translateDeclareName(declare.toString());
if (label.indexOf("warning") != -1) kind = ProgramElementNode.Kind.DECLARE_WARNING;
if (label.indexOf("error") != -1) kind = ProgramElementNode.Kind.DECLARE_ERROR;
} else if (methodDeclaration instanceof InterTypeDeclaration) {
kind = ProgramElementNode.Kind.INTRODUCTION;
label = translateInterTypeDecName(new String(((InterTypeDeclaration)methodDeclaration).selector));
}
ProgramElementNode peNode = new ProgramElementNode(
label,
kind,
makeLocation(methodDeclaration),
methodDeclaration.modifiers,
"",
new ArrayList());
if (kind == ProgramElementNode.Kind.METHOD) {
// !! should probably discriminate more
if (label.equals("main")) {
((ProgramElementNode)stack.peek()).setRunnable(true);
}
}
if (methodDeclaration.binding != null) {
Member member = EclipseFactory.makeResolvedMember(methodDeclaration.binding);
peNode.setBytecodeName(member.getName());
peNode.setBytecodeSignature(member.getSignature());
}
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
ProgramElementNode peNode = new ProgramElementNode(
new String(fieldDeclaration.name),
ProgramElementNode.Kind.FIELD,
makeLocation(fieldDeclaration),
fieldDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
stack.pop();
}
// public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// new String(importRef.toString()),
// ProgramElementNode.Kind.,
// makeLocation(importRef),
// 0,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(0, peNode);
// stack.push(peNode);
// return true;
// }
// public void endVisit(ImportReference importRef,CompilationUnitScope scope) {
// stack.pop();
// }
public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
if (constructorDeclaration.isDefaultConstructor) {
stack.push(null); // a little wierd but does the job
return true;
}
ProgramElementNode peNode = new ProgramElementNode(
new String(constructorDeclaration.selector),
ProgramElementNode.Kind.CONSTRUCTOR,
makeLocation(constructorDeclaration),
constructorDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
stack.pop();
}
// public boolean visit(Clinit clinit, ClassScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// "<clinit>",
// ProgramElementNode.Kind.INITIALIZER,
// makeLocation(clinit),
// clinit.modifiers,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(peNode);
// stack.push(peNode);
// return false;
// }
// public void endVisit(Clinit clinit, ClassScope scope) {
// stack.pop();
// }
/** This method works-around an odd traverse implementation on Initializer
*/
private Initializer inInitializer = null;
public boolean visit(Initializer initializer, MethodScope scope) {
if (initializer == inInitializer) return false;
inInitializer = initializer;
ProgramElementNode peNode = new ProgramElementNode(
"...",
ProgramElementNode.Kind.INITIALIZER,
makeLocation(initializer),
initializer.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
initializer.block.traverse(this, scope);
stack.pop();
return false;
}
// ??? handle non-existant files
private ISourceLocation makeLocation(AstNode node) {
String fileName = new String(currCompilationResult.getFileName());
// AMC - different strategies based on node kind
int startLine = getStartLine(node);
int endLine = getEndLine(node);
ISourceLocation loc = null;
if ( startLine <= endLine ) {
// found a valid end line for this node...
loc = new SourceLocation(new File(fileName), startLine, endLine);
} else {
loc = new SourceLocation(new File(fileName), startLine);
}
return loc;
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AstNode n){
// if ( n instanceof AbstractVariableDeclaration ) return getStartLine( (AbstractVariableDeclaration)n);
// if ( n instanceof AbstractMethodDeclaration ) return getStartLine( (AbstractMethodDeclaration)n);
// if ( n instanceof TypeDeclaration ) return getStartLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AstNode n){
if ( n instanceof AbstractVariableDeclaration ) return getEndLine( (AbstractVariableDeclaration)n);
if ( n instanceof AbstractMethodDeclaration ) return getEndLine( (AbstractMethodDeclaration)n);
if ( n instanceof TypeDeclaration ) return getEndLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractVariableDeclaration avd ) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractVariableDeclaration avd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractMethodDeclaration amd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractMethodDeclaration amd) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( TypeDeclaration td ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( TypeDeclaration td){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceEnd);
}
// !!! move or replace
private String translateAdviceName(String label) {
if (label.indexOf("before") != -1) return "before";
if (label.indexOf("returning") != -1) return "after returning";
if (label.indexOf("after") != -1) return "after";
if (label.indexOf("around") != -1) return "around";
else return "<advice>";
}
// !!! move or replace
private String translateDeclareName(String name) {
int colonIndex = name.indexOf(":");
if (colonIndex != -1) {
return name.substring(0, colonIndex);
} else {
return name;
}
}
// !!! move or replace
private String translateInterTypeDecName(String name) {
int index = name.lastIndexOf('$');
if (index != -1) {
return name.substring(index+1);
} else {
return name;
}
}
// !!! move or replace
private String translatePointcutName(String name) {
int index = name.indexOf("$$")+2;
int endIndex = name.lastIndexOf('$');
if (index != -1 && endIndex != -1) {
return name.substring(index, endIndex);
} else {
return name;
}
}
}
|
39,959
|
Bug 39959 AJC Compiler generates invalid class files under certain circunstances.
|
I made a package (I will attach it to this bug with the name bug.zip) which shows a sample Java program that correctly runs when compiled with javac and have classloading problems every time it is compiled with ajc. Please see the file README.TO.DEMONSTRATE.BUG inside the bug.zip archive for detailed (although simple) instructions on reproducing the bug. There are two shell scripts attached to make things easier. Please keep me informed of the status of this issue.
|
resolved fixed
|
ee03a3e
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-29T11:00:21Z
| 2003-07-11T19:00:00Z
|
tests/bugs/bootstrapClasspath/UsesDOMParser.java
| |
39,626
|
Bug 39626 Compiler error when compiling a buggy class
|
I use AspectJ 1.1 from within eclipse. After some time of developing, I get following stack trace (Wrapped in the eclipse gui), when I try to compile a java file with a huge amount of syntax errors, missing variables, and other problems. As soon as I have fixed these issues, I can comnpile normally as ever. Unfortunatly I can not provide any more detailed information because: this errors pops up randomly, disappears when the bug is fixed, I have neither the time nor the permission to create a more accurate sample java.lang.NullPointerException at java.lang.String.<init>(String.java:214) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:231) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:259) at org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration.traverse (AnonymousLocalTypeDeclaration.java:138) at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse (QualifiedAllocationExpression.java:342) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:299) at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:147) at org.eclipse.jdt.internal.compiler.ast.ForStatement.traverse (ForStatement.java:347) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java:157) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:946) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:303) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.internalBuild (AsmBuilder.java:169) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.build (AsmBuilder.java:66) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit (EclipseFactory.java:303) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java:67) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:372) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:133) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:78) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:164) LoadTest.java CrefoClient/src/com/dcbank/scoring/socketserver kind regards Arno Schmidmeier
|
resolved fixed
|
7886970
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T09:10:45Z
| 2003-07-04T09:13:20Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Stack;
import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelManager;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.Member;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
import org.eclipse.jdt.internal.compiler.ast.LocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MemberTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
public static void build(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
new AsmBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
private AsmBuilder(CompilationResult result) {
LangUtil.throwIaxIfNull(result, "result");
currCompilationResult = result;
stack = new Stack();
}
/**
* Called only by
* build(CompilationUnitDeclaration unit, StructureModel structureModel)
*/
private void internalBuild(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
}
// ---- summary
// add unit to package (or root if no package),
// first removing any duplicate (XXX? removes children if 3 classes in same file?)
// push the node on the stack
// and traverse
// -- create node to add
final File file = new File(new String(unit.getFileName()));
final ProgramElementNode cuNode;
{
// AMC - use the source start and end from the compilation unit decl
int startLine = getStartLine(unit);
int endLine = getEndLine(unit);
ISourceLocation sourceLocation
= new SourceLocation(file, startLine, endLine);
cuNode = new ProgramElementNode(
new String(file.getName()),
ProgramElementNode.Kind.FILE_JAVA,
sourceLocation,
0,
"",
new ArrayList());
}
// -- get node (package or root) to add to
final StructureNode addToNode;
{
ImportReference currentPackage = unit.currentPackage;
if (null == currentPackage) {
addToNode = structureModel.getRoot();
} else {
String pkgName;
{
StringBuffer nameBuffer = new StringBuffer();
final char[][] importName = currentPackage.getImportName();
final int last = importName.length-1;
for (int i = 0; i < importName.length; i++) {
nameBuffer.append(new String(importName[i]));
if (i < last) {
nameBuffer.append('.');
}
}
pkgName = nameBuffer.toString();
}
ProgramElementNode pkgNode = null;
for (Iterator it = structureModel.getRoot().getChildren().iterator();
it.hasNext(); ) {
ProgramElementNode currNode = (ProgramElementNode)it.next();
if (pkgName.equals(currNode.getName())) {
pkgNode = currNode;
break; // any reason not to quit when found?
}
}
if (pkgNode == null) {
// note packages themselves have no source location
pkgNode = new ProgramElementNode(
pkgName,
ProgramElementNode.Kind.PACKAGE,
new ArrayList());
structureModel.getRoot().addChild(pkgNode);
}
addToNode = pkgNode;
}
}
// -- remove duplicates before adding (XXX use them instead?)
for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext(); ) {
ProgramElementNode child = (ProgramElementNode)itt.next();
ISourceLocation childLoc = child.getSourceLocation();
if (null == childLoc) {
// XXX ok, packages have null source locations
// signal others?
} else if (childLoc.getSourceFile().equals(file)) {
itt.remove();
}
}
// -- add and traverse
addToNode.addChild(cuNode);
stack.push(cuNode);
unit.traverse(this, unit.scope);
// -- update file map (XXX do this before traversal?)
try {
structureModel.addToFileMap(file.getCanonicalPath(), cuNode);
} catch (IOException e) {
System.err.println("IOException " + e.getMessage()
+ " creating path for " + file );
// XXX signal IOException when canonicalizing file path
}
}
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
String name = new String(typeDeclaration.name);
//System.err.println("type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (typeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (typeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(typeDeclaration),
typeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
stack.pop();
}
// ??? share impl with visit(TypeDeclaration, ..) ?
public boolean visit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
String name = new String(memberTypeDeclaration.name);
//System.err.println("member type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
String name = new String(memberTypeDeclaration.name);
String fullName = new String(memberTypeDeclaration.binding.constantPoolName());
int dollar = fullName.indexOf('$');
fullName = fullName.substring(dollar+1);
//
// System.err.println("member type with name: " + name + ", " +
// new String(fullName));
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
fullName,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
//??? we add this to the compilation unit
findEnclosingClass(stack).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
public boolean visit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
return visit((LocalTypeDeclaration)memberTypeDeclaration, scope);
}
public void endVisit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
private StructureNode findEnclosingClass(Stack stack) {
for (int i = stack.size()-1; i >= 0; i--) {
ProgramElementNode pe = (ProgramElementNode)stack.get(i);
if (pe.getProgramElementKind() == ProgramElementNode.Kind.CLASS) {
return pe;
}
}
return (StructureNode)stack.peek();
}
// !!! improve name and type generation
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
ProgramElementNode.Kind kind = ProgramElementNode.Kind.METHOD;
String label = new String(methodDeclaration.selector);
if (methodDeclaration instanceof AdviceDeclaration) {
kind = ProgramElementNode.Kind.ADVICE;
label = translateAdviceName(label);
} else if (methodDeclaration instanceof PointcutDeclaration) {
kind = ProgramElementNode.Kind.POINTCUT;
label = translatePointcutName(label);
} else if (methodDeclaration instanceof DeclareDeclaration) {
DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
label = translateDeclareName(declare.toString());
// TODO: fix this horrible way of checking what kind of declare it is
if (label.indexOf("warning") != -1) {
kind = ProgramElementNode.Kind.DECLARE_WARNING;
} else if (label.indexOf("error") != -1) {
kind = ProgramElementNode.Kind.DECLARE_ERROR;
} else if (label.indexOf("parents") != -1) {
kind = ProgramElementNode.Kind.DECLARE_PARENTS;
} else if (label.indexOf("soft") != -1) {
kind = ProgramElementNode.Kind.DECLARE_SOFT;
} else {
kind = ProgramElementNode.Kind.ERROR;
}
} else if (methodDeclaration instanceof InterTypeDeclaration) {
kind = ProgramElementNode.Kind.INTRODUCTION;
label = translateInterTypeDecName(new String(((InterTypeDeclaration)methodDeclaration).selector));
}
ProgramElementNode peNode = new ProgramElementNode(
label,
kind,
makeLocation(methodDeclaration),
methodDeclaration.modifiers,
"",
new ArrayList());
if (kind == ProgramElementNode.Kind.METHOD) {
// !! should probably discriminate more
if (label.equals("main")) {
((ProgramElementNode)stack.peek()).setRunnable(true);
}
}
if (methodDeclaration.binding != null) {
Member member = EclipseFactory.makeResolvedMember(methodDeclaration.binding);
peNode.setBytecodeName(member.getName());
peNode.setBytecodeSignature(member.getSignature());
}
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
ProgramElementNode peNode = new ProgramElementNode(
new String(fieldDeclaration.name),
ProgramElementNode.Kind.FIELD,
makeLocation(fieldDeclaration),
fieldDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
stack.pop();
}
// public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// new String(importRef.toString()),
// ProgramElementNode.Kind.,
// makeLocation(importRef),
// 0,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(0, peNode);
// stack.push(peNode);
// return true;
// }
// public void endVisit(ImportReference importRef,CompilationUnitScope scope) {
// stack.pop();
// }
public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
if (constructorDeclaration.isDefaultConstructor) {
stack.push(null); // a little wierd but does the job
return true;
}
ProgramElementNode peNode = new ProgramElementNode(
new String(constructorDeclaration.selector),
ProgramElementNode.Kind.CONSTRUCTOR,
makeLocation(constructorDeclaration),
constructorDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
stack.pop();
}
// public boolean visit(Clinit clinit, ClassScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// "<clinit>",
// ProgramElementNode.Kind.INITIALIZER,
// makeLocation(clinit),
// clinit.modifiers,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(peNode);
// stack.push(peNode);
// return false;
// }
// public void endVisit(Clinit clinit, ClassScope scope) {
// stack.pop();
// }
/** This method works-around an odd traverse implementation on Initializer
*/
private Initializer inInitializer = null;
public boolean visit(Initializer initializer, MethodScope scope) {
if (initializer == inInitializer) return false;
inInitializer = initializer;
ProgramElementNode peNode = new ProgramElementNode(
"...",
ProgramElementNode.Kind.INITIALIZER,
makeLocation(initializer),
initializer.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
initializer.block.traverse(this, scope);
stack.pop();
return false;
}
// ??? handle non-existant files
private ISourceLocation makeLocation(AstNode node) {
String fileName = new String(currCompilationResult.getFileName());
// AMC - different strategies based on node kind
int startLine = getStartLine(node);
int endLine = getEndLine(node);
ISourceLocation loc = null;
if ( startLine <= endLine ) {
// found a valid end line for this node...
loc = new SourceLocation(new File(fileName), startLine, endLine);
} else {
loc = new SourceLocation(new File(fileName), startLine);
}
return loc;
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AstNode n){
// if ( n instanceof AbstractVariableDeclaration ) return getStartLine( (AbstractVariableDeclaration)n);
// if ( n instanceof AbstractMethodDeclaration ) return getStartLine( (AbstractMethodDeclaration)n);
// if ( n instanceof TypeDeclaration ) return getStartLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AstNode n){
if ( n instanceof AbstractVariableDeclaration ) return getEndLine( (AbstractVariableDeclaration)n);
if ( n instanceof AbstractMethodDeclaration ) return getEndLine( (AbstractMethodDeclaration)n);
if ( n instanceof TypeDeclaration ) return getEndLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractVariableDeclaration avd ) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractVariableDeclaration avd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractMethodDeclaration amd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractMethodDeclaration amd) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( TypeDeclaration td ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( TypeDeclaration td){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceEnd);
}
// !!! move or replace
private String translateAdviceName(String label) {
if (label.indexOf("before") != -1) return "before";
if (label.indexOf("returning") != -1) return "after returning";
if (label.indexOf("after") != -1) return "after";
if (label.indexOf("around") != -1) return "around";
else return "<advice>";
}
// !!! move or replace
private String translateDeclareName(String name) {
int colonIndex = name.indexOf(":");
if (colonIndex != -1) {
return name.substring(0, colonIndex);
} else {
return name;
}
}
// !!! move or replace
private String translateInterTypeDecName(String name) {
int index = name.lastIndexOf('$');
if (index != -1) {
return name.substring(index+1);
} else {
return name;
}
}
// !!! move or replace
private String translatePointcutName(String name) {
int index = name.indexOf("$$")+2;
int endIndex = name.lastIndexOf('$');
if (index != -1 && endIndex != -1) {
return name.substring(index, endIndex);
} else {
return name;
}
}
}
|
39,626
|
Bug 39626 Compiler error when compiling a buggy class
|
I use AspectJ 1.1 from within eclipse. After some time of developing, I get following stack trace (Wrapped in the eclipse gui), when I try to compile a java file with a huge amount of syntax errors, missing variables, and other problems. As soon as I have fixed these issues, I can comnpile normally as ever. Unfortunatly I can not provide any more detailed information because: this errors pops up randomly, disappears when the bug is fixed, I have neither the time nor the permission to create a more accurate sample java.lang.NullPointerException at java.lang.String.<init>(String.java:214) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:231) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:259) at org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration.traverse (AnonymousLocalTypeDeclaration.java:138) at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse (QualifiedAllocationExpression.java:342) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:299) at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:147) at org.eclipse.jdt.internal.compiler.ast.ForStatement.traverse (ForStatement.java:347) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java:157) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:946) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:303) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.internalBuild (AsmBuilder.java:169) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.build (AsmBuilder.java:66) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit (EclipseFactory.java:303) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java:67) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:372) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:133) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:78) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:164) LoadTest.java CrefoClient/src/com/dcbank/scoring/socketserver kind regards Arno Schmidmeier
|
resolved fixed
|
7886970
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T09:10:45Z
| 2003-07-04T09:13:20Z
|
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AjdtBuilderTests.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
import junit.framework.*;
public class AjdtBuilderTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AjdtBuilderTests.class.getName());
//$JUnit-BEGIN$
suite.addTestSuite(AjBuildManagerTest.class);
//$JUnit-END$
return suite;
}
public AjdtBuilderTests(String name) { super(name); }
}
|
39,626
|
Bug 39626 Compiler error when compiling a buggy class
|
I use AspectJ 1.1 from within eclipse. After some time of developing, I get following stack trace (Wrapped in the eclipse gui), when I try to compile a java file with a huge amount of syntax errors, missing variables, and other problems. As soon as I have fixed these issues, I can comnpile normally as ever. Unfortunatly I can not provide any more detailed information because: this errors pops up randomly, disappears when the bug is fixed, I have neither the time nor the permission to create a more accurate sample java.lang.NullPointerException at java.lang.String.<init>(String.java:214) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:231) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit (AsmBuilder.java:259) at org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration.traverse (AnonymousLocalTypeDeclaration.java:138) at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse (QualifiedAllocationExpression.java:342) at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse (MessageSend.java:299) at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:147) at org.eclipse.jdt.internal.compiler.ast.ForStatement.traverse (ForStatement.java:347) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (MethodDeclaration.java:157) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (TypeDeclaration.java:946) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (CompilationUnitDeclaration.java:303) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.internalBuild (AsmBuilder.java:169) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.build (AsmBuilder.java:66) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.finishedCompilationUnit (EclipseFactory.java:303) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(AjCompiler.java:67) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:338) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation (AjBuildManager.java:372) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild (AjBuildManager.java:133) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBuildManager.java:78) at org.aspectj.ajde.internal.CompilerAdapter.compile (CompilerAdapter.java:117) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (AspectJBuildManager.java:164) LoadTest.java CrefoClient/src/com/dcbank/scoring/socketserver kind regards Arno Schmidmeier
|
resolved fixed
|
7886970
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T09:10:45Z
| 2003-07-04T09:13:20Z
|
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
| |
39,974
|
Bug 39974 Some strange error when compiling the observer example with JBuilder7 integrated AJDE
|
When I compiled the observer/subject protocol example with JBuilder7 integrated AJDE,there was a strange internal error C:/JBuilder7/extras/aspectj-110/doc/examples/observer/Observer.java:0: Internal compiler error java.lang.NullPointerException at org.aspectj.ajdt.internal.compiler.lookup.EclipseWorld.makeResolvedMember (Unknown Source) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.visit(Unknown Source) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse (Unknown Source) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse (Unknown Source) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse (Unknown Source) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.internalBuild (Unknown Source) at org.aspectj.ajdt.internal.core.builder.AsmBuilder.build(Unknown Source) at org.aspectj.ajdt.internal.compiler.lookup.EclipseWorld.finishedCompilationUnit (Unknown Source) at org.aspectj.ajdt.internal.compiler.AjCompiler.process(Unknown Source) at org.eclipse.jdt.internal.compiler.Compiler.compile(Unknown Source) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Unknown Source) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Unknown Source) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$BatchBuilder.run(Unknown Source) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (Unknown Source) at org.aspectj.ajde.internal.CompilerAdapter.compile(Unknown Source) at org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run (Unknown Source) I firstly fix it by changing the interface Subject and Observer like this: interface Observer { void update();} interface Subject { Object getData(); } then it could compile successfully ,however,I immediately got another confusing.The compiler only made Display.java Observer.java Subject.java SubjectObserverProtocol.java and SubjectObserverProtocolImpl.java but ignoring the others.I don't know why,it seems to be a bug. Meanwhile, I use ajc command-line to compile this example ,it can get through without any exceptions.
|
resolved fixed
|
f5d31ba
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T09:54:07Z
| 2003-07-12T08:53:20Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.core.builder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Stack;
import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelManager;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.Member;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.Initializer;
import org.eclipse.jdt.internal.compiler.ast.LocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MemberTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
public static void build(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
new AsmBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
protected AsmBuilder(CompilationResult result) {
LangUtil.throwIaxIfNull(result, "result");
currCompilationResult = result;
stack = new Stack();
}
/**
* Called only by
* build(CompilationUnitDeclaration unit, StructureModel structureModel)
*/
private void internalBuild(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
}
// ---- summary
// add unit to package (or root if no package),
// first removing any duplicate (XXX? removes children if 3 classes in same file?)
// push the node on the stack
// and traverse
// -- create node to add
final File file = new File(new String(unit.getFileName()));
final ProgramElementNode cuNode;
{
// AMC - use the source start and end from the compilation unit decl
int startLine = getStartLine(unit);
int endLine = getEndLine(unit);
ISourceLocation sourceLocation
= new SourceLocation(file, startLine, endLine);
cuNode = new ProgramElementNode(
new String(file.getName()),
ProgramElementNode.Kind.FILE_JAVA,
sourceLocation,
0,
"",
new ArrayList());
}
// -- get node (package or root) to add to
final StructureNode addToNode;
{
ImportReference currentPackage = unit.currentPackage;
if (null == currentPackage) {
addToNode = structureModel.getRoot();
} else {
String pkgName;
{
StringBuffer nameBuffer = new StringBuffer();
final char[][] importName = currentPackage.getImportName();
final int last = importName.length-1;
for (int i = 0; i < importName.length; i++) {
nameBuffer.append(new String(importName[i]));
if (i < last) {
nameBuffer.append('.');
}
}
pkgName = nameBuffer.toString();
}
ProgramElementNode pkgNode = null;
for (Iterator it = structureModel.getRoot().getChildren().iterator();
it.hasNext(); ) {
ProgramElementNode currNode = (ProgramElementNode)it.next();
if (pkgName.equals(currNode.getName())) {
pkgNode = currNode;
break; // any reason not to quit when found?
}
}
if (pkgNode == null) {
// note packages themselves have no source location
pkgNode = new ProgramElementNode(
pkgName,
ProgramElementNode.Kind.PACKAGE,
new ArrayList());
structureModel.getRoot().addChild(pkgNode);
}
addToNode = pkgNode;
}
}
// -- remove duplicates before adding (XXX use them instead?)
for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext(); ) {
ProgramElementNode child = (ProgramElementNode)itt.next();
ISourceLocation childLoc = child.getSourceLocation();
if (null == childLoc) {
// XXX ok, packages have null source locations
// signal others?
} else if (childLoc.getSourceFile().equals(file)) {
itt.remove();
}
}
// -- add and traverse
addToNode.addChild(cuNode);
stack.push(cuNode);
unit.traverse(this, unit.scope);
// -- update file map (XXX do this before traversal?)
try {
structureModel.addToFileMap(file.getCanonicalPath(), cuNode);
} catch (IOException e) {
System.err.println("IOException " + e.getMessage()
+ " creating path for " + file );
// XXX signal IOException when canonicalizing file path
}
}
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
String name = new String(typeDeclaration.name);
//System.err.println("type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (typeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (typeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(typeDeclaration),
typeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
stack.pop();
}
// ??? share impl with visit(TypeDeclaration, ..) ?
public boolean visit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
String name = new String(memberTypeDeclaration.name);
//System.err.println("member type with name: " + name);
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
else if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
name,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MemberTypeDeclaration memberTypeDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
String name = new String(memberTypeDeclaration.name);
String fullName = "<undefined>";
if (memberTypeDeclaration.binding != null
&& memberTypeDeclaration.binding.constantPoolName() != null) {
fullName = new String(memberTypeDeclaration.binding.constantPoolName());
}
int dollar = fullName.indexOf('$');
fullName = fullName.substring(dollar+1);
//
// System.err.println("member type with name: " + name + ", " +
// new String(fullName));
ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
ProgramElementNode peNode = new ProgramElementNode(
fullName,
kind,
makeLocation(memberTypeDeclaration),
memberTypeDeclaration.modifiers,
"",
new ArrayList());
//??? we add this to the compilation unit
findEnclosingClass(stack).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(LocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
public boolean visit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
return visit((LocalTypeDeclaration)memberTypeDeclaration, scope);
}
public void endVisit(AnonymousLocalTypeDeclaration memberTypeDeclaration, BlockScope scope) {
stack.pop();
}
private StructureNode findEnclosingClass(Stack stack) {
for (int i = stack.size()-1; i >= 0; i--) {
ProgramElementNode pe = (ProgramElementNode)stack.get(i);
if (pe.getProgramElementKind() == ProgramElementNode.Kind.CLASS) {
return pe;
}
}
return (StructureNode)stack.peek();
}
// !!! improve name and type generation
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
ProgramElementNode.Kind kind = ProgramElementNode.Kind.METHOD;
String label = new String(methodDeclaration.selector);
if (methodDeclaration instanceof AdviceDeclaration) {
kind = ProgramElementNode.Kind.ADVICE;
label = translateAdviceName(label);
} else if (methodDeclaration instanceof PointcutDeclaration) {
kind = ProgramElementNode.Kind.POINTCUT;
label = translatePointcutName(label);
} else if (methodDeclaration instanceof DeclareDeclaration) {
DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
label = translateDeclareName(declare.toString());
// TODO: fix this horrible way of checking what kind of declare it is
if (label.indexOf("warning") != -1) {
kind = ProgramElementNode.Kind.DECLARE_WARNING;
} else if (label.indexOf("error") != -1) {
kind = ProgramElementNode.Kind.DECLARE_ERROR;
} else if (label.indexOf("parents") != -1) {
kind = ProgramElementNode.Kind.DECLARE_PARENTS;
} else if (label.indexOf("soft") != -1) {
kind = ProgramElementNode.Kind.DECLARE_SOFT;
} else {
kind = ProgramElementNode.Kind.ERROR;
}
} else if (methodDeclaration instanceof InterTypeDeclaration) {
kind = ProgramElementNode.Kind.INTRODUCTION;
label = translateInterTypeDecName(new String(((InterTypeDeclaration)methodDeclaration).selector));
}
ProgramElementNode peNode = new ProgramElementNode(
label,
kind,
makeLocation(methodDeclaration),
methodDeclaration.modifiers,
"",
new ArrayList());
if (kind == ProgramElementNode.Kind.METHOD) {
// !! should probably discriminate more
if (label.equals("main")) {
((ProgramElementNode)stack.peek()).setRunnable(true);
}
}
if (methodDeclaration.binding != null) {
Member member = EclipseFactory.makeResolvedMember(methodDeclaration.binding);
peNode.setBytecodeName(member.getName());
peNode.setBytecodeSignature(member.getSignature());
}
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
stack.pop();
}
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
ProgramElementNode peNode = new ProgramElementNode(
new String(fieldDeclaration.name),
ProgramElementNode.Kind.FIELD,
makeLocation(fieldDeclaration),
fieldDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
stack.pop();
}
// public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// new String(importRef.toString()),
// ProgramElementNode.Kind.,
// makeLocation(importRef),
// 0,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(0, peNode);
// stack.push(peNode);
// return true;
// }
// public void endVisit(ImportReference importRef,CompilationUnitScope scope) {
// stack.pop();
// }
public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
if (constructorDeclaration.isDefaultConstructor) {
stack.push(null); // a little wierd but does the job
return true;
}
ProgramElementNode peNode = new ProgramElementNode(
new String(constructorDeclaration.selector),
ProgramElementNode.Kind.CONSTRUCTOR,
makeLocation(constructorDeclaration),
constructorDeclaration.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
stack.pop();
}
// public boolean visit(Clinit clinit, ClassScope scope) {
// ProgramElementNode peNode = new ProgramElementNode(
// "<clinit>",
// ProgramElementNode.Kind.INITIALIZER,
// makeLocation(clinit),
// clinit.modifiers,
// "",
// new ArrayList());
// ((StructureNode)stack.peek()).addChild(peNode);
// stack.push(peNode);
// return false;
// }
// public void endVisit(Clinit clinit, ClassScope scope) {
// stack.pop();
// }
/** This method works-around an odd traverse implementation on Initializer
*/
private Initializer inInitializer = null;
public boolean visit(Initializer initializer, MethodScope scope) {
if (initializer == inInitializer) return false;
inInitializer = initializer;
ProgramElementNode peNode = new ProgramElementNode(
"...",
ProgramElementNode.Kind.INITIALIZER,
makeLocation(initializer),
initializer.modifiers,
"",
new ArrayList());
((StructureNode)stack.peek()).addChild(peNode);
stack.push(peNode);
initializer.block.traverse(this, scope);
stack.pop();
return false;
}
// ??? handle non-existant files
private ISourceLocation makeLocation(AstNode node) {
String fileName = "";
if (currCompilationResult.getFileName() != null) new String(currCompilationResult.getFileName());
// AMC - different strategies based on node kind
int startLine = getStartLine(node);
int endLine = getEndLine(node);
ISourceLocation loc = null;
if ( startLine <= endLine ) {
// found a valid end line for this node...
loc = new SourceLocation(new File(fileName), startLine, endLine);
} else {
loc = new SourceLocation(new File(fileName), startLine);
}
return loc;
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AstNode n){
// if ( n instanceof AbstractVariableDeclaration ) return getStartLine( (AbstractVariableDeclaration)n);
// if ( n instanceof AbstractMethodDeclaration ) return getStartLine( (AbstractMethodDeclaration)n);
// if ( n instanceof TypeDeclaration ) return getStartLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AstNode n){
if ( n instanceof AbstractVariableDeclaration ) return getEndLine( (AbstractVariableDeclaration)n);
if ( n instanceof AbstractMethodDeclaration ) return getEndLine( (AbstractMethodDeclaration)n);
if ( n instanceof TypeDeclaration ) return getEndLine( (TypeDeclaration)n);
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
n.sourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractVariableDeclaration avd ) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractVariableDeclaration avd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
avd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( AbstractMethodDeclaration amd ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( AbstractMethodDeclaration amd) {
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
amd.declarationSourceEnd);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getStartLine( TypeDeclaration td ){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceStart);
}
// AMC - overloaded set of methods to get start and end lines for
// various ASTNode types. They have no common ancestor in the
// hierarchy!!
private int getEndLine( TypeDeclaration td){
return ProblemHandler.searchLineNumber(
currCompilationResult.lineSeparatorPositions,
td.declarationSourceEnd);
}
// !!! move or replace
private String translateAdviceName(String label) {
if (label.indexOf("before") != -1) return "before";
if (label.indexOf("returning") != -1) return "after returning";
if (label.indexOf("after") != -1) return "after";
if (label.indexOf("around") != -1) return "around";
else return "<advice>";
}
// !!! move or replace
private String translateDeclareName(String name) {
int colonIndex = name.indexOf(":");
if (colonIndex != -1) {
return name.substring(0, colonIndex);
} else {
return name;
}
}
// !!! move or replace
private String translateInterTypeDecName(String name) {
int index = name.lastIndexOf('$');
if (index != -1) {
return name.substring(index+1);
} else {
return name;
}
}
// !!! move or replace
private String translatePointcutName(String name) {
int index = name.indexOf("$$")+2;
int endIndex = name.lastIndexOf('$');
if (index != -1 && endIndex != -1) {
return name.substring(index, endIndex);
} else {
return name;
}
}
}
|
38,717
|
Bug 38717 ".lst" file parsing errors should include sourceline information
|
To check for this bug add an erroneous line to an ".lst" file and compile it with AJDE. The error message returned is project-specific. It should be specific to the ".lst" file in which the error originated (i.e. the message needs a SourceLocation).
|
resolved fixed
|
a26cac9
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T17:29:44Z
| 2003-06-10T15:46:40Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/AjdtCommand.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.ajc;
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
import org.aspectj.ajdt.internal.core.builder.AjBuildManager;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.CountingMessageHandler;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.MessageUtil;
import org.eclipse.jdt.internal.core.builder.MissingSourceFileException;
/**
* ICommand adapter for the AspectJ compiler.
* Not thread-safe.
*/
public class AjdtCommand implements ICommand {
/** Message String for any AbortException thrown from ICommand API's */
public static final String ABORT_MESSAGE = "ABORT";
private boolean canRepeatCommand = true;
AjBuildManager buildManager = null;
String[] savedArgs = null;
/**
* Run AspectJ compiler, wrapping any exceptions thrown as
* ABORT messages (containing ABORT_MESSAGE String).
* @param args the String[] for the compiler
* @param handler the IMessageHandler for any messages
* @see org.aspectj.bridge.ICommand#runCommand(String[], IMessageHandler)
* @return false if handler has errors or the command failed
*/
public boolean runCommand(String[] args, IMessageHandler handler) {
buildManager = new AjBuildManager(handler);
savedArgs = new String[args.length];
System.arraycopy(args, 0, savedArgs, 0, savedArgs.length);
for (int i = 0; i < args.length; i++) {
if ("-help".equals(args[i])) {
// should be info, but handler usually suppresses
MessageUtil.abort(handler, BuildArgParser.getUsage());
return true;
}
}
return doCommand(handler, false);
}
/**
* Run AspectJ compiler, wrapping any exceptions thrown as
* ABORT messages (containing ABORT_MESSAGE String).
* @param handler the IMessageHandler for any messages
* @see org.aspectj.bridge.ICommand#repeatCommand(IMessageHandler)
* @return false if handler has errors or the command failed
*/
public boolean repeatCommand(IMessageHandler handler) {
if (null == buildManager) {
MessageUtil.abort(handler, "repeatCommand called before runCommand");
return false;
}
return doCommand(handler, true);
}
/**
* Delegate of both runCommand and repeatCommand.
* This invokes the argument parser each time
* (even when repeating).
* If the parser detects errors, this signals an
* abort with the usage message and returns false.
* @param handler the IMessageHandler sink for any messages
* @param repeat if true, do incremental build, else do batch build
* @return false if handler has any errors or command failed
*/
protected boolean doCommand(IMessageHandler handler, boolean repeat) {
try {
//buildManager.setMessageHandler(handler);
CountingMessageHandler counter = new CountingMessageHandler(handler);
if (counter.hasErrors()) {
return false;
}
// regenerate configuration b/c world might have changed (?)
AjBuildConfig config = genBuildConfig(savedArgs, counter);
if (!config.hasSources()) {
MessageUtil.error(counter, "no sources specified");
}
if (counter.hasErrors()) { // print usage for config errors
String usage = BuildArgParser.getUsage();
MessageUtil.abort(handler, usage);
return false;
}
//System.err.println("errs: " + counter.hasErrors());
return ((repeat
? buildManager.incrementalBuild(config, handler)
: buildManager.batchBuild(config, handler))
&& !counter.hasErrors());
} catch (AbortException ae) {
if (ae.isSilent()) {
throw ae;
} else {
MessageUtil.abort(handler, ABORT_MESSAGE, ae);
}
} catch (MissingSourceFileException t) {
MessageUtil.error(handler, t.getMessage());
} catch (Throwable t) {
MessageUtil.abort(handler, ABORT_MESSAGE, t);
}
return false;
}
/**
* This creates a build configuration for the arguments.
* Errors reported to the handler:
* <ol>
* <li>The parser detects some directly</li>
* <li>The parser grabs some from the error stream
* emitted by its superclass</li>
* <li>The configuration has a self-test</li>
* </ol>
* In the latter two cases, the errors do not have
* a source location context for locating the error.
*/
public static AjBuildConfig genBuildConfig(String[] args, CountingMessageHandler handler) {
BuildArgParser parser = new BuildArgParser();
AjBuildConfig config = parser.genBuildConfig(args, handler);
String message = parser.getOtherMessages(true);
if (null != message) {
IMessage.Kind kind = inferKind(message);
IMessage m = new Message(message, kind, null, null);
handler.handleMessage(m);
}
message = config.configErrors();
if (null != message) {
IMessage.Kind kind = inferKind(message);
IMessage m = new Message(message, kind, null, null);
handler.handleMessage(m);
}
return config;
}
/** @return IMessage.WARNING unless message contains error or info */
protected static IMessage.Kind inferKind(String message) { // XXX dubious
if (-1 != message.indexOf("error")) {
return IMessage.ERROR;
} else if (-1 != message.indexOf("info")) {
return IMessage.INFO;
} else {
return IMessage.WARNING;
}
}
}
|
38,717
|
Bug 38717 ".lst" file parsing errors should include sourceline information
|
To check for this bug add an erroneous line to an ".lst" file and compile it with AJDE. The error message returned is project-specific. It should be specific to the ".lst" file in which the error originated (i.e. the message needs a SourceLocation).
|
resolved fixed
|
a26cac9
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-07-30T17:29:44Z
| 2003-06-10T15:46:40Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.ajc;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
import org.aspectj.ajdt.internal.core.builder.AjCompilerOptions;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.ConfigParser;
import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.batch.Main;
public class BuildArgParser extends Main {
private static final String BUNDLE_NAME = "org.aspectj.ajdt.ajc.messages";
private static boolean LOADED_BUNDLE = false;
/** to initialize super's PrintWriter but refer to underlying StringWriter */
private static class StringPrintWriter extends PrintWriter {
public final StringWriter stringWriter;
StringPrintWriter(StringWriter sw) {
super(sw);
this.stringWriter = sw;
}
}
/** @return multi-line String usage for the compiler */
public static String getUsage() {
if (!LOADED_BUNDLE) { // get eclipse usage unless bundle loaded...
new BuildArgParser();
}
return Main.bind("misc.usage", Main.bind("compiler.version"));
}
/**
* StringWriter sink for some errors.
* This only captures errors not handled by any IMessageHandler parameter
* and only when no PrintWriter is set in the constructor.
* XXX This relies on (Sun's) implementation of StringWriter,
* which returns the actual (not copy) internal StringBuffer.
*/
private final StringBuffer errorSink;
/**
* Overrides super's bundle.
*/
public BuildArgParser(PrintWriter writer) {
super(writer, writer, false);
bundle = ResourceBundle.getBundle(BUNDLE_NAME);
if (!LOADED_BUNDLE) {
LOADED_BUNDLE = true;
}
if (writer instanceof StringPrintWriter) {
errorSink = ((StringPrintWriter) writer).stringWriter.getBuffer();
} else {
errorSink = null;
}
}
/** Set up to capture messages using getOtherMessages(boolean) */
public BuildArgParser() {
this(new StringPrintWriter(new StringWriter()));
}
/**
* Generate build configuration for the input args,
* passing to handler any error messages.
* @param args the String[] arguments for the build configuration
* @param handler the IMessageHandler handler for any errors
* @return AjBuildConfig per args,
* which will be invalid unless there are no handler errors.
*/
public AjBuildConfig genBuildConfig(String[] args, IMessageHandler handler) {
return genBuildConfig(args, handler, true);
}
/**
* Generate build configuration for the input args,
* passing to handler any error messages.
* @param args the String[] arguments for the build configuration
* @param handler the IMessageHandler handler for any errors
* @param setClasspath determines if the classpath should be parsed and set on the build configuration
* @return AjBuildConfig per args,
* which will be invalid unless there are no handler errors.
*/
public AjBuildConfig genBuildConfig(String[] args, IMessageHandler handler, boolean setClasspath) {
AjBuildConfig buildConfig = new AjBuildConfig();
try {
// sets filenames to be non-null in order to make sure that file paramters are ignored
super.filenames = new String[] { "" };
List fileList = new ArrayList();
AjcConfigParser parser = new AjcConfigParser(buildConfig, handler);
parser.parseCommandLine(args);
boolean incrementalMode = buildConfig.isIncrementalMode()
|| buildConfig.isIncrementalFileMode();
List files = parser.getFiles();
if (!LangUtil.isEmpty(files)) {
if (incrementalMode) {
MessageUtil.error(handler, "incremental mode only handles source files using -sourceroots");
} else {
fileList.addAll(files);
}
}
List javaArgList = new ArrayList();
// disable all special eclipse warnings by default
//??? might want to instead override getDefaultOptions()
javaArgList.add("-warn:none");
// these next four lines are some nonsense to fool the eclipse batch compiler
// without these it will go searching for reasonable values from properties
//TODO fix org.eclipse.jdt.internal.compiler.batch.Main so this hack isn't needed
javaArgList.add("-classpath");
javaArgList.add(System.getProperty("user.dir"));
javaArgList.add("-bootclasspath");
javaArgList.add(System.getProperty("user.dir"));
javaArgList.addAll(parser.getUnparsedArgs());
// if (javaArgList.size() != 0) {
super.configure((String[])javaArgList.toArray(new String[javaArgList.size()]));
// }
if (buildConfig.getSourceRoots() != null) {
for (Iterator i = buildConfig.getSourceRoots().iterator(); i.hasNext(); ) {
fileList.addAll(collectSourceRootFiles((File)i.next()));
}
}
buildConfig.setFiles(fileList);
if (destinationPath != null) { // XXX ?? unparsed but set?
buildConfig.setOutputDir(new File(destinationPath));
}
if (setClasspath) {
buildConfig.setClasspath(getClasspath(parser));
}
if (incrementalMode
&& (0 == buildConfig.getSourceRoots().size())) {
MessageUtil.error(handler, "specify a source root when in incremental mode");
}
setDebugOptions();
buildConfig.setJavaOptions(options);
} catch (InvalidInputException iie) {
MessageUtil.error(handler, iie.getMessage());
}
return buildConfig;
}
/**
* Get messages not dumped to handler or any PrintWriter.
* @param flush if true, empty errors
* @return null if none, String otherwise
* @see BuildArgParser()
*/
public String getOtherMessages(boolean flush) {
if (null == errorSink) {
return null;
}
String result = errorSink.toString().trim();
if (0 == result.length()) {
result = null;
}
if (flush) {
errorSink.setLength(0);
}
return result;
}
private void setDebugOptions() {
options.put(
CompilerOptions.OPTION_LocalVariableAttribute,
CompilerOptions.GENERATE);
options.put(
CompilerOptions.OPTION_LineNumberAttribute,
CompilerOptions.GENERATE);
options.put(
CompilerOptions.OPTION_SourceFileAttribute,
CompilerOptions.GENERATE);
}
private Collection collectSourceRootFiles(File dir) {
return Arrays.asList(FileUtil.listFiles(dir, FileUtil.aspectjSourceFileFilter));
}
/**
* If the classpath is not set, we use the environment's java.class.path, but remove
* the aspectjtools.jar entry from that list in order to prevent wierd bootstrap issues
* (refer to bug#39959).
*/
public List getClasspath(AjcConfigParser parser) {
List ret = new ArrayList();
if (parser.bootclasspath == null) {
addClasspath(System.getProperty("sun.boot.class.path", ""), ret);
} else {
addClasspath(parser.bootclasspath, ret);
}
String extdirs = parser.extdirs;
if (extdirs == null) {
extdirs = System.getProperty("java.ext.dirs", "");
}
addExtDirs(extdirs, ret);
if (parser.classpath == null) {
addClasspath(System.getProperty("java.class.path", ""), ret);
List fixedList = new ArrayList();
for (Iterator it = ret.iterator(); it.hasNext(); ) {
String entry = (String)it.next();
if (!entry.endsWith("aspectjtools.jar")) {
fixedList.add(entry);
}
}
ret = fixedList;
} else {
addClasspath(parser.classpath, ret);
}
//??? eclipse seems to put outdir on the classpath
//??? we're brave and believe we don't need it
return ret;
}
private void addExtDirs(String extdirs, List classpathCollector) {
StringTokenizer tokenizer = new StringTokenizer(extdirs, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
// classpathCollector.add(tokenizer.nextToken());
File dirFile = new File((String)tokenizer.nextToken());
if (dirFile.exists() && dirFile.isDirectory()) {
File[] files = FileUtil.listFiles(dirFile, new FileFilter() {
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().endsWith(".jar");
}
});
for (int i = 0; i < files.length; i++) {
classpathCollector.add(files[i].getAbsolutePath());
}
}
}
}
private void addClasspath(String classpath, List classpathCollector) {
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
classpathCollector.add(tokenizer.nextToken());
}
}
// !!! extract error handling to be common so that the IDEs can use it
private class AjcConfigParser extends ConfigParser {
private String bootclasspath = null;
private String classpath = null;
private String extdirs = null;
private List unparsedArgs = new ArrayList();
private AjBuildConfig buildConfig;
private IMessageHandler handler;
public AjcConfigParser(AjBuildConfig buildConfig, IMessageHandler handler) {
this.buildConfig = buildConfig;
this.handler = handler;
}
public List getUnparsedArgs() {
return unparsedArgs;
}
/**
* Extract AspectJ-specific options (except for argfiles).
* Caller should warn when sourceroots is empty but in
* incremental mode.
* Signals warnings or errors through handler set in constructor.
*/
public void parseOption(String arg, LinkedList args) { // XXX use ListIterator.remove()
int nextArgIndex = args.indexOf(arg)+1; // XXX assumes unique
// trim arg?
if (LangUtil.isEmpty(arg)) {
showWarning("empty arg found");
} else if (arg.equals("-injars")) {;
if (args.size() > nextArgIndex) {
buildConfig.getAjOptions().put(AjCompilerOptions.OPTION_InJARs, CompilerOptions.PRESERVE);
StringTokenizer st = new StringTokenizer(
((ConfigParser.Arg)args.get(nextArgIndex)).getValue(),
File.pathSeparator);
while (st.hasMoreTokens()) {
String filename = st.nextToken();
File jarFile = makeFile(filename);
if (jarFile.exists() && FileUtil.hasZipSuffix(filename)) {
buildConfig.getInJars().add(jarFile);
} else {
showError("bad injar: " + filename);
}
}
args.remove(args.get(nextArgIndex));
}
} else if (arg.equals("-aspectpath")) {;
if (args.size() > nextArgIndex) {
StringTokenizer st = new StringTokenizer(
((ConfigParser.Arg)args.get(nextArgIndex)).getValue(),
File.pathSeparator);
while (st.hasMoreTokens()) {
String filename = st.nextToken();
File jarFile = makeFile(filename);
if (jarFile.exists() && FileUtil.hasZipSuffix(filename)) {
buildConfig.getAspectpath().add(jarFile);
} else {
showError("bad aspectpath: " + filename);
}
}
args.remove(args.get(nextArgIndex));
}
} else if (arg.equals("-sourceroots")) {
if (args.size() > nextArgIndex) {
List sourceRoots = new ArrayList();
StringTokenizer st = new StringTokenizer(
((ConfigParser.Arg)args.get(nextArgIndex)).getValue(),
File.pathSeparator);
while (st.hasMoreTokens()) {
File f = makeFile(st.nextToken());
if (f.isDirectory() && f.canRead()) {
sourceRoots.add(f);
} else {
showError("bad sourceroot: " + f);
}
}
if (0 < sourceRoots.size()) {
buildConfig.setSourceRoots(sourceRoots);
}
args.remove(args.get(nextArgIndex));
} else {
showError("-sourceroots requires list of directories");
}
} else if (arg.equals("-outjar")) {
if (args.size() > nextArgIndex) {
buildConfig.getAjOptions().put(AjCompilerOptions.OPTION_OutJAR, CompilerOptions.GENERATE);
File jarFile = makeFile(((ConfigParser.Arg)args.get(nextArgIndex)).getValue());
if (FileUtil.hasZipSuffix(jarFile)) {
try {
if (!jarFile.exists()) {
jarFile.createNewFile();
}
buildConfig.setOutputJar(jarFile);
} catch (IOException ioe) {
showError("unable to create outjar file: " + jarFile);
}
} else {
showError("invalid -outjar file: " + jarFile);
}
args.remove(args.get(nextArgIndex));
} else {
showError("-outjar requires jar path argument");
}
} else if (arg.equals("-incremental")) {
buildConfig.setIncrementalMode(true);
} else if (arg.equals("-XincrementalFile")) {
if (args.size() > nextArgIndex) {
File file = makeFile(((ConfigParser.Arg)args.get(nextArgIndex)).getValue());
buildConfig.setIncrementalFile(file);
if (!file.canRead()) {
showError("bad -XincrementalFile : " + file);
// if not created before recompile test, stop after first compile
}
args.remove(args.get(nextArgIndex));
} else {
showError("-XincrementalFile requires file argument");
}
} else if (arg.equals("-emacssym")) {
buildConfig.setEmacsSymMode(true);
buildConfig.setGenerateModelMode(true);
} else if (arg.equals("-noweave") || arg.equals( "-XnoWeave")) {
buildConfig.setNoWeave(true);
} else if (arg.equals("-XserializableAspects")) {
buildConfig.setXserializableAspects(true);
} else if (arg.equals("-XnoInline")) {
buildConfig.setXnoInline(true);
} else if (arg.equals("-Xlintfile")) {
if (args.size() > nextArgIndex) {
File lintSpecFile = makeFile(((ConfigParser.Arg)args.get(nextArgIndex)).getValue());
// XXX relax restriction on props file suffix?
if (lintSpecFile.canRead() && lintSpecFile.getName().endsWith(".properties")) {
buildConfig.setLintSpecFile(lintSpecFile);
} else {
showError("bad -Xlintfile file: " + lintSpecFile);
buildConfig.setLintSpecFile(null);
}
args.remove(args.get(nextArgIndex));
} else {
showError("-Xlintfile requires .properties file argument");
}
} else if (arg.equals("-Xlint")) {
buildConfig.getAjOptions().put(
AjCompilerOptions.OPTION_Xlint,
CompilerOptions.GENERATE);
buildConfig.setLintMode(AjBuildConfig.AJLINT_DEFAULT);
} else if (arg.startsWith("-Xlint:")) {
if (7 < arg.length()) {
buildConfig.setLintMode(arg.substring(7));
} else {
showError("invalid lint option " + arg);
}
} else if (arg.equals("-bootclasspath")) {
if (args.size() > nextArgIndex) {
bootclasspath = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
args.remove(args.get(nextArgIndex));
} else {
showError("-bootclasspath requires classpath entries");
}
} else if (arg.equals("-classpath")) {
if (args.size() > nextArgIndex) {
classpath = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
args.remove(args.get(nextArgIndex));
} else {
showError("-classpath requires classpath entries");
}
} else if (arg.equals("-extdirs")) {
if (args.size() > nextArgIndex) {
extdirs = ((ConfigParser.Arg)args.get(nextArgIndex)).getValue();
args.remove(args.get(nextArgIndex));
} else {
showError("-extdirs requires list of external directories");
}
// error on directory unless -d, -{boot}classpath, or -extdirs
} else if (arg.equals("-d")) {
dirLookahead(arg, args, nextArgIndex);
// } else if (arg.equals("-classpath")) {
// dirLookahead(arg, args, nextArgIndex);
// } else if (arg.equals("-bootclasspath")) {
// dirLookahead(arg, args, nextArgIndex);
// } else if (arg.equals("-extdirs")) {
// dirLookahead(arg, args, nextArgIndex);
} else if (new File(arg).isDirectory()) {
showError("dir arg not permitted: " + arg);
} else {
// argfile, @file parsed by superclass
// no eclipse options parsed:
// -d args, -help (handled),
// -classpath, -target, -1.3, -1.4, -source [1.3|1.4]
// -nowarn, -warn:[...], -deprecation, -noImportError,
// -proceedOnError, -g:[...], -preserveAllLocals,
// -referenceInfo, -encoding, -verbose, -log, -time
// -noExit, -repeat
unparsedArgs.add(arg);
}
}
protected void dirLookahead(String arg, LinkedList argList, int nextArgIndex) {
unparsedArgs.add(arg);
ConfigParser.Arg next = (ConfigParser.Arg) argList.get(nextArgIndex);
String value = next.getValue();
if (!LangUtil.isEmpty(value)) {
if (new File(value).isDirectory()) {
unparsedArgs.add(value);
argList.remove(next);
return;
}
}
}
public void showError(String message) {
MessageUtil.error(handler, CONFIG_MSG + message);
}
protected void showWarning(String message) {
MessageUtil.warn(handler, message);
}
}
}
|
41,170
|
Bug 41170 -classpath entries in .lst files overwrite command-line -classpath entries
|
If the command-line specifies both a -classpath entry and a .lst file with a -classpath entry, the .lst file entry seems to replace rather than supplement the command-line entry. I expect options to be cumulative. See tests/bugs/options/classpath
|
resolved wontfix
|
40fb451
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-06T00:29:13Z
| 2003-08-06T00:33:20Z
|
tests/bugs/options/classpath/Client.java
| |
41,170
|
Bug 41170 -classpath entries in .lst files overwrite command-line -classpath entries
|
If the command-line specifies both a -classpath entry and a .lst file with a -classpath entry, the .lst file entry seems to replace rather than supplement the command-line entry. I expect options to be cumulative. See tests/bugs/options/classpath
|
resolved wontfix
|
40fb451
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-06T00:29:13Z
| 2003-08-06T00:33:20Z
|
tests/bugs/options/classpath/lib/Library.java
| |
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
ajbrowser/testsrc/org/aspectj/tools/ajbrowser/BrowserManagerTest.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.tools.ajbrowser;
import java.io.File;
import javax.swing.*;
import junit.framework.*;
//import org.aspectj.asm.*;
import org.aspectj.bridge.*;
import org.aspectj.bridge.IMessage;
import org.aspectj.ajde.*;
/**
* @author Mik Kersten
*/
public class BrowserManagerTest extends TestCase {
public BrowserManagerTest(String name) {
super(name);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(BrowserManagerTest.class);
return result;
}
public void testInitNoArgs() {
//String[] args = { "C:/Dev/aspectj/modules/ajde/testdata/examples/figures-coverage/all.lst" };
String[] args = { };
BrowserManager.getDefault().init(args, true);
}
public void testAddProjectTask() {
BrowserManager.getDefault().init(new String[]{}, true);
Ajde.getDefault().getTaskListManager().addProjectTask(
"project-level task",
IMessage.ERROR);
assertTrue("confirmation result", verifySuccess("Project task is visible."));
}
public void testAddSourceLineTasks() {
BrowserManager.getDefault().init(new String[]{}, true);
ISourceLocation dummyLocation = new SourceLocation(new File("<file>"), -1, -1);
Ajde.getDefault().getTaskListManager().addSourcelineTask(
"error task",
dummyLocation,
IMessage.ERROR);
Ajde.getDefault().getTaskListManager().addSourcelineTask(
"warning task",
dummyLocation,
IMessage.WARNING);
Ajde.getDefault().getTaskListManager().addSourcelineTask(
"info task",
dummyLocation,
IMessage.INFO);
assertTrue("confirmation result", verifySuccess("3 kinds of sourceline tasks are visible."));
}
private boolean verifySuccess(String message) {
int result = JOptionPane.showConfirmDialog(
BrowserManager.getDefault().getRootFrame(),
"Verify Results",
message,
JOptionPane.YES_NO_OPTION);
return result == JOptionPane.YES_OPTION;
}
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
ajbrowser/testsrc/org/aspectj/tools/ajbrowser/InteractiveBrowserTest.java
| |
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import org.aspectj.bridge.IMessage;
import org.aspectj.util.LangUtil;
/**
* @author Mik Kersten
*/
public class CompilerMessagesCellRenderer extends JLabel implements ListCellRenderer {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
String label = "<no message>";
String detail = null;
IMessage.Kind kind = IMessage.ERROR;
if (value instanceof IMessage) {
IMessage cm = (IMessage) value;
label = cm.getMessage();
if (LangUtil.isEmpty(label)) {
label = cm.getMessage().toString();
}
kind = cm.getKind();
Throwable thrown = cm.getThrown();
if (null != thrown) {
detail = LangUtil.renderException(thrown);
}
} else if (null != value) {
label = value.toString();
}
setText(label);
if (kind.equals(IMessage.WARNING)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon());
} else if (IMessage.ERROR.isSameOrLessThan(kind)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getErrorIcon());
} else {
setIcon(null);
}
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
setOpaque(true);
if (null != detail) {
setToolTipText(detail);
}
return this;
}
}
|
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
org.aspectj.ajdt.core/testdata/bug-40257/d1/A.java
| |
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
org.aspectj.ajdt.core/testdata/bug-40257/d1/d2/B.java
| |
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
org.aspectj.ajdt.core/testdata/bug-40257/d3/C.java
| |
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/AjdtAjcTests.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.ajc;
import junit.framework.*;
public class AjdtAjcTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AjdtAjcTests.class.getName());
//$JUnit-BEGIN$
suite.addTestSuite(AjdtCommandTestCase.class);
suite.addTestSuite(BuildArgParserTestCase.class);
suite.addTestSuite(ConsoleMessageHandlerTestCase.class);
//$JUnit-END$
return suite;
}
public AjdtAjcTests(String name) { super(name); }
}
|
40,257
|
Bug 40257 parsing of "../" paths in LST files is broken
|
Relative paths (e.g. "../") are no longer parser properly in AJDE 1.1.0.
|
resolved fixed
|
acdf688
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T08:10:01Z
| 2003-07-16T18:26:40Z
|
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.ajc;
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
import org.aspectj.ajdt.internal.core.builder.AjCompilerOptions;
import org.aspectj.bridge.MessageWriter;
import org.aspectj.testing.util.TestUtil;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import junit.framework.TestCase;
/**
* Some black-box test is happening here.
*/
public class BuildArgParserTestCase extends TestCase {
private BuildArgParser parser = new BuildArgParser();
private static final String TEST_DIR = "testdata" + File.separator + "ajc" + File.separator;
private MessageWriter messageWriter = new MessageWriter(new PrintWriter(System.out), false);
public BuildArgParserTestCase(String name) {
super(name);
}
public void testDefaultClasspathAndTargetCombo() throws InvalidInputException {
String ENTRY = "1.jar;2.jar";
final String classpath = System.getProperty("java.class.path");
try {
System.setProperty("java.class.path", ENTRY); // see finally below
AjBuildConfig config = parser.genBuildConfig(new String[] { }, messageWriter);
String err = parser.getOtherMessages(true);
//!!!assertTrue(err, null == err);
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("1.jar"));
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("2.jar"));
config = parser.genBuildConfig(new String[] { "-1.3" }, messageWriter);
// these errors are deffered to the compiler now
//err = parser.getOtherMessages(true);
//!!!assertTrue(err, null == err);
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("1.jar"));
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("2.jar"));
config = parser.genBuildConfig(new String[] { "-1.3" }, messageWriter);
err = parser.getOtherMessages(true);
//!!!assertTrue(err, null == err);
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("1.jar"));
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("2.jar"));
config = parser.genBuildConfig(new String[] {
"-classpath", ENTRY, "-1.4" }, messageWriter);
// these errors are deffered to the compiler now
//err = parser.getOtherMessages(true);
//assertTrue("expected errors for missing jars", null != err);
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("1.jar"));
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("2.jar"));
} finally {
// do finally to avoid messing up classpath for other tests
System.setProperty("java.class.path", classpath);
String setPath = System.getProperty("java.class.path");
String m = "other tests will fail - classpath not reset";
assertEquals(m, classpath, setPath);
}
}
public void testAjOptions() throws InvalidInputException {
AjBuildConfig config = parser.genBuildConfig(new String[] { "-Xlint" }, messageWriter);
assertTrue(
"default options",
config.getAjOptions().get(AjCompilerOptions.OPTION_Xlint).equals(
CompilerOptions.GENERATE));
}
public void testAspectpath() throws InvalidInputException {
final String SOURCE_JAR = "testdata/testclasses.jar";
final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator
+ "../weaver/testdata/tracing.jar" + File.pathSeparator
+ "../weaver/testdata/dummyAspect.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-aspectpath", SOURCE_JAR },
messageWriter);
assertTrue(((File)config.getAspectpath().get(0)).getName(), ((File)config.getAspectpath().get(0)).getName().equals("testclasses.jar"));
config = parser.genBuildConfig(new String[] {
"-aspectpath", SOURCE_JARS },
messageWriter);
assertTrue("size", + config.getAspectpath().size() == 3);
}
public void testInJars() throws InvalidInputException {
final String SOURCE_JAR = "testdata/testclasses.jar";
final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator
+ "../weaver/testdata/tracing.jar" + File.pathSeparator
+ "../weaver/testdata/dummyAspect.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-injars", SOURCE_JAR },
messageWriter);
//XXX don't let this remain in both places in beta1
assertTrue(
"" + config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs),
config.getAjOptions().get(AjCompilerOptions.OPTION_InJARs).equals(CompilerOptions.PRESERVE));
assertTrue(((File)config.getInJars().get(0)).getName(), ((File)config.getInJars().get(0)).getName().equals("testclasses.jar"));
config = parser.genBuildConfig(new String[] {
"-injars", SOURCE_JARS },
messageWriter);
assertTrue("size", + config.getInJars().size() == 3);
}
public void testBadInJars() throws InvalidInputException {
final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator + "b.far" + File.pathSeparator + "c.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-injars", SOURCE_JARS },
messageWriter);
assertTrue("size: " + config.getInJars().size(), config.getInJars().size() == 1);
}
public void testMultipleSourceRoots() throws InvalidInputException {
final String SRCROOT_1 = "testdata/src1/p1";
final String SRCROOT_2 = "testdata/ajc";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots", SRCROOT_1 + File.pathSeparator + SRCROOT_2 },
messageWriter);
assertEquals(new File(SRCROOT_1).getAbsolutePath(), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
new File(SRCROOT_1+File.separator+"A.java").getAbsoluteFile(),
new File(SRCROOT_1+File.separator+"Foo.java").getAbsoluteFile(),
new File(SRCROOT_2+File.separator+"A.java").getAbsoluteFile(),
new File(SRCROOT_2+File.separator+"B.java").getAbsoluteFile(),
new File(SRCROOT_2+File.separator+"X.aj").getAbsoluteFile(),
new File(SRCROOT_2+File.separator+"Y.aj").getAbsoluteFile(),
new File(SRCROOT_2+File.separator+"pkg"+File.separator+"Hello.java").getAbsoluteFile(),
});
//System.out.println(config.getFiles());
TestUtil.assertSetEquals(expectedFiles, config.getFiles());
}
public void testSourceRootDir() throws InvalidInputException {
final String SRCROOT = "testdata/ajc";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots", SRCROOT },
messageWriter);
assertEquals(new File(SRCROOT).getAbsolutePath(), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
new File(SRCROOT+File.separator+"A.java").getAbsoluteFile(),
new File(SRCROOT+File.separator+"B.java").getAbsoluteFile(),
new File(SRCROOT+File.separator+"X.aj").getAbsoluteFile(),
new File(SRCROOT+File.separator+"Y.aj").getAbsoluteFile(),
new File(SRCROOT+File.separator+"pkg"+File.separator+"Hello.java").getAbsoluteFile(),
});
//System.out.println(config.getFiles());
TestUtil.assertSetEquals(expectedFiles, config.getFiles());
}
public void testBadSourceRootDir() throws InvalidInputException {
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots",
"testdata/mumbleDoesNotExist;testdata/ajc" },
messageWriter);
assertTrue(config.getSourceRoots().toString(), config.getSourceRoots().size() == 1);
config = parser.genBuildConfig(new String[] {
"-sourceroots" },
messageWriter);
assertTrue("" + config.getSourceRoots(), config.getSourceRoots().size() == 0);
}
//??? we've decided not to make this an error
public void testSourceRootDirWithFiles() throws InvalidInputException {
final String SRCROOT = "testdata/ajc/pkg";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots", SRCROOT, "testdata/src1/A.java"},
messageWriter);
assertEquals(new File(SRCROOT).getAbsolutePath(), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
new File(SRCROOT+File.separator+"Hello.java").getAbsoluteFile(),
new File("testdata"+File.separator+"src1"+File.separator+"A.java").getAbsoluteFile(),
});
TestUtil.assertSetEquals(expectedFiles, config.getFiles());
}
public void testExtDirs() throws InvalidInputException {
final String DIR = "testdata";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-extdirs", DIR },
messageWriter);
assertTrue(config.getClasspath().toString(), config.getClasspath().contains(
new File(DIR + File.separator + "testclasses.jar").getAbsolutePath()
));
}
public void testBootclasspath() throws InvalidInputException {
final String PATH = "mumble/rt.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-bootclasspath", PATH },
messageWriter);
assertTrue(config.getClasspath().toString(), config.getClasspath().get(0).equals(PATH));
config = parser.genBuildConfig(new String[] {
},
messageWriter);
assertTrue(config.getClasspath().toString(), !config.getClasspath().get(0).equals(PATH));
}
public void testOutputJar() throws InvalidInputException {
final String OUT_JAR = "testdata/testclasses.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-outjar", OUT_JAR },
messageWriter);
//XXX don't let this remain in both places in beta1
assertTrue(
"will generate: " + config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR),
config.getAjOptions().get(AjCompilerOptions.OPTION_OutJAR).equals(CompilerOptions.GENERATE));
assertTrue(
"testclasses jar: " + config.getOutputJar().getName(),
config.getOutputJar().getAbsolutePath().equals(new File(OUT_JAR).getAbsolutePath()));
File nonExistingJar = new File("testdata/mumbleDoesNotExist.jar");
config = parser.genBuildConfig(new String[] {
"-outjar", nonExistingJar.getAbsolutePath() },
messageWriter);
assertTrue(
"testclasses jar: " + config.getOutputJar().getName(),
config.getOutputJar().getAbsolutePath().equals(nonExistingJar.getAbsolutePath()));
nonExistingJar.delete();
}
//XXX shouldn't need -1.4 to get this to pass
public void testCombinedOptions() throws InvalidInputException {
AjBuildConfig config = parser.genBuildConfig(new String[] { "-Xlint", "-target", "1.4", "-1.4" }, messageWriter);
String TARGET = "1.4";
assertTrue(
"target set",
config.getJavaOptions().get(CompilerOptions.OPTION_TargetPlatform).equals(TARGET));
assertTrue(
"Xlint option set",
config.getAjOptions().get(AjCompilerOptions.OPTION_Xlint).equals(
CompilerOptions.GENERATE));
}
public void testOutputDirectorySetting() throws InvalidInputException {
AjBuildConfig config = parser.genBuildConfig(new String[] { "-d", TEST_DIR }, messageWriter);
assertTrue(
new File(config.getOutputDir().getPath()).getAbsolutePath() + " ?= " +
new File(TEST_DIR).getAbsolutePath(),
config.getOutputDir().getAbsolutePath().equals((new File(TEST_DIR)).getAbsolutePath()));
}
public void testClasspathSetting() throws InvalidInputException {
String ENTRY = "1.jar;2.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] { "-classpath", ENTRY }, messageWriter);
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("1.jar"));
assertTrue(
config.getClasspath().toString(),
config.getClasspath().contains("2.jar"));
}
public void testArgInConfigFile() throws InvalidInputException {
String FILE_PATH = "@" + TEST_DIR + "configWithArgs.lst";
String OUT_PATH = "bin";
AjBuildConfig config = parser.genBuildConfig(new String[] { FILE_PATH }, messageWriter);
assertNotNull(config);
File outputDir = config.getOutputDir();
assertNotNull(outputDir);
assertEquals(outputDir.getPath(), OUT_PATH);
}
public void testXlint() throws InvalidInputException {
AjdtCommand command = new AjdtCommand();
AjBuildConfig config = parser.genBuildConfig(new String[] {"-Xlint"}, messageWriter);
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT));
config = parser.genBuildConfig(new String[] {"-Xlint:warn"}, messageWriter);
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_WARN));
config = parser.genBuildConfig(new String[] {"-Xlint:error"}, messageWriter);
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_ERROR));
config = parser.genBuildConfig(new String[] {"-Xlint:ignore"}, messageWriter);
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_IGNORE));
}
public void testXlintfile() throws InvalidInputException {
String lintFile = "testdata/lintspec.properties";
String badLintFile = "lint.props";
AjBuildConfig config = parser.genBuildConfig(new String[] {"-Xlintfile", lintFile}, messageWriter);
assertTrue(new File(lintFile).exists());
assertTrue(config.getLintSpecFile().getAbsolutePath(), config.getLintSpecFile().getAbsolutePath().equals(new File(lintFile).getAbsolutePath()));
}
public void testOptions() throws InvalidInputException {
AjdtCommand command = new AjdtCommand();
String TARGET = "1.4";
AjBuildConfig config = parser.genBuildConfig(new String[] {"-target", TARGET, "-source", TARGET}, messageWriter);
assertTrue(
"target set",
config.getJavaOptions().get(CompilerOptions.OPTION_TargetPlatform).equals(TARGET));
assertTrue(
"source set",
config.getJavaOptions().get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4));
}
public void testLstFileExpansion() throws IOException, FileNotFoundException, InvalidInputException {
String FILE_PATH = TEST_DIR + "config.lst";
String SOURCE_PATH_1 = "A.java";
String SOURCE_PATH_2 = "B.java";
File f = new File(FILE_PATH);
AjBuildConfig config = parser.genBuildConfig(new String[] { "@" + FILE_PATH }, messageWriter);
List resultList = config.getFiles();
assertTrue("correct number of files", resultList.size() == 2);
assertTrue(resultList.toString() + new File(TEST_DIR + SOURCE_PATH_1).getAbsoluteFile(),
resultList.contains(new File(TEST_DIR + SOURCE_PATH_1).getAbsoluteFile()));
assertTrue(resultList.toString() + SOURCE_PATH_2,
resultList.contains(new File(TEST_DIR + SOURCE_PATH_2).getAbsoluteFile()));
}
//??? do we need to remove this limitation
// public void testArgInConfigFileAndRelativizingPathParam() throws InvalidInputException {
// String FILE_PATH = "@" + TEST_DIR + "configWithArgs.lst";
// String OUT_PATH = TEST_DIR + "bin";
// AjBuildConfig config = parser.genBuildConfig(new String[] { FILE_PATH });
//
// assertTrue(
// config.getOutputDir().getPath() + " ?= " + OUT_PATH,
// config.getOutputDir().getAbsolutePath().equals((new File(OUT_PATH)).getAbsolutePath()));
// }
public void testAjFileInclusion() throws InvalidInputException {
parser.genBuildConfig(new String[] { TEST_DIR + "X.aj", TEST_DIR + "Y.aj"}, messageWriter);
}
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
40,534
|
Bug 40534 Declare warning/error output - more detail required.
|
At present the declare warning and declare error functionality of the compiler provides no detailed information about what it is in the user code that has led to the generation of the compile-time warning or error. Consider the following test case... public class A { public static void main(String[] args) { A a = new A(); a.doSomething(); System.out.println("All done"); } void doSomething() { System.out.println("Doing something"); } } // end of class A public aspect MyAspect { pointcut noDoing() : call(* *.doSomething(..)); declare warning : noDoing() : "Don't do it!"; } When I compile these two files I get the following warning ... c:\src\A.java:16 Don't do it! ..which is great if all I want to know is where the offending code is. But not nearly enough if I want to know what it is on the line that is contravening the policy (or policies) that I have specified in my aspect. In the above example it would be even more useful if the warning message was something like ... c:\src\A.java:16 Don't do it! : calling method : void A.doSomething() For large projects where there is an architectural imperative to reduce or completely remove coupling between certain components declare warning/error would be of far greater use if it could return more detailed info to say *why* not just *where* the desired enforcement rules have been broken.
|
resolved fixed
|
684c9c1
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T10:51:36Z
| 2003-07-20T16:53:20Z
|
bridge/src/org/aspectj/bridge/IMessage.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.bridge;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* Wrap message with any associated throwable or source location.
*/
public interface IMessage {
/** no messages */
public static final IMessage[] RA_IMessage = new IMessage[0];
// int values must sync with KINDS order below
public static final Kind INFO = new Kind("info", 10);
public static final Kind DEBUG = new Kind("debug", 20);
public static final Kind WARNING = new Kind("warning", 30);
public static final Kind ERROR = new Kind("error", 40);
public static final Kind FAIL = new Kind("fail", 50);
public static final Kind ABORT = new Kind("abort", 60);
// XXX prefer another Kind to act as selector for "any",
// but can't prohibit creating messages with it.
//public static final Kind ANY = new Kind("any-selector", 0);
/** list of Kind in precedence order. 0 is less than
* IMessage.Kind.COMPARATOR.compareTo(KINDS.get(i), KINDS.get(i + 1))
*/
public static final List KINDS =
Collections.unmodifiableList(
Arrays.asList(
new Kind[] { INFO, DEBUG, WARNING, ERROR, FAIL, ABORT }));
/** @return non-null String with simple message */
String getMessage();
/** @return the kind of this message */
Kind getKind();
/** @return true if this is an error */
boolean isError();
/** @return true if this is a warning */
boolean isWarning();
/** @return true if this is an internal debug message */
boolean isDebug();
/** @return true if this is information for the user */
boolean isInfo();
/** @return true if the process is aborting */
boolean isAbort(); // XXX ambiguous
/** @return true if something failed */
boolean isFailed();
/** @return Throwable associated with this message, or null if none */
Throwable getThrown();
/** @return source location associated with this message, or null if none */
ISourceLocation getSourceLocation();
public static final class Kind implements Comparable {
public static final Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
Kind one = (Kind) o1;
Kind two = (Kind) o2;
if (null == one) {
return (null == two ? 0 : -1);
} else if (null == two) {
return 1;
} else if (one == two) {
return 0;
} else {
return (one.precedence - two.precedence);
}
}
};
/**
* @param kind the Kind floor
* @return false if kind is null or this
* has less precedence than kind,
* true otherwise.
*/
public boolean isSameOrLessThan(Kind kind) {
return (0 >= COMPARATOR.compare(this, kind));
}
public int compareTo(Object other) {
return COMPARATOR.compare(this, other);
}
private final int precedence;
private final String name;
private Kind(String name, int precedence) {
this.name = name;
this.precedence = precedence;
}
public String toString() {
return name;
}
}
}
|
40,534
|
Bug 40534 Declare warning/error output - more detail required.
|
At present the declare warning and declare error functionality of the compiler provides no detailed information about what it is in the user code that has led to the generation of the compile-time warning or error. Consider the following test case... public class A { public static void main(String[] args) { A a = new A(); a.doSomething(); System.out.println("All done"); } void doSomething() { System.out.println("Doing something"); } } // end of class A public aspect MyAspect { pointcut noDoing() : call(* *.doSomething(..)); declare warning : noDoing() : "Don't do it!"; } When I compile these two files I get the following warning ... c:\src\A.java:16 Don't do it! ..which is great if all I want to know is where the offending code is. But not nearly enough if I want to know what it is on the line that is contravening the policy (or policies) that I have specified in my aspect. In the above example it would be even more useful if the warning message was something like ... c:\src\A.java:16 Don't do it! : calling method : void A.doSomething() For large projects where there is an architectural imperative to reduce or completely remove coupling between certain components declare warning/error would be of far greater use if it could return more detailed info to say *why* not just *where* the desired enforcement rules have been broken.
|
resolved fixed
|
684c9c1
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T10:51:36Z
| 2003-07-20T16:53:20Z
|
bridge/src/org/aspectj/bridge/Message.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.bridge;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
/**
* Implement messages.
* This implementation is immutable if ISourceLocation is immutable.
*/
public class Message implements IMessage { // XXX toString or renderer?
private final String message;
private final IMessage.Kind kind;
private final Throwable thrown;
private final ISourceLocation sourceLocation;
/** convenience for constructing failure messages */
public static Message fail(String message, Throwable thrown) {
return new Message(message, IMessage.FAIL, thrown, null);
}
/**
* Create a (compiler) error or warning message
* @param message the String used as the underlying message
* @param sourceLocation the ISourceLocation, if any, associated with this message
* @param isError if true, use IMessage.ERROR; else use IMessage.WARNING
*/
public Message(String message, ISourceLocation location, boolean isError) {
this(message, (isError ? IMessage.ERROR : IMessage.WARNING), null,
location);
}
/**
* Create a message, handling null values for message and kind
* if thrown is not null.
* @param message the String used as the underlying message
* @param kind the IMessage.Kind of message - not null
* @param thrown the Throwable, if any, associated with this message
* @param sourceLocation the ISourceLocation, if any, associated with this message
* @throws IllegalArgumentException if message is null and
* thrown is null or has a null message, or if kind is null
* and thrown is null.
*/
public Message(String message, IMessage.Kind kind, Throwable thrown,
ISourceLocation sourceLocation) {
this.message = message;
this.kind = kind;
this.thrown = thrown;
this.sourceLocation = sourceLocation;
if (null == message) {
if (null != thrown) {
message = thrown.getMessage();
}
if (null == message) {
throw new IllegalArgumentException("null message");
}
}
if (null == kind) {
throw new IllegalArgumentException("null kind");
}
}
/** @return the kind of this message */
public IMessage.Kind getKind() {
return kind;
}
/** @return true if kind == IMessage.ERROR */
public boolean isError() {
return kind == IMessage.ERROR;
}
/** @return true if kind == IMessage.WARNING */
public boolean isWarning() {
return kind == IMessage.WARNING;
}
/** @return true if kind == IMessage.DEBUG */
public boolean isDebug() {
return kind == IMessage.DEBUG;
}
/**
* @return true if kind == IMessage.INFO
*/
public boolean isInfo() {
return kind == IMessage.INFO;
}
/** @return true if kind == IMessage.ABORT */
public boolean isAbort() {
return kind == IMessage.ABORT;
}
/**
* @return true if kind == IMessage.FAIL
*/
public boolean isFailed() {
return kind == IMessage.FAIL;
}
/** @return non-null String with simple message */
final public String getMessage() {
return message;
}
/** @return Throwable associated with this message, or null if none */
final public Throwable getThrown() {
return thrown;
}
/** @return ISourceLocation associated with this message, or null if none */
final public ISourceLocation getSourceLocation() {
return sourceLocation;
}
public String toString() {
return Message.renderToString(this);
}
public static String renderToString(IMessage message) {
ISourceLocation loc = message.getSourceLocation();
String locString = (null == loc ? "" : " at " + loc);
Throwable thrown = message.getThrown();
return message.getKind() + locString + ": " + message.getMessage()
+ (null == thrown ? "" : render(thrown));
}
public static String render(Throwable thrown) { // XXX cf LangUtil.debugStr
if (null == thrown) return "null throwable";
Throwable t = null;
if (thrown instanceof InvocationTargetException) {
t = ((InvocationTargetException)thrown).getTargetException();
} else if (thrown instanceof ClassNotFoundException) {
t = ((ClassNotFoundException) thrown).getException();
}
if (null != t) {
return render(t);
}
StringWriter buf = new StringWriter();
PrintWriter writer = new PrintWriter(buf);
writer.println(" Message rendering thrown=" + thrown.getClass().getName());
writer.println(thrown.getMessage());
thrown.printStackTrace(writer);
try { buf.close(); }
catch (IOException ioe) {}
return buf.getBuffer().toString();
}
}
|
40,534
|
Bug 40534 Declare warning/error output - more detail required.
|
At present the declare warning and declare error functionality of the compiler provides no detailed information about what it is in the user code that has led to the generation of the compile-time warning or error. Consider the following test case... public class A { public static void main(String[] args) { A a = new A(); a.doSomething(); System.out.println("All done"); } void doSomething() { System.out.println("Doing something"); } } // end of class A public aspect MyAspect { pointcut noDoing() : call(* *.doSomething(..)); declare warning : noDoing() : "Don't do it!"; } When I compile these two files I get the following warning ... c:\src\A.java:16 Don't do it! ..which is great if all I want to know is where the offending code is. But not nearly enough if I want to know what it is on the line that is contravening the policy (or policies) that I have specified in my aspect. In the above example it would be even more useful if the warning message was something like ... c:\src\A.java:16 Don't do it! : calling method : void A.doSomething() For large projects where there is an architectural imperative to reduce or completely remove coupling between certain components declare warning/error would be of far greater use if it could return more detailed info to say *why* not just *where* the desired enforcement rules have been broken.
|
resolved fixed
|
684c9c1
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T10:51:36Z
| 2003-07-20T16:53:20Z
|
testing/src/org/aspectj/testing/xml/SoftMessage.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.xml;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import org.aspectj.bridge.*;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.LangUtil;
/**
* Implement messages.
* This implementation is immutable if ISourceLocation is immutable.
*/
public class SoftMessage implements IMessage { // XXX mutable dup of Message
public static String XMLNAME = "message";
public static final File NO_FILE = ISourceLocation.NO_FILE;
private String message;
private IMessage.Kind kind;
private Throwable thrown;
private ISourceLocation sourceLocation;
//private ISourceLocation pseudoSourceLocation; // set directly
// collapse enclosed source location for shorter, property-based xml
private String file;
private int line = Integer.MAX_VALUE;
/** convenience for constructing failure messages */
public static SoftMessage fail(String message, Throwable thrown) {
return new SoftMessage(message, IMessage.FAIL, thrown, null);
}
/**
* Print messages.
* @param messages List of IMessage
*/
public static void writeXml(XMLWriter out, IMessageHolder messages) {
if ((null == out) || (null == messages)
|| (0 == messages.numMessages(null, true))) {
return;
}
List list = messages.getUnmodifiableListView();
for (Iterator iter = list.iterator(); iter.hasNext();) {
writeXml(out, (IMessage) iter.next());
}
}
/**
* Print messages.
* @param messages IMessage[]
*/
public static void writeXml(XMLWriter out, IMessage[] messages) {
if ((null == out) || (null == messages)) {
return;
}
for (int i = 0; i < messages.length; i++) {
writeXml(out, messages[i]);
}
}
/** print message as an element
* @throws IllegalArgumentException if message.getThrown() is not null
*/
public static void writeXml(XMLWriter out, IMessage message) { // XXX short form only, no files
if ((null == out) || (null == message)) {
return;
}
Throwable thrown = message.getThrown();
if (null != thrown) {
String m = "unable to write " + message + " thrown not permitted";
throw new IllegalArgumentException(m);
}
final String elementName = XMLNAME;
out.startElement(elementName, false);
out.printAttribute("kind", message.getKind().toString());
String value = message.getMessage();
if (null != value) {
out.printAttribute("message", value);
}
ISourceLocation sl = message.getSourceLocation();
if (null != sl) {
out.endAttributes();
SoftSourceLocation.writeXml(out, sl);
}
out.endElement(elementName);
}
public SoftMessage() {} // XXX programmatic only
/**
* Create a (compiler) error or warning message
* @param message the String used as the underlying message
* @param sourceLocation the ISourceLocation, if any, associated with this message
* @param isError if true, use IMessage.ERROR; else use IMessage.WARNING
*/
public SoftMessage(String message, ISourceLocation location, boolean isError) {
this(message, (isError ? IMessage.ERROR : IMessage.WARNING), null,
location);
}
/**
* Create a message, handling null values for message and kind
* if thrown is not null.
* @param message the String used as the underlying message
* @param kind the IMessage.Kind of message - not null
* @param thrown the Throwable, if any, associated with this message
* @param sourceLocation the ISourceLocation, if any, associated with this message
* @throws IllegalArgumentException if message is null and
* thrown is null or has a null message, or if kind is null
* and thrown is null.
*/
public SoftMessage(String message, IMessage.Kind kind, Throwable thrown,
ISourceLocation sourceLocation) {
this.message = message;
this.kind = kind;
this.thrown = thrown;
this.sourceLocation = sourceLocation;
if (null == message) {
if (null != thrown) {
message = thrown.getMessage();
}
if (null == message) {
throw new IllegalArgumentException("null message");
}
}
if (null == kind) {
throw new IllegalArgumentException("null kind");
}
}
/** @return the kind of this message */
public IMessage.Kind getKind() {
return kind;
}
/** @return true if kind == IMessage.ERROR */
public boolean isError() {
return kind == IMessage.ERROR;
}
/** @return true if kind == IMessage.WARNING */
public boolean isWarning() {
return kind == IMessage.WARNING;
}
/** @return true if kind == IMessage.DEBUG */
public boolean isDebug() {
return kind == IMessage.DEBUG;
}
/**
* @return true if kind == IMessage.INFO
*/
public boolean isInfo() {
return kind == IMessage.INFO;
}
/** @return true if kind == IMessage.ABORT */
public boolean isAbort() {
return kind == IMessage.ABORT;
}
/**
* @return true if kind == IMessage.FAIL
*/
public boolean isFailed() {
return kind == IMessage.FAIL;
}
/** @return non-null String with simple message */
final public String getMessage() {
return message;
}
/** @return Throwable associated with this message, or null if none */
final public Throwable getThrown() {
return thrown;
}
/**
* This returns any ISourceLocation set or a mock-up
* if file and/or line were set.
* @return ISourceLocation associated with this message,
* a mock-up if file or line is available, or null if none
*/
final public ISourceLocation getSourceLocation() {
if ((null == sourceLocation)
&& ((null != file) || (line != Integer.MAX_VALUE))) {
File f = (null == file ? NO_FILE : new File(file));
int line = (this.line == Integer.MAX_VALUE ? 0 : this.line);
sourceLocation = new SourceLocation(f, line);
}
return sourceLocation;
}
/** set the kind of this message */
public void setMessageKind(IMessage.Kind kind) {
this.kind = (null == kind ? IMessage.ERROR : kind);
}
/** set the file for the underlying source location of this message
* @throws IllegalStateException if source location was set directly
* or indirectly by calling getSourceLocation after setting
* file or line.
*/
public void setFile(String path) {
LangUtil.throwIaxIfFalse(!LangUtil.isEmpty(path), "empty path");
if (null != sourceLocation) {
throw new IllegalStateException("cannot set line after creating source location");
}
this.file = path;
}
/** set the kind of this message */
public void setKindAsString(String kind) {
setMessageKind(MessageUtil.getKind(kind));
}
public void setSourceLocation(ISourceLocation sourceLocation) {
this.sourceLocation = sourceLocation;
}
/**
* Set the line for the underlying source location.
* @throws IllegalStateException if source location was set directly
* or indirectly by calling getSourceLocation after setting
* file or line.
*/
public void setLineAsString(String line) {
if (null != sourceLocation) {
throw new IllegalStateException("cannot set line after creating source location");
}
this.line = Integer.valueOf(line).intValue();
SourceLocation.validLine(this.line);
}
public void setText(String text) {
this.message = (null == text ? "" : text);
}
public String toString() {
StringBuffer result = new StringBuffer();
result.append(getKind().toString());
String messageString = getMessage();
if (!LangUtil.isEmpty(messageString)) {
result.append(messageString);
}
ISourceLocation loc = getSourceLocation();
if ((null != loc) && (loc != ISourceLocation.NO_FILE)) {
result.append(" at " + loc);
}
if (null != thrown) {
result.append(" -- " + LangUtil.renderExceptionShort(thrown));
}
return result.toString();
}
}
|
40,534
|
Bug 40534 Declare warning/error output - more detail required.
|
At present the declare warning and declare error functionality of the compiler provides no detailed information about what it is in the user code that has led to the generation of the compile-time warning or error. Consider the following test case... public class A { public static void main(String[] args) { A a = new A(); a.doSomething(); System.out.println("All done"); } void doSomething() { System.out.println("Doing something"); } } // end of class A public aspect MyAspect { pointcut noDoing() : call(* *.doSomething(..)); declare warning : noDoing() : "Don't do it!"; } When I compile these two files I get the following warning ... c:\src\A.java:16 Don't do it! ..which is great if all I want to know is where the offending code is. But not nearly enough if I want to know what it is on the line that is contravening the policy (or policies) that I have specified in my aspect. In the above example it would be even more useful if the warning message was something like ... c:\src\A.java:16 Don't do it! : calling method : void A.doSomething() For large projects where there is an architectural imperative to reduce or completely remove coupling between certain components declare warning/error would be of far greater use if it could return more detailed info to say *why* not just *where* the desired enforcement rules have been broken.
|
resolved fixed
|
684c9c1
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-07T10:51:36Z
| 2003-07-20T16:53:20Z
|
weaver/src/org/aspectj/weaver/Checker.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver;
import java.util.Collection;
import java.util.Collections;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.Message;
import org.aspectj.weaver.patterns.DeclareErrorOrWarning;
import org.aspectj.weaver.patterns.PerClause;
public class Checker extends ShadowMunger {
private String msg;
private boolean isError;
public Checker(DeclareErrorOrWarning deow) {
super(deow.getPointcut(), deow.getStart(), deow.getEnd(), deow.getSourceContext());
this.msg = deow.getMessage();
this.isError = deow.isError();
}
public ShadowMunger concretize(ResolvedTypeX fromType, World world, PerClause clause) {
pointcut = pointcut.concretize(fromType, 0, this);
return this;
}
public void specializeOn(Shadow shadow) {
throw new RuntimeException("illegal state");
}
public void implementOn(Shadow shadow) {
throw new RuntimeException("illegal state");
}
public boolean match(Shadow shadow, World world) {
if (super.match(shadow, world)) {
world.getMessageHandler().handleMessage(
new Message(msg,
isError ? IMessage.ERROR : IMessage.WARNING,
null,
shadow.getSourceLocation()));
}
return false;
}
public int compareTo(Object other) {
return 0;
}
public Collection getThrownExceptions() { return Collections.EMPTY_LIST; }
}
|
41,123
|
Bug 41123 Weaving failure when using injars
|
Sample run that fails using injars: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj C:\devel\test\libraryWeave>jar cf ajee.jar ajee\testing\*.class C:\devel\test\libraryWeave>ajc -injars ajee.jar model\BusObj.java model\MonitorB usObj.java C:\devel\test\libraryWeave\model\BusObj.java:3 Class must implement the inherite d abstract method ExecutionMonitor.MonitoredItem.ajc$interMethodDispatch2 $ajee_t esting_ExecutionMonitor$record(String, String) public class BusObj { ^^^^^^ 1 error It works in a single pass compilation: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj model\BusObj.jav a model\MonitorBusObj.java C:\devel\test\libraryWeave> Sample source code: package ajee.testing; public aspect ExecutionMonitor { public interface MonitoredItem {} private void MonitoredItem.record(String eventType, String eventName) {} } --- package model; public class BusObj { } --- package model; import ajee.testing.ExecutionMonitor; public aspect MonitorBusObj { declare parents: BusObj implements ExecutionMonitor.MonitoredItem; }
|
resolved fixed
|
3e59745
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T01:23:31Z
| 2003-08-05T05:06:40Z
|
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.ajdt.internal.compiler.lookup;
import java.util.*;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.bridge.IMessage;
import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.*;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
/**
* Overrides the default eclipse LookupEnvironment for two purposes.
*
* 1. To provide some additional phases to <code>completeTypeBindings</code>
* that weave declare parents and inter-type declarations at the correct time.
*
* 2. To intercept the loading of new binary types to ensure the they will have
* declare parents and inter-type declarations woven when appropriate.
*
* @author Jim Hugunin
*/
public class AjLookupEnvironment extends LookupEnvironment {
public EclipseFactory factory = null;
// private boolean builtInterTypesAndPerClauses = false;
private List pendingTypesToWeave = new ArrayList();
private Map dangerousInterfaces = new HashMap();
public AjLookupEnvironment(
ITypeRequestor typeRequestor,
CompilerOptions options,
ProblemReporter problemReporter,
INameEnvironment nameEnvironment) {
super(typeRequestor, options, problemReporter, nameEnvironment);
}
//??? duplicates some of super's code
public void completeTypeBindings() {
// builtInterTypesAndPerClauses = false;
//pendingTypesToWeave = new ArrayList();
stepCompleted = BUILD_TYPE_HIERARCHY;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
units[i].scope.checkAndSetImports();
}
stepCompleted = CHECK_AND_SET_IMPORTS;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
units[i].scope.connectTypeHierarchy();
}
stepCompleted = CONNECT_TYPE_HIERARCHY;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
units[i].scope.buildFieldsAndMethods();
}
// would like to gather up all TypeDeclarations at this point and put them in the factory
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
factory.addSourceTypeBinding(b[j]);
}
}
// need to build inter-type declarations for all AspectDeclarations at this point
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
buildInterTypeAndPerClause(b[j].scope);
}
}
factory.finishTypeMungers();
// now do weaving
Collection typeMungers = factory.getTypeMungers();
Collection declareParents = factory.getDeclareParents();
doPendingWeaves();
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents);
units[i] = null; // release unnecessary reference to the parsed unit
}
stepCompleted = BUILD_FIELDS_AND_METHODS;
lastCompletedUnitIndex = lastUnitIndex;
}
private void doPendingWeaves() {
for (Iterator i = pendingTypesToWeave.iterator(); i.hasNext(); ) {
SourceTypeBinding t = (SourceTypeBinding)i.next();
weaveInterTypeDeclarations(t);
}
pendingTypesToWeave.clear();
}
private void buildInterTypeAndPerClause(ClassScope s) {
TypeDeclaration dec = s.referenceContext;
if (dec instanceof AspectDeclaration) {
((AspectDeclaration)dec).buildInterTypeAndPerClause(s);
}
SourceTypeBinding sourceType = s.referenceContext.binding;
// test classes don't extend aspects
if (sourceType.superclass != null) {
ResolvedTypeX parent = factory.fromEclipse(sourceType.superclass);
if (parent.isAspect() && !(dec instanceof AspectDeclaration)) {
factory.showMessage(IMessage.ERROR, "class \'" + new String(sourceType.sourceName) +
"\' can not extend aspect \'" + parent.getName() + "\'",
factory.fromEclipse(sourceType).getSourceLocation(), null);
}
}
ReferenceBinding[] memberTypes = sourceType.memberTypes;
for (int i = 0, length = memberTypes.length; i < length; i++) {
buildInterTypeAndPerClause(((SourceTypeBinding) memberTypes[i]).scope);
}
}
private void weaveInterTypeDeclarations(CompilationUnitScope unit, Collection typeMungers, Collection declareParents) {
for (int i = 0, length = unit.topLevelTypes.length; i < length; i++) {
weaveInterTypeDeclarations(unit.topLevelTypes[i], typeMungers, declareParents, false);
}
}
private void weaveInterTypeDeclarations(SourceTypeBinding sourceType) {
if (!factory.areTypeMungersFinished()) {
if (!pendingTypesToWeave.contains(sourceType)) pendingTypesToWeave.add(sourceType);
} else {
weaveInterTypeDeclarations(sourceType, factory.getTypeMungers(), factory.getDeclareParents(), true);
}
}
private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, Collection typeMungers, Collection declareParents, boolean skipInners) {
ResolvedTypeX onType = factory.fromEclipse(sourceType);
WeaverStateInfo info = onType.getWeaverState();
if (info != null && !info.isOldStyle()) {
Collection mungers =
onType.getWeaverState().getTypeMungers(onType);
//System.out.println("mungers: " + mungers);
for (Iterator i = mungers.iterator(); i.hasNext(); ) {
ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
EclipseTypeMunger munger = factory.makeEclipseTypeMunger(m);
if (munger.munge(sourceType)) {
if (onType.isInterface() &&
munger.getMunger().needsAccessToTopmostImplementor())
{
if (!onType.getWorld().getCrosscuttingMembersSet().containsAspect(munger.getAspectType())) {
dangerousInterfaces.put(onType,
"implementors of " + onType + " must be woven by " +
munger.getAspectType());
}
}
}
}
return;
}
//System.out.println("dangerousInterfaces: " + dangerousInterfaces);
for (Iterator i = dangerousInterfaces.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
ResolvedTypeX interfaceType = (ResolvedTypeX)entry.getKey();
if (onType.isTopmostImplementor(interfaceType)) {
factory.showMessage(IMessage.ERROR,
onType + ": " + entry.getValue(),
onType.getSourceLocation(), null);
}
}
boolean needOldStyleWarning = (info != null && info.isOldStyle());
onType.clearInterTypeMungers();
for (Iterator i = declareParents.iterator(); i.hasNext();) {
doDeclareParents((DeclareParents)i.next(), sourceType);
}
for (Iterator i = typeMungers.iterator(); i.hasNext();) {
EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
if (munger.matches(onType)) {
if (needOldStyleWarning) {
factory.showMessage(IMessage.WARNING,
"The class for " + onType + " should be recompiled with ajc-1.1.1 for best results",
onType.getSourceLocation(), null);
needOldStyleWarning = false;
}
onType.addInterTypeMunger(munger);
}
}
for (Iterator i = onType.getInterTypeMungers().iterator(); i.hasNext();) {
EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
//System.out.println("applying: " + munger + " to " + new String(sourceType.sourceName));
munger.munge(sourceType);
}
if (skipInners) return;
ReferenceBinding[] memberTypes = sourceType.memberTypes;
for (int i = 0, length = memberTypes.length; i < length; i++) {
if (memberTypes[i] instanceof SourceTypeBinding) {
weaveInterTypeDeclarations((SourceTypeBinding) memberTypes[i], typeMungers, declareParents, false);
}
}
}
private void doDeclareParents(DeclareParents declareParents, SourceTypeBinding sourceType) {
List newParents = declareParents.findMatchingNewParents(factory.fromEclipse(sourceType));
if (!newParents.isEmpty()) {
for (Iterator i = newParents.iterator(); i.hasNext(); ) {
ResolvedTypeX parent = (ResolvedTypeX)i.next();
addParent(sourceType, parent);
}
}
}
private void addParent(SourceTypeBinding sourceType, ResolvedTypeX parent) {
ReferenceBinding parentBinding = (ReferenceBinding)factory.makeTypeBinding(parent);
if (parentBinding.isClass()) {
sourceType.superclass = parentBinding;
} else {
ReferenceBinding[] oldI = sourceType.superInterfaces;
ReferenceBinding[] newI;
if (oldI == null) {
newI = new ReferenceBinding[1];
newI[0] = parentBinding;
} else {
int n = oldI.length;
newI = new ReferenceBinding[n+1];
System.arraycopy(oldI, 0, newI, 0, n);
newI[n] = parentBinding;
}
sourceType.superInterfaces = newI;
}
}
private List pendingTypesToFinish = new ArrayList();
boolean inBinaryTypeCreation = false;
public BinaryTypeBinding createBinaryTypeFrom(
IBinaryType binaryType,
PackageBinding packageBinding,
boolean needFieldsAndMethods)
{
if (inBinaryTypeCreation) {
BinaryTypeBinding ret = super.createBinaryTypeFrom(
binaryType,
packageBinding,
needFieldsAndMethods);
pendingTypesToFinish.add(ret);
return ret;
}
inBinaryTypeCreation = true;
try {
BinaryTypeBinding ret = super.createBinaryTypeFrom(
binaryType,
packageBinding,
needFieldsAndMethods);
weaveInterTypeDeclarations(ret);
return ret;
} finally {
inBinaryTypeCreation = false;
if (!pendingTypesToFinish.isEmpty()) {
for (Iterator i = pendingTypesToFinish.iterator(); i.hasNext(); ) {
weaveInterTypeDeclarations((BinaryTypeBinding)i.next());
}
pendingTypesToFinish.clear();
}
}
}
}
|
41,123
|
Bug 41123 Weaving failure when using injars
|
Sample run that fails using injars: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj C:\devel\test\libraryWeave>jar cf ajee.jar ajee\testing\*.class C:\devel\test\libraryWeave>ajc -injars ajee.jar model\BusObj.java model\MonitorB usObj.java C:\devel\test\libraryWeave\model\BusObj.java:3 Class must implement the inherite d abstract method ExecutionMonitor.MonitoredItem.ajc$interMethodDispatch2 $ajee_t esting_ExecutionMonitor$record(String, String) public class BusObj { ^^^^^^ 1 error It works in a single pass compilation: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj model\BusObj.jav a model\MonitorBusObj.java C:\devel\test\libraryWeave> Sample source code: package ajee.testing; public aspect ExecutionMonitor { public interface MonitoredItem {} private void MonitoredItem.record(String eventType, String eventName) {} } --- package model; public class BusObj { } --- package model; import ajee.testing.ExecutionMonitor; public aspect MonitorBusObj { declare parents: BusObj implements ExecutionMonitor.MonitoredItem; }
|
resolved fixed
|
3e59745
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T01:23:31Z
| 2003-08-05T05:06:40Z
|
tests/bugs/moreInterfaceLibrary/model/BusObj.java
| |
41,123
|
Bug 41123 Weaving failure when using injars
|
Sample run that fails using injars: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj C:\devel\test\libraryWeave>jar cf ajee.jar ajee\testing\*.class C:\devel\test\libraryWeave>ajc -injars ajee.jar model\BusObj.java model\MonitorB usObj.java C:\devel\test\libraryWeave\model\BusObj.java:3 Class must implement the inherite d abstract method ExecutionMonitor.MonitoredItem.ajc$interMethodDispatch2 $ajee_t esting_ExecutionMonitor$record(String, String) public class BusObj { ^^^^^^ 1 error It works in a single pass compilation: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj model\BusObj.jav a model\MonitorBusObj.java C:\devel\test\libraryWeave> Sample source code: package ajee.testing; public aspect ExecutionMonitor { public interface MonitoredItem {} private void MonitoredItem.record(String eventType, String eventName) {} } --- package model; public class BusObj { } --- package model; import ajee.testing.ExecutionMonitor; public aspect MonitorBusObj { declare parents: BusObj implements ExecutionMonitor.MonitoredItem; }
|
resolved fixed
|
3e59745
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T01:23:31Z
| 2003-08-05T05:06:40Z
|
tests/bugs/moreInterfaceLibrary/model/MonitorBusObj.java
| |
41,123
|
Bug 41123 Weaving failure when using injars
|
Sample run that fails using injars: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj C:\devel\test\libraryWeave>jar cf ajee.jar ajee\testing\*.class C:\devel\test\libraryWeave>ajc -injars ajee.jar model\BusObj.java model\MonitorB usObj.java C:\devel\test\libraryWeave\model\BusObj.java:3 Class must implement the inherite d abstract method ExecutionMonitor.MonitoredItem.ajc$interMethodDispatch2 $ajee_t esting_ExecutionMonitor$record(String, String) public class BusObj { ^^^^^^ 1 error It works in a single pass compilation: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj model\BusObj.jav a model\MonitorBusObj.java C:\devel\test\libraryWeave> Sample source code: package ajee.testing; public aspect ExecutionMonitor { public interface MonitoredItem {} private void MonitoredItem.record(String eventType, String eventName) {} } --- package model; public class BusObj { } --- package model; import ajee.testing.ExecutionMonitor; public aspect MonitorBusObj { declare parents: BusObj implements ExecutionMonitor.MonitoredItem; }
|
resolved fixed
|
3e59745
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T01:23:31Z
| 2003-08-05T05:06:40Z
|
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.bcel;
import java.lang.reflect.Modifier;
import java.util.Iterator;
import java.util.Set;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.FieldGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.Type;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.NameMangler;
import org.aspectj.weaver.NewConstructorTypeMunger;
import org.aspectj.weaver.NewFieldTypeMunger;
import org.aspectj.weaver.NewMethodTypeMunger;
import org.aspectj.weaver.NewParentTypeMunger;
import org.aspectj.weaver.PerObjectInterfaceTypeMunger;
import org.aspectj.weaver.PrivilegedAccessMunger;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.ResolvedTypeX;
import org.aspectj.weaver.TypeX;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.patterns.Pointcut;
//XXX addLazyMethodGen is probably bad everywhere
public class BcelTypeMunger extends ConcreteTypeMunger {
public BcelTypeMunger(ResolvedTypeMunger munger, ResolvedTypeX aspectType) {
super(munger, aspectType);
}
public String toString() {
return "(BcelTypeMunger " + getMunger() + ")";
}
public boolean munge(BcelClassWeaver weaver) {
boolean changed = false;
if (munger.getKind() == ResolvedTypeMunger.Field) {
changed = mungeNewField(weaver, (NewFieldTypeMunger)munger);
} else if (munger.getKind() == ResolvedTypeMunger.Method) {
changed = mungeNewMethod(weaver, (NewMethodTypeMunger)munger);
} else if (munger.getKind() == ResolvedTypeMunger.PerObjectInterface) {
changed = mungePerObjectInterface(weaver, (PerObjectInterfaceTypeMunger)munger);
} else if (munger.getKind() == ResolvedTypeMunger.PrivilegedAccess) {
changed = mungePrivilegedAccess(weaver, (PrivilegedAccessMunger)munger);
} else if (munger.getKind() == ResolvedTypeMunger.Constructor) {
changed = mungeNewConstructor(weaver, (NewConstructorTypeMunger)munger);
} else if (munger.getKind() == ResolvedTypeMunger.Parent) {
changed = mungeNewParent(weaver, (NewParentTypeMunger)munger);
} else {
throw new RuntimeException("unimplemented");
}
if (changed && munger.changesPublicSignature()) {
WeaverStateInfo info =
weaver.getLazyClassGen().getOrCreateWeaverStateInfo();
info.addConcreteMunger(this);
}
return changed;
}
private boolean mungeNewParent(BcelClassWeaver weaver, NewParentTypeMunger munger) {
LazyClassGen gen = weaver.getLazyClassGen();
ResolvedTypeX newParent = munger.getNewParent();
if (newParent.isClass()) {
//gen.setSuperClass(newParent);
} else {
gen.addInterface(newParent);
}
return true;
}
private boolean mungePrivilegedAccess(
BcelClassWeaver weaver,
PrivilegedAccessMunger munger)
{
LazyClassGen gen = weaver.getLazyClassGen();
ResolvedMember member = munger.getMember();
ResolvedTypeX onType = weaver.getWorld().resolve(member.getDeclaringType());
//System.out.println("munging: " + gen + " with " + member);
if (onType.equals(gen.getType())) {
if (member.getKind() == Member.FIELD) {
//System.out.println("matched: " + gen);
addFieldGetter(gen, member,
AjcMemberMaker.privilegedAccessMethodForFieldGet(aspectType, member));
addFieldSetter(gen, member,
AjcMemberMaker.privilegedAccessMethodForFieldSet(aspectType, member));
return true;
} else if (member.getKind() == Member.METHOD) {
addMethodDispatch(gen, member,
AjcMemberMaker.privilegedAccessMethodForMethod(aspectType, member));
return true;
} else if (member.getKind() == Member.CONSTRUCTOR) {
for (Iterator i = gen.getMethodGens().iterator(); i.hasNext(); ) {
LazyMethodGen m = (LazyMethodGen)i.next();
if (m.getMemberView() != null && m.getMemberView().getKind() == Member.CONSTRUCTOR) {
// m.getMemberView().equals(member)) {
m.forcePublic();
//return true;
}
}
return true;
//throw new BCException("no match for " + member + " in " + gen);
} else if (member.getKind() == Member.STATIC_INITIALIZATION) {
gen.forcePublic();
return true;
} else {
throw new RuntimeException("unimplemented");
}
}
return false;
}
private void addFieldGetter(
LazyClassGen gen,
ResolvedMember field,
ResolvedMember accessMethod)
{
LazyMethodGen mg = makeMethodGen(gen, accessMethod);
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
if (field.isStatic()) {
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
BcelWorld.makeBcelType(field.getType()), Constants.GETSTATIC));
} else {
il.append(fact.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
BcelWorld.makeBcelType(field.getType()), Constants.GETFIELD));
}
il.append(fact.createReturn(BcelWorld.makeBcelType(field.getType())));
mg.getBody().insert(il);
gen.addMethodGen(mg);
}
private void addFieldSetter(
LazyClassGen gen,
ResolvedMember field,
ResolvedMember accessMethod)
{
LazyMethodGen mg = makeMethodGen(gen, accessMethod);
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
Type fieldType = BcelWorld.makeBcelType(field.getType());
if (field.isStatic()) {
il.append(fact.createLoad(fieldType, 0));
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
fieldType, Constants.PUTSTATIC));
} else {
il.append(fact.ALOAD_0);
il.append(fact.createLoad(fieldType, 1));
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
fieldType, Constants.PUTFIELD));
}
il.append(fact.createReturn(Type.VOID));
mg.getBody().insert(il);
gen.addMethodGen(mg);
}
private void addMethodDispatch(
LazyClassGen gen,
ResolvedMember method,
ResolvedMember accessMethod)
{
LazyMethodGen mg = makeMethodGen(gen, accessMethod);
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
//Type fieldType = BcelWorld.makeBcelType(field.getType());
Type[] paramTypes = BcelWorld.makeBcelTypes(method.getParameterTypes());
int pos = 0;
if (!method.isStatic()) {
il.append(fact.ALOAD_0);
pos++;
}
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
il.append(fact.createLoad(paramType, pos));
pos+=paramType.getSize();
}
il.append(Utility.createInvoke(fact, (BcelWorld)aspectType.getWorld(),
method));
il.append(fact.createReturn(BcelWorld.makeBcelType(method.getReturnType())));
mg.getBody().insert(il);
gen.addMethodGen(mg);
}
private LazyMethodGen makeMethodGen(LazyClassGen gen, ResolvedMember member) {
return new LazyMethodGen(
member.getModifiers(),
BcelWorld.makeBcelType(member.getReturnType()),
member.getName(),
BcelWorld.makeBcelTypes(member.getParameterTypes()),
TypeX.getNames(member.getExceptions()),
gen);
}
private FieldGen makeFieldGen(LazyClassGen gen, ResolvedMember member) {
return new FieldGen(
member.getModifiers(),
BcelWorld.makeBcelType(member.getReturnType()),
member.getName(),
gen.getConstantPoolGen());
}
private boolean mungePerObjectInterface(
BcelClassWeaver weaver,
PerObjectInterfaceTypeMunger munger)
{
LazyClassGen gen = weaver.getLazyClassGen();
if (couldMatch(gen.getBcelObjectType(), munger.getTestPointcut())) {
FieldGen fg = makeFieldGen(gen,
AjcMemberMaker.perObjectField(gen.getType(), aspectType));
gen.addField(fg.getField());
Type fieldType = BcelWorld.makeBcelType(aspectType);
LazyMethodGen mg = new LazyMethodGen(
Modifier.PUBLIC,
fieldType,
NameMangler.perObjectInterfaceGet(aspectType),
new Type[0], new String[0],
gen);
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
il.append(fact.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.GETFIELD));
il.append(fact.createReturn(fieldType));
mg.getBody().insert(il);
gen.addMethodGen(mg);
LazyMethodGen mg1 = new LazyMethodGen(
Modifier.PUBLIC,
Type.VOID,
NameMangler.perObjectInterfaceSet(aspectType),
new Type[]{fieldType,}, new String[0],
gen);
InstructionList il1 = new InstructionList();
il1.append(fact.ALOAD_0);
il1.append(fact.createLoad(fieldType, 1));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTFIELD));
il1.append(fact.createReturn(Type.VOID));
mg1.getBody().insert(il1);
gen.addMethodGen(mg1);
gen.addInterface(munger.getInterfaceType());
return true;
} else {
return false;
}
}
private boolean couldMatch(
BcelObjectType bcelObjectType,
Pointcut pointcut) {
return !bcelObjectType.isInterface();
}
private boolean mungeNewMethod(BcelClassWeaver weaver, NewMethodTypeMunger munger) {
ResolvedMember signature = munger.getSignature();
ResolvedMember dispatchMethod = munger.getDispatchMethod(aspectType);
LazyClassGen gen = weaver.getLazyClassGen();
ResolvedTypeX onType = weaver.getWorld().resolve(signature.getDeclaringType());
boolean onInterface = onType.isInterface();
if (onType.equals(gen.getType())) {
ResolvedMember introMethod =
AjcMemberMaker.interMethod(signature, aspectType, onInterface);
LazyMethodGen mg = makeMethodGen(gen, introMethod);
if (!onInterface && !Modifier.isAbstract(introMethod.getModifiers())) {
InstructionList body = mg.getBody();
InstructionFactory fact = gen.getFactory();
int pos = 0;
if (!signature.isStatic()) {
body.append(fact.createThis());
pos++;
}
Type[] paramTypes = BcelWorld.makeBcelTypes(introMethod.getParameterTypes());
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
body.append(fact.createLoad(paramType, pos));
pos+=paramType.getSize();
}
body.append(Utility.createInvoke(fact, weaver.getWorld(), dispatchMethod));
body.append(fact.createReturn(BcelWorld.makeBcelType(introMethod.getReturnType())));
} else {
//??? this is okay
//if (!(mg.getBody() == null)) throw new RuntimeException("bas");
}
// XXX make sure to check that we set exceptions properly on this guy.
weaver.addLazyMethodGen(mg);
addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled());
return true;
} else if (onInterface && gen.getType().isTopmostImplementor(onType) &&
!Modifier.isAbstract(signature.getModifiers()))
{
ResolvedMember introMethod =
AjcMemberMaker.interMethod(signature, aspectType, false);
LazyMethodGen mg = makeMethodGen(gen, introMethod);
//
Type[] paramTypes = BcelWorld.makeBcelTypes(introMethod.getParameterTypes());
Type returnType = BcelWorld.makeBcelType(introMethod.getReturnType());
InstructionList body = mg.getBody();
InstructionFactory fact = gen.getFactory();
int pos = 0;
if (!introMethod.isStatic()) {
body.append(fact.createThis());
pos++;
}
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
body.append(fact.createLoad(paramType, pos));
pos+=paramType.getSize();
}
body.append(Utility.createInvoke(fact, weaver.getWorld(), dispatchMethod));
body.append(fact.createReturn(returnType));
mg.definingType = onType;
weaver.addOrReplaceLazyMethodGen(mg);
addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled());
return true;
} else {
return false;
}
}
private void addNeededSuperCallMethods(
BcelClassWeaver weaver,
ResolvedTypeX onType,
Set neededSuperCalls)
{
LazyClassGen gen = weaver.getLazyClassGen();
for (Iterator iter = neededSuperCalls.iterator(); iter.hasNext(); ) {
ResolvedMember superMethod = (ResolvedMember) iter.next();
if (weaver.addDispatchTarget(superMethod)) {
//System.err.println("super type: " + superMethod.getDeclaringType() + ", " + gen.getType());
boolean isSuper = !superMethod.getDeclaringType().equals(gen.getType());
String dispatchName;
if (isSuper) dispatchName = NameMangler.superDispatchMethod(onType, superMethod.getName());
else dispatchName = NameMangler.protectedDispatchMethod(onType, superMethod.getName());
LazyMethodGen dispatcher = makeDispatcher(gen, dispatchName, superMethod, weaver.getWorld(), isSuper);
weaver.addLazyMethodGen(dispatcher);
}
}
}
private boolean mungeNewConstructor(
BcelClassWeaver weaver,
NewConstructorTypeMunger newConstructorTypeMunger)
{
final LazyClassGen currentClass = weaver.getLazyClassGen();
final InstructionFactory fact = currentClass.getFactory();
ResolvedMember newConstructorMember = newConstructorTypeMunger.getSyntheticConstructor();
TypeX onType = newConstructorMember.getDeclaringType();
if (! onType.equals(currentClass.getType())) return false;
ResolvedMember explicitConstructor = newConstructorTypeMunger.getExplicitConstructor();
//int declaredParameterCount = newConstructorTypeMunger.getDeclaredParameterCount();
LazyMethodGen freshConstructor =
makeMethodGen(currentClass, newConstructorMember);
currentClass.addMethodGen(freshConstructor);
//weaver.addLazyMethodGen(freshConstructor);
InstructionList body = freshConstructor.getBody();
// add to body: push arts for call to pre, from actual args starting at 1 (skipping this), going to
// declared argcount + 1
TypeX[] declaredParams = newConstructorTypeMunger.getSignature().getParameterTypes();
Type[] paramTypes = freshConstructor.getArgumentTypes();
int frameIndex = 1;
for (int i = 0, len = declaredParams.length; i < len; i++) {
body.append(fact.createLoad(paramTypes[i], frameIndex));
frameIndex += paramTypes[i].getSize();
}
// do call to pre
Member preMethod = AjcMemberMaker.preIntroducedConstructor(aspectType, onType, declaredParams);
body.append(Utility.createInvoke(fact, null, preMethod));
// create a local, and store return pre stuff into it.
int arraySlot = freshConstructor.allocateLocal(1);
body.append(fact.createStore(Type.OBJECT, arraySlot));
// put this on the stack
body.append(fact.ALOAD_0);
// unpack pre args onto stack
TypeX[] superParamTypes = explicitConstructor.getParameterTypes();
for (int i = 0, len = superParamTypes.length; i < len; i++) {
body.append(fact.createLoad(Type.OBJECT, arraySlot));
body.append(Utility.createConstant(fact, i));
body.append(fact.createArrayLoad(Type.OBJECT));
body.append(Utility.createConversion(fact, Type.OBJECT, BcelWorld.makeBcelType(superParamTypes[i])));
}
// call super/this
body.append(Utility.createInvoke(fact, null, explicitConstructor));
// put this back on the stack
body.append(fact.ALOAD_0);
// unpack params onto stack
Member postMethod = AjcMemberMaker.postIntroducedConstructor(aspectType, onType, declaredParams);
TypeX[] postParamTypes = postMethod.getParameterTypes();
for (int i = 1, len = postParamTypes.length; i < len; i++) {
body.append(fact.createLoad(Type.OBJECT, arraySlot));
body.append(Utility.createConstant(fact, superParamTypes.length + i-1));
body.append(fact.createArrayLoad(Type.OBJECT));
body.append(Utility.createConversion(fact, Type.OBJECT, BcelWorld.makeBcelType(postParamTypes[i])));
}
// call post
body.append(Utility.createInvoke(fact, null, postMethod));
// don't forget to return!!
body.append(fact.RETURN);
return true;
}
private static LazyMethodGen makeDispatcher(
LazyClassGen onGen,
String dispatchName,
ResolvedMember superMethod,
BcelWorld world,
boolean isSuper)
{
Type[] paramTypes = BcelWorld.makeBcelTypes(superMethod.getParameterTypes());
Type returnType = BcelWorld.makeBcelType(superMethod.getReturnType());
int modifiers = Modifier.PUBLIC;
if (onGen.isInterface()) modifiers |= Modifier.ABSTRACT;
LazyMethodGen mg =
new LazyMethodGen(
modifiers,
returnType,
dispatchName,
paramTypes,
TypeX.getNames(superMethod.getExceptions()),
onGen);
InstructionList body = mg.getBody();
if (onGen.isInterface()) return mg;
// assert (!superMethod.isStatic())
InstructionFactory fact = onGen.getFactory();
int pos = 0;
body.append(fact.createThis());
pos++;
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
body.append(fact.createLoad(paramType, pos));
pos+=paramType.getSize();
}
if (isSuper) {
body.append(Utility.createSuperInvoke(fact, world, superMethod));
} else {
body.append(Utility.createInvoke(fact, world, superMethod));
}
body.append(fact.createReturn(returnType));
return mg;
}
private boolean mungeNewField(BcelClassWeaver weaver, NewFieldTypeMunger munger) {
ResolvedMember initMethod = munger.getInitMethod(aspectType);
LazyClassGen gen = weaver.getLazyClassGen();
ResolvedMember field = munger.getSignature();
ResolvedTypeX onType = weaver.getWorld().resolve(field.getDeclaringType());
boolean onInterface = onType.isInterface();
if (onType.equals(gen.getType())) {
if (onInterface) {
LazyMethodGen mg = makeMethodGen(gen,
AjcMemberMaker.interFieldInterfaceGetter(field, onType, aspectType));
gen.addMethodGen(mg);
LazyMethodGen mg1 = makeMethodGen(gen,
AjcMemberMaker.interFieldInterfaceSetter(field, onType, aspectType));
gen.addMethodGen(mg1);
} else {
weaver.addInitializer(this);
FieldGen fg = makeFieldGen(gen,
AjcMemberMaker.interFieldClassField(field, aspectType));
gen.addField(fg.getField());
}
return true;
} else if (onInterface && gen.getType().isTopmostImplementor(onType)) {
// wew know that we can't be static since we don't allow statics on interfaces
if (field.isStatic()) throw new RuntimeException("unimplemented");
weaver.addInitializer(this);
//System.err.println("impl body on " + gen.getType() + " for " + munger);
Type fieldType = BcelWorld.makeBcelType(field.getType());
FieldGen fg = makeFieldGen(gen,
AjcMemberMaker.interFieldInterfaceField(field, onType, aspectType));
gen.addField(fg.getField());
//this uses a shadow munger to add init method to constructors
//weaver.getShadowMungers().add(makeInitCallShadowMunger(initMethod));
LazyMethodGen mg = makeMethodGen(gen,
AjcMemberMaker.interFieldInterfaceGetter(field, gen.getType(), aspectType));
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
if (field.isStatic()) {
il.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.GETSTATIC));
} else {
il.append(fact.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.GETFIELD));
}
il.append(fact.createReturn(fieldType));
mg.getBody().insert(il);
gen.addMethodGen(mg);
LazyMethodGen mg1 = makeMethodGen(gen,
AjcMemberMaker.interFieldInterfaceSetter(field, gen.getType(), aspectType));
InstructionList il1 = new InstructionList();
if (field.isStatic()) {
il1.append(fact.createLoad(fieldType, 0));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTSTATIC));
} else {
il1.append(fact.ALOAD_0);
il1.append(fact.createLoad(fieldType, 1));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTFIELD));
}
il1.append(fact.createReturn(Type.VOID));
mg1.getBody().insert(il1);
gen.addMethodGen(mg1);
return true;
} else {
return false;
}
}
}
|
41,123
|
Bug 41123 Weaving failure when using injars
|
Sample run that fails using injars: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj C:\devel\test\libraryWeave>jar cf ajee.jar ajee\testing\*.class C:\devel\test\libraryWeave>ajc -injars ajee.jar model\BusObj.java model\MonitorB usObj.java C:\devel\test\libraryWeave\model\BusObj.java:3 Class must implement the inherite d abstract method ExecutionMonitor.MonitoredItem.ajc$interMethodDispatch2 $ajee_t esting_ExecutionMonitor$record(String, String) public class BusObj { ^^^^^^ 1 error It works in a single pass compilation: C:\devel\test\libraryWeave>ajc ajee\testing\ExecutionMonitor.aj model\BusObj.jav a model\MonitorBusObj.java C:\devel\test\libraryWeave> Sample source code: package ajee.testing; public aspect ExecutionMonitor { public interface MonitoredItem {} private void MonitoredItem.record(String eventType, String eventName) {} } --- package model; public class BusObj { } --- package model; import ajee.testing.ExecutionMonitor; public aspect MonitorBusObj { declare parents: BusObj implements ExecutionMonitor.MonitoredItem; }
|
resolved fixed
|
3e59745
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T01:23:31Z
| 2003-08-05T05:06:40Z
|
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.bcel;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.Attribute;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.classfile.Method;
import org.apache.bcel.generic.BranchHandle;
import org.apache.bcel.generic.BranchInstruction;
import org.apache.bcel.generic.CPInstruction;
import org.apache.bcel.generic.ClassGenException;
import org.apache.bcel.generic.CodeExceptionGen;
import org.apache.bcel.generic.Instruction;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.InstructionTargeter;
import org.apache.bcel.generic.LineNumberGen;
import org.apache.bcel.generic.LocalVariableGen;
import org.apache.bcel.generic.LocalVariableInstruction;
import org.apache.bcel.generic.MethodGen;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.Select;
import org.apache.bcel.generic.Type;
import org.aspectj.bridge.IMessage;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.Member;
import org.aspectj.weaver.ResolvedTypeX;
/**
* A LazyMethodGen should be treated as a MethodGen. It's our way of abstracting over the
* low-level Method objects. It converts through {@link MethodGen} to create
* and to serialize, but that's it.
*
* <p> At any rate, there are two ways to create LazyMethodGens.
* One is from a method, which
* does work through MethodGen to do the correct thing.
* The other is the creation of a completely empty
* LazyMethodGen, and it is used when we're constructing code from scratch.
*
* <p> We stay away from targeters for rangey things like Shadows and Exceptions.
*/
public final class LazyMethodGen {
private int accessFlags;
private final Type returnType;
private final String name;
private final Type[] argumentTypes;
//private final String[] argumentNames;
private final String[] declaredExceptions;
private final InstructionList body; // leaving null for abstracts
private final Attribute[] attributes;
private final LazyClassGen enclosingClass;
private final BcelMethod memberView;
private int maxLocals;
private boolean canInline = true;
private boolean hasExceptionHandlers;
/**
* only used by {@link BcelClassWeaver}
*/
List /*ShadowMungers*/ matchedShadows;
// Used for interface introduction
// this is the type of the interface the method is technically on
public ResolvedTypeX definingType = null;
public LazyMethodGen(
int accessFlags,
Type returnType,
String name,
Type[] paramTypes,
String[] declaredExceptions,
LazyClassGen enclosingClass)
{
this.memberView = null; // ??? should be okay, since constructed ones aren't woven into
this.accessFlags = accessFlags;
this.returnType = returnType;
this.name = name;
this.argumentTypes = paramTypes;
//this.argumentNames = Utility.makeArgNames(paramTypes.length);
this.declaredExceptions = declaredExceptions;
if (!Modifier.isAbstract(accessFlags)) {
body = new InstructionList();
setMaxLocals(calculateMaxLocals());
} else {
body = null;
}
this.attributes = new Attribute[0];
this.enclosingClass = enclosingClass;
assertGoodBody();
}
private int calculateMaxLocals() {
int ret = 0;
if (!Modifier.isStatic(accessFlags)) ret++;
for (int i = 0, len = argumentTypes.length; i < len; i++) {
ret += argumentTypes[i].getSize();
}
return ret;
}
// build from an existing method
public LazyMethodGen(Method m, LazyClassGen enclosingClass) {
this.enclosingClass = enclosingClass;
if (!(m.isAbstract() || m.isNative()) && m.getCode() == null) {
throw new RuntimeException("bad non-abstract method with no code: " + m + " on " + enclosingClass);
}
if ((m.isAbstract() || m.isNative()) && m.getCode() != null) {
throw new RuntimeException("bad abstract method with code: " + m + " on " + enclosingClass);
}
MethodGen gen = new MethodGen(m, enclosingClass.getName(), enclosingClass.getConstantPoolGen());
this.memberView = new BcelMethod(enclosingClass.getBcelObjectType(), m);
this.accessFlags = gen.getAccessFlags();
this.returnType = gen.getReturnType();
this.name = gen.getName();
this.argumentTypes = gen.getArgumentTypes();
//this.argumentNames = gen.getArgumentNames();
this.declaredExceptions = gen.getExceptions();
this.attributes = gen.getAttributes();
this.maxLocals = gen.getMaxLocals();
if (gen.isAbstract() || gen.isNative()) {
body = null;
} else {
body = gen.getInstructionList();
unpackHandlers(gen);
unpackLineNumbers(gen);
unpackLocals(gen);
}
assertGoodBody();
}
// XXX we're relying on the javac promise I've just made up that we won't have an early exception
// in the list mask a later exception: That is, for two exceptions E and F,
// if E preceeds F, then either E \cup F = {}, or E \nonstrictsubset F. So when we add F,
// we add it on the _OUTSIDE_ of any handlers that share starts or ends with it.
// with that in mind, we merrily go adding ranges for exceptions.
private void unpackHandlers(MethodGen gen) {
CodeExceptionGen[] exns = gen.getExceptionHandlers();
if (exns != null) {
int len = exns.length;
if (len > 0) hasExceptionHandlers = true;
int priority = len - 1;
for (int i = 0; i < len; i++, priority--) {
CodeExceptionGen exn = exns[i];
InstructionHandle start =
Range.genStart(
body,
getOutermostExceptionStart(exn.getStartPC()));
InstructionHandle end = Range.genEnd(body, getOutermostExceptionEnd(exn.getEndPC()));
// this doesn't necessarily handle overlapping correctly!!!
ExceptionRange er =
new ExceptionRange(
body,
exn.getCatchType() == null
? null
: BcelWorld.fromBcel(exn.getCatchType()),
priority);
er.associateWithTargets(start, end, exn.getHandlerPC());
exn.setStartPC(null); // also removes from target
exn.setEndPC(null); // also removes from target
exn.setHandlerPC(null); // also removes from target
}
gen.removeExceptionHandlers();
}
}
private InstructionHandle getOutermostExceptionStart(InstructionHandle ih) {
while (true) {
if (ExceptionRange.isExceptionStart(ih.getPrev())) {
ih = ih.getPrev();
} else {
return ih;
}
}
}
private InstructionHandle getOutermostExceptionEnd(InstructionHandle ih) {
while (true) {
if (ExceptionRange.isExceptionEnd(ih.getNext())) {
ih = ih.getNext();
} else {
return ih;
}
}
}
private void unpackLineNumbers(MethodGen gen) {
LineNumberTag lr = null;
for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
InstructionTargeter[] targeters = ih.getTargeters();
if (targeters != null) {
for (int i = targeters.length - 1; i >= 0; i--) {
InstructionTargeter targeter = targeters[i];
if (targeter instanceof LineNumberGen) {
LineNumberGen lng = (LineNumberGen) targeter;
lng.updateTarget(ih, null);
lr = new LineNumberTag(lng.getSourceLine());
}
}
}
if (lr != null) {
ih.addTargeter(lr);
}
}
gen.removeLineNumbers();
}
private void unpackLocals(MethodGen gen) {
Set locals = new HashSet();
for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
InstructionTargeter[] targeters = ih.getTargeters();
List ends = new ArrayList(0);
if (targeters != null) {
for (int i = targeters.length - 1; i >= 0; i--) {
InstructionTargeter targeter = targeters[i];
if (targeter instanceof LocalVariableGen) {
LocalVariableGen lng = (LocalVariableGen) targeter;
LocalVariableTag lr = new LocalVariableTag(BcelWorld.fromBcel(lng.getType()), lng.getName(), lng.getIndex());
if (lng.getStart() == ih) {
lng.setStart(null);
locals.add(lr);
} else {
lng.setEnd(null);
ends.add(lr);
}
}
}
}
for (Iterator i = locals.iterator(); i.hasNext(); ) {
ih.addTargeter((LocalVariableTag) i.next());
}
locals.removeAll(ends);
}
gen.removeLocalVariables();
}
// ===============
public int allocateLocal(Type type) {
return allocateLocal(type.getSize());
}
public int allocateLocal(int slots) {
int max = getMaxLocals();
setMaxLocals(max + slots);
return max;
}
public Method getMethod() {
try {
MethodGen gen = pack();
return gen.getMethod();
} catch (ClassGenException e) {
enclosingClass.getBcelObjectType().getResolvedTypeX().getWorld().showMessage(
IMessage.ERROR, "problem generating method " +
this.getClassName() + "." + this.getName() + ": " + e.getMessage(),
this.getMemberView() == null ? null : this.getMemberView().getSourceLocation(), null);
throw e;
}
}
// =============================
public String toString() {
return toLongString();
}
public String toShortString() {
org.apache.bcel.classfile.Utility util = null; // EVIL!
String access = util.accessToString(getAccessFlags());
StringBuffer buf = new StringBuffer();
if (!access.equals("")) {
buf.append(access);
buf.append(" ");
}
buf.append(util.signatureToString(getReturnType().getSignature(), true));
buf.append(" ");
buf.append(getName());
buf.append("(");
{
int len = argumentTypes.length;
if (len > 0) {
buf.append(util.signatureToString(argumentTypes[0].getSignature(), true));
for (int i = 1; i < argumentTypes.length; i++) {
buf.append(", ");
buf.append(util.signatureToString(argumentTypes[i].getSignature(), true));
}
}
}
buf.append(")");
{
int len = declaredExceptions != null ? declaredExceptions.length : 0;
if (len > 0) {
buf.append(" throws ");
buf.append(declaredExceptions[0]);
for (int i = 1; i < declaredExceptions.length; i++) {
buf.append(", ");
buf.append(declaredExceptions[i]);
}
}
}
return buf.toString();
}
public String toLongString() {
ByteArrayOutputStream s = new ByteArrayOutputStream();
print(new PrintStream(s));
return new String(s.toByteArray());
}
public void print() {
print(System.out);
}
public void print(PrintStream out) {
out.print(" " + toShortString());
printAspectAttributes(out);
InstructionList body = getBody();
if (body == null) {
out.println(";");
return;
}
out.println(":");
new BodyPrinter(out).run();
out.println(" end " + toShortString());
}
private void printAspectAttributes(PrintStream out) {
ISourceContext context = null;
if (enclosingClass != null && enclosingClass.getType() != null) {
context = enclosingClass.getType().getSourceContext();
}
List as = BcelAttributes.readAjAttributes(attributes, context);
if (! as.isEmpty()) {
out.println(" " + as.get(0)); // XXX assuming exactly one attribute, munger...
}
}
private class BodyPrinter {
Map prefixMap = new HashMap();
Map suffixMap = new HashMap();
Map labelMap = new HashMap();
InstructionList body;
PrintStream out;
ConstantPool pool;
List ranges;
BodyPrinter(PrintStream out) {
this.pool = enclosingClass.getConstantPoolGen().getConstantPool();
this.body = getBody();
this.out = out;
}
void run() {
//killNops();
assignLabels();
print();
}
// label assignment
void assignLabels() {
LinkedList exnTable = new LinkedList();
String pendingLabel = null;
// boolean hasPendingTargeters = false;
int lcounter = 0;
for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
InstructionTargeter[] targeters = ih.getTargeters();
if (targeters != null) {
for (int i = targeters.length - 1; i >= 0; i--) {
InstructionTargeter t = targeters[i];
if (t instanceof ExceptionRange) {
// assert isRangeHandle(h);
ExceptionRange r = (ExceptionRange) t;
if (r.getStart() == ih) {
insertHandler(r, exnTable);
}
} else if (t instanceof BranchInstruction) {
if (pendingLabel == null) {
pendingLabel = "L" + lcounter++;
}
} else {
// assert isRangeHandle(h)
}
}
}
if (pendingLabel != null) {
labelMap.put(ih, pendingLabel);
if (! Range.isRangeHandle(ih)) {
pendingLabel = null;
}
}
}
int ecounter = 0;
for (Iterator i = exnTable.iterator(); i.hasNext();) {
ExceptionRange er = (ExceptionRange) i.next();
String exceptionLabel = "E" + ecounter++;
labelMap.put(Range.getRealStart(er.getHandler()), exceptionLabel);
labelMap.put(er.getHandler(), exceptionLabel);
}
}
// printing
void print() {
int depth = 0;
int currLine = -1;
bodyPrint:
for (InstructionHandle ih = body.getStart(); ih != null; ih = ih.getNext()) {
if (Range.isRangeHandle(ih)) {
Range r = Range.getRange(ih);
// don't print empty ranges, that is, ranges who contain no actual instructions
for (InstructionHandle xx = r.getStart(); Range.isRangeHandle(xx); xx = xx.getNext()) {
if (xx == r.getEnd()) continue bodyPrint;
}
// doesn't handle nested: if (r.getStart().getNext() == r.getEnd()) continue;
if (r.getStart() == ih) {
printRangeString(r, depth++);
} else {
if (r.getEnd() != ih) throw new RuntimeException("bad");
printRangeString(r, --depth);
}
} else {
printInstruction(ih, depth);
int line = getLineNumber(ih, currLine);
if (line != currLine) {
currLine = line;
out.println(" (line " + line + ")");
} else {
out.println();
}
}
}
}
void printRangeString(Range r, int depth) {
printDepth(depth);
out.println(getRangeString(r, labelMap));
}
String getRangeString(Range r, Map labelMap) {
if (r instanceof ExceptionRange) {
ExceptionRange er = (ExceptionRange) r;
return er.toString() + " -> " + labelMap.get(er.getHandler());
//
// + " PRI " + er.getPriority();
} else {
return r.toString();
}
}
void printDepth(int depth) {
pad(BODY_INDENT);
while (depth > 0) {
out.print("| ");
depth--;
}
}
void printLabel(String s, int depth) {
int space = Math.max(CODE_INDENT - depth * 2, 0);
if (s == null) {
pad(space);
} else {
space = Math.max(space - (s.length() + 2), 0);
pad(space);
out.print(s);
out.print(": ");
}
}
void printInstruction(InstructionHandle h, int depth) {
printDepth(depth);
printLabel((String) labelMap.get(h), depth);
Instruction inst = h.getInstruction();
if (inst instanceof CPInstruction) {
CPInstruction cpinst = (CPInstruction) inst;
out.print(Constants.OPCODE_NAMES[cpinst.getOpcode()].toUpperCase());
out.print(" ");
out.print(pool.constantToString(pool.getConstant(cpinst.getIndex())));
} else if (inst instanceof Select) {
Select sinst = (Select) inst;
out.println(Constants.OPCODE_NAMES[sinst.getOpcode()].toUpperCase());
int[] matches = sinst.getMatchs();
InstructionHandle[] targets = sinst.getTargets();
InstructionHandle defaultTarget = sinst.getTarget();
for (int i = 0, len = matches.length; i < len; i++) {
printDepth(depth);
printLabel(null, depth);
out.print(" ");
out.print(matches[i]);
out.print(": \t");
out.println(labelMap.get(targets[i]));
}
printDepth(depth);
printLabel(null, depth);
out.print(" ");
out.print("default: \t");
out.print(labelMap.get(defaultTarget));
} else if (inst instanceof BranchInstruction) {
BranchInstruction brinst = (BranchInstruction) inst;
out.print(Constants.OPCODE_NAMES[brinst.getOpcode()].toUpperCase());
out.print(" ");
out.print(labelMap.get(brinst.getTarget()));
} else if (inst instanceof LocalVariableInstruction) {
LocalVariableInstruction lvinst = (LocalVariableInstruction) inst;
out.print(inst.toString(false).toUpperCase());
int index = lvinst.getIndex();
LocalVariableTag tag = getLocalVariableTag(h, index);
if (tag != null) {
out.print(" // ");
out.print(tag.getType());
out.print(" ");
out.print(tag.getName());
}
} else {
out.print(inst.toString(false).toUpperCase());
}
}
static final int BODY_INDENT = 4;
static final int CODE_INDENT = 16;
void pad(int size) {
for (int i = 0; i < size; i++) {
out.print(" ");
}
}
}
static LocalVariableTag getLocalVariableTag(
InstructionHandle ih,
int index)
{
InstructionTargeter[] targeters = ih.getTargeters();
if (targeters == null) return null;
for (int i = targeters.length - 1; i >= 0; i--) {
InstructionTargeter t = targeters[i];
if (t instanceof LocalVariableTag) {
LocalVariableTag lvt = (LocalVariableTag) t;
if (lvt.getSlot() == index) return lvt;
}
}
return null;
}
static int getLineNumber(
InstructionHandle ih,
int prevLine)
{
InstructionTargeter[] targeters = ih.getTargeters();
if (targeters == null) return prevLine;
for (int i = targeters.length - 1; i >= 0; i--) {
InstructionTargeter t = targeters[i];
if (t instanceof LineNumberTag) {
return ((LineNumberTag)t).getLineNumber();
}
}
return prevLine;
}
public boolean isStatic() {
return Modifier.isStatic(getAccessFlags());
}
public boolean isAbstract() {
return Modifier.isAbstract(getAccessFlags());
}
public void addExceptionHandler(
InstructionHandle start,
InstructionHandle end,
InstructionHandle handlerStart,
ObjectType catchType,
boolean highPriority) {
InstructionHandle start1 = Range.genStart(body, start);
InstructionHandle end1 = Range.genEnd(body, end);
ExceptionRange er =
new ExceptionRange(body, BcelWorld.fromBcel(catchType), highPriority);
er.associateWithTargets(start1, end1, handlerStart);
}
public int getAccessFlags() {
return accessFlags;
}
public Type[] getArgumentTypes() {
return argumentTypes;
}
// public String[] getArgumentNames() {
// return argumentNames;
// }
public LazyClassGen getEnclosingClass() {
return enclosingClass;
}
public int getMaxLocals() {
return maxLocals;
}
public String getName() {
return name;
}
public Type getReturnType() {
return returnType;
}
public void setMaxLocals(int maxLocals) {
this.maxLocals = maxLocals;
}
public InstructionList getBody() {
return body;
}
public boolean hasBody() { return body != null; }
public Attribute[] getAttributes() {
return attributes;
}
public String[] getDeclaredExceptions() {
return declaredExceptions;
}
public String getClassName() {
return enclosingClass.getName();
}
// ---- packing!
public MethodGen pack() {
//killNops();
MethodGen gen =
new MethodGen(
getAccessFlags(),
getReturnType(),
getArgumentTypes(),
null, //getArgumentNames(),
getName(),
getEnclosingClass().getName(),
new InstructionList(),
getEnclosingClass().getConstantPoolGen());
for (int i = 0, len = declaredExceptions.length; i < len; i++) {
gen.addException(declaredExceptions[i]);
}
for (int i = 0, len = attributes.length; i < len; i++) {
gen.addAttribute(attributes[i]);
}
if (hasBody()) {
packBody(gen);
gen.setMaxLocals();
gen.setMaxStack();
} else {
gen.setInstructionList(null);
}
return gen;
}
/** fill the newly created method gen with our body,
* inspired by InstructionList.copy()
*/
public void packBody(MethodGen gen) {
HashMap map = new HashMap();
InstructionList fresh = gen.getInstructionList();
/* Make copies of all instructions, append them to the new list
* and associate old instruction references with the new ones, i.e.,
* a 1:1 mapping.
*/
for (InstructionHandle ih = getBody().getStart(); ih != null; ih = ih.getNext()) {
if (Range.isRangeHandle(ih)) {
continue;
}
Instruction i = ih.getInstruction();
Instruction c = Utility.copyInstruction(i);
if (c instanceof BranchInstruction)
map.put(ih, fresh.append((BranchInstruction) c));
else
map.put(ih, fresh.append(c));
}
// at this point, no rangeHandles are in fresh. Let's use that...
/* Update branch targets and insert various attributes.
* Insert our exceptionHandlers
* into a sorted list, so they can be added in order later.
*/
InstructionHandle ih = getBody().getStart();
InstructionHandle jh = fresh.getStart();
LinkedList exnList = new LinkedList();
// map from localvariabletag to instruction handle
Map localVariableStarts = new HashMap();
Map localVariableEnds = new HashMap();
int currLine = -1;
while (ih != null) {
if (map.get(ih) == null) {
// we're a range instruction
Range r = Range.getRange(ih);
if (r instanceof ExceptionRange) {
ExceptionRange er = (ExceptionRange) r;
if (er.getStart() == ih) {
//System.err.println("er " + er);
if (!er.isEmpty()){
// order is important, insert handlers in order of start
insertHandler(er, exnList);
}
}
} else {
// we must be a shadow range or something equally useless,
// so forget about doing anything
}
// just increment ih.
ih = ih.getNext();
} else {
// assert map.get(ih) == jh
Instruction i = ih.getInstruction();
Instruction j = jh.getInstruction();
if (i instanceof BranchInstruction) {
BranchInstruction bi = (BranchInstruction) i;
BranchInstruction bj = (BranchInstruction) j;
InstructionHandle itarget = bi.getTarget(); // old target
// try {
// New target is in hash map
bj.setTarget(remap(itarget, map));
// } catch (NullPointerException e) {
// print();
// System.out.println("Was trying to remap " + bi);
// System.out.println("who's target was supposedly " + itarget);
// throw e;
// }
if (bi instanceof Select) {
// Either LOOKUPSWITCH or TABLESWITCH
InstructionHandle[] itargets = ((Select) bi).getTargets();
InstructionHandle[] jtargets = ((Select) bj).getTargets();
for (int k = itargets.length - 1; k >= 0; k--) {
// Update all targets
jtargets[k] = remap(itargets[k], map);
jtargets[k].addTargeter(bj);
}
}
}
// now deal with line numbers
// and store up info for local variables
InstructionTargeter[] targeters = ih.getTargeters();
if (targeters != null) {
for (int k = targeters.length - 1; k >= 0; k--) {
InstructionTargeter targeter = targeters[k];
if (targeter instanceof LineNumberTag) {
int line = ((LineNumberTag)targeter).getLineNumber();
if (line != currLine) {
gen.addLineNumber(jh, line);
currLine = line;
}
} else if (targeter instanceof LocalVariableTag) {
LocalVariableTag lvt = (LocalVariableTag) targeter;
if (i instanceof LocalVariableInstruction) {
int index = ((LocalVariableInstruction)i).getIndex();
if (lvt.getSlot() == index) {
if (localVariableStarts.get(lvt) == null) {
localVariableStarts.put(lvt, jh);
}
localVariableEnds.put(lvt, jh);
}
}
}
}
}
// now continue
ih = ih.getNext();
jh = jh.getNext();
}
}
// now add exception handlers
for (Iterator iter = exnList.iterator(); iter.hasNext();) {
ExceptionRange r = (ExceptionRange) iter.next();
if (r.isEmpty()) continue;
gen.addExceptionHandler(
remap(r.getRealStart(), map),
remap(r.getRealEnd(), map),
remap(r.getHandler(), map),
(r.getCatchType() == null)
? null
: (ObjectType) BcelWorld.makeBcelType(r.getCatchType()));
}
// now add local variables
gen.removeLocalVariables();
// BCEL sometimes creates extra local variables with the same name. We now
// remove them and add back to the gen.
Map duplicatedLocalMap = new HashMap();
for (Iterator iter = localVariableStarts.keySet().iterator(); iter.hasNext(); ) {
LocalVariableTag tag = (LocalVariableTag) iter.next();
// have we already added one with the same slot number and start location?
// if so, just continue.
InstructionHandle start = (InstructionHandle) localVariableStarts.get(tag);
Set slots = (Set) duplicatedLocalMap.get(start);
if (slots == null) {
slots = new HashSet();
duplicatedLocalMap.put(start, slots);
}
if (slots.contains(new Integer(tag.getSlot()))) {
// we already have a var starting at this tag with this slot
continue;
}
slots.add(new Integer(tag.getSlot()));
gen.addLocalVariable(
tag.getName(),
BcelWorld.makeBcelType(tag.getType()),
tag.getSlot(),
(InstructionHandle) localVariableStarts.get(tag),
(InstructionHandle) localVariableEnds.get(tag));
}
}
/** This proedure should not currently be used.
*/
// public void killNops() {
// InstructionHandle curr = body.getStart();
// while (true) {
// if (curr == null) break;
// InstructionHandle next = curr.getNext();
// if (curr.getInstruction() instanceof NOP) {
// InstructionTargeter[] targeters = curr.getTargeters();
// if (targeters != null) {
// for (int i = 0, len = targeters.length; i < len; i++) {
// InstructionTargeter targeter = targeters[i];
// targeter.updateTarget(curr, next);
// }
// }
// try {
// body.delete(curr);
// } catch (TargetLostException e) {
// }
// }
// curr = next;
// }
// }
private static InstructionHandle remap(InstructionHandle ih, Map map) {
while (true) {
Object ret = map.get(ih);
if (ret == null) {
ih = ih.getNext();
} else {
return (InstructionHandle) ret;
}
}
}
// exception ordering.
// What we should be doing is dealing with priority inversions way earlier than we are
// and counting on the tree structure. In which case, the below code is in fact right.
// XXX THIS COMMENT BELOW IS CURRENTLY WRONG.
// An exception A preceeds an exception B in the exception table iff:
// * A and B were in the original method, and A preceeded B in the original exception table
// * If A has a higher priority than B, than it preceeds B.
// * If A and B have the same priority, then the one whose START happens EARLIEST has LEAST priority.
// in short, the outermost exception has least priority.
// we implement this with a LinkedList. We could possibly implement this with a java.util.SortedSet,
// but I don't trust the only implementation, TreeSet, to do the right thing.
private static void insertHandler(ExceptionRange fresh, LinkedList l) {
// for (ListIterator iter = l.listIterator(); iter.hasNext();) {
// ExceptionRange r = (ExceptionRange) iter.next();
// if (fresh.getPriority() >= r.getPriority()) {
// iter.previous();
// iter.add(fresh);
// return;
// }
// }
l.add(0, fresh);
}
public boolean isPrivate() {
return Modifier.isPrivate(getAccessFlags());
}
// ----
/** A good body is a body with the following properties:
*
* <ul>
* <li> For each branch instruction S in body, target T of S is in body.
* <li> For each branch instruction S in body, target T of S has S as a targeter.
* <li> For each instruction T in body, for each branch instruction S that is a
* targeter of T, S is in body.
* <li> For each non-range-handle instruction T in body, for each instruction S
* that is a targeter of T, S is
* either a branch instruction, an exception range or a tag
* <li> For each range-handle instruction T in body, there is exactly one targeter S
* that is a range.
* <li> For each range-handle instruction T in body, the range R targeting T is in body.
* <li> For each instruction T in body, for each exception range R targeting T, R is
* in body.
* <li> For each exception range R in body, let T := R.handler. T is in body, and R is one
* of T's targeters
* <li> All ranges are properly nested: For all ranges Q and R, if Q.start preceeds
* R.start, then R.end preceeds Q.end.
* </ul>
*
* Where the shorthand "R is in body" means "R.start is in body, R.end is in body, and
* any InstructionHandle stored in a field of R (such as an exception handle) is in body".
*/
public void assertGoodBody() {
// XXX this is REALLY slow since we get the string first...
assertGoodBody(getBody(), toString());
}
// XXX we might not want to release with any calls to this incredibly inefficient method.
public static void assertGoodBody(InstructionList il, String from) {
if (true) return;
if (il == null) return;
Set body = new HashSet();
Stack ranges = new Stack();
for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
body.add(ih);
if (ih.getInstruction() instanceof BranchInstruction) {
body.add(ih.getInstruction());
}
}
for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) {
assertGoodHandle(ih, body, ranges, from);
InstructionTargeter[] ts = ih.getTargeters();
if (ts != null) {
for (int i = ts.length - 1; i >= 0; i--) {
assertGoodTargeter(ts[i], ih, body, from);
}
}
}
}
private static void assertGoodHandle(InstructionHandle ih, Set body, Stack ranges, String from) {
Instruction inst = ih.getInstruction();
if ((inst instanceof BranchInstruction) ^ (ih instanceof BranchHandle)) {
throw new BCException("bad instruction/handle pair in " + from);
}
if (Range.isRangeHandle(ih)) {
assertGoodRangeHandle(ih, body, ranges, from);
} else if (inst instanceof BranchInstruction) {
assertGoodBranchInstruction((BranchHandle) ih, (BranchInstruction) inst, body, ranges, from);
}
}
private static void assertGoodBranchInstruction(
BranchHandle ih,
BranchInstruction inst,
Set body,
Stack ranges,
String from)
{
if (ih.getTarget() != inst.getTarget()) {
throw new BCException("bad branch instruction/handle pair in " + from);
}
InstructionHandle target = ih.getTarget();
assertInBody(target, body, from);
assertTargetedBy(target, inst, from);
if (inst instanceof Select) {
Select sel = (Select) inst;
InstructionHandle[] itargets = sel.getTargets();
for (int k = itargets.length - 1; k >= 0; k--) {
assertInBody(itargets[k], body, from);
assertTargetedBy(itargets[k], inst, from);
}
}
}
/** ih is an InstructionHandle or a BranchInstruction */
private static void assertInBody(Object ih, Set body, String from) {
if (! body.contains(ih)) throw new BCException("thing not in body in " + from);
}
private static void assertGoodRangeHandle(InstructionHandle ih, Set body, Stack ranges, String from) {
Range r = getRangeAndAssertExactlyOne(ih, from);
assertGoodRange(r, body, from);
if (r.getStart() == ih) {
ranges.push(r);
} else if (r.getEnd() == ih) {
if (ranges.peek() != r) throw new BCException("bad range inclusion in " + from);
ranges.pop();
}
}
private static void assertGoodRange(Range r, Set body, String from) {
assertInBody(r.getStart(), body, from);
assertRangeHandle(r.getStart(), from);
assertTargetedBy(r.getStart(), r, from);
assertInBody(r.getEnd(), body, from);
assertRangeHandle(r.getEnd(), from);
assertTargetedBy(r.getEnd(), r, from);
if (r instanceof ExceptionRange) {
ExceptionRange er = (ExceptionRange) r;
assertInBody(er.getHandler(), body, from);
assertTargetedBy(er.getHandler(), r, from);
}
}
private static void assertRangeHandle(InstructionHandle ih, String from) {
if (! Range.isRangeHandle(ih)) throw new BCException("bad range handle " + ih + " in " + from);
}
private static void assertTargetedBy(
InstructionHandle target,
InstructionTargeter targeter,
String from)
{
InstructionTargeter[] ts = target.getTargeters();
if (ts == null) throw new BCException("bad targeting relationship in " + from);
for (int i = ts.length - 1; i >= 0; i--) {
if (ts[i] == targeter) return;
}
throw new RuntimeException("bad targeting relationship in " + from);
}
private static void assertTargets(InstructionTargeter targeter, InstructionHandle target, String from) {
if (targeter instanceof Range) {
Range r = (Range) targeter;
if (r.getStart() == target || r.getEnd() == target) return;
if (r instanceof ExceptionRange) {
if (((ExceptionRange)r).getHandler() == target) return;
}
} else if (targeter instanceof BranchInstruction) {
BranchInstruction bi = (BranchInstruction) targeter;
if (bi.getTarget() == target) return;
if (targeter instanceof Select) {
Select sel = (Select) targeter;
InstructionHandle[] itargets = sel.getTargets();
for (int k = itargets.length - 1; k >= 0; k--) {
if (itargets[k] == target) return;
}
}
} else if (targeter instanceof Tag) {
return;
}
throw new BCException(targeter + " doesn't target " + target + " in " + from );
}
private static Range getRangeAndAssertExactlyOne(InstructionHandle ih, String from) {
Range ret = null;
InstructionTargeter[] ts = ih.getTargeters();
if (ts == null) throw new BCException("range handle with no range in " + from);
for (int i = ts.length - 1; i >= 0; i--) {
if (ts[i] instanceof Range) {
if (ret != null) throw new BCException("range handle with multiple ranges in " + from);
ret = (Range) ts[i];
}
}
if (ret == null) throw new BCException("range handle with no range in " + from);
return ret;
}
private static void assertGoodTargeter(
InstructionTargeter t,
InstructionHandle ih,
Set body,
String from)
{
assertTargets(t, ih, from);
if (t instanceof Range) {
assertGoodRange((Range) t, body, from);
} else if (t instanceof BranchInstruction) {
assertInBody(t, body, from);
}
}
// ----
boolean isAdviceMethod() {
return memberView.getAssociatedShadowMunger() != null;
}
boolean isAjSynthetic() {
if (memberView == null) return true;
return memberView.isAjSynthetic();
}
public AjAttribute.EffectiveSignatureAttribute getEffectiveSignature() {
//if (memberView == null) return null;
return memberView.getEffectiveSignature();
}
public String getSignature() {
return Member.typesToSignature(BcelWorld.fromBcel(getReturnType()),
BcelWorld.fromBcel(getArgumentTypes()));
}
public BcelMethod getMemberView() {
return memberView;
}
public void forcePublic() {
accessFlags = Utility.makePublic(accessFlags);
}
public boolean getCanInline() {
return canInline;
}
public void setCanInline(boolean canInline) {
this.canInline = canInline;
}
public boolean hasExceptionHandlers() {
return hasExceptionHandlers;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.tools.ajbrowser;
import java.io.IOException;
import java.util.*;
import javax.swing.JFrame;
import org.aspectj.ajde.*;
import org.aspectj.ajde.ui.*;
import org.aspectj.ajde.ui.internal.UserPreferencesStore;
import org.aspectj.ajde.ui.swing.*;
import org.aspectj.asm.*;
/**
* IDE manager for standalone AJDE application.
*
* @author Mik Kersten
*/
public class BrowserManager {
private static final BrowserManager INSTANCE = new BrowserManager();
private BrowserProperties browserProjectProperties;
private EditorManager editorManager;
public static BrowserManager getDefault() {
return INSTANCE;
}
private List configFiles = new ArrayList();
public static final String TITLE = "AspectJ Browser";
private static TopFrame topFrame = null;
public final StructureModelListener VIEW_LISTENER = new StructureModelListener() {
public void modelUpdated(StructureModel model) {
FileStructureView fsv = Ajde.getDefault().getStructureViewManager().getDefaultFileView();
if (fsv != null) {
fsv.setSourceFile(BrowserManager.getDefault().getEditorManager().getCurrFile());
}
}
};
public void init(String[] configFilesArgs, boolean visible) {
try {
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(true);
browserProjectProperties = new BrowserProperties(preferencesAdapter);
TaskListManager taskListManager = new CompilerMessagesPanel();
BasicEditor ajdeEditor = new BasicEditor();
BrowserUIAdapter browserUIAdapter = new BrowserUIAdapter();
topFrame = new TopFrame();
configFiles = getConfigFilesList(configFilesArgs);
AjdeUIManager.getDefault().init(
ajdeEditor,
taskListManager,
browserProjectProperties,
preferencesAdapter,
browserUIAdapter,
new IconRegistry(),
topFrame,
true);
editorManager = new EditorManager(ajdeEditor);
Ajde.getDefault().getBuildManager().addListener(BUILD_MESSAGES_LISTENER);
MultiStructureViewPanel multiViewPanel = new MultiStructureViewPanel(
AjdeUIManager.getDefault().getViewManager().getBrowserPanel(),
AjdeUIManager.getDefault().getFileStructurePanel()
);
topFrame.init(
multiViewPanel,
(CompilerMessagesPanel)taskListManager,
editorManager.getEditorPanel()
);
if (visible) topFrame.setVisible(true);
if (configFiles.size() == 0) {
Ajde.getDefault().getErrorHandler().handleWarning(
"No build configuration selected. "
+ "Select a \".lst\" build configuration file in order to compile and navigate structure.");
} else {
//UiManager.getDefault().getViewManager().updateConfigsList();
}
AjdeUIManager.getDefault().getOptionsFrame().addOptionsPanel(new BrowserOptionsPanel());
StructureModelManager.getDefault().addListener(VIEW_LISTENER);
//String lastOpenFilePath = browserProjectProperties.getLastOpenSourceFilePath();
//editorManager.showSourceLine(lastOpenFilePath, 1, false);
//Ajde.getDefault().getStructureViewManager().fireNavigationAction(lastOpenFilePath, 6);
//Ajde.getDefault().enableLogging(System.out);
if (configFilesArgs.length > 0 && configFilesArgs[0] != null) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(configFilesArgs[0]);
}
} catch (Throwable t) {
t.printStackTrace();
Ajde.getDefault().getErrorHandler().handleError(
"AJDE failed to initialize.",
t);
}
}
public void resetEditorFrame() {
topFrame.resetSourceEditorPanel();
}
public void resetEditor() {
BrowserManager.getDefault().getRootFrame().setSize(BrowserManager.getDefault().getRootFrame().getWidth()+1, BrowserManager.getDefault().getRootFrame().getHeight()+1);
BrowserManager.getDefault().getRootFrame().doLayout();
BrowserManager.getDefault().getRootFrame().repaint();
}
public void setStatusInformation(String text) {
topFrame.statusText_label.setText(text);
}
public void setEditorStatusText(String text) {
topFrame.setTitle(BrowserManager.TITLE + " - " + text);
}
public void saveAll() {
editorManager.saveContents();
}
public void showMessages() {
topFrame.showMessagesPanel();
}
public void hideMessages() {
topFrame.hideMessagesPanel();
}
public JFrame getRootFrame() {
return topFrame;
}
public void openFile(String filePath) {
try {
if (filePath.endsWith(".lst")) {
AjdeUIManager.getDefault().getBuildConfigEditor().openFile(filePath);
topFrame.setEditorPanel(AjdeUIManager.getDefault().getBuildConfigEditor());
} else if (filePath.endsWith(".java") || filePath.endsWith(".aj")){
editorManager.showSourceLine(filePath, 0, false);
} else {
Ajde.getDefault().getErrorHandler().handleError("File: " + filePath
+ " could not be opened because the extension was not recoginzed.");
}
} catch (IOException ioe) {
Ajde.getDefault().getErrorHandler().handleError("Could not open file: " + filePath, ioe);
} catch (InvalidResourceException ire) {
Ajde.getDefault().getErrorHandler().handleError("Invalid file: " + filePath, ire);
}
browserProjectProperties.setLastOpenSourceFilePath(filePath);
}
private List getConfigFilesList(String[] configFiles) {
List configs = new ArrayList();
for (int i = 0; i < configFiles.length; i++) {
if (configFiles[i].endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) {
configs.add(configFiles[i]);
}
}
return configs;
}
// private static class Runner {
//
// public static void invoke(String className) {
// try {
// if (className == null || className.length() == 0) {
// Ajde.getDefault().getErrorHandler().handleWarning("No main class specified, please select a class to run.");
//
// } else {
// Class[] argTypes = { String[].class };
// java.lang.reflect.Method method = Class.forName(className).getDeclaredMethod("main", argTypes);
// Object[] args = { new String[0] };
// method.invoke(null, args);
// }
// } catch(ClassNotFoundException cnfe) {
// Ajde.getDefault().getErrorHandler().handleWarning("Main class not found: " + className +
// "\nMake sure that you have \".\" on your classpath.");
// } catch(NoSuchMethodException nsme) {
// Ajde.getDefault().getErrorHandler().handleWarning("Class: " + className + " does not declare public static void main(String[])");
// } catch(java.lang.reflect.InvocationTargetException ite) {
// Ajde.getDefault().getErrorHandler().handleWarning("Could not execute: " + className);
// } catch(IllegalAccessException iae) {
// Ajde.getDefault().getErrorHandler().handleWarning("Class: " + className + " does not declare public main method");
// }
// }
// }
private final BuildListener BUILD_MESSAGES_LISTENER = new BuildListener() {
public void compileStarted(String buildConfigFile) { }
public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) {
int timeInSeconds = buildTime/1000;
if (succeeded && !warnings) {
hideMessages();
} else {
showMessages();
}
}
public void compileAborted(String buildConfigFile, String message) { }
};
public List getConfigFiles() {
return configFiles;
}
public BrowserProperties getBrowserProjectProperties() {
return browserProjectProperties;
}
/**
* @return
*/
public EditorManager getEditorManager() {
return editorManager;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.tools.ajbrowser;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.filechooser.FileFilter;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.swing.*;
import org.aspectj.asm.ProgramElementNode;
/**
* UI for standalone operation.
*
* @author Mik Kersten
*/
public class TopFrame extends JFrame {
private static final File CURRENT_DIR = new File(".");
JLabel statusText_label = new JLabel();
//private AJButtonMenuCombo lastBuildCombo = null;
private JPanel editor_panel = null;
private JPanel sourceEditor_panel = null;
private JMenuBar menuBar = new JMenuBar();
private JMenu jMenu1 = new JMenu();
private JMenu jMenu2 = new JMenu();
private JMenuItem projectBuild_menuItem = new JMenuItem();
private FlowLayout left_flowLayout = new FlowLayout();
private Border border1;
private Border border2;
private JMenuItem jMenuItem1 = new JMenuItem();
private JMenuItem exit_menuItem = new JMenuItem();
private JSplitPane top_splitPane = new JSplitPane();
private BorderLayout borderLayout2 = new BorderLayout();
private BorderLayout borderLayout1 = new BorderLayout();
private BorderLayout borderLayout3 = new BorderLayout();
private JMenuItem projectRun_menuItem = new JMenuItem();
private JMenuItem projectRunOther_menuItem = new JMenuItem();
private Border border3;
private JPanel status_panel = new JPanel();
private BorderLayout borderLayout4 = new BorderLayout();
private Border emptyBorder = BorderFactory.createEmptyBorder();
private JPanel toolbar_panel = new JPanel();
private JSplitPane right_splitPane = new JSplitPane();
private JPanel messages_panel = null;
private JMenu tools_menu = new JMenu();
private JMenuItem joinpointProbe_menuItem = new JMenuItem();
private JMenuItem projectDebug_menuItem = new JMenuItem();
private Border border4;
private Border border5;
private Border border6;
private Border border7;
private JMenuItem svProperties_menuItem = new JMenuItem();
private File lastChosenDir = CURRENT_DIR;
JPanel toolBar_panel = new JPanel();
JToolBar build_toolBar = new JToolBar();
JButton closeConfig_button = new JButton();
JButton openConfig_button = new JButton();
JButton run_button = new JButton();
JToolBar project_toolBar = new JToolBar();
JButton save_button = new JButton();
JButton options_button = new JButton();
JButton editConfig_button = new JButton();
JToolBar file_toolBar = new JToolBar();
JPanel filler_panel = new JPanel();
BorderLayout borderLayout5 = new BorderLayout();
BorderLayout borderLayout6 = new BorderLayout();
Border border8;
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JPanel multiView_panel;
private AJButtonMenuCombo buildCombo;
//JPanel view_panel;
//JSplitPane structureView_pane = new JSplitPane();
//JPanel browser_panel = null;
// public final BuildConfigListener CONFIGURATION_LISTENER = new BuildConfigListener() {
// public void currConfigChanged(String configFilePath) {
// AjdeUIManager.getDefault().getViewManager().updateView();
// }
//
// public void configsListUpdated(java.util.List configsList) {
// //AjdeUIManager.getDefault().getViewManager().updateConfigsList();
// }
// };
public void init(MultiStructureViewPanel multiViewPanel, JPanel compilerMessagesPanel, JPanel editorPanel) {
try {
this.multiView_panel = multiViewPanel;
//this.browser_panel = browserPanel;
//this.fileStructure_panel = fileStructurePanel;
this.messages_panel = compilerMessagesPanel;
this.editor_panel = editorPanel;
this.sourceEditor_panel = editorPanel;
jbInit();
svProperties_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBrowserOptionsIcon());
projectBuild_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBuildIcon());
projectRun_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon());
projectRunOther_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon());
projectDebug_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getDebugIcon());
this.setJMenuBar(menuBar);
this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.ADVICE)).getImage());
this.setLocation(75, 10);
this.setSize(900, 650);
this.setTitle(BrowserManager.TITLE);
//bindKeys();
fixButtonBorders();
messages_panel.setVisible(false);
JPopupMenu orderMenu = new BuildConfigPopupMenu(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
BrowserManager.getDefault().saveAll();
}
});
buildCombo = new AJButtonMenuCombo(
"Build",
"Build",
AjdeUIManager.getDefault().getIconRegistry().getBuildIcon(),
orderMenu,
false);
build_toolBar.add(buildCombo, 1);
refreshBuildMenu();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void refreshBuildMenu() {
JPopupMenu orderMenu = new BuildConfigPopupMenu(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
BrowserManager.getDefault().saveAll();
}
});
buildCombo.setMenu(orderMenu);
}
public void setEditorPanel(JPanel panel) {
editor_panel = panel;
right_splitPane.remove(editor_panel);
right_splitPane.add(panel, JSplitPane.TOP);
panel.setVisible(true);
}
/**
* @todo get rid of this method and make jbinit() work properly
*/
private void fixButtonBorders() {
run_button.setBorder(null);
options_button.setBorder(null);
openConfig_button.setBorder(null);
closeConfig_button.setBorder(null);
save_button.setBorder(null);
editConfig_button.setBorder(null);
}
// private void bindKeys() { // XXX broken?
// this.addKeyListener(new KeyAdapter() {
// public void keyPressed(KeyEvent e) {
// if (e.getModifiers() == java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) {
// if (e.getKeyCode() == KeyEvent.VK_F11) {
// if (e.isShiftDown()) {
// buildFresh();
// } else {
// build();
// }
// } else if (e.getKeyCode() == KeyEvent.VK_S) {
// Ajde.getDefault().getEditorManager().saveContents();
// } else if (e.getKeyCode() == KeyEvent.VK_P) {
// AjdeUIManager.getDefault().showOptionsFrame();
// } else if (e.getKeyCode() == KeyEvent.VK_R) {
// runInSameVM();
// }
// }
// }
// });
// }
private void jbInit() throws Exception {
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98));
border2 = BorderFactory.createEtchedBorder(Color.white,new Color(148, 145, 140));
border3 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98));
border4 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98));
border5 = BorderFactory.createEmptyBorder();
border6 = BorderFactory.createEmptyBorder();
border7 = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(148, 145, 140),new Color(103, 101, 98));
border8 = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(Color.white,new Color(156, 156, 158)),BorderFactory.createEmptyBorder(2,2,2,2));
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2);
jMenu1.setFont(new java.awt.Font("Dialog", 0, 11));
jMenu1.setText("File");
jMenu1.setMnemonic(KeyEvent.VK_F);
jMenu2.setFont(new java.awt.Font("Dialog", 0, 11));
jMenu2.setText("Project");
jMenu2.setMnemonic(KeyEvent.VK_P);
projectBuild_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
projectBuild_menuItem.setText("Build");
projectBuild_menuItem.setMnemonic(KeyEvent.VK_B);
projectBuild_menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_B, ActionEvent.ALT_MASK));
projectBuild_menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
projectBuild_menuItem_actionPerformed(e);
}
});
left_flowLayout.setAlignment(FlowLayout.LEFT);
jMenuItem1.setFont(new java.awt.Font("Dialog", 0, 11));
jMenuItem1.setText("Save");
jMenuItem1.setMnemonic(KeyEvent.VK_S);
jMenuItem1.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_S, ActionEvent.ALT_MASK));
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuItem1_actionPerformed(e);
}
});
exit_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
exit_menuItem.setText("Exit");
exit_menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
exit_menuItem_actionPerformed(e);
}
});
top_splitPane.setPreferredSize(new Dimension(706, 800));
top_splitPane.setDividerSize(4);
this.getContentPane().setLayout(borderLayout3);
projectRun_menuItem.setEnabled(true);
projectRun_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
projectRun_menuItem.setText("Run in same VM");
projectRun_menuItem.setToolTipText("Run in same VM (hold shift down to run in separate process)");
projectRun_menuItem.setMnemonic(KeyEvent.VK_R);
projectRun_menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_R, ActionEvent.ALT_MASK));
projectRun_menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
projectRun_menuItem_actionPerformed(e);
}
});
projectRunOther_menuItem.setEnabled(true);
projectRunOther_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
projectRunOther_menuItem.setText("Run in separate process");
projectRunOther_menuItem.setMnemonic(KeyEvent.VK_P);
projectRunOther_menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_P, ActionEvent.ALT_MASK));
projectRunOther_menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
projectRunOther_menuItem_actionPerformed(e);
}
});
statusText_label.setFont(new java.awt.Font("Dialog", 0, 11));
statusText_label.setBorder(BorderFactory.createLoweredBevelBorder());
statusText_label.setMaximumSize(new Dimension(2000, 20));
statusText_label.setPreferredSize(new Dimension(300, 20));
status_panel.setLayout(borderLayout4);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(WindowEvent e) {
this_windowClosed(e);
}
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
}
});
toolbar_panel.setLayout(borderLayout5);
right_splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
right_splitPane.setBorder(null);
right_splitPane.setDividerSize(4);
tools_menu.setFont(new java.awt.Font("Dialog", 0, 11));
tools_menu.setText("Tools");
tools_menu.setMnemonic(KeyEvent.VK_T);
projectDebug_menuItem.setEnabled(false);
projectDebug_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
projectDebug_menuItem.setText("Debug");
svProperties_menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
svProperties_menuItem_actionPerformed(e);
}
});
svProperties_menuItem.setText("Options...");
svProperties_menuItem.setActionCommand("AJDE Console...");
svProperties_menuItem.setFont(new java.awt.Font("Dialog", 0, 11));
svProperties_menuItem.setMnemonic(KeyEvent.VK_O);
svProperties_menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_O, ActionEvent.ALT_MASK));
build_toolBar.setBorder(emptyBorder);
build_toolBar.setFloatable(false);
closeConfig_button.setMaximumSize(new Dimension(100, 20));
closeConfig_button.setEnabled(true);
closeConfig_button.setFont(new java.awt.Font("Dialog", 0, 11));
closeConfig_button.setBorder(null);
closeConfig_button.setMinimumSize(new Dimension(24, 20));
closeConfig_button.setPreferredSize(new Dimension(20, 20));
closeConfig_button.setToolTipText("Close build configuration");
closeConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getCloseConfigIcon());
closeConfig_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
closeConfig_button_actionPerformed(e);
}
});
openConfig_button.setMaximumSize(new Dimension(100, 20));
openConfig_button.setEnabled(true);
openConfig_button.setFont(new java.awt.Font("Dialog", 0, 11));
openConfig_button.setBorder(null);
openConfig_button.setMinimumSize(new Dimension(24, 20));
openConfig_button.setPreferredSize(new Dimension(20, 20));
openConfig_button.setToolTipText("Select build configuration...");
openConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getOpenConfigIcon());
openConfig_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
openConfig_button_actionPerformed(e);
}
});
run_button.setMaximumSize(new Dimension(60, 20));
run_button.setEnabled(true);
run_button.setFont(new java.awt.Font("Dialog", 0, 11));
run_button.setBorder(null);
run_button.setMinimumSize(new Dimension(24, 20));
run_button.setPreferredSize(new Dimension(20, 20));
run_button.setToolTipText("Run in same VM (hold shift down to run in separate process)");
run_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon());
run_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
run_button_actionPerformed(e);
}
});
project_toolBar.setBorder(emptyBorder);
save_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
save_button_actionPerformed(e);
}
});
save_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getSaveIcon());
save_button.setText("Save");
save_button.setToolTipText("Save");
save_button.setPreferredSize(new Dimension(55, 20));
save_button.setMinimumSize(new Dimension(24, 20));
save_button.setFont(new java.awt.Font("Dialog", 0, 11));
save_button.setBorder(null);
save_button.setMaximumSize(new Dimension(60, 20));
options_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
options_button_actionPerformed(e);
}
});
options_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBrowserOptionsIcon());
options_button.setText("Options");
options_button.setToolTipText("Options...");
options_button.setPreferredSize(new Dimension(60, 20));
options_button.setMinimumSize(new Dimension(24, 20));
options_button.setFont(new java.awt.Font("Dialog", 0, 11));
options_button.setBorder(null);
options_button.setMaximumSize(new Dimension(80, 20));
editConfig_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
editConfig_button_actionPerformed(e);
}
});
editConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_LST));
editConfig_button.setText("Edit Config");
editConfig_button.setToolTipText("Edit Config...");
editConfig_button.setPreferredSize(new Dimension(80, 20));
editConfig_button.setMinimumSize(new Dimension(24, 20));
editConfig_button.setFont(new java.awt.Font("Dialog", 0, 11));
editConfig_button.setBorder(null);
editConfig_button.setMaximumSize(new Dimension(80, 20));
file_toolBar.setBorder(emptyBorder);
toolBar_panel.setLayout(borderLayout6);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel1.setText(" Build: ");
jLabel2.setText(" Run: ");
jLabel2.setFont(new java.awt.Font("Dialog", 0, 11));
//fileStructure_panel.setFont(new java.awt.Font("Dialog", 0, 11));
//browser_panel.setFont(new java.awt.Font("Dialog", 0, 11));
this.getContentPane().add(top_splitPane, BorderLayout.CENTER);
top_splitPane.add(right_splitPane, JSplitPane.RIGHT);
top_splitPane.add(multiView_panel, JSplitPane.LEFT);
right_splitPane.add(messages_panel, JSplitPane.BOTTOM);
right_splitPane.add(editor_panel, JSplitPane.TOP);
//structureView_pane.add(fileStructure_panel, JSplitPane.RIGHT);
//structureView_pane.add(browser_panel, JSplitPane.LEFT);
this.getContentPane().add(status_panel, BorderLayout.SOUTH);
status_panel.add(statusText_label, BorderLayout.CENTER);
this.getContentPane().add(toolbar_panel, BorderLayout.NORTH);
toolbar_panel.add(filler_panel, BorderLayout.CENTER);
toolbar_panel.add(toolBar_panel, BorderLayout.WEST);
//file_toolBar.add(editConfig_button, null);
file_toolBar.add(save_button, null);
file_toolBar.add(options_button, null);
toolBar_panel.add(build_toolBar, BorderLayout.WEST);
toolBar_panel.add(project_toolBar, BorderLayout.CENTER);
project_toolBar.add(jLabel2, null);
project_toolBar.add(run_button, null);
build_toolBar.add(jLabel1, null);
build_toolBar.add(openConfig_button, null);
build_toolBar.add(closeConfig_button, null);
toolBar_panel.add(file_toolBar, BorderLayout.EAST);
menuBar.add(jMenu1);
menuBar.add(jMenu2);
menuBar.add(tools_menu);
jMenu1.add(jMenuItem1);
jMenu1.addSeparator();
jMenu1.add(exit_menuItem);
jMenu2.add(projectBuild_menuItem);
jMenu2.add(projectRun_menuItem);
jMenu2.add(projectRunOther_menuItem);
//jMenu2.add(projectDebug_menuItem);
tools_menu.add(joinpointProbe_menuItem);
tools_menu.add(svProperties_menuItem);
top_splitPane.setDividerLocation(380);
right_splitPane.setDividerLocation(500);
project_toolBar.addSeparator();
project_toolBar.addSeparator();
}
private void exit_menuItem_actionPerformed(ActionEvent e) {
quit();
}
private void this_windowClosing(WindowEvent e) {
quit();
}
private void quit() {
this.dispose();
System.exit(0);
}
void treeMode_comboBox_actionPerformed(ActionEvent e) { }
void save_button_actionPerformed(ActionEvent e) {
BrowserManager.getDefault().getEditorManager().saveContents();
}
void this_windowClosed(WindowEvent e) {
quit();
}
public void showMessagesPanel() {
right_splitPane.setDividerLocation(right_splitPane.getHeight()-100);
messages_panel.setVisible(true);
}
public void hideMessagesPanel() {
right_splitPane.setDividerLocation(right_splitPane.getHeight());
messages_panel.setVisible(false);
}
void jMenuItem1_actionPerformed(ActionEvent e) {
BrowserManager.getDefault().getEditorManager().saveContents();
}
void projectBuild_menuItem_actionPerformed(ActionEvent e) {
BrowserManager.getDefault().saveAll();
if (EditorManager.isShiftDown(e.getModifiers())) {
buildFresh();
} else {
build();
}
}
void run_button_actionPerformed(ActionEvent e) {
if (EditorManager.isShiftDown(e.getModifiers())) {
runInNewVM();
} else {
runInSameVM();
}
}
void projectRunOther_menuItem_actionPerformed(ActionEvent e) {
runInNewVM();
}
void projectRun_menuItem_actionPerformed(ActionEvent e) {
if (EditorManager.isShiftDown(e.getModifiers())) {
runInNewVM();
} else {
runInSameVM();
}
}
void build_button_actionPerformed(ActionEvent e) {
BrowserManager.getDefault().saveAll();
if (EditorManager.isShiftDown(e.getModifiers())) {
buildFresh();
} else {
build();
}
}
void options_button_actionPerformed(ActionEvent e) {
AjdeUIManager.getDefault().showOptionsFrame();
}
void editConfig_button_actionPerformed(ActionEvent e) {
//Ajde.getDefault().getConfigurationManager().editConfigFile(UiManager.getDefault().getViewManager().getCurrConfigFile());
BrowserManager.getDefault().openFile(Ajde.getDefault().getConfigurationManager().getActiveConfigFile());
refreshBuildMenu();
}
public void resetSourceEditorPanel() {
right_splitPane.removeAll();
right_splitPane.add(sourceEditor_panel, JSplitPane.TOP);
}
private void svProperties_menuItem_actionPerformed(ActionEvent e) {
AjdeUIManager.getDefault().showOptionsFrame();
}
private void openConfig_button_actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(lastChosenDir);
fileChooser.setFileFilter(new FileFilter() {
public boolean accept(File f) {
return (f.getPath().endsWith(".lst") || f.isDirectory());
}
public String getDescription() {
return "AspectJ Build Configuration (*.lst)";
}
});
int returnVal = fileChooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File result = fileChooser.getSelectedFile();
String path = result.getAbsolutePath();//.replace('\\', '/');
BrowserManager.getDefault().getConfigFiles().add(0, path);
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(path);
lastChosenDir = result.getParentFile();
if (null == lastChosenDir) {
lastChosenDir = CURRENT_DIR;
}
refreshBuildMenu();
}
}
private void closeConfig_button_actionPerformed(ActionEvent e) {
BrowserManager.getDefault().getConfigFiles().remove(Ajde.getDefault().getConfigurationManager().getActiveConfigFile());
if (!BrowserManager.getDefault().getConfigFiles().isEmpty()) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile((String)BrowserManager.getDefault().getConfigFiles().get(0));
}
refreshBuildMenu();
}
private void buildFresh() {
Ajde.getDefault().getBuildManager().buildFresh();
}
private void build() {
Ajde.getDefault().getBuildManager().build();
}
private void runInSameVM() {
Ajde.getDefault().runInSameVM();
}
private void runInNewVM() {
Ajde.getDefault().runInNewVM();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.internal;
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.*;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.BuildConfigListener;
import org.aspectj.ajde.BuildConfigManager;
import org.aspectj.ajde.ui.BuildConfigModel;
import org.aspectj.ajde.ui.BuildConfigNode;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.Message;
import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.ConfigParser;
/**
* @author Mik Kersten
*/
public class LstBuildConfigManager implements BuildConfigManager {
private List configFiles = new ArrayList();
private List listeners = new ArrayList();
private LstBuildConfigFileUpdater fileUpdater = new LstBuildConfigFileUpdater();
protected String currConfigFilePath = null;
private static final FilenameFilter SOURCE_FILE_FILTER = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".java")
|| name.endsWith(".aj")
|| name.endsWith(".lst");
}
};
private static final FileFilter DIR_FILTER = new FileFilter() {
public boolean accept(File file) {
return file.isDirectory();
}
};
public BuildConfigModel buildModel(String configFilePath) {
File configFile = new File(configFilePath);
String rootPath = configFile.getParent();
String configFileName = configFile.getName();
BuildConfigModel model = new BuildConfigModel(configFilePath);
List configFiles = new ArrayList();
List importedFiles = new ArrayList();
List badEntries = null;
try {
LstBuildConfigFileParser configParser = new LstBuildConfigFileParser(configFilePath);
configParser.parseConfigFile(new File(configFilePath));
configFiles = configParser.getFiles();
importedFiles = configParser.getImportedFiles();
badEntries = configParser.getProblemEntries();
} catch (ConfigParser.ParseException pe) {
// String filePath = "<unknown>";
// if (pe.getFile() != null) filePath = pe.getFile().getAbsolutePath();
IMessage message = new Message(
pe.getMessage(),
IMessage.ERROR,
pe,
new SourceLocation(pe.getFile(), pe.getLine(), 1));
Ajde.getDefault().getTaskListManager().addSourcelineTask(message);
}
List relativePaths = relativizeFilePaths(configFiles, rootPath);
BuildConfigNode root = new BuildConfigNode(configFileName, BuildConfigNode.Kind.FILE_LST, rootPath);
buildDirTree(root, rootPath, importedFiles, configFileName);
model.setRoot(root);
addFilesToDirTree(model, relativePaths, badEntries);
pruneEmptyDirs(root);
sortModel((BuildConfigNode)model.getRoot(), ALPHABETICAL_COMPARATOR);
//addImportedFilesToDirTree(model, importedFiles);
addProblemEntries(root, badEntries);
return model;
}
private void addProblemEntries(BuildConfigNode root, List badEntries) {
for (Iterator it = badEntries.iterator(); it.hasNext(); ) {
root.addChild(new BuildConfigNode(
it.next().toString(),
BuildConfigNode.Kind.ERROR, null)
);
}
}
public void writeModel(BuildConfigModel model) {
// final List paths = new ArrayList();
// StructureWalker walker = new StructureWalker() {
// protected void postProcess(StructureNode node) {
// BuildConfigNode configNode = (BuildConfigNode)node;
// if (configNode.isActive() && configNode.isValidResource()) {
// paths.add(configNode.getResourcePath());
// }
// }
// };
// model.getRoot().walk(walker);
List activeSourceFiles = model.getActiveNodes(BuildConfigNode.Kind.FILE_ASPECTJ);
activeSourceFiles.addAll(model.getActiveNodes(BuildConfigNode.Kind.FILE_JAVA));
List activeImportedFiles = model.getActiveNodes(BuildConfigNode.Kind.FILE_LST);
fileUpdater.writeConfigFile(model.getSourceFile(), activeSourceFiles, activeImportedFiles);
}
public void writePaths(String configFilePath, List files) {
fileUpdater.writeConfigFile(configFilePath, files);
}
public void addFilesToConfig(String configFilePath, List paths) {
}
public void removeFilesFromConfig(String configFilePath, List files) {
}
private List relativizeFilePaths(List configFiles, String rootPath) {
List relativePathsList = new ArrayList();
for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
File file = (File)it.next();
relativePathsList.add(fileUpdater.relativizePath(file.getPath(), rootPath));
}
return relativePathsList;
}
// private String relativizePath(String path, String rootPath) {
// path = path.replace('\\', '/');
// rootPath = rootPath.replace('\\', '/');
// int pathIndex = path.indexOf(rootPath);
// if (pathIndex > -1) {
// return path.substring(pathIndex + rootPath.length() + 1);
// } else {
// return path;
// }
// }
private void buildDirTree(BuildConfigNode node, String rootPath, List importedFiles, String configFileName) {
File[] dirs = new File(node.getResourcePath()).listFiles(DIR_FILTER);
if (dirs == null) return;
for (int i = 0; i < dirs.length; i++) {
BuildConfigNode dir = new BuildConfigNode(dirs[i].getName(), BuildConfigNode.Kind.DIRECTORY, dirs[i].getPath());
File[] files = dirs[i].listFiles(SOURCE_FILE_FILTER);
for (int j = 0; j < files.length; j++) {
if (files[j] != null) {// && !files[j].getName().endsWith(".lst")) {
String filePath = fileUpdater.relativizePath(files[j].getPath(), rootPath);
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA;
if (!files[j].getName().endsWith(".lst")) {
//kind = BuildConfigNode.Kind.FILE_LST;
BuildConfigNode file = new BuildConfigNode(files[j].getName(), kind, filePath);
file.setActive(false);
dir.addChild(file);
}
}
}
node.addChild(dir);
boolean foundMatch = false;
for (Iterator it = importedFiles.iterator(); it.hasNext(); ) {
File importedFile = (File)it.next();
if (importedFile.getParentFile().getAbsolutePath().equals(dirs[i].getAbsolutePath())) {
foundMatch = true;
BuildConfigNode importedFileNode = new BuildConfigNode(
importedFile.getName(),
BuildConfigNode.Kind.FILE_LST,
fileUpdater.relativizePath(importedFile.getPath(), rootPath));
importedFileNode.setActive(true);
//dir.getChildren().clear();
boolean found = false;
for (Iterator it2 = dir.getChildren().iterator(); it2.hasNext(); ) {
if (((BuildConfigNode)it2.next()).getName().equals(importedFile.getName())) {
found = true;
}
}
if (!found) dir.addChild(importedFileNode);
}
}
//if (!foundMatch)
buildDirTree(dir, rootPath, importedFiles, configFileName);
}
if (node.getName().endsWith(".lst")) {
File[] files = new File(rootPath).listFiles(SOURCE_FILE_FILTER);
if (files == null) return;
for (int i = 0; i < files.length; i++) {
if (files[i] != null && !files[i].getName().equals(configFileName)) {// && !files[i].getName().endsWith(".lst")) {
BuildConfigNode.Kind kind = BuildConfigNode.Kind.FILE_JAVA;
if (files[i].getName().endsWith(".lst")) {
kind = BuildConfigNode.Kind.FILE_LST;
}
BuildConfigNode file = new BuildConfigNode(files[i].getName(), kind, files[i].getName());
file.setActive(false);
node.addChild(file);
}
}
}
}
private void addFilesToDirTree(BuildConfigModel model, List configFiles, List badEntries) {
for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
String path = (String)it.next();
if (path.startsWith("..")) {
File file = new File(path);
BuildConfigNode node = new BuildConfigNode(file.getName(), BuildConfigNode.Kind.FILE_JAVA, path);
BuildConfigNode upPath = model.getNodeForPath(file.getParentFile().getPath());
if (upPath == model.getRoot()) {
upPath = new BuildConfigNode(file.getParentFile().getPath(), BuildConfigNode.Kind.DIRECTORY, file.getParentFile().getAbsolutePath());
model.getRoot().addChild(upPath);
}
node.setActive(true);
upPath.addChild(node);
} else if (!(new File(path).isAbsolute())) {
String name = new File(path).getName();
BuildConfigNode existingNode = model.getNodeForPath(path);
existingNode.setActive(true);
} else {
badEntries.add("Use relative paths only, omitting: " + path);
}
}
}
private boolean pruneEmptyDirs(BuildConfigNode node) {
List nodesToRemove = new ArrayList();
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
BuildConfigNode currNode = (BuildConfigNode)it.next();
boolean hasValidChildren = pruneEmptyDirs(currNode);
if (!currNode.isValidResource() && !hasValidChildren) {
nodesToRemove.add(currNode);
}
}
for (Iterator it = nodesToRemove.iterator(); it.hasNext(); ) {
StructureNode currNode = (StructureNode)it.next();
node.removeChild(currNode);
}
return node.getChildren().size() > 0;
}
public String getActiveConfigFile() {
if (currConfigFilePath == null) return null;
if (currConfigFilePath.equals(DEFAULT_CONFIG_LABEL)) {
return Ajde.getDefault().getProjectProperties().getDefaultBuildConfigFile();// getDefaultConfigFile();
} else {
return currConfigFilePath;
}
}
public void setActiveConfigFile(String currConfigFilePath) {
if (currConfigFilePath.equals(DEFAULT_CONFIG_LABEL)) {
this.currConfigFilePath = Ajde.getDefault().getProjectProperties().getDefaultBuildConfigFile();//getDefaultConfigFile();
} else {
this.currConfigFilePath = currConfigFilePath;
}
notifyConfigChanged();
}
public void addListener(BuildConfigListener configurationListener) {
listeners.add(configurationListener);
}
public void removeListener(BuildConfigListener configurationListener) {
listeners.remove(configurationListener);
}
private void notifyConfigChanged() {
for (Iterator it = listeners.iterator(); it.hasNext(); ) {
((BuildConfigListener)it.next()).currConfigChanged(currConfigFilePath);
}
}
private void notifyConfigsListUpdated() {
for (Iterator it = listeners.iterator(); it.hasNext(); ) {
((BuildConfigListener)it.next()).configsListUpdated(configFiles);
}
}
private void sortModel(BuildConfigNode node, Comparator comparator) {
if (node == null || node.getChildren() == null) return;
Collections.sort(node.getChildren(), comparator);
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
BuildConfigNode nextNode = (BuildConfigNode)it.next();
if (nextNode != null) sortModel(nextNode, comparator);
}
}
private static final Comparator ALPHABETICAL_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
BuildConfigNode n1 = (BuildConfigNode)o1;
BuildConfigNode n2 = (BuildConfigNode)o2;
return n1.getName().compareTo(n2.getName());
}
};
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import org.aspectj.asm.AdviceAssociation;
import org.aspectj.asm.InheritanceAssociation;
import org.aspectj.asm.IntroductionAssociation;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.Relation;
/**
* Uses the factory pattern.
*
* @author Mik Kersten
*/
public abstract class AbstractIconRegistry {
protected final String RESOURCE_PATH = "org/aspectj/ajde/resources/";
protected final String STRUCTURE_PATH = RESOURCE_PATH + "structure/";
protected final AbstractIcon PROJECT = createIcon(STRUCTURE_PATH + "project.gif");
protected final AbstractIcon PACKAGE = createIcon(STRUCTURE_PATH + "package.gif");
protected final AbstractIcon ASPECT = createIcon(STRUCTURE_PATH + "aspect.gif");
protected final AbstractIcon INITIALIZER = createIcon(STRUCTURE_PATH + "code.gif");
protected final AbstractIcon INTRODUCTION = createIcon(STRUCTURE_PATH + "introduction.gif");
protected final AbstractIcon CONSTRUCTOR = createIcon(STRUCTURE_PATH + "method.gif");
protected final AbstractIcon POINTCUT = createIcon(STRUCTURE_PATH + "pointcut.gif");
protected final AbstractIcon ADVICE = createIcon(STRUCTURE_PATH + "advice.gif");
protected final AbstractIcon DECLARE_PARENTS = createIcon(STRUCTURE_PATH + "declareParents.gif");
protected final AbstractIcon DECLARE_WARNING = createIcon(STRUCTURE_PATH + "declareWarning.gif");
protected final AbstractIcon DECLARE_ERROR = createIcon(STRUCTURE_PATH + "declareError.gif");
protected final AbstractIcon DECLARE_SOFT = createIcon(STRUCTURE_PATH + "declareSoft.gif");
protected final AbstractIcon CODE = createIcon(STRUCTURE_PATH + "code.gif");
protected final AbstractIcon ERROR = createIcon(STRUCTURE_PATH + "error.gif");
protected final AbstractIcon FILE = createIcon(STRUCTURE_PATH + "file.gif");
protected final AbstractIcon FILE_JAVA = createIcon(STRUCTURE_PATH + "file-java.gif");
protected final AbstractIcon FILE_ASPECTJ = createIcon(STRUCTURE_PATH + "file-aspectj.gif");
protected final AbstractIcon FILE_LST = createIcon(STRUCTURE_PATH + "file-lst.gif");
protected final AbstractIcon METHOD = createIcon(STRUCTURE_PATH + "method.gif");
protected final AbstractIcon FIELD = createIcon(STRUCTURE_PATH + "field.gif");
protected final AbstractIcon CLASS = createIcon(STRUCTURE_PATH + "class.gif");
protected final AbstractIcon INTERFACE = createIcon(STRUCTURE_PATH + "interface.gif");
protected final AbstractIcon RELATION_ADVICE_FORWARD = createIcon(STRUCTURE_PATH + "adviceForward.gif");
protected final AbstractIcon RELATION_ADVICE_BACK = createIcon(STRUCTURE_PATH + "adviceBack.gif");
protected final AbstractIcon RELATION_INHERITANCE_FORWARD = createIcon(STRUCTURE_PATH + "inheritanceForward.gif");
protected final AbstractIcon RELATION_INHERITANCE_BACK = createIcon(STRUCTURE_PATH + "inheritanceBack.gif");
protected final AbstractIcon RELATION_REFERENCE_FORWARD = createIcon(STRUCTURE_PATH + "referenceForward.gif");
protected final AbstractIcon RELATION_REFERENCE_BACK = createIcon(STRUCTURE_PATH + "referenceBack.gif");
public AbstractIcon getRelationIcon(Relation relation) {
if (relation.getAssociationName().equals(AdviceAssociation.NAME)) {
return RELATION_ADVICE_FORWARD;
} else if (relation.getAssociationName().equals(IntroductionAssociation.NAME)) {
return RELATION_ADVICE_FORWARD;
} else if (relation.getAssociationName().equals(InheritanceAssociation.NAME)) {
return RELATION_INHERITANCE_FORWARD;
} else {
return RELATION_REFERENCE_FORWARD;
}
}
/**
* @return null if the kind could not be resolved
*/
protected AbstractIcon getStructureIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) {
return getStructureIcon(kind, ProgramElementNode.Accessibility.PUBLIC);
}
/**
* Assumes "public" visibility for the icon.
*
* @return null if the kind could not be resolved
*/
public AbstractIcon getStructureIcon(ProgramElementNode.Kind kind) {
if (kind == ProgramElementNode.Kind.PROJECT) {
return PROJECT;
} else if (kind == ProgramElementNode.Kind.PACKAGE) {
return PACKAGE;
} else if (kind == ProgramElementNode.Kind.FILE) {
return FILE;
} else if (kind == ProgramElementNode.Kind.FILE_JAVA) {
return FILE_JAVA;
} else if (kind == ProgramElementNode.Kind.FILE_ASPECTJ) {
return FILE_ASPECTJ;
} else if (kind == ProgramElementNode.Kind.FILE_LST) {
return FILE_LST;
} else if (kind == ProgramElementNode.Kind.CLASS) {
return CLASS;
} else if (kind == ProgramElementNode.Kind.INTERFACE) {
return INTERFACE;
} else if (kind == ProgramElementNode.Kind.ASPECT) {
return ASPECT;
} else if (kind == ProgramElementNode.Kind.INITIALIZER) {
return INITIALIZER;
} else if (kind == ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR) {
return INTRODUCTION;
} else if (kind == ProgramElementNode.Kind.INTER_TYPE_FIELD) {
return INTRODUCTION;
} else if (kind == ProgramElementNode.Kind.INTER_TYPE_METHOD) {
return INTRODUCTION;
} else if (kind == ProgramElementNode.Kind.CONSTRUCTOR) {
return CONSTRUCTOR;
} else if (kind == ProgramElementNode.Kind.METHOD) {
return METHOD;
} else if (kind == ProgramElementNode.Kind.FIELD) {
return FIELD;
} else if (kind == ProgramElementNode.Kind.POINTCUT) {
return POINTCUT;
} else if (kind == ProgramElementNode.Kind.ADVICE) {
return ADVICE;
} else if (kind == ProgramElementNode.Kind.DECLARE_PARENTS) {
return DECLARE_PARENTS;
} else if (kind == ProgramElementNode.Kind.DECLARE_WARNING) {
return DECLARE_WARNING;
} else if (kind == ProgramElementNode.Kind.DECLARE_ERROR) {
return DECLARE_ERROR;
} else if (kind == ProgramElementNode.Kind.DECLARE_SOFT) {
return DECLARE_SOFT;
} else if (kind == ProgramElementNode.Kind.DECLARE_PRECEDENCE) {
return DECLARE_SOFT;
} else if (kind == ProgramElementNode.Kind.CODE) {
return CODE;
} else if (kind == ProgramElementNode.Kind.ERROR) {
return ERROR;
} else {
System.err.println("AJDE Message: unresolved icon kind " + kind);
return null;
}
}
/**
* Implement to create platform-specific icons.
*/
protected abstract AbstractIcon createIcon(String path);
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.aspectj.asm.StructureModel;
/**
* @author Mik Kersten
*/
public class BuildConfigModel extends StructureModel {
private String sourceFile;
public BuildConfigModel(String sourceFile) {
this.sourceFile = sourceFile;
}
/**
* @param path java.io.File.separator delimited path
* @return corresponding node if the path is found, the root otherwise
*/
public BuildConfigNode getNodeForPath(String path) {
BuildConfigNode upPathMatch = searchUpPaths(path);
if (upPathMatch != null && upPathMatch != root) {
return upPathMatch;
} else {
StringTokenizer st = new StringTokenizer(path, "/");
BuildConfigNode node = (BuildConfigNode)root;
return getNodeForPathHelper(st, node);
}
}
private BuildConfigNode searchUpPaths(String path) {
for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) {
BuildConfigNode node = (BuildConfigNode)it.next();
if (node.getName().equals(path)) return node;
}
return null;
}
private BuildConfigNode getNodeForPathHelper(StringTokenizer st, BuildConfigNode node) {
BuildConfigNode parent = node;
while (st.hasMoreElements()) {
String pathItem = (String)st.nextElement();
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
node = (BuildConfigNode)it.next();
String childName = node.getName();
if (childName.equals(pathItem)) {
return getNodeForPathHelper(st, node);
}
}
}
return parent;
}
public List getActiveNodes(BuildConfigNode.Kind kind) {
List nodes = new ArrayList();
getActiveNodesHelper((BuildConfigNode)getRoot(), kind, nodes);
return nodes;
}
private void getActiveNodesHelper(BuildConfigNode node, BuildConfigNode.Kind kind, List nodes) {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
BuildConfigNode currNode = (BuildConfigNode)it.next();
if (currNode.getBuildConfigNodeKind().equals(kind)
&& currNode.isActive()) {
nodes.add(currNode);
}
getActiveNodesHelper(currNode, kind, nodes);
}
}
public String getSourceFile() {
return sourceFile;
}
public void setSourceFile(String sourceFile) {
this.sourceFile = sourceFile;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.List;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class BuildConfigNode extends StructureNode {
private String resourcePath;
private Kind kind;
private boolean isActive = true;
public BuildConfigNode(String name, Kind kind, String resourcePath) {
super(name, kind.toString());
this.kind = kind;
this.resourcePath = resourcePath;
}
public BuildConfigNode(String name, String kind, String resourcePath, List children) {
super(name, kind, children);
this.resourcePath = resourcePath;
}
public String getResourcePath() {
return resourcePath;
}
public void setResourcePath(String resourcePath) {
this.resourcePath = resourcePath;
}
public boolean isValidResource() {
return name.endsWith(".java")
|| name.endsWith(".aj")
|| name.endsWith(".lst");
}
public boolean isActive() {
return isActive;
}
public void setActive(boolean isActive) {
this.isActive = isActive;
}
/**
* Uses "typesafe enum" pattern.
*/
public static class Kind implements Serializable {
public static final Kind FILE_JAVA = new Kind("Java source file");
public static final Kind FILE_ASPECTJ = new Kind("AspectJ source file");
public static final Kind FILE_LST = new Kind("build configuration file");
public static final Kind ERROR = new Kind("error");
public static final Kind DIRECTORY = new Kind("directory");
public static final Kind[] ALL = { FILE_JAVA, FILE_ASPECTJ, FILE_LST, DIRECTORY };
private final String name;
private Kind(String name) {
this.name = name;
}
public String toString() {
return name;
}
public boolean equals(Object o) {
return o.equals(name);
}
public boolean isDeclareKind() {
return name.startsWith("declare");
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
public Kind getBuildConfigNodeKind() {
return kind;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.RelationNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelManager;
import org.aspectj.asm.StructureNode;
/**
* Prototype functionality for package view clients.
*/
public class StructureModelUtil {
/**
* This method returns a map from affected source lines in a class to
* a List of aspects affecting that line.
* Based on method of same name by mik kirsten. To be replaced when StructureModelUtil
* corrects its implementation
*
* @param the full path of the source file to get a map for
*
* @return a Map from line numbers to a List of ProgramElementNodes.
*/
public static Map getLinesToAspectMap(String sourceFilePath) {
Map annotationsMap =
StructureModelManager.getDefault().getInlineAnnotations(
sourceFilePath,
true,
true);
Map aspectMap = new HashMap();
Set keys = annotationsMap.keySet();
for (Iterator it = keys.iterator(); it.hasNext();) {
Object key = it.next();
List annotations = (List) annotationsMap.get(key);
for (Iterator it2 = annotations.iterator(); it2.hasNext();) {
ProgramElementNode node = (ProgramElementNode) it2.next();
List relations = node.getRelations();
for (Iterator it3 = relations.iterator(); it3.hasNext();) {
RelationNode relationNode = (RelationNode) it3.next();
if (relationNode.getKind().equals("Advice")) {
List children = relationNode.getChildren();
List aspects = new Vector();
for (Iterator it4 = children.iterator();
it4.hasNext();
) {
Object object = it4.next();
if (object instanceof LinkNode) {
ProgramElementNode pNode =
((LinkNode) object).getProgramElementNode();
if (pNode.getProgramElementKind()
== ProgramElementNode.Kind.ADVICE) {
StructureNode theAspect = pNode.getParent();
aspects.add(theAspect);
}
}
}
if (!aspects.isEmpty()) {
aspectMap.put(key, aspects);
}
}
}
}
}
return aspectMap;
}
/**
* This method is copied from StructureModelUtil inoder for it to use the working
* version of getLineToAspectMap()
*
* @return the set of aspects with advice that affects the specified package
*/
public static Set getAspectsAffectingPackage(ProgramElementNode packageNode) {
List files = StructureModelUtil.getFilesInPackage(packageNode);
Set aspects = new HashSet();
for (Iterator it = files.iterator(); it.hasNext();) {
ProgramElementNode fileNode = (ProgramElementNode) it.next();
Map adviceMap =
getLinesToAspectMap(
fileNode.getSourceLocation().getSourceFile().getAbsolutePath());
Collection values = adviceMap.values();
for (Iterator it2 = values.iterator(); it2.hasNext();) {
aspects.add(it2.next());
}
}
return aspects;
}
public static List getPackagesInModel() {
List packages = new ArrayList();
StructureModel model =
Ajde.getDefault().getStructureModelManager().getStructureModel();
if (model.equals(StructureModel.NO_STRUCTURE)) {
return null;
} else {
return getPackagesHelper(
(ProgramElementNode) model.getRoot(),
ProgramElementNode.Kind.PACKAGE,
null,
packages);
}
}
private static List getPackagesHelper(
ProgramElementNode node,
ProgramElementNode.Kind kind,
String prename,
List matches) {
if (kind == null || node.getProgramElementKind().equals(kind)) {
if (prename == null) {
prename = new String(node.toString());
} else {
prename = new String(prename + "." + node);
}
Object[] o = new Object[2];
o[0] = node;
o[1] = prename;
matches.add(o);
}
for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
StructureNode nextNode = (StructureNode) it.next();
if (nextNode instanceof ProgramElementNode) {
getPackagesHelper(
(ProgramElementNode) nextNode,
kind,
prename,
matches);
}
}
return matches;
}
/**
* Helper function sorts a list of resources into alphabetical order
*/
private List sortElements(List oldElements) {
Object[] temp = oldElements.toArray();
SortingComparator comparator = new SortingComparator();
Arrays.sort(temp, comparator);
List newResources = Arrays.asList(temp);
return newResources;
}
private static List sortArray(List oldElements) {
Object[] temp = oldElements.toArray();
SortArrayComparator comparator = new SortArrayComparator();
Arrays.sort(temp, comparator);
List newElements = Arrays.asList(temp);
return newElements;
}
private class SortingComparator implements Comparator {
public int compare(Object o1, Object o2) {
ProgramElementNode p1 = (ProgramElementNode) o1;
ProgramElementNode p2 = (ProgramElementNode) o2;
String name1 = p1.getName();
String name2 = p2.getName();
return name1.compareTo(name2);
}
}
private static class SortArrayComparator implements Comparator {
public int compare(Object o1, Object o2) {
Object[] array1 = (Object[]) o1;
Object[] array2 = (Object[]) o2;
ProgramElementNode p1 = (ProgramElementNode) array1[1];
ProgramElementNode p2 = (ProgramElementNode) array2[1];
String name1 = p1.getName();
String name2 = p2.getName();
return name1.compareTo(name2);
}
}
/**
* @return all of the AspectJ and Java source files in a package
*/
public static List getFilesInPackage(ProgramElementNode packageNode) {
List packageContents;
if (packageNode == null) {
return null;
} else {
packageContents = packageNode.getChildren();
}
List files = new ArrayList();
for (Iterator it = packageContents.iterator(); it.hasNext(); ) {
ProgramElementNode packageItem = (ProgramElementNode)it.next();
if (packageItem.getProgramElementKind() == ProgramElementNode.Kind.FILE_JAVA
|| packageItem.getProgramElementKind() == ProgramElementNode.Kind.FILE_ASPECTJ) {
files.add(packageItem);
}
}
return files;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class StructureSearchManager {
/**
* @param pattern case-sensitive substring of node name
*
* @return null if a corresponding node was not found
*/
public List findMatches(
String pattern,
ProgramElementNode.Kind kind) {
List matches = new ArrayList();
StructureModel model = Ajde.getDefault().getStructureModelManager().getStructureModel();
if (model.equals(StructureModel.NO_STRUCTURE)) {
return null;
} else {
return findMatchesHelper((ProgramElementNode)model.getRoot(), pattern, kind, matches);
}
}
private List findMatchesHelper(
ProgramElementNode node,
String pattern,
ProgramElementNode.Kind kind,
List matches) {
if (node != null && node.getName().indexOf(pattern) != -1) {
if (kind == null || node.getProgramElementKind().equals(kind)) {
matches.add(node);
}
}
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureNode nextNode = (StructureNode)it.next();
if (nextNode instanceof ProgramElementNode) {
findMatchesHelper(
(ProgramElementNode)nextNode,
pattern,
kind,
matches);
}
}
return matches;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureView.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.Iterator;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
public abstract class StructureView {
private StructureViewNode rootNode = null;
private StructureViewNode activeNode = null;
protected StructureViewProperties viewProperties = null;
protected StructureViewRenderer renderer = null;
public StructureViewProperties getViewProperties() {
return viewProperties;
}
public StructureViewNode getRootNode() {
return rootNode;
}
public void setRootNode(StructureViewNode rootNode) {
this.rootNode = rootNode;
}
public void setViewProperties(StructureViewProperties viewProperties) {
this.viewProperties = viewProperties;
}
public void setRenderer(StructureViewRenderer renderer) {
this.renderer = renderer;
}
protected void notifyViewUpdated() {
if (renderer != null) renderer.updateView(this);
}
/**
* @return the view node corresponding to the active ProgramElementNode or null
*/
public StructureViewNode getActiveNode() {
if (activeNode != null
&& activeNode.getStructureNode() instanceof ProgramElementNode) {
return activeNode;
} else {
return null;
}
}
/**
* Searches from the root node of the view down in order to find matches.
*
* @return the first match
*/
public StructureViewNode findCorrespondingViewNode(ProgramElementNode node) {
return findCorrespondingViewNodeHelper(rootNode, node);
}
private StructureViewNode findCorrespondingViewNodeHelper(StructureViewNode node, ProgramElementNode pNode) {
if (node != null
&& node.getStructureNode() != null
&& node.getStructureNode().equals(pNode)) {
return node;
}
if (node != null && node.getChildren() != null) {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureViewNode foundNode = findCorrespondingViewNodeHelper((StructureViewNode)it.next(), pNode);
if (foundNode != null) return foundNode;
}
}
return null;
}
public void setActiveNode(StructureViewNode activeNode) {
this.activeNode = activeNode;
if (renderer != null) renderer.setActiveNode(activeNode);
}
public void setActiveNode(StructureViewNode activeNode, int sourceLine) {
this.activeNode = activeNode;
if (renderer != null) renderer.setActiveNode(activeNode, sourceLine);
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.internal.NavigationHistoryModel;
import org.aspectj.ajde.ui.internal.TreeStructureViewBuilder;
import org.aspectj.asm.AdviceAssociation;
import org.aspectj.asm.InheritanceAssociation;
import org.aspectj.asm.IntroductionAssociation;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.ReferenceAssociation;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelListener;
import org.aspectj.asm.StructureModelManager;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class StructureViewManager {
private TreeStructureViewBuilder treeViewBuilder;
private String buildConfigFilePath = null;
private NavigationHistoryModel historyModel = new NavigationHistoryModel();
private ArrayList structureViews = new ArrayList();
private FileStructureView defaultFileView = null;
private static final StructureViewProperties DEFAULT_VIEW_PROPERTIES;
private static final List AVAILABLE_RELATIONS;
public final StructureModelListener VIEW_LISTENER = new StructureModelListener() {
public void modelUpdated(StructureModel model) {
Ajde.getDefault().logEvent("updating structure views: " + structureViews);
//
// if (defaultFileView != null) {
// defaultFileView.setSourceFile(Ajde.getDefault().getEditorManager().getCurrFile());
// }
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
treeViewBuilder.buildView((StructureView)it.next(), (StructureModel)model);
}
}
};
/**
* @param nodeFactory concrete factory for creating view nodes
*/
public StructureViewManager(StructureViewNodeFactory nodeFactory) {
treeViewBuilder = new TreeStructureViewBuilder(nodeFactory);
StructureModelManager.getDefault().addListener(VIEW_LISTENER);
}
public void fireNavigateBackAction(StructureView view) {
ProgramElementNode backNode = historyModel.navigateBack();
if (backNode == null) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("No node to navigate back to in history");
} else {
navigationAction(backNode, false);
}
}
public void fireNavigateForwardAction(StructureView view) {
ProgramElementNode forwardNode = historyModel.navigateForward();
if (forwardNode == null) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("No node to navigate forward to in history");
} else {
navigationAction(forwardNode, false);
}
}
/**
* Only navigations of the default view are registered with
* the history.
* @param newFilePath the canonicalized path to the new file
*/
public void fireNavigationAction(String newFilePath, int lineNumber) {
StructureNode currNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
newFilePath,
lineNumber);
if (currNode instanceof ProgramElementNode) {
navigationAction((ProgramElementNode)currNode, true);
}
}
/**
* History is recorded for {@link LinkNode} navigations.
*/
public void fireNavigationAction(StructureNode structureNode) {
ProgramElementNode node = null;
boolean recordHistory = false;
if (structureNode instanceof LinkNode) {
node = ((LinkNode)structureNode).getProgramElementNode();
recordHistory = true;
} else if (structureNode instanceof ProgramElementNode) {
node = (ProgramElementNode)structureNode;
}
if (node != null) navigationAction(node, recordHistory);
}
/**
* Highlights the given node in all structure views. If the node represents code
* and as such is below the granularity visible in the view the parent is highlighted,
* along with the corresponding sourceline.
*/
private void navigationAction(ProgramElementNode node, boolean recordHistory) {
if (node == null
|| node == StructureModel.NO_STRUCTURE) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Source not available for node: " + node.getName());
return;
}
Ajde.getDefault().logEvent("navigating to node: " + node + ", recordHistory: " + recordHistory);
if (recordHistory) historyModel.navigateToNode(node);
if (defaultFileView != null && node.getSourceLocation() != null) {
String newFilePath = node.getSourceLocation().getSourceFile().getAbsolutePath();
if (defaultFileView.getSourceFile() != null
&& !defaultFileView.getSourceFile().equals(newFilePath)) {
defaultFileView.setSourceFile(newFilePath);
treeViewBuilder.buildView(defaultFileView, StructureModelManager.getDefault().getStructureModel());
}
}
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
StructureView view = (StructureView)it.next();
if (!(view instanceof GlobalStructureView) || !recordHistory || defaultFileView == null) {
if (node.getProgramElementKind().equals(ProgramElementNode.Kind.CODE)) {
ProgramElementNode parentNode = (ProgramElementNode)node.getParent();
if (parentNode != null) {
StructureViewNode currNode = view.findCorrespondingViewNode(parentNode);
int lineOffset = node.getSourceLocation().getLine() - parentNode.getSourceLocation().getLine();
if (currNode != null) view.setActiveNode(currNode, lineOffset);
}
} else {
StructureViewNode currNode = view.findCorrespondingViewNode(node);
if (currNode != null) view.setActiveNode(currNode);
}
}
}
}
private ProgramElementNode getProgramElementNode(StructureViewNode node) {
if (node.getStructureNode() instanceof ProgramElementNode) {
return (ProgramElementNode)node.getStructureNode();
} else if (node.getStructureNode() instanceof LinkNode) {
return ((LinkNode)node.getStructureNode()).getProgramElementNode();
} else {
return null;
}
}
public void refreshView(StructureView view) {
StructureViewNode activeNode = view.getActiveNode();
treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getStructureModel());
view.setActiveNode(activeNode);
}
public StructureViewProperties getDefaultViewProperties() {
return DEFAULT_VIEW_PROPERTIES;
}
/**
* Returns the list of all available relations.
*/
public List getAvailableRelations() {
return AVAILABLE_RELATIONS;
}
/**
* @param properties can not be null
*/
public GlobalStructureView createGlobalView(GlobalViewProperties properties) {
GlobalStructureView view = new GlobalStructureView(properties);
structureViews.add(view);
return view;
}
/**
* @param sourceFilePath full path to corresponding source file
* @param properties if null default properties will be used
* @return always returns a view intance
*/
public FileStructureView createViewForSourceFile(String sourceFilePath, StructureViewProperties properties) {
Ajde.getDefault().logEvent("creating view for file: " + sourceFilePath);
if (properties == null) properties = DEFAULT_VIEW_PROPERTIES;
FileStructureView view = new FileStructureView(properties);
view.setSourceFile(sourceFilePath);
treeViewBuilder.buildView(view, StructureModelManager.getDefault().getStructureModel());
structureViews.add(view);
return view;
}
/**
* @return true if the view was found and removed, false otherwise
*/
public boolean deleteView(StructureView view) {
return structureViews.remove(view);
}
public void setDefaultFileView(FileStructureView defaultFileView) {
this.defaultFileView = defaultFileView;
}
public FileStructureView getDefaultFileView() {
return defaultFileView;
}
static {
AVAILABLE_RELATIONS = new ArrayList();
AVAILABLE_RELATIONS.add(AdviceAssociation.METHOD_CALL_SITE_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.METHOD_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.CONSTRUCTOR_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.FIELD_ACCESS_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.INITIALIZER_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.HANDLER_RELATION);
AVAILABLE_RELATIONS.add(AdviceAssociation.INTRODUCTION_RELATION);
AVAILABLE_RELATIONS.add(IntroductionAssociation.INTRODUCES_RELATION);
AVAILABLE_RELATIONS.add(InheritanceAssociation.IMPLEMENTS_RELATION);
AVAILABLE_RELATIONS.add(InheritanceAssociation.INHERITS_RELATION);
AVAILABLE_RELATIONS.add(InheritanceAssociation.INHERITS_MEMBERS_RELATION);
AVAILABLE_RELATIONS.add(ReferenceAssociation.USES_POINTCUT_RELATION);
AVAILABLE_RELATIONS.add(ReferenceAssociation.IMPORTS_RELATION);
DEFAULT_VIEW_PROPERTIES = new StructureViewProperties();
DEFAULT_VIEW_PROPERTIES.setRelations(AVAILABLE_RELATIONS);
}
}
// this.multiFileViewMode = multiFileViewMode;
// if (!multiFileViewMode) {
// structureViews.add(DEFAULT_FILE_VIEW);
// structureViews.add(DECLARATION_VIEW);
// structureViews.add(CROSSCUTTING_VIEW);
// structureViews.add(INHERITANCE_VIEW);
// }
// public GlobalStructureView getGlobalStructureView(StructureViewProperties.Hierarchy hierarchy) {
// if (hierarchy == StructureViewProperties.Hierarchy.CROSSCUTTING) {
// return CROSSCUTTING_VIEW;
// } else if (hierarchy == StructureViewProperties.Hierarchy.INHERITANCE) {
// return INHERITANCE_VIEW;
// } else {
// return DECLARATION_VIEW;
// }
// }
// public FileStructureView getDefaultFileStructureView() {
// return DEFAULT_FILE_VIEW;
// }
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureViewNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.List;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public interface StructureViewNode {
public StructureNode getStructureNode();
public AbstractIcon getIcon();
/**
* Add a child node.
*/
public void add(StructureViewNode child);
/**
* Remove a child node.
*/
public void remove(StructureViewNode child);
/**
* @return an empty list if there are no children
*/
public List getChildren();
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.List;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.RelationNode;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public abstract class StructureViewNodeFactory {
private AbstractIconRegistry iconRegistry;
public StructureViewNodeFactory(AbstractIconRegistry iconRegistry) {
this.iconRegistry = iconRegistry;
}
public StructureViewNode createNode(StructureNode node) {
return createNode(node, null);
}
public StructureViewNode createNode(StructureNode node, List children) {
AbstractIcon icon;
if (node instanceof ProgramElementNode) {
ProgramElementNode pNode = (ProgramElementNode)node;
icon = iconRegistry.getStructureIcon(pNode.getProgramElementKind(), pNode.getAccessibility());
} else if (node instanceof RelationNode) {
RelationNode relationNode = (RelationNode)node;
icon = iconRegistry.getRelationIcon(relationNode.getRelation());
} else if (node instanceof LinkNode) {
LinkNode linkNode = (LinkNode)node;
icon = iconRegistry.getStructureIcon(
linkNode.getProgramElementNode().getProgramElementKind(),
linkNode.getProgramElementNode().getAccessibility());
} else {
icon = new AbstractIcon(null);
}
return createConcreteNode(node, icon, children);
}
/**
* Implementors must override this method in order to create new nodes.
*/
protected abstract StructureViewNode createConcreteNode(StructureNode node, AbstractIcon icon, List children);
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.io.ObjectStreamException;
import java.util.ArrayList;
import java.util.List;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.Relation;
/**
* Nested properties use the typesafe enum pattern.
*
* @author Mik Kersten
*/
public class StructureViewProperties {
/**
* @deprecated
*/
public static final String SORT_DECLARATIONAL = StructureViewProperties.Sorting.DECLARATIONAL.toString();
/**
* @deprecated
*/
public void setSorting(String sorting) { }
private List relations = new ArrayList();
private List filteredMemberAccessibility = new ArrayList();
private List filteredMemberModifiers = new ArrayList();
private List filteredMemberKinds = new ArrayList();
private List grouping = new ArrayList();
private Sorting sorting = Sorting.DECLARATIONAL;
private Granularity granularity = Granularity.MEMBER;
public List getRelations() {
return relations;
}
public void setRelations(List relations) {
this.relations = relations;
}
public void addRelation(Relation relation) {
relations.add(relation);
}
public void removeRelation(Relation relation) {
relations.remove(relation);
}
public void setFilteredMemberAccessibility(List memberVisibility) {
this.filteredMemberAccessibility = memberVisibility;
}
public List getFilteredMemberAccessibility() {
return filteredMemberAccessibility;
}
public void addFilteredMemberAccessibility(ProgramElementNode.Accessibility accessibility) {
this.filteredMemberAccessibility.add(accessibility);
}
public void removeFilteredMemberAccessibility(ProgramElementNode.Accessibility accessibility) {
this.filteredMemberAccessibility.remove(accessibility);
}
public List getFilteredMemberModifiers() {
return filteredMemberModifiers;
}
public void setFilteredMemberModifiers(List memberModifiers) {
this.filteredMemberModifiers = memberModifiers;
}
public void addFilteredMemberModifiers(ProgramElementNode.Modifiers modifiers) {
this.filteredMemberModifiers.add(modifiers);
}
public void removeFilteredMemberModifiers(ProgramElementNode.Modifiers modifiers) {
this.filteredMemberModifiers.remove(modifiers);
}
public StructureViewProperties.Sorting getSorting() {
return sorting;
}
public void setSorting(StructureViewProperties.Sorting sorting) {
this.sorting = sorting;
}
public List getFilteredMemberKinds() {
return filteredMemberKinds;
}
public void setFilteredMemberKinds(List memberKinds) {
this.filteredMemberKinds = memberKinds;
}
public void addFilteredMemberKind(ProgramElementNode.Kind kind) {
this.filteredMemberKinds.add(kind);
}
public void removeFilteredMemberKind(ProgramElementNode.Kind kind) {
this.filteredMemberKinds.remove(kind);
}
public List getGrouping() {
return grouping;
}
public void setGrouping(List grouping) {
this.grouping = grouping;
}
public void addGrouping(Grouping grouping) {
this.grouping.add(grouping);
}
public void removeGrouping(Grouping grouping) {
this.grouping.remove(grouping);
}
public Granularity getGranularity() {
return granularity;
}
public void setGranularity(Granularity granularity) {
this.granularity = granularity;
}
public String getName() {
return "<unnamed view>";
}
public String toString() {
return "\nView Properties:"
+ "\n-> sorting: " + sorting
+ "\n-> grouping: " + grouping
+ "\n-> filtered member kinds: " + filteredMemberKinds
+ "\n-> filtered member accessibility: " + filteredMemberAccessibility
+ "\n-> filtered member modifiers: " + filteredMemberModifiers
+ "\n-> relations: " + relations;
}
public static class Hierarchy {
public static final Hierarchy DECLARATION = new Hierarchy("package hierarchy");
public static final Hierarchy CROSSCUTTING = new Hierarchy("crosscutting structure");
public static final Hierarchy INHERITANCE = new Hierarchy("type hierarchy");
public static final Hierarchy[] ALL = { DECLARATION, CROSSCUTTING, INHERITANCE };
private final String name;
private Hierarchy(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
public static class Grouping {
public static final Grouping KIND = new Grouping("group by kind");
public static final Grouping VISIBILITY = new Grouping("group by visibility");
public static final Grouping[] ALL = { KIND, VISIBILITY };
private final String name;
private Grouping(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
public static class Sorting {
public static final Sorting ALPHABETICAL = new Sorting("sort alphabetically");
public static final Sorting DECLARATIONAL = new Sorting("sort declarationally");
public static final Sorting[] ALL = { ALPHABETICAL, DECLARATIONAL };
private final String name;
private Sorting(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
public static class Granularity {
public static final Granularity PACKAGE = new Granularity("package");
public static final Granularity FILE = new Granularity("file");
public static final Granularity TYPE = new Granularity("type");
public static final Granularity MEMBER = new Granularity("member");
public static final Granularity DECLARED_ELEMENTS = new Granularity("declared body elements");
public static final Granularity[] ALL = { PACKAGE, FILE, TYPE, MEMBER, DECLARED_ELEMENTS };
private final String name;
private Granularity(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.internal;
import java.util.Stack;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
public class NavigationHistoryModel {
private ProgramElementNode currNode = null;
private Stack backHistory = new Stack();
private Stack forwardHistory = new Stack();
/**
* @return null if the history is empty
*/
public ProgramElementNode navigateBack() {
if (backHistory.isEmpty() || currNode == null) return null;
forwardHistory.push(currNode);
currNode = (ProgramElementNode)backHistory.pop();
return currNode;
}
/**
* @return null if the history is empty
*/
public ProgramElementNode navigateForward() {
if (forwardHistory.isEmpty() || currNode == null) return null;
backHistory.push(currNode);
currNode = (ProgramElementNode)forwardHistory.pop();
return currNode;
}
public void navigateToNode(ProgramElementNode toNode) {
if (currNode != null) backHistory.push(currNode);
currNode = toNode;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.aspectj.ajde.ui.FileStructureView;
import org.aspectj.ajde.ui.GlobalStructureView;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewNode;
import org.aspectj.ajde.ui.StructureViewNodeFactory;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.Relation;
import org.aspectj.asm.RelationNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class TreeStructureViewBuilder {
private StructureViewNodeFactory nodeFactory;
public TreeStructureViewBuilder(StructureViewNodeFactory nodeFactory) {
this.nodeFactory = nodeFactory;
}
/**
* @todo get rid of instanceof tests
*/
public void buildView(StructureView view, StructureModel model) {
StructureViewProperties properties = view.getViewProperties();
StructureNode modelRoot = null;
boolean noStructure = false;
if (isFileView(view)) {
FileStructureView fileView = (FileStructureView)view;
if (fileView.getSourceFile() == null) {
modelRoot = StructureModel.NO_STRUCTURE;
noStructure = true;
} else {
modelRoot = model.findRootNodeForSourceFile(fileView.getSourceFile());
}
} else {
modelRoot = model.getRoot();
}
StructureViewNode viewRoot = null;
if (!isFileView(view)) {
StructureViewProperties.Hierarchy hierarchy
= ((GlobalStructureView)view).getGlobalViewProperties().getHierarchy();
if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)
|| hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) {
viewRoot = buildCustomTree((GlobalStructureView)view, model);
}
}
if (viewRoot == null) {
viewRoot = createViewNode(modelRoot, view.getViewProperties());//modelRoot;
}
if (view.getViewProperties().getSorting() == StructureViewProperties.Sorting.ALPHABETICAL
|| (!isFileView(view) &&
((GlobalStructureView)view).getGlobalViewProperties().getHierarchy().equals(StructureViewProperties.Hierarchy.DECLARATION))) {
sortView(viewRoot, ALPHABETICAL_COMPARATOR);
} else {
sortView(viewRoot, DECLARATIONAL_COMPARATOR);
}
addPackageNode(view, viewRoot);
view.setRootNode(viewRoot);
}
private void addPackageNode(StructureView view, StructureViewNode viewRoot) {
if (isFileView(view)) {
ProgramElementNode fileNode = (ProgramElementNode)viewRoot.getStructureNode();
StructureNode parentNode = fileNode.getParent();
if (parentNode instanceof ProgramElementNode
&& ((ProgramElementNode)parentNode).getProgramElementKind().equals(ProgramElementNode.Kind.PACKAGE)) {
String name = ((ProgramElementNode)parentNode).getName();
ProgramElementNode packageNode = new ProgramElementNode(name, ProgramElementNode.Kind.PACKAGE, null);
packageNode.setSourceLocation(fileNode.getSourceLocation());
StructureViewNode packageViewNode = createViewNode(
packageNode,
view.getViewProperties()
);
viewRoot.getChildren().add(0, packageViewNode);
};
}
}
private StructureViewNode createViewNode(StructureNode node, StructureViewProperties properties) {
if (node == null) return null;
List children = new ArrayList();
if (node instanceof ProgramElementNode) {
ProgramElementNode pNode = (ProgramElementNode)node;
if (pNode.getRelations() != null) {
for (Iterator it = pNode.getRelations().iterator(); it.hasNext(); ) {
StructureNode structureNode = (StructureNode)it.next();
if (acceptNode(structureNode, properties)) {
children.add(createViewNode(structureNode, properties));
}
}
}
if (pNode.isRunnable() && pNode.getParent() != null) {
ProgramElementNode parent = (ProgramElementNode)pNode.getParent();
if (parent.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS)
|| parent.getProgramElementKind().equals(ProgramElementNode.Kind.ASPECT)) {
parent.setRunnable(true);
pNode.setRunnable(false);
}
}
}
if (node.getChildren() != null) {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureNode structureNode = (StructureNode)it.next();
if (acceptNode(structureNode, properties)) {
children.add(createViewNode(structureNode, properties));
}
}
}
StructureViewNode viewNode = nodeFactory.createNode(node, children);//new TreeViewNode(root, null, children);
return viewNode;
}
/**
* @todo get rid of this test, fix polymorphism
*/
private boolean isFileView(StructureView view) {
return view instanceof FileStructureView
&& !(view instanceof GlobalStructureView);
}
private boolean acceptGranularity(ProgramElementNode.Kind kind, StructureViewProperties.Granularity granularity) {
if (granularity == StructureViewProperties.Granularity.DECLARED_ELEMENTS) {
return true;
} else if (granularity == StructureViewProperties.Granularity.MEMBER &&
(kind != ProgramElementNode.Kind.CODE)) {
return true;
} else if (granularity == StructureViewProperties.Granularity.TYPE
&& (kind == ProgramElementNode.Kind.PROJECT
|| kind == ProgramElementNode.Kind.PACKAGE
|| kind.isSourceFileKind()
|| kind.isTypeKind())) {
return true;
} else if (granularity == StructureViewProperties.Granularity.FILE
&& (kind == ProgramElementNode.Kind.PROJECT
|| kind == ProgramElementNode.Kind.PACKAGE
|| kind.isSourceFileKind())) {
return true;
} else if (granularity == StructureViewProperties.Granularity.PACKAGE
&& (kind == ProgramElementNode.Kind.PROJECT
|| kind == ProgramElementNode.Kind.PACKAGE)) {
return true;
} else {
return false;
}
}
private boolean acceptNode(StructureNode node, StructureViewProperties properties) {
if (node instanceof ProgramElementNode) {
ProgramElementNode pNode = (ProgramElementNode)node;
if (!acceptGranularity(pNode.getProgramElementKind(), properties.getGranularity())) {
return false;
} else if (pNode.isMemberKind()) {
if (properties.getFilteredMemberAccessibility().contains(pNode.getAccessibility())) {
return false;
}
if (properties.getFilteredMemberKinds().contains(pNode.getProgramElementKind())) {
return false;
}
for (Iterator it = pNode.getModifiers().iterator(); it.hasNext(); ) {
if (properties.getFilteredMemberModifiers().contains(it.next())) {
return false;
}
}
}
} else if (node instanceof RelationNode) {
Relation relation = ((RelationNode)node).getRelation();
return properties.getRelations().contains(relation);
} else {
return true;
}
return true;
}
private void sortView(StructureViewNode node, Comparator comparator) {
if (node == null || node.getChildren() == null) return;
Collections.sort(node.getChildren(), comparator);
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureViewNode nextNode = (StructureViewNode)it.next();
if (nextNode != null) sortView(nextNode, comparator);
}
}
private StructureViewNode buildCustomTree(GlobalStructureView view, StructureModel model) {
StructureNode rootNode = model.getRoot();
StructureViewNode treeNode = nodeFactory.createNode(rootNode);
List rootNodes = new ArrayList();
getRoots(rootNode, rootNodes, view.getGlobalViewProperties().getHierarchy());
for (Iterator it = rootNodes.iterator(); it.hasNext(); ) {
if (view.getGlobalViewProperties().getHierarchy().equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) {
treeNode.add(getCrosscuttingChildren((StructureNode)it.next()));
} else if (view.getGlobalViewProperties().getHierarchy().equals(StructureViewProperties.Hierarchy.INHERITANCE)) {
treeNode.add(getInheritanceChildren(
(StructureNode)it.next(),
view.getViewProperties().getRelations())
);
}
}
return treeNode;
}
private void getRoots(StructureNode rootNode, List roots, StructureViewProperties.Hierarchy hierarchy) {
if (rootNode != null && rootNode.getChildren() != null) {
for (Iterator it = rootNode.getChildren().iterator(); it.hasNext(); ) {
StructureNode node = (StructureNode)it.next();
if (node instanceof ProgramElementNode) {
if (acceptNodeAsRoot((ProgramElementNode)node, hierarchy)) {
ProgramElementNode pNode = (ProgramElementNode)node;
List relations = pNode.getRelations();
String delimiter = "";
if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) {
delimiter = "uses pointcut";
} else if (hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) {
delimiter = "inherits";
}
if (relations != null && relations.toString().indexOf(delimiter) == -1) {
boolean found = false;
for (Iterator it2 = roots.iterator(); it2.hasNext(); ) {
if (((ProgramElementNode)it2.next()).equals(pNode)) found = true;
}
if (!found) roots.add(pNode);
}
}
}
getRoots(node, roots, hierarchy);
}
}
}
public boolean acceptNodeAsRoot(ProgramElementNode node, StructureViewProperties.Hierarchy hierarchy) {
if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) {
return node.getProgramElementKind().equals(ProgramElementNode.Kind.ADVICE)
|| node.getProgramElementKind().equals(ProgramElementNode.Kind.POINTCUT);
} else if (hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) {
return node.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS);
} else {
return false;
}
}
private StructureViewNode getInheritanceChildren(StructureNode node, List associations) {
StructureViewNode treeNode = nodeFactory.createNode(node);
//StructureViewNode treeNode = new StructureViewNodeAdapter(node);
List relations = ((ProgramElementNode)node).getRelations();
if (relations != null) {
for (Iterator it = relations.iterator(); it.hasNext(); ) {
RelationNode relation = (RelationNode)it.next();
if (relation.getName().equals("is inherited by")) {
for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) {
ProgramElementNode pNode = ((LinkNode)it2.next()).getProgramElementNode();
StructureViewNode newNode = getInheritanceChildren(pNode, associations);
StructureViewNode typeChildren = buildTree(newNode.getStructureNode(), associations);
for (int i = 0; i < typeChildren.getChildren().size(); i++) {
newNode.add((StructureViewNode)typeChildren.getChildren().get(i));
}
treeNode.add(newNode);
}
}
}
}
return treeNode;
}
private StructureViewNode getCrosscuttingChildren(StructureNode node) {
//StructureViewNodeAdapter treeNode = new StructureViewNodeAdapter(node);
StructureViewNode treeNode = nodeFactory.createNode(node);
List relations = ((ProgramElementNode)node).getRelations();
if (relations != null) {
for (Iterator it = relations.iterator(); it.hasNext(); ) {
RelationNode relation = (RelationNode)it.next();
if (relation.getName().equals("pointcut used by")) {
for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) {
ProgramElementNode pNode = ((LinkNode)it2.next()).getProgramElementNode();
StructureViewNode newNode = getCrosscuttingChildren(pNode);
for (Iterator it3 = pNode.getRelations().iterator(); it3.hasNext(); ) {
RelationNode relationNode = (RelationNode)it3.next();
if (relationNode.getName().indexOf("pointcut") == -1) {
newNode.add(getRelations(relationNode));
}
}
treeNode.add(newNode);
}
} else if (relations.toString().indexOf("uses pointcut") == -1) {
for (Iterator it4 = relations.iterator(); it4.hasNext(); ) {
RelationNode relationNode = (RelationNode)it4.next();
if (relationNode.getName().indexOf("pointcut") == -1) {
treeNode.add(getRelations(relationNode));
}
}
}
}
}
return treeNode;
}
private StructureViewNode buildTree(StructureNode node, List associations) {
//StructureViewNode treeNode = new StructureViewNodeAdapter(node);
StructureViewNode treeNode = nodeFactory.createNode(node);
if (node instanceof ProgramElementNode) {
List relations = ((ProgramElementNode)node).getRelations();
if (relations != null) {
for (Iterator it = relations.iterator(); it.hasNext(); ) {
RelationNode relationNode = (RelationNode)it.next();
if (associations.contains(relationNode.getRelation().toString())) {
treeNode.add(buildTree(relationNode, associations));
}
}
}
}
if (node != null) {
List children = null;
children = node.getChildren();
if (children != null) {
List childList = new ArrayList();
for (Iterator itt = children.iterator(); itt.hasNext(); ) {
StructureNode child = (StructureNode)itt.next();
if (child instanceof ProgramElementNode) {
ProgramElementNode progNode = (ProgramElementNode)child;
if (!progNode.isCode()) {
childList.add(buildTree(child, associations));
}
} else {
childList.add(buildTree(child, associations));
}
}
//sortNodes(childList);
for (Iterator it = childList.iterator(); it.hasNext(); ) {
treeNode.add((StructureViewNode)it.next());
}
}
}
return treeNode;
}
private StructureViewNode getRelations(RelationNode node) {
//StructureViewNode treeNode = new StructureViewNode(node);
StructureViewNode treeNode = nodeFactory.createNode(node);
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
treeNode.add(
nodeFactory.createNode((StructureNode)it.next())
);
}
return treeNode;
}
/**
* For debugging only.
*/
private void dumpView(StructureViewNode root, int level) {
System.out.println(root.getStructureNode());
for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) {
dumpView((StructureViewNode)it.next(), level++);
}
for (int i = 0; i < level; i++) {
System.out.print(' ');
}
}
private static final Comparator ALPHABETICAL_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
StructureNode sv1 = ((StructureViewNode)o1).getStructureNode();
StructureNode sv2 = ((StructureViewNode)o2).getStructureNode();
if (sv1 instanceof ProgramElementNode && sv2 instanceof ProgramElementNode) {
ProgramElementNode p1 = (ProgramElementNode)sv1;
ProgramElementNode p2 = (ProgramElementNode)sv2;
return p1.getName().compareTo(p2.getName());
} else {
return 0;
}
}
};
private static final Comparator DECLARATIONAL_COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
StructureNode sv1 = ((StructureViewNode)o1).getStructureNode();
StructureNode sv2 = ((StructureViewNode)o2).getStructureNode();
if (sv1 instanceof ProgramElementNode && sv2 instanceof ProgramElementNode) {
ProgramElementNode p1 = (ProgramElementNode)sv1;
ProgramElementNode p2 = (ProgramElementNode)sv2;
if (p1.getSourceLocation() == null) {
return 0;
} else if (p1.getSourceLocation().getLine() < p2.getSourceLocation().getLine()) {
return -1;
} else {
return 1;
}
} else {
return 0;
}
}
};
}
// private boolean acceptNode(ProgramElementNode node) {
// return true;
// if (node.getKind().equals("package")) return true;
//
// if (node.getKind().equals("file")) {
// if (granularity == ViewProperties.Granularity.PACKAGE) {
// return false;
// } else {
// return true;
// }
// }
//
// if (node.getKind().equals("class") || node.getKind().equals("aspect") || node.getKind().equals("interface")) {
// if (granularity == ViewProperties.Granularity.FILE || granularity == ViewProperties.Granularity.PACKAGE) {
// return false;
// } else {
// return true;
// }
// }
//
// if (node.isMemberKind()) {
// if (granularity == ViewProperties.Granularity.MEMBER) {
// for (Iterator it = modifiers.iterator(); it.hasNext(); ) {
// if (node.getModifiers().contains((String)it.next())) return false;
// }
// for (Iterator it2 = visibility.iterator(); it2.hasNext(); ) {
// if (node.getAccessibility().equals((String)it2.next())) return false;
// }
// if (filteredMemberKinds.contains(node.getKind())) {
// return false;
// } else {
// return true;
// }
// } else {
// return false;
// }
// }
//
// if (node.isCode()) return false;
//
// return false;
// }
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.Frame;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.BuildListener;
import org.aspectj.ajde.BuildProgressMonitor;
import org.aspectj.ajde.EditorAdapter;
import org.aspectj.ajde.ErrorHandler;
import org.aspectj.ajde.ProjectPropertiesAdapter;
import org.aspectj.ajde.TaskListManager;
import org.aspectj.ajde.ui.FileStructureView;
import org.aspectj.ajde.ui.IdeUIAdapter;
import org.aspectj.ajde.ui.UserPreferencesAdapter;
import org.aspectj.ajde.ui.internal.AjcBuildOptions;
/**
* @author Mik Kersten
*/
public class AjdeUIManager {
protected static final AjdeUIManager INSTANCE = new AjdeUIManager();
private BrowserViewManager viewManager = null;
private BuildProgressMonitor buildProgressMonitor = null;
private ErrorHandler errorHandler = null;
private UserPreferencesAdapter userPreferencesAdapter = null;
private AjcBuildOptions buildOptionsAdapter = null;
private IdeUIAdapter ideUIAdapter = null;
private TreeViewBuildConfigEditor buildConfigEditor = null;
private IconRegistry iconRegistry;
private OptionsFrame optionsFrame = null;
private Frame rootFrame = null;
private StructureViewPanel fileStructurePanel = null;
/**
* Order of initialization is critical here.
*/
public void init(
EditorAdapter editorAdapter,
TaskListManager taskListManager,
ProjectPropertiesAdapter projectProperties,
UserPreferencesAdapter userPreferencesAdapter,
IdeUIAdapter ideUIAdapter,
IconRegistry iconRegistry,
Frame rootFrame,
boolean useFileView) {
try {
BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame);
ErrorHandler errorHandler = new AjdeErrorHandler();
this.iconRegistry = iconRegistry;
//ConfigurationManager configManager = new LstConfigurationManager();
this.ideUIAdapter = ideUIAdapter;
this.userPreferencesAdapter = userPreferencesAdapter;
this.buildOptionsAdapter = new AjcBuildOptions(userPreferencesAdapter);
this.buildConfigEditor = new TreeViewBuildConfigEditor();
this.rootFrame = rootFrame;
Ajde.init(
editorAdapter,
taskListManager,
compileProgress,
projectProperties,
buildOptionsAdapter,
new SwingTreeViewNodeFactory(iconRegistry),
ideUIAdapter,
errorHandler);
Ajde.getDefault().getBuildManager().addListener(STATUS_TEXT_UPDATER);
//Ajde.getDefault().setConfigurationManager(configManager);
if (useFileView) {
FileStructureView structureView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(
Ajde.getDefault().getEditorAdapter().getCurrFile(),
Ajde.getDefault().getStructureViewManager().getDefaultViewProperties()
);
Ajde.getDefault().getStructureViewManager().setDefaultFileView(structureView);
fileStructurePanel = new StructureViewPanel(structureView);
}
viewManager = new BrowserViewManager();
optionsFrame = new OptionsFrame(iconRegistry);
//Ajde.getDefault().getStructureViewManager().refreshView(
// Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
//);
//viewManager.updateView();
} catch (Throwable t) {
Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t);
}
}
public static AjdeUIManager getDefault() {
return INSTANCE;
}
public BrowserViewManager getViewManager() {
return viewManager;
}
public Frame getRootFrame() {
return rootFrame;
}
public OptionsFrame getOptionsFrame() {
return optionsFrame;
}
public void showOptionsFrame() {
int x = (rootFrame.getWidth()/2) + rootFrame.getX() - optionsFrame.getWidth()/2;
int y = (rootFrame.getHeight()/2) + rootFrame.getY() - optionsFrame.getHeight()/2;
optionsFrame.setLocation(x, y);
optionsFrame.show();
}
public AjcBuildOptions getBuildOptions() {
return buildOptionsAdapter;
}
private final BuildListener STATUS_TEXT_UPDATER = new BuildListener() {
public void compileStarted(String buildConfigFile) {
ideUIAdapter.displayStatusInformation(" Building: " + buildConfigFile + "...");
}
public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) {
int timeInSeconds = buildTime/1000;
if (succeeded) {
ideUIAdapter.displayStatusInformation(" Build succeeded in " + timeInSeconds + " second(s).");
//hideMessages();
} else {
ideUIAdapter.displayStatusInformation(" Build failed in " + timeInSeconds + " second(s)");
//showMessages();
}
}
public void compileAborted(String buildConfigFile, String message) {
ideUIAdapter.displayStatusInformation("Compile aborted: " + message);
}
};
public IdeUIAdapter getIdeUIAdapter() {
return ideUIAdapter;
}
public TreeViewBuildConfigEditor getBuildConfigEditor() {
return buildConfigEditor;
}
public StructureViewPanel getFileStructurePanel() {
return fileStructurePanel;
}
public IconRegistry getIconRegistry() {
return iconRegistry;
}
}
//public abstract class AjdeAction {
// public abstract void actionPerformed(ActionEvent e);
//
// public abstract String getName();
//
// public abstract ImageIcon getIcon();
//}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.border.Border;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.GlobalStructureView;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.Relation;
public class BrowserStructureViewToolPanel extends JPanel {
private StructureView currentView;
private StructureViewPanel viewPanel;
protected BorderLayout borderLayout1 = new BorderLayout();
protected Border border1;
protected Border border2;
AJButtonMenuCombo granularityCombo;
AJButtonMenuCombo filterCombo;
AJButtonMenuCombo relationsCombo;
JPanel buttons_panel = new JPanel();
JPanel spacer_panel = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
JPanel view_panel = new JPanel();
JComboBox view_comboBox = null;
JLabel view_label = new JLabel();
BorderLayout borderLayout4 = new BorderLayout();
public BrowserStructureViewToolPanel(
java.util.List structureViews,
StructureView currentView,
StructureViewPanel viewPanel) {
this.currentView = currentView;
this.viewPanel = viewPanel;
view_comboBox = new JComboBox();
view_comboBox.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
view_comboBox.addItem(it.next());
}
try {
jbInit();
} catch (Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
initToolBar();
}
private void initToolBar() {
try {
granularityCombo = new AJButtonMenuCombo(
"Visible granularity",
"Visible granularity",
AjdeUIManager.getDefault().getIconRegistry().getGranularityIcon(),
createGranularityMenu(),
false);
filterCombo = new AJButtonMenuCombo(
"Filter members",
"Filter members",
AjdeUIManager.getDefault().getIconRegistry().getFilterIcon(),
createFilterMenu(),
false);
relationsCombo = new AJButtonMenuCombo(
"Filter associations",
"Filter associations",
AjdeUIManager.getDefault().getIconRegistry().getRelationsIcon(),
createRelationsMenu(),
false);
buttons_panel.add(granularityCombo, BorderLayout.WEST);
buttons_panel.add(filterCombo, BorderLayout.CENTER);
buttons_panel.add(relationsCombo, BorderLayout.EAST);
} catch(Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
}
private JPopupMenu createFilterMenu() {
JPopupMenu filterMenu = new JPopupMenu();
ProgramElementNode.Accessibility[] accessibility = ProgramElementNode.Accessibility.ALL;
for (int i = 0; i < accessibility.length; i++) {
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(accessibility[i]);
menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getAccessibilitySwingIcon(accessibility[i]));
filterMenu.add(menuItem);
}
filterMenu.add(new JSeparator());
ProgramElementNode.Kind[] kinds = ProgramElementNode.Kind.ALL;
for (int i = 0; i < kinds.length; i++) {
if (kinds[i].isMemberKind()) {
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kinds[i]);
menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(kinds[i]).getIconResource());
filterMenu.add(menuItem);
}
}
filterMenu.add(new JSeparator());
ProgramElementNode.Modifiers[] modifiers = ProgramElementNode.Modifiers.ALL;
for (int i = 0; i < modifiers.length; i++) {
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifiers[i]);
filterMenu.add(menuItem);
}
return filterMenu;
}
private JPopupMenu createRelationsMenu() {
JPopupMenu relationsMenu = new JPopupMenu();
java.util.List relations = Ajde.getDefault().getStructureViewManager().getAvailableRelations();
for (Iterator it = relations.iterator(); it.hasNext(); ) {
Relation relation = (Relation)it.next();
CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(relation);
menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getRelationIcon(relation).getIconResource());
relationsMenu.add(menuItem);
}
return relationsMenu;
}
private JPopupMenu createGranularityMenu() {
JPopupMenu orderMenu = new JPopupMenu();
StructureViewProperties.Granularity[] granularity = StructureViewProperties.Granularity.ALL;
ButtonGroup group = new ButtonGroup();
for (int i = 0; i < granularity.length; i++) {
RadioSelectionMenuButton menuItem = new RadioSelectionMenuButton(granularity[i], group);
orderMenu.add(menuItem);
if (granularity[i].equals(StructureViewProperties.Granularity.MEMBER)) {
menuItem.setSelected(true);
}
}
return orderMenu;
}
private class RadioSelectionMenuButton extends JRadioButtonMenuItem {
public RadioSelectionMenuButton(StructureViewProperties.Granularity granularity, ButtonGroup group) {
super(granularity.toString());
super.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
group.add(this);
this.addActionListener(new RadioSelectionMenuActionListener(granularity));
}
}
private class RadioSelectionMenuActionListener implements ActionListener {
private StructureViewProperties.Granularity granularity;
public RadioSelectionMenuActionListener(StructureViewProperties.Granularity granularity) {
this.granularity = granularity;
}
public void actionPerformed(ActionEvent e) {
currentView.getViewProperties().setGranularity(granularity);
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
}
}
private class CheckBoxSelectionMenuButton extends JCheckBoxMenuItem {
public CheckBoxSelectionMenuButton(String name) {
super(name);
this.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
this.setBackground(AjdeWidgetStyles.DEFAULT_BACKGROUND_COLOR);
//super.setSelected(true);
}
public CheckBoxSelectionMenuButton(ProgramElementNode.Accessibility accessibility) {
this(accessibility.toString());
this.addActionListener(new CheckBoxSelectionMenuActionListener(accessibility));
}
public CheckBoxSelectionMenuButton(ProgramElementNode.Kind kind) {
this(kind.toString());
this.addActionListener(new CheckBoxSelectionMenuActionListener(kind));
}
public CheckBoxSelectionMenuButton(ProgramElementNode.Modifiers modifiers) {
this(modifiers.toString());
this.addActionListener(new CheckBoxSelectionMenuActionListener(modifiers));
}
public CheckBoxSelectionMenuButton(StructureViewProperties.Sorting sorting) {
this(sorting.toString());
this.addActionListener(new CheckBoxSelectionMenuActionListener(sorting));
}
public CheckBoxSelectionMenuButton(Relation relation) {
this(relation.toString());
this.addActionListener(new CheckBoxSelectionMenuActionListener(relation));
}
}
/**
* Ewwwwww!
*/
private class CheckBoxSelectionMenuActionListener implements ActionListener {
private ProgramElementNode.Accessibility accessibility = null;
private ProgramElementNode.Kind kind = null;
private ProgramElementNode.Modifiers modifiers = null;
private StructureViewProperties.Sorting sorting = null;
private Relation relation = null;
public CheckBoxSelectionMenuActionListener(ProgramElementNode.Accessibility accessibility) {
this.accessibility = accessibility;
}
public CheckBoxSelectionMenuActionListener(ProgramElementNode.Kind kind) {
this.kind = kind;
}
public CheckBoxSelectionMenuActionListener(ProgramElementNode.Modifiers modifiers) {
this.modifiers = modifiers;
}
public CheckBoxSelectionMenuActionListener(StructureViewProperties.Sorting sorting) {
this.sorting = sorting;
}
public CheckBoxSelectionMenuActionListener(Relation relation) {
this.relation = relation;
}
public void actionPerformed(ActionEvent e) {
if (!(e.getSource() instanceof CheckBoxSelectionMenuButton)) return;
CheckBoxSelectionMenuButton checkMenu = (CheckBoxSelectionMenuButton)e.getSource();
if (accessibility != null) {
if (checkMenu.isSelected()) {
currentView.getViewProperties().addFilteredMemberAccessibility(accessibility);
} else {
currentView.getViewProperties().removeFilteredMemberAccessibility(accessibility);
}
} else if (kind != null) {
if (checkMenu.isSelected()) {
currentView.getViewProperties().addFilteredMemberKind(kind);
} else {
currentView.getViewProperties().removeFilteredMemberKind(kind);
}
} else if (modifiers != null) {
if (checkMenu.isSelected()) {
currentView.getViewProperties().addFilteredMemberModifiers(modifiers);
} else {
currentView.getViewProperties().removeFilteredMemberModifiers(modifiers);
}
} else if (sorting != null) {
if (checkMenu.isSelected()) {
currentView.getViewProperties().setSorting(sorting);
} else {
currentView.getViewProperties().setSorting(StructureViewProperties.Sorting.DECLARATIONAL);
}
} else if (relation != null) {
if (checkMenu.isSelected()) {
currentView.getViewProperties().removeRelation(relation);
} else {
currentView.getViewProperties().addRelation(relation);
}
}
Ajde.getDefault().getStructureViewManager().refreshView(
currentView
);
}
}
// public void highlightNode(ProgramElementNode node) {
// treeManager.navigationAction(node, true, true);
// }
private void order_comboBox_actionPerformed(ActionEvent e) {
Ajde.getDefault().getStructureViewManager().refreshView(
currentView
);
}
private void jbInit() throws Exception {
this.setLayout(borderLayout2);
buttons_panel.setLayout(borderLayout3);
buttons_panel.setMinimumSize(new Dimension(105, 10));
buttons_panel.setPreferredSize(new Dimension(105, 10));
view_comboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
view_comboBox_actionPerformed(e);
}
});
view_label.setFont(new java.awt.Font("Dialog", 0, 11));
view_label.setText(" Global View ");
view_comboBox.setFont(new java.awt.Font("SansSerif", 0, 11));
view_comboBox.setPreferredSize(new Dimension(125, 22));
view_panel.setLayout(borderLayout4);
view_panel.add(view_label, BorderLayout.WEST);
this.add(buttons_panel, BorderLayout.EAST);
this.add(spacer_panel, BorderLayout.CENTER);
this.add(view_panel, BorderLayout.WEST);
view_panel.add(view_comboBox, BorderLayout.CENTER);
}
private void order_button_actionPerformed(ActionEvent e) {
}
private void orderPopup_button_actionPerformed(ActionEvent e) {
}
void separator_button_actionPerformed(ActionEvent e) {
}
void view_comboBox_actionPerformed(ActionEvent e) {
StructureView view = (StructureView)view_comboBox.getSelectedItem();
viewPanel.setCurrentView(view);
if (((GlobalStructureView)view).getGlobalViewProperties().getHierarchy()
== StructureViewProperties.Hierarchy.DECLARATION) {
granularityCombo.setEnabled(true);
relationsCombo.setEnabled(true);
filterCombo.setEnabled(true);
} else {
granularityCombo.setEnabled(false);
relationsCombo.setEnabled(false);
filterCombo.setEnabled(false);
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.ListCellRenderer;
import javax.swing.border.Border;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
class BrowserView extends JPanel {
private BrowserViewPanel masterView;
private BrowserViewPanel slaveView;
private boolean slaveViewVisible = false;
private String lastSelectedConfig = "";
private IconRegistry icons = null;
private BorderLayout borderLayout1 = new BorderLayout();
private Border default_border;
private JPanel toolBar_panel = new JPanel();
private BorderLayout borderLayout2 = new BorderLayout();
JPanel mainToolBar_panel = new JPanel();
JToolBar config_toolBar = new JToolBar();
JComboBox configs_comboBox = null;
BorderLayout borderLayout3 = new BorderLayout();
JToolBar nav_toolBar = new JToolBar();
JButton forward_button = new JButton();
JButton back_button = new JButton();
GridLayout gridLayout1 = new GridLayout();
JSplitPane views_splitPane = new JSplitPane();
JToolBar command_toolBar = new JToolBar();
JToggleButton splitView_button = new JToggleButton();
JToggleButton zoomToFile_button = new JToggleButton();
JButton joinpointProbe_button = new JButton();
public BrowserView(BrowserViewPanel masterView, BrowserViewPanel slaveView, IconRegistry icons) {
try {
this.masterView = masterView;
this.slaveView = slaveView;
this.icons = icons;
configs_comboBox = new JComboBox(Ajde.getDefault().getProjectProperties().getBuildConfigFiles().toArray());
configs_comboBox.setRenderer(new ConfigsCellRenderer());
// configs_comboBox.addItemListener(new ItemListener() {
// public void itemStateChanged(ItemEvent e) {
// Ajde.getDefault().getConfigurationManager().setCurrConfigFile(lastSelectedConfig);
// }
// });
if (Ajde.getDefault().getProjectProperties().getBuildConfigFiles().size() > 0) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile((String)Ajde.getDefault().getProjectProperties().getBuildConfigFiles().get(0));
}
jbInit();
fixButtonBorders();
views_splitPane.add(masterView, JSplitPane.TOP);
views_splitPane.add(slaveView, JSplitPane.BOTTOM);
setSlaveViewVisible(false);
nav_toolBar.remove(joinpointProbe_button);
} catch(Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
}
public void setSlaveViewVisible(boolean visible) {
slaveViewVisible = visible;
if (visible) {
views_splitPane.add(slaveView, JSplitPane.BOTTOM);
views_splitPane.setDividerLocation(this.getHeight()-250);
//masterView.scrollToHighlightedNode();
} else {
views_splitPane.remove(slaveView);
views_splitPane.setDividerLocation(this.getHeight());
}
}
public boolean isSlaveViewVisible() {
return slaveViewVisible;
}
public void updateConfigs(java.util.List configsList) {
configs_comboBox.removeAllItems();
for (Iterator it = configsList.iterator(); it.hasNext(); ) {
configs_comboBox.addItem((String)it.next());
}
}
public void setSelectedConfig(String config) {
for (int i = 0; i < configs_comboBox.getItemCount(); i++) {
if (configs_comboBox.getItemAt(i).equals(config)) {
configs_comboBox.setSelectedIndex(i);
}
}
}
public String getSelectedConfig() {
return (String)configs_comboBox.getSelectedItem();
}
/**
* @todo get rid of this method and make the GUI-designer generated code work properly
*/
private void fixButtonBorders() {
back_button.setBorder(BorderFactory.createEmptyBorder());
forward_button.setBorder(BorderFactory.createEmptyBorder());
zoomToFile_button.setBorder(BorderFactory.createEmptyBorder());
splitView_button.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.blue));
}
private void jbInit() throws Exception {
default_border = BorderFactory.createEmptyBorder();
this.setLayout(borderLayout1);
toolBar_panel.setLayout(borderLayout2);
toolBar_panel.setBorder(BorderFactory.createEtchedBorder());
config_toolBar.setBorder(default_border);
config_toolBar.setFloatable(false);
configs_comboBox.setPreferredSize(new Dimension(200, 20));
configs_comboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
configs_comboBox_actionPerformed(e);
}
});
configs_comboBox.setMinimumSize(new Dimension(40, 20));
configs_comboBox.setFont(new java.awt.Font("SansSerif", 0, 11));
mainToolBar_panel.setLayout(borderLayout3);
nav_toolBar.setFloatable(false);
nav_toolBar.setBorder(default_border);
forward_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
forward_button_actionPerformed(e);
}
});
forward_button.setIcon(icons.getForwardIcon());
forward_button.setToolTipText("Navigate forward");
forward_button.setPreferredSize(new Dimension(20, 20));
forward_button.setMinimumSize(new Dimension(20, 20));
forward_button.setBorder(default_border);
forward_button.setMaximumSize(new Dimension(24, 20));
back_button.setMaximumSize(new Dimension(24, 20));
back_button.setBorder(default_border);
back_button.setMinimumSize(new Dimension(20, 20));
back_button.setPreferredSize(new Dimension(20, 20));
back_button.setToolTipText("Navigate back");
back_button.setIcon(icons.getBackIcon());
back_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
back_button_actionPerformed(e);
}
});
// structureViews_box.add(comment_editorPane, null);
views_splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
views_splitPane.setDividerSize(2);
command_toolBar.setBorder(default_border);
command_toolBar.setFloatable(false);
splitView_button.setFont(new java.awt.Font("Dialog", 0, 11));
splitView_button.setBorder(default_border);
splitView_button.setMaximumSize(new Dimension(24, 24));
splitView_button.setPreferredSize(new Dimension(20, 20));
splitView_button.setToolTipText("Togge split-tree view mode");
splitView_button.setIcon(icons.getSplitStructureViewIcon());
splitView_button.setSelectedIcon(icons.getMergeStructureViewIcon());
splitView_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
//splitView_button_actionPerformed(e);
}
});
zoomToFile_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
//zoomToFile_button_actionPerformed(e);
}
});
zoomToFile_button.setIcon(icons.getZoomStructureToFileModeIcon());
zoomToFile_button.setSelectedIcon(icons.getZoomStructureToGlobalModeIcon());
zoomToFile_button.setBorder(BorderFactory.createRaisedBevelBorder());
zoomToFile_button.setMaximumSize(new Dimension(24, 24));
zoomToFile_button.setPreferredSize(new Dimension(20, 20));
zoomToFile_button.setToolTipText("Toggle file-view mode");
zoomToFile_button.setFont(new java.awt.Font("Dialog", 0, 11));
joinpointProbe_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
joinpointProbe_button_actionPerformed(e);
}
});
joinpointProbe_button.setIcon(icons.getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT));
joinpointProbe_button.setToolTipText("Create joinpoint probe");
joinpointProbe_button.setPreferredSize(new Dimension(20, 20));
joinpointProbe_button.setMinimumSize(new Dimension(20, 20));
joinpointProbe_button.setBorder(default_border);
joinpointProbe_button.setMaximumSize(new Dimension(24, 20));
this.add(toolBar_panel, BorderLayout.NORTH);
toolBar_panel.add(mainToolBar_panel, BorderLayout.NORTH);
mainToolBar_panel.add(config_toolBar, BorderLayout.CENTER);
config_toolBar.add(configs_comboBox, null);
mainToolBar_panel.add(nav_toolBar, BorderLayout.EAST);
nav_toolBar.add(splitView_button, null);
nav_toolBar.add(zoomToFile_button, null);
nav_toolBar.add(joinpointProbe_button, null);
nav_toolBar.add(back_button, null);
nav_toolBar.add(forward_button, null);
mainToolBar_panel.add(command_toolBar, BorderLayout.WEST);
this.add(views_splitPane, BorderLayout.CENTER);
views_splitPane.setDividerLocation(400);
}
void forward_button_actionPerformed(ActionEvent e) {
//AjdeUIManager.getDefault().getViewManager().navigateForwardAction();
}
void back_button_actionPerformed(ActionEvent e) {
//AjdeUIManager.getDefault().getViewManager().navigateBackAction();
}
// void splitView_button_actionPerformed(ActionEvent e) {
// AjdeUIManager.getDefault().getViewManager().setSplitViewMode(!slaveViewVisible);
// }
static class ConfigsCellRenderer extends JLabel implements ListCellRenderer {
public ConfigsCellRenderer() {
setOpaque(true);
}
public Component getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
if (value == null) return this;
java.io.File file = new File(value.toString());
setText(file.getName());
setBackground(isSelected ? Color.gray : Color.lightGray);
// setForeground(isSelected ? Color.lightGray : Color.gray);
return this;
}
}
void configDesigner_button_mouseClicked(MouseEvent e) {
}
void configDesigner_button_mousePressed(MouseEvent e) {
}
void configDesigner_button_mouseReleased(MouseEvent e) {
}
void configDesigner_button_mouseEntered(MouseEvent e) {
}
void configDesigner_button_mouseExited(MouseEvent e) {
}
void configDesigner_button_actionPerformed(ActionEvent e) {
}
void viewManager_button_mouseClicked(MouseEvent e) {
}
void viewManager_button_mousePressed(MouseEvent e) {
}
void viewManager_button_mouseReleased(MouseEvent e) {
}
void viewManager_button_mouseEntered(MouseEvent e) {
}
void viewManager_button_mouseExited(MouseEvent e) {
}
void viewManager_button_actionPerformed(ActionEvent e) {
}
// void zoomToFile_button_actionPerformed(ActionEvent e) {
// AjdeUIManager.getDefault().getViewManager().setGlobalMode(!AjdeUIManager.getDefault().getViewManager().isGlobalMode());
// AjdeUIManager.getDefault().getViewManager().updateView();
// }
void configs_comboBox_actionPerformed(ActionEvent e) {
if (configs_comboBox.getSelectedItem() != null) {
if (!configs_comboBox.getSelectedItem().toString().equals(lastSelectedConfig)) {
//TopManager.INSTANCE.VIEW_MANAGER.readStructureView();
lastSelectedConfig = configs_comboBox.getSelectedItem().toString();
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lastSelectedConfig);
}
}
}
private void joinpointProbe_button_actionPerformed(ActionEvent e) {
//joinpointProbeWizard();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.util.*;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.*;
import org.aspectj.asm.*;
/**
* Responsible for displaying and controlling the configuration and output of a
* master and slave structure view.
*
* @author Mik Kersten
*/
public class BrowserViewManager {
private StructureViewPanel browserPanel = null;
private boolean globalMode = true;
private boolean splitViewMode = false;
private IconRegistry icons;
private Stack backHistory = new Stack();
private Stack forwardHistory = new Stack();
private ProgramElementNode currNode = null;
private final GlobalStructureView DECLARATION_VIEW;
private final GlobalStructureView CROSSCUTTING_VIEW;
private final GlobalStructureView INHERITANCE_VIEW;
private final GlobalViewProperties DECLARATION_VIEW_PROPERTIES;
private final GlobalViewProperties CROSSCUTTING_VIEW_PROPERTIES;
private final GlobalViewProperties INHERITANCE_VIEW_PROPERTIES;
public BrowserViewManager() {
java.util.List views = new ArrayList();
views.add(DECLARATION_VIEW);
views.add(CROSSCUTTING_VIEW);
views.add(INHERITANCE_VIEW);
browserPanel = new StructureViewPanel(views);
}
public StructureViewPanel getBrowserPanel() {
return browserPanel;
}
public void extractAndInsertSignatures(java.util.List signatures, boolean calls) {
PointcutWizard pointcutWizard = new PointcutWizard(signatures);
pointcutWizard.setVisible(true);
pointcutWizard.setLocation(AjdeUIManager.getDefault().getRootFrame().getX()+100, AjdeUIManager.getDefault().getRootFrame().getY()+100);
}
{
DECLARATION_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.DECLARATION);
CROSSCUTTING_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.CROSSCUTTING);
INHERITANCE_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_CALL_SITE_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.HANDLER_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.INITIALIZER_RELATION);
CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.FIELD_ACCESS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.IMPLEMENTS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_MEMBERS_RELATION);
INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_RELATION);
DECLARATION_VIEW_PROPERTIES.setRelations(Ajde.getDefault().getStructureViewManager().getAvailableRelations());
CROSSCUTTING_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(CROSSCUTTING_VIEW_PROPERTIES);
INHERITANCE_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(INHERITANCE_VIEW_PROPERTIES);
DECLARATION_VIEW = Ajde.getDefault().getStructureViewManager().createGlobalView(DECLARATION_VIEW_PROPERTIES);
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
class BrowserViewTreeListener implements TreeSelectionListener, MouseListener {
private StructureTree tree = null;
public BrowserViewTreeListener(StructureTree tree) {
this.tree = tree;
}
public void valueChanged(TreeSelectionEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseClicked(MouseEvent e) {
singleClickNavigation(e);
//doubleClickNavigation(e);
maybeShowPopup(e);
}
public void singleClickNavigation(MouseEvent e) {
SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
if (treeNode != null && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) {
StructureNode currNode = (StructureNode)treeNode.getUserObject();
if (currNode instanceof ProgramElementNode && !e.isControlDown()
&& !e.isShiftDown() && e.getModifiers() != 4) {
//AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((ProgramElementNode)currNode);
//if (AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) {
// AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView((ProgramElementNode)currNode);
//}
} else if (currNode instanceof LinkNode) {
//if (!AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) {
// AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((LinkNode)currNode);
//} else {
// AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode());
//}
}
}
}
public void doubleClickNavigation(MouseEvent e) {
int clickCount = e.getClickCount();
SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
if (treeNode != null) {
StructureNode currNode = (StructureNode)treeNode.getUserObject();
if (currNode instanceof ProgramElementNode && !e.isControlDown() && !e.isShiftDown()
&& e.getModifiers() != 4) {
//AjdeUIManager.getDefault().getViewManager().showNodeInMasterView(((LinkNode)currNode).getProgramElementNode());
//AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode());
} else if (currNode instanceof LinkNode) {
if (clickCount == 1) {
//AjdeUIManager.getDefault().getViewManager().showLink((LinkNode)currNode);
} else if (clickCount == 2) {
//navigationAction((ProgramElementNode)((LinkNode)currNode).getProgramElementNode(), true, true);
}
}
}
}
/**
* @todo this should probably use <CODE>e.isPopupTrigger()</CODE> but that
* doesn't work for some reason, so we just check if the right mouse button
* has been clicked.
*/
private void maybeShowPopup(MouseEvent e) {
if (e.getModifiers() == InputEvent.BUTTON3_MASK && tree.getSelectionCount() > 0) {
TreePath[] selectionPaths = tree.getSelectionPaths();
final List signatures = new ArrayList();
for (int i = 0; i < selectionPaths.length; i++) {
StructureNode currNode = (StructureNode)((SwingTreeViewNode)selectionPaths[i].getLastPathComponent()).getUserObject();
if (currNode instanceof LinkNode || currNode instanceof ProgramElementNode) {
signatures.add(currNode);
}
}
JPopupMenu popup = new JPopupMenu();
JMenuItem showSourcesItem = new JMenuItem("Display sources", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.CODE));
showSourcesItem.setFont(new java.awt.Font("Dialog", 0, 11));
showSourcesItem.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//AjdeUIManager.getDefault().getViewManager().showSourcesNodes(signatures);
// USED THE FOLLOWING FROM: BrowserViewManager:
// public void showSourcesNodes(java.util.List nodes) {
// for (Iterator it = nodes.iterator(); it.hasNext(); ) {
// ProgramElementNode currNode = null;
// StructureNode structureNode = (StructureNode)it.next();
// if (structureNode instanceof LinkNode) {
// currNode = ((LinkNode)structureNode).getProgramElementNode();
// } else {
// currNode = (ProgramElementNode)structureNode;
// }
// ISourceLocation sourceLoc = currNode.getSourceLocation();
// if (null != sourceLoc) {
// Ajde.getDefault().getEditorManager().addViewForSourceLine(
// sourceLoc.getSourceFile().getAbsolutePath(),
// sourceLoc.getLine());
// }
// }
// }
}
});
popup.add(showSourcesItem);
popup.addSeparator();
JMenuItem generatePCD = new JMenuItem("Pointcut Wizard (alpha)...", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT));
generatePCD.setFont(new java.awt.Font("Dialog", 0, 11));
generatePCD.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
AjdeUIManager.getDefault().getViewManager().extractAndInsertSignatures(signatures, true);
}
});
popup.add(generatePCD);
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.ProgramElementNode;
public class BuildConfigPopupMenu extends JPopupMenu {
public BuildConfigPopupMenu(final AbstractAction action) {
java.util.List configFiles = Ajde.getDefault().getProjectProperties().getBuildConfigFiles();
for (Iterator it = configFiles.iterator(); it.hasNext(); ) {
final String buildConfig = (String)it.next();
JMenuItem buildItem = new JMenuItem(buildConfig);
buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT);
buildItem.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(buildConfig);
// ??? should we be able to do a build refresh if shift is down?
// if (EditorManager.isShiftDown(e.getModifiers())) {
// Ajde.getDefault().getBuildManager().buildFresh();
// } else {
Ajde.getDefault().getBuildManager().build();
// }
action.actionPerformed(e);
}
});
buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.FILE_LST).getIconResource());
this.add(buildItem);
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.aspectj.ajde.ui.AbstractIcon;
import org.aspectj.ajde.ui.AbstractIconRegistry;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.Relation;
/**
* Default icons. Override behavior for custom icons.
*
* @author Mik Kersten
*/
public class IconRegistry extends AbstractIconRegistry {
//public static IconRegistry INSTANCE = null;
protected String RESOURCE_PATH = "org/aspectj/ajde/resources/";
private final Icon START_AJDE = makeIcon("actions/startAjde.gif");
private final Icon STOP_AJDE = makeIcon("actions/stopAjde.gif");
private final Icon BUILD = makeIcon("actions/build.gif");
private final Icon DEBUG = makeIcon("actions/debug.gif");
private final Icon EXECUTE = makeIcon("actions/execute.gif");
private final Icon AJBROWSER = makeIcon("structure/advice.gif");
private final Icon AJBROWSER_ENABLED = makeIcon("actions/browserEnabled.gif");
private final Icon AJBROWSER_DISABLED = makeIcon("actions/browserDisabled.gif");
private final Icon STRUCTURE_VIEW = makeIcon("actions/structureView.gif");
private final Icon HIDE_ASSOCIATIONS = makeIcon("actions/hideAssociations.gif");
private final Icon HIDE_NON_AJ = makeIcon("actions/hideNonAJ.gif");
private final Icon GRANULARITY = makeIcon("actions/granularity.gif");
private final Icon AJDE_SMALL = makeIcon("actions/ajdeSmall.gif");
private final Icon ERROR = makeIcon("structure/error.gif");
private final Icon WARNING = makeIcon("structure/warning.gif");
private final Icon INFO = makeIcon("structure/info.gif");
private final Icon POPUP = makeIcon("actions/popup.gif");
private final Icon FILTER = makeIcon("actions/filter.gif");
private final Icon RELATIONS = makeIcon("actions/relations.gif");
private final Icon ORDER = makeIcon("actions/order.gif");
private final Icon ZOOM_STRUCTURE_TO_FILE_MODE = makeIcon("actions/zoomStructureToFileMode.gif");
private final Icon ZOOM_STRUCTURE_TO_GLOBAL_MODE = makeIcon("actions/zoomStructureToGlobalMode.gif");
private final Icon SPLIT_STRUCTURE_VIEW = makeIcon("actions/splitStructureView.gif");
private final Icon MERGE_STRUCTURE_VIEW = makeIcon("actions/mergeStructureView.gif");
private final Icon BACK = makeIcon("actions/back.gif");
private final Icon FORWARD = makeIcon("actions/forward.gif");
private final Icon SEARCH = makeIcon("actions/search.gif");
private final Icon OPEN_CONFIG = makeIcon("actions/openConfig.gif");
private final Icon CLOSE_CONFIG = makeIcon("actions/closeConfig.gif");
private final Icon SAVE = makeIcon("actions/save.gif");
private final Icon SAVE_ALL = makeIcon("actions/saveAll.gif");
private final Icon BROWSER_OPTIONS = makeIcon("actions/browseroptions.gif");
private final Icon ACCESSIBILITY_PUBLIC = makeIcon("structure/accessibility-public.gif");
private final Icon ACCESSIBILITY_PACKAGE = makeIcon("structure/accessibility-package.gif");
private final Icon ACCESSIBILITY_PROTECTED = makeIcon("structure/accessibility-protected.gif");
private final Icon ACCESSIBILITY_PRIVATE = makeIcon("structure/accessibility-private.gif");
private final Icon ACCESSIBILITY_PRIVILEGED = makeIcon("structure/accessibility-privileged.gif");
public Icon getAjdeSmallIcon() { return AJDE_SMALL; }
public Icon getHideAssociationsIcon() { return HIDE_ASSOCIATIONS; }
public Icon getHideNonAJIcon() { return HIDE_NON_AJ; }
public Icon getGranularityIcon() { return GRANULARITY; }
public Icon getErrorIcon() { return ERROR; }
public Icon getWarningIcon() { return WARNING; }
public Icon getInfoIcon() { return INFO; }
public Icon getAJBrowserIcon() { return AJBROWSER; }
public Icon getAJBrowserEnabledIcon() { return AJBROWSER_ENABLED; }
public Icon getAJBrowserDisabledIcon() { return AJBROWSER_DISABLED; }
public Icon getPopupIcon() { return POPUP; }
public Icon getFilterIcon() { return FILTER; }
public Icon getOrderIcon() { return ORDER; }
public Icon getRelationsIcon() { return RELATIONS; }
public Icon getStartAjdeIcon() { return START_AJDE; }
public Icon getStopAjdeIcon() { return STOP_AJDE; }
public Icon getBackIcon() { return BACK; }
public Icon getForwardIcon() { return FORWARD; }
public Icon getSearchIcon() { return SEARCH; }
public Icon getBuildIcon() { return BUILD; }
public Icon getDebugIcon() { return DEBUG; }
public Icon getExecuteIcon() { return EXECUTE; }
public Icon getOpenConfigIcon() { return OPEN_CONFIG; }
public Icon getCloseConfigIcon() { return CLOSE_CONFIG; }
public Icon getOpenIcon() { return OPEN_CONFIG; }
public Icon getSaveIcon() { return SAVE; }
public Icon getSaveAllIcon() { return SAVE_ALL; }
public Icon getBrowserOptionsIcon() { return BROWSER_OPTIONS; }
public Icon getZoomStructureToFileModeIcon() { return ZOOM_STRUCTURE_TO_FILE_MODE; }
public Icon getZoomStructureToGlobalModeIcon() { return ZOOM_STRUCTURE_TO_GLOBAL_MODE; }
public Icon getSplitStructureViewIcon() { return SPLIT_STRUCTURE_VIEW; }
public Icon getMergeStructureViewIcon() { return MERGE_STRUCTURE_VIEW; }
public Icon getStructureViewIcon() { return STRUCTURE_VIEW; }
public Icon getAssociationSwingIcon(Relation relation) {
return convertToSwingIcon(getRelationIcon(relation));
}
protected AbstractIcon getStructureIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) {
return getStructureIcon(kind);
}
public Icon getStructureSwingIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) {
return convertToSwingIcon(getStructureIcon(kind, accessibility));
}
public Icon getStructureSwingIcon(ProgramElementNode.Kind kind) {
return convertToSwingIcon(getStructureIcon(kind));
}
public Icon getAccessibilitySwingIcon(ProgramElementNode.Accessibility accessibility) {
if (accessibility == ProgramElementNode.Accessibility.PUBLIC) {
return ACCESSIBILITY_PUBLIC;
} else if (accessibility == ProgramElementNode.Accessibility.PACKAGE) {
return ACCESSIBILITY_PACKAGE;
} else if (accessibility == ProgramElementNode.Accessibility.PROTECTED) {
return ACCESSIBILITY_PROTECTED;
} else if (accessibility == ProgramElementNode.Accessibility.PRIVATE) {
return ACCESSIBILITY_PRIVATE;
} else if (accessibility == ProgramElementNode.Accessibility.PRIVILEGED) {
return ACCESSIBILITY_PRIVILEGED;
} else {
return null;
}
}
public Icon convertToSwingIcon(AbstractIcon iconAdapter) {
if (iconAdapter != null) {
return (Icon)iconAdapter.getIconResource();
} else {
return null;
}
}
protected AbstractIcon createIcon(String path) {
return new AbstractIcon(new ImageIcon(ClassLoader.getSystemResource(path)));
}
protected Icon makeIcon(String iconPath) {
return new ImageIcon(ClassLoader.getSystemResource(RESOURCE_PATH + iconPath));
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.*;
import javax.swing.*;
import org.aspectj.ajde.ui.*;
import org.aspectj.asm.InheritanceAssociation;
/**
* @author Mik Kersten
*/
class PointcutWizard extends JFrame {
private BrowserViewPanel typeTreeView = null;
private java.util.List signatures = null;
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel4 = new JPanel();
JLabel jLabel1 = new JLabel();
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
JLabel jLabel4 = new JLabel();
JPanel jPanel3 = new JPanel();
JCheckBox jCheckBox5 = new JCheckBox();
JCheckBox jCheckBox4 = new JCheckBox();
JCheckBox jCheckBox3 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
JCheckBox jCheckBox1 = new JCheckBox();
JButton cancel_button = new JButton();
JButton ok_button = new JButton();
JPanel jPanel5 = new JPanel();
public PointcutWizard(java.util.List signatures) {
this.signatures = signatures;
ArrayList views = new ArrayList();
views.add(StructureViewProperties.Hierarchy.INHERITANCE);
typeTreeView = new BrowserViewPanel(AjdeUIManager.getDefault().getIconRegistry(), views, StructureViewProperties.Hierarchy.INHERITANCE);
throw new RuntimeException("unimplemented, can't get the current file");
//typeTreeView.updateTree(Ajde.getDefault().getEditorManager().getCurrFile());
// try {
// jbInit();
// }
// catch(Exception e) {
// Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
// }
// this.setSize(400, 400);
// this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)).getImage());
}
private Map getViewProperties() {
Map views = new HashMap();
GlobalViewProperties INHERITANCE_VIEW = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE);
INHERITANCE_VIEW.addRelation(InheritanceAssociation.INHERITS_RELATION);
views.put(INHERITANCE_VIEW.toString(), INHERITANCE_VIEW);
return views;
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel1.setText("Generate pointcut designator for corresponding joinpoints:");
jPanel1.setLayout(borderLayout1);
jPanel4.setLayout(borderLayout2);
jPanel2.setLayout(borderLayout3);
jLabel4.setText("Select the target type that will host the generated pointcut:");
jLabel4.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel4.setToolTipText("");
jPanel3.setMaximumSize(new Dimension(32767, 34));
jCheckBox5.setEnabled(false);
jCheckBox5.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox5.setSelected(true);
jCheckBox5.setText("call");
jCheckBox4.setEnabled(false);
jCheckBox4.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox4.setText("execution");
jCheckBox3.setEnabled(false);
jCheckBox3.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox3.setText("initialization");
jCheckBox2.setEnabled(false);
jCheckBox2.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox2.setText("static initialization");
jCheckBox1.setEnabled(false);
jCheckBox1.setFont(new java.awt.Font("Dialog", 0, 11));
jCheckBox1.setText("field get/set");
cancel_button.setFont(new java.awt.Font("Dialog", 0, 11));
cancel_button.setText("Cancel");
cancel_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancel_button_actionPerformed(e);
}
});
ok_button.setText("OK");
ok_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
ok_button_actionPerformed(e);
}
});
ok_button.setFont(new java.awt.Font("Dialog", 0, 11));
this.setTitle("Pointcut Wizard");
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jPanel4, BorderLayout.NORTH);
jPanel4.add(jLabel1, BorderLayout.NORTH);
jPanel4.add(jPanel3, BorderLayout.CENTER);
jPanel3.add(jCheckBox5, null);
jPanel3.add(jCheckBox4, null);
jPanel3.add(jCheckBox3, null);
jPanel3.add(jCheckBox2, null);
jPanel3.add(jCheckBox1, null);
jPanel1.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jLabel4, BorderLayout.NORTH);
jPanel2.add(typeTreeView, BorderLayout.CENTER);
jPanel1.add(jPanel5, BorderLayout.SOUTH);
jPanel5.add(ok_button, null);
jPanel5.add(cancel_button, null);
}
private void ok_button_actionPerformed(ActionEvent e) {
throw new RuntimeException("unimplemented, can't paste");
// Ajde.getDefault().getEditorManager().pasteToCaretPos(generatePcd());
// this.dispose();
}
private void cancel_button_actionPerformed(ActionEvent e) {
this.dispose();
}
private String generatePcd() {
String pcd = "\n\n" +
" pointcut temp(): \n";
for (Iterator it = signatures.iterator(); it.hasNext(); ) {
pcd += " call(* " + it.next() + ")";
if (it.hasNext()) {
pcd += " ||";
} else {
pcd += ";";
}
pcd += "\n";
}
return pcd;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureModelListener;
public class SimpleStructureViewToolPanel extends JPanel {
private StructureView currentView;
private JButton separator_button = new JButton();
private boolean hideNonAJEnabled = false;
private boolean hideAssociationsEnabled = false;
private boolean sortEnabled = false;
Border border1;
Border border2;
JButton structureView_button = new JButton();
JPanel label_panel = new JPanel();
JLabel currConfig_field = new JLabel();
JPanel spacer_panel = new JPanel();
JPanel jPanel2 = new JPanel();
JButton forward_button = new JButton();
JPanel navigation_panel = new JPanel();
JButton back_button = new JButton();
BorderLayout borderLayout1 = new BorderLayout();
JPanel buttons_panel = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
BorderLayout borderLayout4 = new BorderLayout();
public final StructureModelListener MODEL_LISTENER = new StructureModelListener() {
public void modelUpdated(StructureModel model) {
String path = Ajde.getDefault().getConfigurationManager().getActiveConfigFile();
String fileName = "<no active config>";
if (path != null) fileName = new File(path).getName();
updateCurrConfigLabel(fileName);
}
};
JButton hideNonAJ_button = new JButton();
JPanel navigation_panel1 = new JPanel();
JButton hideAssociations_button = new JButton();
BorderLayout borderLayout5 = new BorderLayout();
JButton sort_button = new JButton();
public SimpleStructureViewToolPanel(StructureView currentView) {
this.currentView = currentView;
Ajde.getDefault().getStructureModelManager().addListener(MODEL_LISTENER);
try {
jbInit();
} catch (Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
}
updateCurrConfigLabel("<no active config>");
}
private void updateCurrConfigLabel(String text) {
currConfig_field.setText(" File View (" + text + ")");
}
private void jbInit() throws Exception {
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(156, 156, 158),new Color(109, 109, 110));
border2 = BorderFactory.createEmptyBorder(0,1,0,0);
separator_button.setPreferredSize(new Dimension(2, 16));
separator_button.setMinimumSize(new Dimension(2, 16));
separator_button.setEnabled(false);
separator_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
separator_button.setMaximumSize(new Dimension(2, 16));
structureView_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
structureView_button_actionPerformed(e);
}
});
structureView_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureViewIcon());
structureView_button.setBorder(border2);
structureView_button.setToolTipText("Navigate back");
structureView_button.setPreferredSize(new Dimension(20, 20));
structureView_button.setMinimumSize(new Dimension(20, 20));
structureView_button.setMaximumSize(new Dimension(24, 20));
currConfig_field.setBackground(SystemColor.control);
currConfig_field.setFont(new java.awt.Font("SansSerif", 0, 11));
currConfig_field.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
//currConfig_field.setEditable(false);
currConfig_field.setText(" ");
forward_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
forward_button_actionPerformed(e);
}
});
forward_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getForwardIcon());
forward_button.setToolTipText("Navigate forward");
forward_button.setPreferredSize(new Dimension(20, 20));
forward_button.setMinimumSize(new Dimension(20, 20));
forward_button.setMaximumSize(new Dimension(24, 20));
forward_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
navigation_panel.setLayout(borderLayout1);
back_button.setMaximumSize(new Dimension(24, 20));
back_button.setMinimumSize(new Dimension(20, 20));
back_button.setPreferredSize(new Dimension(20, 20));
back_button.setToolTipText("Navigate back");
back_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getBackIcon());
back_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
back_button_actionPerformed(e);
}
});
back_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
this.setLayout(borderLayout2);
buttons_panel.setLayout(borderLayout3);
label_panel.setLayout(borderLayout4);
hideNonAJ_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
hideNonAJ_button.setMaximumSize(new Dimension(24, 20));
hideNonAJ_button.setMinimumSize(new Dimension(20, 20));
hideNonAJ_button.setPreferredSize(new Dimension(20, 20));
hideNonAJ_button.setToolTipText("Hide non-AspectJ members");
hideNonAJ_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getHideNonAJIcon());
hideNonAJ_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
hideNonAJ_button_actionPerformed(e);
}
});
navigation_panel1.setLayout(borderLayout5);
hideAssociations_button.setMaximumSize(new Dimension(24, 20));
hideAssociations_button.setMinimumSize(new Dimension(20, 20));
hideAssociations_button.setPreferredSize(new Dimension(20, 20));
hideAssociations_button.setToolTipText("Hide associations");
hideAssociations_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getHideAssociationsIcon());
hideAssociations_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
hideAssociations_button_actionPerformed(e);
}
});
hideAssociations_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
sort_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
sort_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
sort_button_actionPerformed(e);
}
});
sort_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getOrderIcon());
sort_button.setToolTipText("Sort member");
sort_button.setPreferredSize(new Dimension(20, 20));
sort_button.setMinimumSize(new Dimension(20, 20));
sort_button.setMaximumSize(new Dimension(24, 20));
label_panel.add(currConfig_field, BorderLayout.CENTER);
//label_panel.add(structureView_button, BorderLayout.WEST);
this.add(spacer_panel, BorderLayout.CENTER);
this.add(buttons_panel, BorderLayout.EAST);
buttons_panel.add(navigation_panel, BorderLayout.CENTER);
navigation_panel.add(back_button, BorderLayout.CENTER);
navigation_panel.add(forward_button, BorderLayout.EAST);
navigation_panel.add(jPanel2, BorderLayout.WEST);
buttons_panel.add(navigation_panel1, BorderLayout.WEST);
navigation_panel1.add(hideAssociations_button, BorderLayout.EAST);
navigation_panel1.add(hideNonAJ_button, BorderLayout.CENTER);
navigation_panel1.add(sort_button, BorderLayout.WEST);
this.add(label_panel, BorderLayout.WEST);
}
private void forward_button_actionPerformed(ActionEvent e) {
Ajde.getDefault().getStructureViewManager().fireNavigateForwardAction(currentView);
}
private void back_button_actionPerformed(ActionEvent e) {
Ajde.getDefault().getStructureViewManager().fireNavigateBackAction(currentView);
}
void structureView_button_actionPerformed(ActionEvent e) {
}
private void hideNonAJ_button_actionPerformed(ActionEvent e) {
if (hideNonAJEnabled) {
hideNonAJ_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
hideNonAJEnabled = false;
currentView.getViewProperties().setFilteredMemberKinds(new ArrayList());
} else {
hideNonAJ_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
hideNonAJEnabled = true;
currentView.getViewProperties().setFilteredMemberKinds(
ProgramElementNode.Kind.getNonAJMemberKinds()
);
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
}
private void hideAssociations_button_actionPerformed(ActionEvent e) {
if (hideAssociationsEnabled) {
hideAssociations_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
hideAssociationsEnabled = false;
currentView.getViewProperties().setRelations(
Ajde.getDefault().getStructureViewManager().getAvailableRelations()
);
} else {
hideAssociations_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
hideAssociationsEnabled = true;
currentView.getViewProperties().setRelations(new ArrayList());
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
}
private void sort_button_actionPerformed(ActionEvent e) {
if (sortEnabled) {
sort_button.setBorder(AjdeWidgetStyles.DEFAULT_BORDER);
sortEnabled = false;
currentView.getViewProperties().setSorting(
StructureViewProperties.Sorting.DECLARATIONAL
);
} else {
sort_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER);
sortEnabled = true;
currentView.getViewProperties().setSorting(
StructureViewProperties.Sorting.ALPHABETICAL
);
}
Ajde.getDefault().getStructureViewManager().refreshView(currentView);
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.AbstractIcon;
import org.aspectj.ajde.ui.GlobalStructureView;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewProperties;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.RelationNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
class StructureTreeManager {
private StructureTree structureTree;
private SwingTreeViewNodeRenderer cellRenderer = null;
private TreeSelectionListener treeListener = null;
private final StructureTreeModel NO_STRUCTURE_MODEL
= new StructureTreeModel(new SwingTreeViewNode(StructureModel.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
/**
* @todo should probably avoid that MouseListener cast
*/
public StructureTreeManager() {
structureTree = new StructureTree();
structureTree.setModel(NO_STRUCTURE_MODEL);
cellRenderer = new SwingTreeViewNodeRenderer();
structureTree.setCellRenderer(cellRenderer);
//if (fileView) {
treeListener = new StructureViewTreeListener(structureTree);
//} else {
// treeListener = new BrowserViewTreeListener(structureTree);
//}
structureTree.addTreeSelectionListener(treeListener);
structureTree.addMouseListener((MouseListener)treeListener);
}
public void highlightNode(ProgramElementNode node) {
highlightNode((SwingTreeViewNode)structureTree.getModel().getRoot(), node);
}
public StructureNode getSelectedStructureNode() {
return (StructureNode)((SwingTreeViewNode)structureTree.getLastSelectedPathComponent()).getUserObject();
}
public void scrollToHighlightedNode() {
structureTree.scrollPathToVisible(structureTree.getSelectionPath());
}
private void highlightNode(SwingTreeViewNode parent, ProgramElementNode node) {
for (int i = 0; i < parent.getChildCount(); i++) {
SwingTreeViewNode currNode = (SwingTreeViewNode)parent.getChildAt(i);
StructureNode sNode = (StructureNode)currNode.getUserObject();
if (sNode instanceof ProgramElementNode &&
((ProgramElementNode)sNode).equals(node)) {
TreePath path = new TreePath(currNode.getPath());
structureTree.setSelectionPath(path);
int currRow = structureTree.getRowForPath(path);
structureTree.expandRow(currRow);
structureTree.scrollRowToVisible(currRow);
} else {
highlightNode(currNode, node);
}
}
}
// public void updateTree(StructureView structureView) {
// displayTree(structureView, 10);
// }
//
// public void updateTree(GlobalStructureView structureView) {
// displayTree(structureView, depth);
// }
public void updateTree(final StructureView structureView) {
if (structureView == null) return;
Runnable update = new Runnable() {
public void run() {
structureTree.removeAll();
SwingTreeViewNode currNode;
if (structureView.getRootNode() == null) {
structureTree.setModel(NO_STRUCTURE_MODEL);
} else {
structureTree.setModel(new StructureTreeModel((SwingTreeViewNode)structureView.getRootNode()));
}
if (structureView instanceof GlobalStructureView) {
GlobalStructureView view = (GlobalStructureView)structureView;
if (view.getGlobalViewProperties().getHierarchy() == StructureViewProperties.Hierarchy.DECLARATION) {
expandTreeToFiles();
} else {
expandTree(15);
}
} else {
expandTree(10);
}
}
};
if (SwingUtilities.isEventDispatchThread()) {
update.run();
} else {
try {
SwingUtilities.invokeAndWait(update);
} catch (Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not update tree.", e);
}
}
}
StructureTree getStructureTree() {
return structureTree;
}
private void expandTreeToFiles() {
for (int i = 0; i < structureTree.getRowCount(); i++) {
TreePath path = structureTree.getPathForRow(i);
SwingTreeViewNode node = (SwingTreeViewNode)path.getLastPathComponent();
if (node.getUserObject() instanceof ProgramElementNode) {
ProgramElementNode pNode = (ProgramElementNode)node.getUserObject();
ProgramElementNode.Kind kind = pNode.getProgramElementKind();
if (kind == ProgramElementNode.Kind.PROJECT
|| kind == ProgramElementNode.Kind.PACKAGE) {
structureTree.expandPath(path);
} else {
structureTree.collapsePath(path);
}
} else {
structureTree.collapsePath(path);
}
}
structureTree.expandPath(structureTree.getPathForRow(0));
}
private void expandTree(int depth) {
for (int i = 0; i < structureTree.getRowCount(); i++) {
TreePath path = structureTree.getPathForRow(i);
SwingTreeViewNode node = (SwingTreeViewNode)path.getLastPathComponent();
if (path.getPath().length-1 > depth || node.getUserObject() instanceof RelationNode) {
structureTree.collapsePath(path);
} else {
structureTree.expandPath(path);
}
}
structureTree.expandPath(structureTree.getPathForRow(0));
}
private class StructureTreeModel extends DefaultTreeModel implements TreeModel {
public StructureTreeModel(TreeNode newRoot) {
super(newRoot);
}
public void valueForPathChanged(TreePath path, Object newValue) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
nodeChanged(node);
}
}
}
// /**
// * @param node if null assume root
// */
// public void navigationAction(ProgramElementNode node, boolean followedLink, boolean forward) {
// if (node == null) {
// structureTree.setSelectionRow(0);
// structureTree.scrollRowToVisible(0);
// } else if (node.getSourceLocation().getSourceFilePath() != null) {
// final String fileName = node.getSourceLocation().getSourceFilePath();
// final int lineNumber = node.getSourceLocation().getLineNumber();
// if (fileName != null && lineNumber > 0) {
// Runnable update = new Runnable() {
// public void run() {
// Ajde.getDefault().getEditorManager().showSourceLine(fileName, lineNumber, true);
// }
// };
//
// if (SwingUtilities.isEventDispatchThread()) {
// update.run();
// } else {
// try {
// SwingUtilities.invokeAndWait(update);
// } catch (Exception ee) {
//
// }
// }
// }
// if (followedLink) {
// highlightNode((SwingTreeViewNode)structureTree.getModel().getRoot(), node);
// }
// }
// }
// if (node instanceof ProgramElementNode) {
// ProgramElementNode lexicalNode = (ProgramElementNode)node;
// setIcon(getProgramElementNodeIcon(lexicalNode));
// } else if (node instanceof RelationNode) {
// RelationNode relationNode = (RelationNode)node;
//
// setIcon(icons.getAssociationSwingIcon(relationNode.getRelation()));
// this.setFont(new Font(this.getFont().getName(), Font.ITALIC, this.getFont().getSize()));
//
// } else if (node instanceof LinkNode) {
// LinkNode link = (LinkNode)node;
// setIcon(getProgramElementNodeIcon(link.getProgramElementNode()));
// } else {
// if (node != null && ProgramElementNode.Kind.PACKAGE.equals(node.getKind())) {
// setIcon(icons.getStructureSwingIcon(ProgramElementNode.Kind.PACKAGE));
// } else if (node != null && ProgramElementNode.Kind.PROJECT.equals(node.getKind())) {
// setIcon(icons.getStructureSwingIcon(ProgramElementNode.Kind.PROJECT));
// } else if (node != null && ProgramElementNode.Kind.FILE.equals(node.getKind())) {
// setIcon(icons.getStructureSwingIcon(ProgramElementNode.Kind.CLASS));
// } else {
// setIcon(null);
// }
// }
// void updateTree(int depth, GlobalViewProperties properties) {
// this.hierarchy = properties.getHierarchy();
// displayTree(depth, null);
// }
//
// void updateTree(String filePath, int depth, GlobalViewProperties properties) {
// this.hierarchy = properties.getHierarchy();
// if (filePath == null || filePath.equals("")) {
// structureTree.setModel(NO_FILE_SELECTED_MODEL);
// } else {
// structureTree.setRootFilePath(filePath);
// displayTree(depth, filePath);
// }
// }
// int accessibility = 0;
// if (pNode.getAccessibility().contains(ProgramElementNode.Accessibility.PUBLIC)) {
// accessibility = 1;
// } else if (pNode.getAccessibility().contains(ProgramElementNode.Accessibility.PROTECTED)) {
// accessibility = 2;
// } else if (pNode.getAccessibility().contains(ProgramElementNode.Accessibility.PRIVATE)) {
// accessibility = 3;
// } else if (pNode.getAccessibility().contains(ProgramElementNode.Accessibility.PRIVILEGED)) {
// accessibility = 3;
// }
//
// if (pNode == null || pNode.getKind() == null) {
// return null;
// } else if (ProgramElementNode.Kind.PROJECT.equals(pNode.getKind())) {
// return icons.getStructureSwingIcon(ProgramElementNode.Kind.PROJECT);
// } else if (ProgramElementNode.Kind.PACKAGE.equals(pNode.getKind())) {
// return icons.getStructureSwingIcon(ProgramElementNode.Kind.PACKAGE);
// } else if (ProgramElementNode.Kind.FILE.equals(pNode.getKind())) {
// return icons.getStructureSwingIcon(ProgramElementNode.Kind.CLASS);
// } else if (ProgramElementNode.Kind.CLASS.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getClassPublicIcon();
// case 2: return icons.getClassProtectedIcon();
// case 3: return icons.getClassPrivateIcon();
// default: return icons.getClassPackageIcon();
// }
// } else if (ProgramElementNode.Kind.INTERFACE.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getInterfacePublicIcon();
// case 2: return icons.getInterfaceProtectedIcon();
// case 3: return icons.getInterfacePrivateIcon();
// default: return icons.getInterfacePackageIcon();
// }
// } else if (ProgramElementNode.Kind.ASPECT.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getAspectPublicIcon();
// case 2: return icons.getAspectProtectedIcon();
// case 3: return icons.getAspectPrivateIcon();
// case 4: return icons.getAspectPrivilegedIcon();
// default: return icons.getAspectPackageIcon();
// }
// } else if (ProgramElementNode.Kind.METHOD.equals(pNode.getKind())
// || ProgramElementNode.Kind.INITIALIZER.equals(pNode.getKind())
// || ProgramElementNode.Kind.CONSTRUCTOR.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getMethodPublicIcon();
// case 2: return icons.getMethodProtectedIcon();
// case 3: return icons.getMethodPrivateIcon();
// default: return icons.getMethodPackageIcon();
// }
// } else if (ProgramElementNode.Kind.FIELD.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getFieldPublicIcon();
// case 2: return icons.getFieldProtectedIcon();
// case 3: return icons.getFieldPrivateIcon();
// default: return icons.getFieldPackageIcon();
// }
// } else if (ProgramElementNode.Kind.INTRODUCTION.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getIntroductionPublicIcon();
// case 2: return icons.getIntroductionProtectedIcon();
// case 3: return icons.getIntroductionPrivateIcon();
// default: return icons.getIntroductionPackageIcon();
// }
// } else if (ProgramElementNode.Kind.POINTCUT.equals(pNode.getKind())) {
// switch (accessibility) {
// case 1: return icons.getJoinpointPublicIcon();
// case 2: return icons.getJoinpointProtectedIcon();
// case 3: return icons.getJoinpointPrivateIcon();
// default: return icons.getJoinpointPackageIcon();
// }
// } else if (ProgramElementNode.Kind.ADVICE.equals(pNode.getKind())) {
// return icons.getAdviceIcon();
// } else if (ProgramElementNode.Kind.DECLARE_PARENTS.equals(pNode.getKind())) {
// return icons.getDeclareParentsIcon();
// } else if (ProgramElementNode.Kind.DECLARE_ERROR.equals(pNode.getKind())) {
// return icons.getDeclareErrorIcon();
// } else if (ProgramElementNode.Kind.DECLARE_WARNING.equals(pNode.getKind())) {
// return icons.getDeclareWarningIcon();
// } else if (ProgramElementNode.Kind.DECLARE_SOFT.equals(pNode.getKind())) {
// return icons.getDeclareSoftIcon();
// } else if (ProgramElementNode.Kind.CODE.equals(pNode.getKind())) {
// return icons.getCodeIcon();
// } else {
// return null;
// }
//
// if (relationNode.getKind().equals(org.aspectj.asm.associations.Advice.NAME) ||
// relationNode.getKind().equals(org.aspectj.asm.associations.Introduction.NAME)) {
// if (relationNode.getRelation().getBackNavigationName().equals(relationNode.getName()) ){
// setIcon(icons.getRelationAdviceBackIcon());
// } else {
// setIcon(icons.getAssociationSwingIcon(relationNode.getRelation()));
// setIcon(icons.getRelationAdviceForwardIcon());
// }
// } else if (relationNode.getKind().equals(org.aspectj.asm.associations.Inheritance.NAME)) {
// if (relationNode.getRelation().getBackNavigationName().equals(relationNode.getName()) ){
// setIcon(icons.getRelationInheritanceBackIcon());
// } else {
// setIcon(icons.getRelationInheritanceForwardIcon());
// }
// } else {
// if (relationNode.getRelation().getBackNavigationName().equals(relationNode.getName()) ){
// setIcon(icons.getRelationReferenceBackIcon());
// } else {
// setIcon(icons.getRelationReferenceForwardIcon());
// }
// }
// public ProgramElementNode getRootProgramElementNode() {
// StructureNode node = (StructureNode)((SwingTreeViewNode)structureTree.getModel().getRoot()).getUserObject();
// if (node instanceof ProgramElementNode) {
// return (ProgramElementNode)node;
// } else {
// return null;
// }
// }
// /**
// * @todo HACK: this is a workaround and can break
// */
// private static ProgramElementNode mapResult = null;
// private ProgramElementNode getNodeForLink(LinkNode node, StructureNode rootNode) {
// ProgramElementNode result = null;
// if (rootNode instanceof ProgramElementNode &&
// ((ProgramElementNode)rootNode).getName().equals(node.getProgramElementNode().getName())) {
// mapResult = (ProgramElementNode)rootNode;
// } else {
// ProgramElementNode linkedNode = node.getProgramElementNode();
// for (Iterator it = rootNode.getChildren().iterator(); it.hasNext(); ) {
// StructureNode child = (StructureNode)it.next();
// getNodeForLink(node, child);
// }
// }
// return mapResult;
// }
// private void sortNodes(List nodes) {
// if (sortNodes) {
// Collections.sort(nodes, structureNodeComparator);
// }
// }
// private class StructureNodeComparator implements Comparator {
// public int compare(Object o1, Object o2) {
// StructureNode t1 = (StructureNode) ((SwingTreeViewNode) o1).getUserObject();
// StructureNode t2 = (StructureNode) ((SwingTreeViewNode) o2).getUserObject();
// if (t1 instanceof ProgramElementNode && t2 instanceof ProgramElementNode) {
// ProgramElementNode p1 = (ProgramElementNode) t1;
// ProgramElementNode p2 = (ProgramElementNode) t2;
// return p1.getName().compareTo(p2.getName());
// } else {
// return 0;
// }
// }
// }
// private class StructureViewNodeAdapter extends DefaultMutableTreeNode {
//
// private StructureViewNode nodeInfo = null;
//
// public StructureViewNodeAdapter(StructureViewNode nodeInfo) {
// super(nodeInfo, true);
// this.nodeInfo = nodeInfo;
// }
//
// public String toString() {
// if (nodeInfo != null) {
// return nodeInfo.toString();
// } else {
// return "";
// }
// }
// }
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.FileStructureView;
import org.aspectj.ajde.ui.StructureView;
import org.aspectj.ajde.ui.StructureViewNode;
import org.aspectj.ajde.ui.StructureViewRenderer;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureNode;
/**
* Represents the configuration of a structure view of the system, rendered
* by the <CODE>StructureTreeManager</CODE>.
*
* @author Mik Kersten
*/
public class StructureViewPanel extends JPanel implements StructureViewRenderer {
protected StructureTreeManager treeManager = new StructureTreeManager();
protected StructureView currentView = null;
private java.util.List structureViews = null;
protected Border border1;
protected Border border2;
JScrollPane tree_ScrollPane = new JScrollPane();
JPanel structureToolBar_panel = null;
BorderLayout borderLayout1 = new BorderLayout();
public StructureViewPanel(FileStructureView structureView) {
currentView = structureView;
initView(structureView);
structureToolBar_panel = new SimpleStructureViewToolPanel(currentView);
init();
}
public StructureViewPanel(java.util.List structureViews) {
this.structureViews = structureViews;
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
initView((StructureView)it.next());
}
currentView = (StructureView)structureViews.get(0);
structureToolBar_panel = new BrowserStructureViewToolPanel(structureViews, currentView, this);
init();
}
private void init() {
try {
jbInit();
} catch (Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not initialize view panel.", e);
}
updateView(currentView);
}
public void setCurrentView(StructureView view) {
currentView = view;
treeManager.updateTree(view);
}
public void updateView(StructureView structureView) {
if (structureView == currentView) {
treeManager.updateTree(structureView);
}
}
private void initView(StructureView view) {
view.setRenderer(this);
}
public void setActiveNode(StructureViewNode node) {
setActiveNode(node, 0);
}
public void setActiveNode(StructureViewNode node, int lineOffset) {
if (node == null) return;
if (!(node.getStructureNode() instanceof ProgramElementNode)) return;
ProgramElementNode pNode = (ProgramElementNode)node.getStructureNode();
treeManager.highlightNode(pNode);
if (pNode.getSourceLocation() != null) {
Ajde.getDefault().getEditorAdapter().showSourceLine(
pNode.getSourceLocation().getSourceFile().getAbsolutePath(),
pNode.getSourceLocation().getLine() + lineOffset,
true
);
}
}
public void highlightActiveNode() {
if (currentView.getActiveNode() == null) return;
StructureNode node = currentView.getActiveNode().getStructureNode();
if (node instanceof ProgramElementNode) {
treeManager.highlightNode((ProgramElementNode)node);
}
}
protected void jbInit() {
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(156, 156, 158),new Color(109, 109, 110));
border2 = BorderFactory.createEmptyBorder(0,1,0,0);
this.setLayout(borderLayout1);
this.add(tree_ScrollPane, BorderLayout.CENTER);
this.add(structureToolBar_panel, BorderLayout.NORTH);
tree_ScrollPane.getViewport().add(treeManager.getStructureTree(), null);
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.tree.DefaultMutableTreeNode;
import org.aspectj.ajde.ui.AbstractIcon;
import org.aspectj.ajde.ui.StructureViewNode;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class SwingTreeViewNode extends DefaultMutableTreeNode implements StructureViewNode {
private StructureNode structureNode;
private AbstractIcon icon;
public SwingTreeViewNode(StructureNode structureNode, AbstractIcon icon, List children) {
super(structureNode, true);
this.structureNode = structureNode;
this.icon = icon;
if (children != null) {
for (Iterator it = children.iterator(); it.hasNext(); ) {
super.add((SwingTreeViewNode)it.next());
}
}
}
public StructureNode getStructureNode() {
return structureNode;
}
public AbstractIcon getIcon() {
return icon;
}
public void add(StructureViewNode child) {
super.add((DefaultMutableTreeNode)child);
}
public void remove(StructureViewNode child) {
super.remove((DefaultMutableTreeNode)child);
}
public List getChildren() {
if (children == null) {
return new ArrayList();
} else {
return children;
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.util.List;
import org.aspectj.ajde.ui.AbstractIcon;
import org.aspectj.ajde.ui.StructureViewNode;
import org.aspectj.ajde.ui.StructureViewNodeFactory;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class SwingTreeViewNodeFactory extends StructureViewNodeFactory {
public SwingTreeViewNodeFactory(IconRegistry iconRegistry) {
super(iconRegistry);
}
protected StructureViewNode createConcreteNode(StructureNode node, AbstractIcon icon, List children) {
return new SwingTreeViewNode(node, icon, children);
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import org.aspectj.asm.LinkNode;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.RelationNode;
import org.aspectj.asm.StructureNode;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
/**
* @author Mik Kersten
*/
class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer {
public Component getTreeCellRendererComponent(JTree tree,
Object treeNode,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
if (treeNode == null) return null;
SwingTreeViewNode viewNode = (SwingTreeViewNode)treeNode;
StructureNode node = viewNode.getStructureNode();
if (node instanceof LinkNode) {
ISourceLocation sourceLoc = ((LinkNode)node).getProgramElementNode().getSourceLocation();
if ((null != sourceLoc)
&& (null != sourceLoc.getSourceFile().getAbsolutePath())) {
setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_COLOR);
} else {
setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_NO_SOURCE_COLOR);
}
} else {
setTextNonSelectionColor(new Color(0, 0, 0));
}
super.getTreeCellRendererComponent(tree, treeNode, sel, expanded, leaf, row, hasFocus);
this.setFont(StructureTree.DEFAULT_FONT);
if (viewNode.getIcon() != null && viewNode.getIcon().getIconResource() != null) {
setIcon((Icon)viewNode.getIcon().getIconResource());
} else {
setIcon(null);
}
if (node instanceof ProgramElementNode) {
ProgramElementNode pNode = (ProgramElementNode)node;
if (pNode.isRunnable()) {
//setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon());
}
if (pNode.isImplementor()) {
//this.setText("<implementor>");
}
if (pNode.isOverrider()) {
//this.setText("<overrider>");
}
} else if (node instanceof RelationNode) {
this.setFont(new Font(this.getFont().getName(), Font.ITALIC, this.getFont().getSize()));
}
if (node.getMessage() != null) {
if (node.getMessage().getKind().equals(IMessage.WARNING)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon());
} else if (node.getMessage().getKind().equals(IMessage.ERROR)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getErrorIcon());
} else {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getInfoIcon());
}
}
return this;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.BuildConfigEditor;
import org.aspectj.ajde.ui.BuildConfigModel;
import org.aspectj.ajde.ui.BuildConfigNode;
import org.aspectj.ajde.ui.InvalidResourceException;
import org.aspectj.asm.ProgramElementNode;
/**
* UI for editing build configuration (".lst") files via a graphical tree-based
* representation.
*
* @author Mik Kersten
*/
public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEditor {
private ConfigTreeNode root;
private ConfigTreeNode currNode;
private BuildConfigModel model = null;
private static java.util.List selectedEntries = new ArrayList();
private String configFile = null;
private File sourcePath = null;
//private BuildConfigModelBuilder configTreeBuilder = new BuildConfigModelBuilder();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JPanel jPanel2 = new JPanel();
JButton cancel_button = new JButton();
BorderLayout borderLayout2 = new BorderLayout();
JButton save_button = new JButton();
JScrollPane jScrollPane = new JScrollPane();
JTree buildConfig_tree = new JTree();
public void openFile(String configFile) throws IOException, InvalidResourceException {
try {
if (configFile == null) {
Ajde.getDefault().getErrorHandler().handleError("No structure is selected for editing.");
return;
}
this.configFile = configFile;
sourcePath = new File(new File(configFile).getParent());
jbInit();
jLabel1.setText(" Build configuration: " + configFile);
model = Ajde.getDefault().getConfigurationManager().buildModel(configFile);
root = buildTree((BuildConfigNode)model.getRoot());
buildConfig_tree.setModel(new DefaultTreeModel(root));
buildConfig_tree.addMouseListener(new ConfigFileMouseAdapter(buildConfig_tree));
buildConfig_tree.setCellRenderer(new ConfigTreeCellRenderer());
for (int j = 0; j < buildConfig_tree.getRowCount(); j++) {
buildConfig_tree.expandPath(buildConfig_tree.getPathForRow(j));
}
} catch(Exception e) {
Ajde.getDefault().getErrorHandler().handleError("Could not open file.", e);
}
}
private ConfigTreeNode buildTree(BuildConfigNode node) {
ConfigTreeNode treeNode = new ConfigTreeNode(node);
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
BuildConfigNode childNode = (BuildConfigNode)it.next();
treeNode.add(buildTree(childNode));
}
return treeNode;
}
private void saveModel() {
Ajde.getDefault().getConfigurationManager().writeModel(model);
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel1.setMaximumSize(new Dimension(80, 30));
jLabel1.setMinimumSize(new Dimension(80, 20));
jLabel1.setPreferredSize(new Dimension(80, 20));
jLabel1.setText("Config File Editor");
cancel_button.setFont(new java.awt.Font("Dialog", 0, 11));
cancel_button.setMaximumSize(new Dimension(73, 20));
cancel_button.setMinimumSize(new Dimension(73, 20));
cancel_button.setPreferredSize(new Dimension(73, 20));
cancel_button.setText("Cancel");
cancel_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancel_button_actionPerformed(e);
}
});
jPanel1.setLayout(borderLayout2);
save_button.setText("Save");
save_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
save_button_actionPerformed(e);
}
});
save_button.setPreferredSize(new Dimension(73, 20));
save_button.setMinimumSize(new Dimension(73, 20));
save_button.setMaximumSize(new Dimension(73, 20));
save_button.setFont(new java.awt.Font("Dialog", 0, 11));
this.add(jPanel1, BorderLayout.NORTH);
jPanel1.add(jPanel2, BorderLayout.EAST);
jPanel2.add(save_button, null);
//jPanel2.add(cancel_button, null);
jPanel1.add(jLabel1, BorderLayout.CENTER);
this.add(jScrollPane, BorderLayout.CENTER);
jScrollPane.getViewport().add(buildConfig_tree, null);
}
private class ConfigTreeNode extends DefaultMutableTreeNode {
public JCheckBox checkBox = null;
public BuildConfigNode modelNode;
public ConfigTreeNode(BuildConfigNode modelNode) {
super(modelNode.getName(), true);
this.modelNode = modelNode;
checkBox = new JCheckBox();
}
public BuildConfigNode getModelNode() {
return modelNode;
}
public void setModelNode(BuildConfigNode modelNode) {
this.modelNode = modelNode;
}
}
private class ConfigFileMouseAdapter extends MouseAdapter {
private JTree tree = null;
final JCheckBox checkBoxProto = new JCheckBox();
final int width = checkBoxProto.getPreferredSize().width;
public ConfigFileMouseAdapter(JTree tree) {
super();
this.tree = tree;
}
public void mousePressed(MouseEvent e) {
int x = e.getX();
int y = e.getY();
TreePath path = tree.getClosestPathForLocation(x,y);
ConfigTreeNode node = (ConfigTreeNode)path.getLastPathComponent();
// if (isCheckBox(x, tree.getPathBounds(path).x)) {
if (node.checkBox.isSelected()) {
node.getModelNode().setActive(false);
node.checkBox.setSelected(false);
} else {
node.getModelNode().setActive(true);
node.checkBox.setSelected(true);
}
((DefaultTreeModel)tree.getModel()).nodeChanged(node);
if (node.getModelNode().getName() != null) {
if (node.checkBox.isSelected()) {
selectedEntries.add(node.getModelNode().getName());
} else {
selectedEntries.remove(node.getModelNode().getName());
}
}
super.mousePressed(e);
}
boolean isCheckBox(int x, int x_) {
int d = x - x_;
return (d < width) && (d > 0);
}
}
static class ConfigTreeCellRenderer extends DefaultTreeCellRenderer {
public Component getTreeCellRendererComponent(JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded,
leaf, row, hasFocus);
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
p.setBackground(Color.white);
//if (leaf) {
setFont(new Font("Dialog", Font.PLAIN, 11));
final JCheckBox cbox = ((ConfigTreeNode)value).checkBox;
cbox.setBackground(Color.white);
if (row != 0) {
p.add(cbox);
}
ConfigTreeNode ctn = (ConfigTreeNode)value;
//if (TreeViewBuildConfigEditor.selectedEntries.contains(ctn.getSourceFile())) {
if (ctn.getModelNode().isActive()) {
cbox.setSelected(true);
}
if (!ctn.getModelNode().isValidResource()) {
ctn.checkBox.setEnabled(false);
}
//}
BuildConfigNode.Kind kind = ctn.getModelNode().getBuildConfigNodeKind();
if (kind.equals(BuildConfigNode.Kind.FILE_ASPECTJ)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_ASPECTJ));
} else if (kind.equals(BuildConfigNode.Kind.FILE_JAVA)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_JAVA));
} else if (kind.equals(BuildConfigNode.Kind.FILE_LST)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_LST));
} else if (kind.equals(BuildConfigNode.Kind.DIRECTORY)) {
setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.PACKAGE));
} else {
setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.ERROR).getIconResource());
p.remove(cbox);
}
// if (ctn.getModelNode().getResourcePath() != null) {
// if (ctn.getModelNode().getResourcePath().endsWith(".java")) {
// this.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.CLASS));
// } else if (ctn.getModelNode().getResourcePath().endsWith(".aj")) {
// this.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.ASPECT));
// } else {
// this.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.PACKAGE));
// }
// }
p.add(this);
return p;
}
}
void cancel_button_actionPerformed(ActionEvent e) {
//resetEditorFrame();
}
void save_button_actionPerformed(ActionEvent e) {
saveModel();
//resetEditorFrame();
}
// private void resetEditorFrame() {
// BrowserManager.getDefault().resetEditorFrame();
// }
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testdata/examples/coverage/ModelCoverage.java
|
import java.io.*;
class Point {
int x;
static int sx;
{ x = 0; }
static { sx = 1; }
public Point() { }
public int getX() { return x; }
public void setX(int x) { this.x = x; }
public int changeX(int x) {
this.x = x;
return x;
}
void doIt() {
try {
File f = new File(".");
f.getCanonicalPath();
} catch (IOException ioe) {
System.err.println("!");
}
setX(10);
new Point();
}
}
class SubPoint extends Point { }
class Line { }
aspect AdvisesRelationCoverage {
before(): execution(*..*.new(..)) { }
before(): get(int *.*) { }
before(): set(int *.*) { }
before(): initialization(Point.new(..)) { }
before(): staticinitialization(Point) { }
before(): handler(IOException) { }
before(): call(* Point.setX(int)) { }
before(): call(Point.new()) { }
before(): within(*) && execution(* Point.setX(..)) { }
before(): within(*) && execution(Point.new()) { }
}
aspect AdviceNamingCoverage {
pointcut named(): call(* *.mumble());
pointcut namedWithOneArg(int i): call(int Point.changeX(int)) && args(i);
pointcut namedWithArgs(int i, int j): set(int Point.x) && args(i, j);
after(): named() { }
after(int i, int j) returning: namedWithArgs(i, j) { }
after() throwing: named() { }
after(): named() { }
before(): named() { }
int around(int i): namedWithOneArg(i) { return i;}
int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); }
before(): named() { }
before(int i): call(* XXX.mumble()) && named() && namedWithOneArg(i) { }
before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { }
before(): call(* *.mumble()) { }
}
abstract aspect AbstractAspect {
abstract pointcut abPtct();
}
aspect InterTypeDecCoverage {
pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..));
declare error: illegalNewFigElt(): "Illegal constructor call.";
declare warning: illegalNewFigElt(): "Illegal constructor call.";
declare parents: Point extends java.io.Serializable;
declare parents: Point+ implements java.util.Observable;
declare parents: Point && Line implements java.util.Observable;
declare soft: SizeException : call(* Point.getX());
declare precedence: AdviceCoverage, InterTypeDecCoverage, *;
public int Point.xxx = 0;
public int Point.check(int i, Line l) { return 1 + i; }
// public Line.new(String s) { }
}
class SizeException extends Exception { }
aspect AdviceCoverage {
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testdata/examples/coverage/pkg/InPackage.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde;
import junit.framework.*;
public class AjdeTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AjdeTests.class.getName());
//$JUnit-BEGIN$
suite.addTestSuite(BuildOptionsTest.class);
suite.addTestSuite(BuildConfigurationTests.class);
suite.addTestSuite(StructureModelRegressionTest.class);
suite.addTestSuite(StructureModelTest.class);
suite.addTestSuite(VersionTest.class);
suite.addTestSuite(CompilerMessagesTest.class);
suite.addTestSuite(AsmDeclarationsTest.class);
suite.addTestSuite(ResourceCopyTestCase.class);
//$JUnit-END$
return suite;
}
public AjdeTests(String name) { super(name); }
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* ******************************************************************/
package org.aspectj.ajde;
import java.util.Iterator;
import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter;
import org.aspectj.asm.*;
import org.aspectj.asm.ProgramElementNode.Kind;
// TODO: check for return types
public class AsmDeclarationsTest extends AjdeTestCase {
private StructureModel model = null;
private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH;
public AsmDeclarationsTest(String name) {
super(name);
}
public void testDeclares() {
ProgramElementNode node = (ProgramElementNode)model.getRoot();
assertNotNull(node);
ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage");
assertNotNull(aspect);
String decErrMessage = "declare error: \"Illegal construct..\"";
ProgramElementNode decErrNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_ERROR, decErrMessage);
assertNotNull(decErrNode);
assertEquals(decErrNode.getName(), decErrMessage);
String decWarnMessage = "declare warning: \"Illegal construct..\"";
ProgramElementNode decWarnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_WARNING, decWarnMessage);
assertNotNull(decWarnNode);
assertEquals(decWarnNode.getName(), decWarnMessage);
String decParentsMessage = "declare parents: Point";
ProgramElementNode decParentsNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsMessage);
assertNotNull(decParentsNode);
assertEquals(decParentsNode.getName(), decParentsMessage);
String decParentsPtnMessage = "declare parents: Point+";
ProgramElementNode decParentsPtnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsPtnMessage);
assertNotNull(decParentsPtnNode);
assertEquals(decParentsPtnNode.getName(), decParentsPtnMessage);
String decParentsTPMessage = "declare parents: <type pattern>";
ProgramElementNode decParentsTPNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsTPMessage);
assertNotNull(decParentsTPNode);
assertEquals(decParentsTPNode.getName(), decParentsTPMessage);
String decSoftMessage = "declare soft: SizeException";
ProgramElementNode decSoftNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_SOFT, decSoftMessage);
assertNotNull(decSoftNode);
assertEquals(decSoftNode.getName(), decSoftMessage);
String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>";
ProgramElementNode decPrecNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PRECEDENCE, decPrecMessage);
assertNotNull(decPrecNode);
assertEquals(decPrecNode.getName(), decPrecMessage);
}
public void testInterTypeMemberDeclares() {
ProgramElementNode node = (ProgramElementNode)model.getRoot();
assertNotNull(node);
ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage");
assertNotNull(aspect);
String fieldMsg = "Point.xxx";
ProgramElementNode fieldNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_FIELD, fieldMsg);
assertNotNull(fieldNode);
assertEquals(fieldNode.getName(), fieldMsg);
String methodMsg = "Point.check(int, Line)";
ProgramElementNode methodNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_METHOD, methodMsg);
assertNotNull(methodNode);
assertEquals(methodNode.getName(), methodMsg);
// TODO: enable
// String constructorMsg = "Point.new(int, int, int)";
// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg);
// assertNotNull(constructorNode);
// assertEquals(constructorNode.getName(), constructorMsg);
}
public void testPointcuts() {
ProgramElementNode node = (ProgramElementNode)model.getRoot();
assertNotNull(node);
ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String ptct = "named()";
ProgramElementNode ptctNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, ptct);
assertNotNull(ptctNode);
assertEquals(ptctNode.getName(), ptct);
String params = "namedWithArgs(int, int)";
ProgramElementNode paramsNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, params);
assertNotNull(paramsNode);
assertEquals(paramsNode.getName(), params);
}
public void testAbstract() {
ProgramElementNode node = (ProgramElementNode)model.getRoot();
assertNotNull(node);
ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AbstractAspect");
assertNotNull(aspect);
String abst = "abPtct()";
ProgramElementNode abstNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, abst);
assertNotNull(abstNode);
assertEquals(abstNode.getName(), abst);
}
public void testAdvice() {
ProgramElementNode node = (ProgramElementNode)model.getRoot();
assertNotNull(node);
ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String anon = "before(): <anonymous pointcut>";
ProgramElementNode anonNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, anon);
assertNotNull(anonNode);
assertEquals(anonNode.getName(), anon);
String named = "before(): named..";
ProgramElementNode namedNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, named);
assertNotNull(namedNode);
assertEquals(namedNode.getName(), named);
String namedWithOneArg = "around(int): namedWithOneArg..";
ProgramElementNode namedWithOneArgNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, namedWithOneArg);
assertNotNull(namedWithOneArgNode);
assertEquals(namedWithOneArgNode.getName(), namedWithOneArg);
String afterReturning = "afterReturning(int, int): namedWithArgs..";
ProgramElementNode afterReturningNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, afterReturning);
assertNotNull(afterReturningNode);
assertEquals(afterReturningNode.getName(), afterReturning);
String around = "around(int): namedWithOneArg..";
ProgramElementNode aroundNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, around);
assertNotNull(aroundNode);
assertEquals(aroundNode.getName(), around);
String compAnon = "before(int): <anonymous pointcut>..";
ProgramElementNode compAnonNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, compAnon);
assertNotNull(compAnonNode);
assertEquals(compAnonNode.getName(), compAnon);
String compNamed = "before(int): named()..";
ProgramElementNode compNamedNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, compNamed);
assertNotNull(compNamedNode);
assertEquals(compNamedNode.getName(), compNamed);
}
protected void setUp() throws Exception {
super.setUp("examples");
assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
model = StructureModelManager.getDefault().getStructureModel();
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* AMC 03.27.2003 changed to allow access to NullIdeManager
* as a singleton - needed for verifying
* compiler warning and error messages.
* ******************************************************************/
package org.aspectj.ajde;
import java.util.List;
import javax.swing.JFrame;
import org.aspectj.ajde.ui.IdeUIAdapter;
import org.aspectj.ajde.ui.UserPreferencesAdapter;
import org.aspectj.ajde.ui.internal.UserPreferencesStore;
import org.aspectj.ajde.ui.swing.*;
/**
* @author Mik Kersten
*/
public class NullIdeManager {
private static NullIdeManager ideManager = null;
private NullIdeTaskListManager taskListManager = null;
private NullIdeProperties projectProperties = null;
public static NullIdeManager getIdeManager() {
if ( null == ideManager ) {
ideManager = new NullIdeManager();
}
return ideManager;
}
public void init(String testProjectPath) {
try {
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false);
projectProperties = new NullIdeProperties(testProjectPath);
taskListManager = new NullIdeTaskListManager();
EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
JFrame nullFrame = new JFrame();
//configurationManager.setConfigFiles(getConfigFilesList(configFiles));
AjdeUIManager.getDefault().init(
ajdeEditor,
taskListManager,
projectProperties,
preferencesAdapter,
uiAdapter,
new IconRegistry(),
nullFrame,
true);
//Ajde.getDefault().enableLogging( System.out );
} catch (Throwable t) {
t.printStackTrace();
Ajde.getDefault().getErrorHandler().handleError(
"Null IDE failed to initialize.",
t);
}
}
public List getCompilationSourceLineTasks() {
return taskListManager.getSourceLineTasks();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde;
import java.util.ArrayList;
import java.util.List;
import org.aspectj.bridge.*;
/**
* Used for displaying tasks, such as compiler messages, to the user.
*
* @author Mik Kersten
*/
public class NullIdeTaskListManager implements TaskListManager {
List sourceLineTasks = new ArrayList();
boolean hasWarning = false;
public void addSourcelineTask(
String message,
ISourceLocation sourceLocation,
IMessage.Kind kind) {
addSourcelineTask(new Message(message, kind, null, sourceLocation));
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
hasWarning = true;
}
}
public void addSourcelineTask(IMessage message) {
sourceLineTasks.add(new SourceLineTask(message));
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
hasWarning = true;
}
System.out.println("> added sourceline task: " + message + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath()
+ ": " + message.getSourceLocation().getLine());
}
public void addProjectTask(String message, IMessage.Kind kind) {
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
hasWarning = true;
}
System.out.println("> added project task: " + message + ", kind: " + kind);
}
public boolean hasWarning() {
return hasWarning;
}
public void clearTasks() {
sourceLineTasks = new ArrayList();
hasWarning = false;
}
/**
* Return the list of source line compiler messages resulting from a compile, so
* that we can test them.
* @return List
*/
public List getSourceLineTasks() {
return sourceLineTasks;
}
public static class SourceLineTask {
IMessage message;
public SourceLineTask(IMessage m) {
message = m;
}
public IMessage getContainedMessage() {
return message;
}
public String toString() {
String loc = "<no location>";
if (null != message.getSourceLocation()) {
loc = message.getSourceLocation().getSourceFile() + ":" + message.getSourceLocation().getLine();
}
return "SourceLineTask [" + message.getMessage()
+ ", " + loc
+ ", " + message.getKind()
+ "]";
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde;
import org.aspectj.ajde.ui.*;
public class NullIdeUIAdapter implements IdeUIAdapter {
public void displayStatusInformation(String message) {
System.out.println("> NullIdeUIAdapter status : " + message);
}
public void resetGUI() {
// not implemented
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde;
import java.io.File;
import java.util.List;
import junit.framework.TestSuite;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
public class StructureModelRegressionTest extends AjdeTestCase {
public StructureModelRegressionTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(StructureModelRegressionTest.class);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(StructureModelRegressionTest.class);
return result;
}
public void test() {
String testLstFile = "testdata/StructureModelRegressionTest/example.lst";
File f = new File(testLstFile);
assertTrue(testLstFile, f.canRead());
assertTrue("saved model: " + testLstFile, verifyAgainstSavedModel(testLstFile));
}
public boolean verifyAgainstSavedModel(String lstFile) {
File modelFile = new File(genStructureModelExternFilePath(lstFile));
StructureModel model = getModelForFile(lstFile);
System.out.println(">> model: " + model.getRoot());
if (modelFile.exists()) {
Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile);
StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel();
//System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot());
// AMC This test will not pass as written until StructureNode defines
// equals. The equals loic is commented out in the StructureNode
// class - adding it back in could have unforeseen system-wide
// consequences, so I've defined a structureNodesEqual( ) helper
// method here instead.
StructureNode rootNode = model.getRoot();
StructureNode savedRootNode = savedModel.getRoot();
return structureNodesEqual( rootNode, savedRootNode );
} else {
Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile);
return true;
}
//return true;
}
private boolean structureNodesEqual( StructureNode s1, StructureNode s2 ) {
final boolean equal = true;
if ( s1 == s2 ) return equal;
if ( null == s1 || null == s2 ) return !equal;
if (!s1.getName( ).equals(s2.getName())) return !equal;
if (!s1.getKind( ).equals(s2.getKind())) return !equal;
// check child nodes
List s1Kids = s1.getChildren();
List s2Kids = s2.getChildren();
if ( s1Kids != null && s2Kids != null ) {
if (s1Kids == null || s2Kids == null) return !equal;
if (s1Kids.size() != s2Kids.size() ) return !equal;
for ( int k=0; k<s1Kids.size(); k++ ) {
StructureNode k1 = (StructureNode) s1Kids.get(k);
StructureNode k2 = (StructureNode) s2Kids.get(k);
if (!structureNodesEqual( k1, k2 )) return !equal;
}
}
return equal;
}
private StructureModel getModelForFile(String lstFile) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile);
Ajde.getDefault().getBuildManager().build(); // was buildStructure...
while(!testerBuildListener.getBuildFinished()) {
try {
Thread.sleep(300);
} catch (InterruptedException ie) { }
}
return Ajde.getDefault().getStructureModelManager().getStructureModel();
}
protected void setUp() throws Exception {
super.setUp("StructureModelRegressionTest");
Ajde.getDefault().getStructureModelManager().setShouldSaveModel(false);
}
public void testModelExists() {
assertTrue(Ajde.getDefault().getStructureModelManager().getStructureModel() != null);
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* AMC 21.01.2003 fixed for new source location in eclipse.org
* ******************************************************************/
package org.aspectj.ajde;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import junit.framework.TestSuite;
import org.aspectj.asm.ModelWalker;
import org.aspectj.asm.ProgramElementNode;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class StructureModelTest extends AjdeTestCase {
private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst";
public StructureModelTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(StructureModelTest.class);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(StructureModelTest.class);
return result;
}
// XXX this should work
// public void testFieldInitializerCorrespondence() throws IOException {
// File testFile = createFile("testdata/examples/figures-coverage/figures/Figure.java");
// StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
// testFile.getCanonicalPath(), 28);
// assertTrue("find result", node != null) ;
// ProgramElementNode pNode = (ProgramElementNode)node;
// ProgramElementNode foundNode = null;
// final List list = pNode.getRelations();
// //System.err.println(">>>> " + pNode + ", " + list);
// assertNotNull("pNode.getRelations()", list);
// for (Iterator it = list.iterator(); it.hasNext(); ) {
// RelationNode relation = (RelationNode)it.next();
//
// if (relation.getRelation().equals(AdviceAssociation.FIELD_ACCESS_RELATION)) {
// for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) {
// LinkNode linkNode = (LinkNode)it2.next();
// if (linkNode.getProgramElementNode().getName().equals("this.currVal = 0")) {
// foundNode = linkNode.getProgramElementNode();
// }
// }
// }
// }
//
// assertTrue("find associated node", foundNode != null) ;
//
// File pointFile = createFile("testdata/examples/figures-coverage/figures/primitives/planar/Point.java");
// StructureNode fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
// pointFile.getCanonicalPath(), 12);
// assertTrue("find result", fieldNode != null);
//
// assertTrue("matches", foundNode.getParent() == fieldNode.getParent());
// }
public void testRootForSourceFile() throws IOException {
File testFile = openFile("figures-coverage/figures/Figure.java");
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
testFile.getCanonicalPath());
assertTrue("find result", node != null) ;
ProgramElementNode pNode = (ProgramElementNode)node;
String child = ((StructureNode)pNode.getChildren().get(0)).getName();
assertTrue("expected Figure got child " + child, child.equals("Figure"));
}
public void testPointcutName() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
//System.err.println("PointcutName, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists());
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
testFile.getCanonicalPath());
//System.err.println(" node: " + node);
assertTrue("find result", node != null) ;
ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getChildren().get(1);
ProgramElementNode pointcut = (ProgramElementNode)pNode.getChildren().get(0);
assertTrue("kind", pointcut.getProgramElementKind().equals(ProgramElementNode.Kind.POINTCUT));
assertTrue("found node: " + pointcut.getName(), pointcut.getName().equals("testptct()"));
}
public void testDeclare() {
}
public void testFileNodeFind() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
//System.err.println("NodeFind, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists());
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
testFile.getCanonicalPath(), 1);
//System.err.println(" node: " + node);
assertTrue("find result", node != null) ;
assertEquals("find result has children", 2, node.getChildren().size()) ;
ProgramElementNode pNode = (ProgramElementNode)node;
assertTrue("found node: " + pNode.getName(), pNode.getProgramElementKind().equals(ProgramElementNode.Kind.FILE_JAVA));
}
/**
* @todo add negative test to make sure things that aren't runnable aren't annotated
*/
public void testMainClassNodeInfo() throws IOException {
StructureModel model = Ajde.getDefault().getStructureModelManager().getStructureModel();
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
File testFile = openFile("figures-coverage/figures/Main.java");
StructureNode node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11);
assertTrue("find result", node != null);
ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getParent();
if (null == pNode) {
assertTrue("null parent of " + node, false);
}
assertTrue("found node: " + pNode.getName(), pNode.isRunnable());
}
/**
* Integrity could be checked somewhere in the API.
*/
public void testModelIntegrity() {
StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot();
assertTrue("root exists", modelRoot != null);
try {
testModelIntegrityHelper(modelRoot);
} catch (Exception e) {
assertTrue(e.toString(), false);
}
}
private void testModelIntegrityHelper(StructureNode node) throws Exception {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureNode child = (StructureNode)it.next();
if (node == child.getParent()) {
testModelIntegrityHelper(child);
} else {
throw new Exception("parent-child check failed for child: " + child.toString());
}
}
}
public void testNoChildIsNull() {
ModelWalker walker = new ModelWalker() {
public void preProcess(StructureNode node) {
if (node.getChildren() == null) return;
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
if (it.next() == null) throw new NullPointerException("null child on node: " + node.getName());
}
}
};
Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot().walk(walker);
}
protected void setUp() throws Exception {
super.setUp("examples");
doSynchronousBuild(CONFIG_FILE_PATH);
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.*;
import junit.framework.TestSuite;
import org.aspectj.ajde.AjdeTestCase;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
public class StructureModelUtilTest extends AjdeTestCase {
private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst";
public StructureModelUtilTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(StructureModelUtilTest.class);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(StructureModelUtilTest.class);
return result;
}
public void testPackageViewUtil() {
List packages = StructureModelUtil.getPackagesInModel();
assertTrue("packages list not null", packages != null);
assertTrue("packages list not empty", !packages.isEmpty());
// System.err.println("> packages: " + packages);
ProgramElementNode packageNode = (ProgramElementNode)((Object[])packages.get(0))[0];
assertTrue("package node not null", packageNode != null);
// System.err.println("> package node: " + packageNode);
List files = StructureModelUtil.getFilesInPackage(packageNode);
assertTrue("fle list not null", files != null);
// System.err.println("> file list: " + files);
Map lineAdviceMap = StructureModelUtil.getLinesToAspectMap(
((ProgramElementNode)files.get(0)).getSourceLocation().getSourceFile().getAbsolutePath()
);
assertTrue("line->advice map not null", lineAdviceMap != null);
// System.err.println("> line->advice map: " + lineAdviceMap);
Set aspects = StructureModelUtil.getAspectsAffectingPackage(packageNode);
assertTrue("aspect list not null", aspects != null);
// System.err.println("> aspects affecting package: " + aspects);
}
protected void setUp() throws Exception {
super.setUp("StructureModelUtilTest");
doSynchronousBuild(CONFIG_FILE_PATH);
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.util.List;
import junit.framework.TestSuite;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.AjdeTestCase;
import org.aspectj.asm.ProgramElementNode;
/**
* @author Mik Kersten
*/
public class StructureSearchManagerTest extends AjdeTestCase {
private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst";
public StructureSearchManagerTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(StructureSearchManagerTest.class);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(StructureSearchManagerTest.class);
return result;
}
public void testFindPatternMatch() {
List matches = Ajde.getDefault().getStructureSearchManager().findMatches(
"Point",
null
);
System.err.println(matches);
assertTrue("non existent node", true);
}
public void testFindPatternAndKindMatch() {
List matches = Ajde.getDefault().getStructureSearchManager().findMatches(
"Point",
ProgramElementNode.Kind.CONSTRUCTOR
);
System.err.println(matches);
assertTrue("non existent node", true);
}
public void testFindNonExistent() {
List matches = Ajde.getDefault().getStructureSearchManager().findMatches(
"mumbleNodeDesNotExist",
null
);
assertTrue("non existent", matches.isEmpty());
}
protected void setUp() throws Exception {
super.setUp("StructureSearchManagerTest");
doSynchronousBuild(CONFIG_FILE_PATH);
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.ajde.ui;
import java.io.File;
import java.util.Iterator;
import junit.framework.TestSuite;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.AjdeTestCase;
import org.aspectj.asm.StructureModel;
import org.aspectj.asm.StructureNode;
/**
* @author Mik Kersten
*/
public class StructureViewManagerTest extends AjdeTestCase {
private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst";
private final String CONFIG_FILE_PATH_2 = "../examples/inheritance/inheritance.lst";
private FileStructureView currentView;
private NullIdeStructureViewRenderer renderer = new NullIdeStructureViewRenderer();
private File testFile;
private StructureViewProperties properties;
public StructureViewManagerTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.swingui.TestRunner.run(StructureViewManagerTest.class);
}
public static TestSuite suite() {
TestSuite result = new TestSuite();
result.addTestSuite(StructureViewManagerTest.class);
return result;
}
public void testModelExists() {
assertTrue(Ajde.getDefault().getStructureModelManager().getStructureModel() != null);
}
public void testNotificationAfterConfigFileChange() {
doSynchronousBuild(CONFIG_FILE_PATH_2);
renderer.setHasBeenNotified(false);
assertTrue("not yet notified", !renderer.getHasBeenNotified());
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(CONFIG_FILE_PATH_2);
assertTrue("notified", renderer.getHasBeenNotified());
renderer.setHasBeenNotified(false);
Ajde.getDefault().getConfigurationManager().setActiveConfigFile("MumbleDoesNotExist.lst");
assertTrue("notified", renderer.getHasBeenNotified());
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode().getChildren().get(0)
== StructureModel.NO_STRUCTURE
);
}
/**
* @todo this should be moved to a StructureModelManager test
*/
public void testFreshStructureModelCreation() {
renderer.setHasBeenNotified(false);
String modelPath = genStructureModelExternFilePath(CONFIG_FILE_PATH);
openFile(modelPath).delete();
//System.err.println("> path: " + modelPath);
Ajde.getDefault().getStructureModelManager().readStructureModel(CONFIG_FILE_PATH);
assertTrue("notified", renderer.getHasBeenNotified());
//System.err.println(">>>>>> " + currentView.getRootNode().getStructureNode());
// AMC should this be currentView, or should we recreate the root... do the latter
//StructureNode n = currentView.getRootNode().getStructureNode();
StructureNode n = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot();
assertTrue(
"no structure",
//currentView.getRootNode().getStructureNode().getChildren().get(0)
n == StructureModel.NO_STRUCTURE
);
}
public void testModelIntegrity() {
doSynchronousBuild(CONFIG_FILE_PATH);
StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot();
assertTrue("root exists", modelRoot != null);
try {
testModelIntegrityHelper(modelRoot);
} catch (Exception e) {
assertTrue(e.toString(), false);
}
}
private void testModelIntegrityHelper(StructureNode node) throws Exception {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
StructureNode child = (StructureNode)it.next();
if (node == child.getParent()) {
testModelIntegrityHelper(child);
} else {
throw new Exception("parent-child check failed for child: " + child.toString());
}
}
}
public void testNotificationAfterBuild() {
renderer.setHasBeenNotified(false);
doSynchronousBuild(CONFIG_FILE_PATH);
assertTrue("notified", renderer.getHasBeenNotified());
}
public void testViewCreationWithNullSourceFileAndProperties() {
currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(null, null);
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode()
== StructureModel.NO_STRUCTURE
);
}
protected void setUp() throws Exception {
super.setUp("StructureViewManagerTest");
doSynchronousBuild(CONFIG_FILE_PATH);
properties = Ajde.getDefault().getStructureViewManager().getDefaultViewProperties();
testFile = openFile("../examples/figures-coverage/figures/Figure.java");
currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(testFile.getAbsolutePath(), properties);
currentView.setRenderer(renderer);
}
protected void tearDown() throws Exception {
super.tearDown();
}
// public void testViewListenerRegistrations() {
// System.err.println("> starting...");
// Ajde.getDefault().getBuildManager().build("C:/Dev/aspectj/tests/ajde/examples/coverage-figures/src/AllFiles.lst");
// while(!testerBuildListener.getBuildFinished()) {
// try {
// Thread.sleep(300);
// } catch (InterruptedException ie) { }
// }
// List renderers = Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView().getRenderers();
// System.err.println("> renderers (1): " + renderers);
//
// testerBuildListener.reset();
// Ajde.getDefault().getBuildManager().build("C:/Dev/aspectj/tests/ajde/examples/coverage-figures/src/AllFiles.lst");
// while(!testerBuildListener.getBuildFinished()) {
// try {
// Thread.sleep(300);
// } catch (InterruptedException ie) { }
// }
// System.err.println("> renderers (2): " + renderers);
// assertTrue("checking renderers", true);
// }
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/AdviceAssociation.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mik Kersten
*/
public class AdviceAssociation implements Association {
public static final String NAME = "Advice";
public static final Relation METHOD_RELATION = new Relation("advises methods", "method advised by", NAME, true, false);
public static final Relation METHOD_CALL_SITE_RELATION = new Relation("advises method call sites", "method call site advised by", NAME, true, false);
public static final Relation CONSTRUCTOR_RELATION = new Relation("advises constructors", "constructors advised by", NAME, true, false);
public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("advises constructions", "construction advised by", NAME, true, false);
public static final Relation HANDLER_RELATION = new Relation("advises exception handlers", "exception handler advised by", NAME, true, false);
public static final Relation INITIALIZER_RELATION = new Relation("advises initializers", "initializers advised by", NAME, true, false);
public static final Relation FIELD_ACCESS_RELATION = new Relation("advises field access", "field access advised by", NAME, true, false);
public static final Relation INTRODUCTION_RELATION = new Relation("advises introduction", "introduction advised by", NAME, true, false);
private List relations = new ArrayList();
public AdviceAssociation() {
relations.add(METHOD_RELATION);
relations.add(METHOD_CALL_SITE_RELATION);
relations.add(CONSTRUCTOR_RELATION);
relations.add(CONSTRUCTOR_CALL_SITE_RELATION);
relations.add(HANDLER_RELATION);
relations.add(INITIALIZER_RELATION);
relations.add(FIELD_ACCESS_RELATION);
relations.add(INTRODUCTION_RELATION);
}
public List getRelations() {
return relations;
}
public List getRelationNodes() {
List relations = new ArrayList();
List methods = new ArrayList();
List methodCallSites = new ArrayList();
List constructors = new ArrayList();
List constructorCallSites = new ArrayList();
List handlers = new ArrayList();
List initializers = new ArrayList();
List fieldAccesses = new ArrayList();
List introductions = new ArrayList();
// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
//
// if (astObject instanceof AdviceDec) {
// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// LinkNode link = StructureNodeFactory.makeLink(node, false);
// if (node instanceof MethodDec) {
// if (((MethodDec)node).isSynthetic()) {
// ASTObject resolvedNode = resolveSyntheticMethodToIntroduction((MethodDec)node);
// introductions.add(StructureNodeFactory.makeLink(resolvedNode, false));
// } else {
// methods.add(link);
// }
// } else if (node instanceof CallExpr) {
// methodCallSites.add(link);
// } else if (node instanceof ConstructorDec) {
// constructors.add(link);
// } else if (node instanceof NewInstanceExpr) {
// constructorCallSites.add(link);
// } else if (node instanceof CatchClause) {
// handlers.add(link);
// } else if (node instanceof InitializerDec) {
// initializers.add(link);
// } else if (node instanceof FieldDec) {
// fieldAccesses.add(link);
// } else if (node instanceof BasicAssignExpr || node instanceof FieldAccessExpr) {
// fieldAccesses.add(link);
// }
// }
// if (!methods.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_RELATION.getForwardNavigationName(), methods));
// if (!methodCallSites.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_CALL_SITE_RELATION.getForwardNavigationName(), methodCallSites));
// if (!constructors.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_RELATION, CONSTRUCTOR_RELATION.getForwardNavigationName(), constructors));
// if (!constructorCallSites.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_CALL_SITE_RELATION, CONSTRUCTOR_CALL_SITE_RELATION.getForwardNavigationName(), constructorCallSites));
// if (!handlers.isEmpty()) relations.add(new RelationNode(HANDLER_RELATION, HANDLER_RELATION.getForwardNavigationName(), handlers));
// if (!initializers.isEmpty()) relations.add(new RelationNode(INITIALIZER_RELATION, INITIALIZER_RELATION.getForwardNavigationName(), initializers));
// if (!fieldAccesses.isEmpty()) relations.add(new RelationNode(FIELD_ACCESS_RELATION, FIELD_ACCESS_RELATION.getForwardNavigationName(), fieldAccesses));
// if (!introductions.isEmpty()) relations.add(new RelationNode(INTRODUCTION_RELATION, INTRODUCTION_RELATION.getForwardNavigationName(), introductions));
// } else {
// if (astObject instanceof IntroducedDec) {
// Set adviceDecs = resolveAdviceAffectingIntroduction((IntroducedDec)astObject);
// if (adviceDecs != null) {
// for (Iterator adIt = adviceDecs.iterator(); adIt.hasNext(); ) {
// introductions.add(StructureNodeFactory.makeLink((ASTObject)adIt.next(), false));
// }
// }
// }
//
// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// if (node instanceof AdviceDec) {
// if (astObject instanceof MethodDec) {
// methods.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof CallExpr) {
// methodCallSites.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof ConstructorDec) {
// constructors.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof NewInstanceExpr) {
// constructorCallSites.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof CatchClause) {
// handlers.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof InitializerDec) {
// initializers.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof FieldDec) {
// fieldAccesses.add(StructureNodeFactory.makeLink(node, false));
// } else if (astObject instanceof BasicAssignExpr
// || astObject instanceof FieldAccessExpr) {
// fieldAccesses.add(StructureNodeFactory.makeLink(node, false));
// }
// }
// }
// if (!methods.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_RELATION.getBackNavigationName(), methods));
// if (!methodCallSites.isEmpty()) relations.add(new RelationNode(METHOD_CALL_SITE_RELATION, METHOD_CALL_SITE_RELATION.getBackNavigationName(), methodCallSites));
// if (!constructors.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_RELATION, CONSTRUCTOR_RELATION.getBackNavigationName(), constructors));
// if (!constructorCallSites.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_CALL_SITE_RELATION, CONSTRUCTOR_CALL_SITE_RELATION.getBackNavigationName(), constructorCallSites));
// if (!handlers.isEmpty()) relations.add(new RelationNode(HANDLER_RELATION, HANDLER_RELATION.getBackNavigationName(), handlers));
// if (!initializers.isEmpty()) relations.add(new RelationNode(INITIALIZER_RELATION, INITIALIZER_RELATION.getBackNavigationName(), initializers));
// if (!fieldAccesses.isEmpty()) relations.add(new RelationNode(FIELD_ACCESS_RELATION, FIELD_ACCESS_RELATION.getBackNavigationName(), fieldAccesses));
// if (!introductions.isEmpty()) relations.add(new RelationNode(INTRODUCTION_RELATION, INTRODUCTION_RELATION.getBackNavigationName(), introductions));
// }
return relations;
}
public String getName() {
return NAME;
}
// /**
// * @todo HACK: this search and hacked name-match should be replace by a fix to the correspondeces db
// */
// private ASTObject resolveSyntheticMethodToIntroduction(MethodDec node) {
// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(node.getDeclaringType().getTypeDec());
// Method method = node.getMethod();
// String name = method.getDeclaringType().getName() + '.' + method.getName();
// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
// Object next = it.next();
// if (next instanceof IntroducedDec) {
// IntroducedDec introducedDec = (IntroducedDec)next;
// if (name.equals(introducedDec.toShortString())) return introducedDec;
// }
// }
// return node;
// }
// /**
// * @todo HACK: this search and hacked name-match should be replace by a fix to the correspondeces db
// */
// private Set resolveAdviceAffectingIntroduction(IntroducedDec node) {
// Set forwardCorrs = StructureModelManager.correspondences.getAffects(node);
// String name = node.getId();
// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
// Object next = it.next();
// if (next instanceof TypeDec) {
// TypeDec typeDec = (TypeDec)next;
// List decs = typeDec.getBody().getList();
// for (Iterator it2 = decs.iterator(); it2.hasNext(); ) {
// Dec bodyDec = (Dec)it2.next();
// if (bodyDec != null && !(bodyDec instanceof InitializerDec)) {
// if (bodyDec instanceof MethodDec && bodyDec.isSynthetic() && name.equals(bodyDec.getName())) {
// MethodDec methodDec = (MethodDec)bodyDec;
// return StructureModelManager.correspondences.getAffectedBy(methodDec);
// }
// }
// }
// }
// }
// return null;
// }
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/Association.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.List;
/**
* @author Mik Kersten
*/
public interface Association {
public List getRelations();
// XXX used ASTObject parameter
public List getRelationNodes();
public String getName();
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/HierarchyWalker.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/IProgramElement.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/IRelationship.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/IStructureModelListener.java
| |
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/InheritanceAssociation.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mik Kersten
*/
public class InheritanceAssociation implements Association {
public static final String NAME = "Inheritance";
public static final Relation INHERITS_RELATION = new Relation("inherits", "is inherited by", NAME, true, true);
public static final Relation IMPLEMENTS_RELATION = new Relation("implements", "is implemented by", NAME, true, true);
public static final Relation INHERITS_MEMBERS_RELATION = new Relation("inherits members", NAME, false);
private List relations = new ArrayList();
public InheritanceAssociation() {
relations.add(INHERITS_RELATION);
relations.add(IMPLEMENTS_RELATION);
relations.add(INHERITS_MEMBERS_RELATION);
}
public List getRelations() {
return relations;
}
public List getRelationNodes() {
List relations = new ArrayList();
// if (astObject instanceof TypeDec) {
// TypeDec typeDec = (TypeDec)astObject;
// boolean isInterface = (astObject instanceof InterfaceDec);
// List superTypes = getTypeLinks(typeDec.getType().getDirectSuperTypes(), true, isInterface);
// List subTypes = getTypeLinks(typeDec.getType().getDirectSubTypes(), true, isInterface);
// if (!superTypes.isEmpty()) relations.add(new RelationNode(INHERITS_RELATION, INHERITS_RELATION.getForwardNavigationName(), superTypes));
// if (!subTypes.isEmpty()) relations.add(new RelationNode(INHERITS_RELATION, INHERITS_RELATION.getBackNavigationName(), subTypes));
//
// List implementedInterfaces = getTypeLinks(typeDec.getType().getDirectSuperTypes(), false, isInterface);
// List implementors = getTypeLinks(typeDec.getType().getDirectSubTypes(), false, isInterface);
// if (!implementedInterfaces.isEmpty()) relations.add(new RelationNode(IMPLEMENTS_RELATION, IMPLEMENTS_RELATION.getForwardNavigationName(), implementedInterfaces));
// if (!implementors.isEmpty()) relations.add(new RelationNode(IMPLEMENTS_RELATION, IMPLEMENTS_RELATION.getBackNavigationName(), implementors));
//
// List inheritedMembers = new ArrayList(getMemberLinks(typeDec.getType().getInheritedMethods()));
// if (!inheritedMembers.isEmpty()) relations.add(new RelationNode(INHERITS_MEMBERS_RELATION, INHERITS_MEMBERS_RELATION.getForwardNavigationName(), inheritedMembers));
// }
return relations;
}
// private List getTypeLinks(Collection types, boolean isInheritance, boolean isInterface) {
// List links = new ArrayList();
// if (types != null) {
// for (Iterator it = types.iterator(); it.hasNext(); ) {
// NameType nameType = (NameType)it.next();
// if (!nameType.getId().equals("Object")) {
// if (isInheritance && ((isInterface && nameType.isInterface()) || (!isInterface && !nameType.isInterface()))
// || !isInheritance && (!isInterface && nameType.isInterface())) {
// Dec dec = nameType.getCorrespondingDec();
// links.add(StructureNodeFactory.makeLink(dec, false));
// }
// }
// }
// }
// return links;
// }
// private List getMemberLinks(Collection members) {
// List links = new ArrayList();
// if (members != null) {
// for (Iterator it = members.iterator(); it.hasNext(); ) {
// Object object = it.next();
// if (object instanceof Method) {
// Method method = (Method)object;
// if (!method.getDeclaringType().getId().equals("Object")) {
// links.add(StructureNodeFactory.makeLink(method.getCorrespondingDec(), false));
// }
// } else if (object instanceof Field) {
// Field field = (Field)object;
// if (!field.getDeclaringType().getId().equals("Object")) {
// links.add(StructureNodeFactory.makeLink(field.getCorrespondingDec(), false));
// }
// }
// }
// }
// return links;
// }
public String getName() {
return NAME;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/IntroductionAssociation.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mik Kersten
*/
public class IntroductionAssociation implements Association {
public static final String NAME = "Introduction";
public static final Relation INTRODUCES_RELATION = new Relation("declares member on", "inter-type declared members", NAME, true, false);
private List relations = new ArrayList();
public IntroductionAssociation() {
relations.add(INTRODUCES_RELATION);
}
public List getRelations() {
return relations;
}
public List getRelationNodes() {
List relations = new ArrayList();
List introduces = new ArrayList();
// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
// if (astObject instanceof IntroducedDec) {
// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// LinkNode link = StructureNodeFactory.makeLink(node, false);
// if (node instanceof TypeDec) {
// introduces.add(link);
// }
// }
// if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getForwardNavigationName(), introduces));
// } else {
// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// if (astObject instanceof TypeDec) {
// if (node instanceof IntroducedDec) {
// introduces.add(StructureNodeFactory.makeLink(node, false));
// }
// }
// }
// if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getBackNavigationName(), introduces));
// }
return relations;
}
public String getName() {
return NAME;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/LinkNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
/**
* @author Mik Kersten
*/
public class LinkNode extends StructureNode {
private ProgramElementNode programElementNode = null;
/**
* Used during de-serialization.
*/
public LinkNode() { }
/**
* @param node can not be null
*/
public LinkNode(ProgramElementNode node) {
super(node.getSignature().toString(), "internal", null);
this.programElementNode = node;
}
public ProgramElementNode getProgramElementNode() {
return programElementNode;
}
public String toString() {
String name = "";
if (programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.ADVICE) ||
programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_FIELD) ||
programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_METHOD) ||
programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR) ||
programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.CODE)) {
name = programElementNode.parent.toString() + ": " + programElementNode.getName();
StructureNode grandparent = programElementNode.parent.parent;
if ( grandparent instanceof ProgramElementNode ) {
ProgramElementNode pe_grandparent = (ProgramElementNode)grandparent;
if ( pe_grandparent.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS) ||
pe_grandparent.getProgramElementKind().equals(ProgramElementNode.Kind.INTERFACE)
) {
name = pe_grandparent.toString() + "." + name;
}
}
} else if (programElementNode.isMemberKind()) {
name = programElementNode.parent.toString() + '.' + programElementNode.getName();
} else {
name = programElementNode.toString();
}
return name;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/ModelWalker.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
/**
* @author Mik Kersten
*/
public class ModelWalker {
private StructureModel model;
public ModelWalker() {
super();
}
public ModelWalker(StructureModel model) {
this.model = model;
}
protected void preProcess(StructureNode node) { }
protected void postProcess(StructureNode node) { }
public StructureNode process(StructureNode node) {
preProcess(node);
node.walk(this);
postProcess(node);
return node;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/ProgramElementNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.*;
import java.io.*;
import org.aspectj.bridge.ISourceLocation;
/**
* @author Mik Kersten
*/
public class ProgramElementNode extends StructureNode {
private List modifiers = new ArrayList();
private List relations = new ArrayList();
private Kind kind;
private Accessibility accessibility;
private String declaringType = "";
private String formalComment = "";
private String packageName = null;
private boolean runnable = false;
private boolean implementor = false;
private boolean overrider = false;
private String bytecodeName;
private String bytecodeSignature;
private String fullSignature;
private String returnType;
/**
* Used during de-externalization.
*/
public ProgramElementNode() { }
/**
* Use to create program element nodes that do not correspond to source locations.
*/
public ProgramElementNode(
String signature,
Kind kind,
List children) {
super(signature, kind.toString(), children);
this.kind = kind;
}
public ProgramElementNode(
String signature,
ProgramElementNode.Kind kind,
ISourceLocation sourceLocation,
int modifiers,
String formalComment,
List children)
{
super(signature, kind.toString(), children);
super.sourceLocation = sourceLocation;
this.kind = kind;
this.formalComment = formalComment;
this.modifiers = genModifiers(modifiers);
this.accessibility = genAccessibility(modifiers);
}
/**
* Use to create program element nodes that correspond to source locations.
*/
public ProgramElementNode(
String signature,
Kind kind,
List modifiers,
Accessibility accessibility,
String declaringType,
String packageName,
String formalComment,
ISourceLocation sourceLocation,
List relations,
List children,
boolean member) {
super(signature, kind.toString(), children);
super.sourceLocation = sourceLocation;
this.kind = kind;
this.modifiers = modifiers;
this.accessibility = accessibility;
this.declaringType = declaringType;
this.packageName = packageName;
this.formalComment = formalComment;
this.relations = relations;
}
public Kind getProgramElementKind() {
return kind;
}
public List getModifiers() {
return modifiers;
}
public Accessibility getAccessibility() {
return accessibility;
}
public String getDeclaringType() {
return declaringType;
}
public String getPackageName() {
if (kind == Kind.PACKAGE) return getSignature();
if (getParent() == null || !(getParent() instanceof ProgramElementNode)) {
return "";
}
return ((ProgramElementNode)getParent()).getPackageName();
}
public String getKind() {
return super.kind;
}
public String getSignature() {
return super.name;
}
public boolean isCode() {
return kind.equals(Kind.CODE);
}
public boolean isMemberKind() {
return kind.isMemberKind();
}
public void setRunnable(boolean value) {
this.runnable = value;
}
public boolean isRunnable() {
return runnable;
}
public boolean isImplementor() {
return implementor;
}
public void setImplementor(boolean value) {
this.implementor = value;
}
public boolean isOverrider() {
return overrider;
}
public void setOverrider(boolean value) {
this.overrider = value;
}
public List getRelations() {
return relations;
}
public void setRelations(List relations) {
if (relations.size() > 0) {
this.relations = relations;
}
}
public String getFormalComment() {
return formalComment;
}
public String toString() {
return super.name;
}
public static List genModifiers(int modifiers) {
List modifiersList = new ArrayList();
if ((modifiers & AccStatic) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccFinal) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccSynchronized) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccVolatile) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccTransient) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccNative) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
if ((modifiers & AccAbstract) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
return modifiersList;
}
public static ProgramElementNode.Accessibility genAccessibility(int modifiers) {
if ((modifiers & AccPublic) != 0) return ProgramElementNode.Accessibility.PUBLIC;
if ((modifiers & AccPrivate) != 0) return ProgramElementNode.Accessibility.PRIVATE;
if ((modifiers & AccProtected) != 0) return ProgramElementNode.Accessibility.PROTECTED;
if ((modifiers & AccPrivileged) != 0) return ProgramElementNode.Accessibility.PRIVILEGED;
else return ProgramElementNode.Accessibility.PACKAGE;
}
/**
* Uses "typesafe enum" pattern.
*/
public static class Modifiers implements Serializable {
public static final Modifiers STATIC = new Modifiers("static");
public static final Modifiers FINAL = new Modifiers("final");
public static final Modifiers ABSTRACT = new Modifiers("abstract");
public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized");
public static final Modifiers VOLATILE = new Modifiers("volatile");
public static final Modifiers STRICTFP = new Modifiers("strictfp");
public static final Modifiers TRANSIENT = new Modifiers("transient");
public static final Modifiers NATIVE = new Modifiers("native");
public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, NATIVE };
private final String name;
private Modifiers(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
/**
* Uses "typesafe enum" pattern.
*/
public static class Accessibility implements Serializable {
public static final Accessibility PUBLIC = new Accessibility("public");
public static final Accessibility PACKAGE = new Accessibility("package");
public static final Accessibility PROTECTED = new Accessibility("protected");
public static final Accessibility PRIVATE = new Accessibility("private");
public static final Accessibility PRIVILEGED = new Accessibility("privileged");
public static final Accessibility[] ALL = { PUBLIC, PACKAGE, PROTECTED, PRIVATE, PRIVILEGED };
private final String name;
private Accessibility(String name) {
this.name = name;
}
public String toString() {
return name;
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
/**
* Uses "typesafe enum" pattern.
*/
public static class Kind implements Serializable {
public static final Kind PROJECT = new Kind("project");
public static final Kind PACKAGE = new Kind("package");
public static final Kind FILE = new Kind("file");
public static final Kind FILE_JAVA = new Kind("java source file");
public static final Kind FILE_ASPECTJ = new Kind("aspect source file");
public static final Kind FILE_LST = new Kind("build configuration file");
public static final Kind CLASS = new Kind("class");
public static final Kind INTERFACE = new Kind("interface");
public static final Kind ASPECT = new Kind("aspect");
public static final Kind INITIALIZER = new Kind("initializer");
public static final Kind INTER_TYPE_FIELD = new Kind("inter-type field");
public static final Kind INTER_TYPE_METHOD = new Kind("inter-type method");
public static final Kind INTER_TYPE_CONSTRUCTOR = new Kind("inter-type constructor");
public static final Kind CONSTRUCTOR = new Kind("constructor");
public static final Kind METHOD = new Kind("method");
public static final Kind FIELD = new Kind("field");
public static final Kind POINTCUT = new Kind("pointcut");
public static final Kind ADVICE = new Kind("advice");
public static final Kind DECLARE_PARENTS = new Kind("declare parents");
public static final Kind DECLARE_WARNING = new Kind("declare warning");
public static final Kind DECLARE_ERROR = new Kind("declare error");
public static final Kind DECLARE_SOFT = new Kind("declare soft");
public static final Kind DECLARE_PRECEDENCE= new Kind("declare precedence");
public static final Kind CODE = new Kind("decBodyElement");
public static final Kind ERROR = new Kind("error");
public static final Kind[] ALL = { PROJECT, PACKAGE, FILE, FILE_JAVA,
FILE_ASPECTJ, FILE_LST, CLASS, INTERFACE, ASPECT,
INITIALIZER, INTER_TYPE_FIELD, INTER_TYPE_METHOD, INTER_TYPE_CONSTRUCTOR,
CONSTRUCTOR, METHOD, FIELD, POINTCUT, ADVICE, DECLARE_PARENTS,
DECLARE_WARNING, DECLARE_ERROR, DECLARE_SOFT, CODE, ERROR };
public static Kind getKindForString(String kindString) {
for (int i = 0; i < ALL.length; i++) {
if (ALL[i].toString().equals(kindString)) return ALL[i];
}
return ERROR;
}
private final String name;
private Kind(String name) {
this.name = name;
}
public String toString() {
return name;
}
public static List getNonAJMemberKinds() {
List list = new ArrayList();
list.add(METHOD);
list.add(FIELD);
list.add(CONSTRUCTOR);
return list;
}
public boolean isMemberKind() {
return this == FIELD
|| this == METHOD
|| this == CONSTRUCTOR
|| this == POINTCUT
|| this == ADVICE;
}
public boolean isTypeKind() {
return this == CLASS
|| this == INTERFACE
|| this == ASPECT;
}
public boolean isSourceFileKind() {
return this == FILE_ASPECTJ
|| this == FILE_JAVA;
}
public boolean isDeclareKind() {
return name.startsWith("declare");
}
// The 4 declarations below are necessary for serialization
private static int nextOrdinal = 0;
private final int ordinal = nextOrdinal++;
private Object readResolve() throws ObjectStreamException {
return ALL[ordinal];
}
}
// XXX these names and values are from org.eclipse.jdt.internal.compiler.env.IConstants
private static int AccPublic = 0x0001;
private static int AccPrivate = 0x0002;
private static int AccProtected = 0x0004;
private static int AccPrivileged = 0x0006; // XXX is this right?
private static int AccStatic = 0x0008;
private static int AccFinal = 0x0010;
private static int AccSynchronized = 0x0020;
private static int AccVolatile = 0x0040;
private static int AccTransient = 0x0080;
private static int AccNative = 0x0100;
private static int AccInterface = 0x0200;
private static int AccAbstract = 0x0400;
private static int AccStrictfp = 0x0800;
public String getBytecodeName() {
return bytecodeName;
}
public String getBytecodeSignature() {
return bytecodeSignature;
}
public void setBytecodeName(String bytecodeName) {
this.bytecodeName = bytecodeName;
}
public void setBytecodeSignature(String bytecodeSignature) {
this.bytecodeSignature = bytecodeSignature;
}
public String getFullSignature() {
return fullSignature;
}
public void setFullSignature(String string) {
fullSignature = string;
}
public void setKind(Kind kind) {
this.kind = kind;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getReturnType() {
return returnType;
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/ReferenceAssociation.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.ArrayList;
import java.util.List;
/**
* @author Mik Kersten
*/
public class ReferenceAssociation implements Association {
public static final String NAME = "Reference";
public static final Relation USES_POINTCUT_RELATION = new Relation("uses pointcut", "pointcut used by", NAME, true, true);
public static final Relation IMPORTS_RELATION = new Relation("imports", NAME, false);
//public static final Relation THROWS_RELATION = new Relation("throws", NAME, false);
//public static final Relation USES_TYPE_RELATION = new Relation("uses type", NAME, false);
private List relations = new ArrayList();
public ReferenceAssociation() {
relations.add(USES_POINTCUT_RELATION);
relations.add(IMPORTS_RELATION);
//relations.add(THROWS_RELATION);
//relations.add(USES_TYPE_RELATION);
}
public List getRelations() {
return relations;
}
public List getRelationNodes() {
List relations = new ArrayList();
List pointcutsUsed = new ArrayList();
List pointcutUsedBy = new ArrayList();
List throwsTypes = new ArrayList();
List imports = new ArrayList();
List usesType = new ArrayList();
// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
//
// if (astObject instanceof AdviceDec) {
// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// if (node instanceof PointcutDec) {
// pointcutsUsed.add(StructureNodeFactory.makeLink(node, false));
// }
// }
// } else if (astObject instanceof PointcutDec) {
// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// if (node instanceof PointcutDec || node instanceof AdviceDec) {
// pointcutUsedBy.add(StructureNodeFactory.makeLink(node, false));
// }
// }
// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
// ASTObject node = (ASTObject)it.next();
// if (node instanceof PointcutDec) {
// pointcutsUsed.add(StructureNodeFactory.makeLink(node, false));
// }
// }
// } else if (astObject instanceof MethodDec) {
// Method method = ((MethodDec)astObject).getMethod();
// TypeDs throwsDs = method.getThrows();
// if (throwsDs != null) {
// for (Iterator it = throwsDs.iterator(); it.hasNext(); ) {
// Object o = it.next();
// if (o instanceof ResolvedTypeD) {
// ResolvedTypeD resolved = (ResolvedTypeD)o;
// if (resolved.getType().getCorrespondingDec() != null) {
// throwsTypes.add(StructureNodeFactory.makeLink(resolved.getType().getCorrespondingDec(), false));
// }
// }
// }
// }
// if (!(method.getReturnType() instanceof PrimitiveType) && method.getReturnType().getCorrespondingDec() != null) {
// usesType.add(StructureNodeFactory.makeLink(method.getReturnType().getCorrespondingDec(), false));
// }
// } else if (astObject instanceof FieldDec) {
// Field field = ((FieldDec)astObject).getField();
// if (!(field.getFieldType() instanceof PrimitiveType) && field.getFieldType().getCorrespondingDec() != null) {
// usesType.add(StructureNodeFactory.makeLink(field.getFieldType().getCorrespondingDec(), false));
// }
// }
// else if (astObject instanceof CompilationUnit) {
// CompilationUnit cu = (CompilationUnit)astObject;
// org.aspectj.compiler.base.ast.Imports cuImports = cu.getImports();
// for (int i = 0; cuImports != null && i < cuImports.getChildCount(); i++) {
// Import imp = cuImports.get(i);
// if (!imp.getStar() && imp != null && imp.getType() != null) {
// Type type = imp.getType();
// Dec dec = type.getCorrespondingDec();
// if (dec != null) imports.add(StructureNodeFactory.makeLink(dec, true));
// }
// }
// }
//
// if (!pointcutsUsed.isEmpty()) relations.add(new RelationNode(USES_POINTCUT_RELATION, USES_POINTCUT_RELATION.getForwardNavigationName(), pointcutsUsed));
// if (!pointcutUsedBy.isEmpty()) relations.add(new RelationNode(USES_POINTCUT_RELATION, USES_POINTCUT_RELATION.getBackNavigationName(), pointcutUsedBy));
// if (!imports.isEmpty()) relations.add(new RelationNode(IMPORTS_RELATION, IMPORTS_RELATION.getForwardNavigationName(), imports));
return relations;
}
public String getName() {
return NAME;
}
}
//public class JavadocSeeAlso {
//
// private static final String DOC =
// "<b>Relates:</b> a declaration to another by the @seeAlso tag<br>" +
// "<b>Symmetric: </b> yes";
//
// public List makeLinks(ASTObject astObject, boolean forwardNavigation) {
// List linkList = new Vector();
// org.aspectj.compiler.base.ast.Comment comment = astObject.getComment();
// try {
// Object[] os = (Object[])comment.getClass().getMethod("seeTags", new Class[]{}).invoke(comment, new Object[]{});
// for (int i = 0; i < os.length; i++) {
// Object o = os[i];
// Dec docDec = null;
// TypeDec typeDec = (TypeDec)o.getClass().getMethod("referencedClass", new Class[]{}).invoke(o, new Object[]{});
// Dec memberDec = (Dec)o.getClass().getMethod("referencedMember", new Class[]{}).invoke(o, new Object[]{});
// if (memberDec != null) {
// docDec = memberDec;
// } else if (typeDec != null) {
// docDec = typeDec;
// }
// if (docDec != null) {
// linkList.add(StructureNodeFactory.makeLink(docDec, false));
//
// }
// }
// } catch (Throwable t) {
// // ingore
// }
// return linkList;
// }
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/Relation.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.io.Serializable;
/**
* @author Mik Kersten
*/
public class Relation implements Serializable {
private String forwardNavigationName;
private String backNavigationName;
private String associationName;
private boolean symmetrical;
private boolean transitive;
public Relation(String forwardNavigationName,
String backNavigationName,
String associationName,
boolean symmetrical,
boolean transitive) {
this.forwardNavigationName = forwardNavigationName;
this.backNavigationName = backNavigationName;
this.associationName = associationName;
this.symmetrical = symmetrical;
this.transitive = transitive;
}
/**
* Constructor for asymetrical relations.
*/
public Relation(String forwardNavigationName,
String associationName,
boolean transitive) {
this(forwardNavigationName, "<no back navigation name>", associationName, false, transitive);
}
public String getForwardNavigationName() {
return forwardNavigationName;
}
public String getBackNavigationName() {
return backNavigationName;
}
public String getAssociationName() {
return associationName;
}
public boolean isSymmetrical() {
return symmetrical;
}
public boolean isTransitive() {
return transitive;
}
public boolean equals(Object o) {
if (!(o instanceof Relation)) return false;
Relation r = (Relation)o;
return forwardNavigationName.equals(r.getForwardNavigationName())
&& backNavigationName.equals(r.getBackNavigationName())
&& associationName.equals(r.getAssociationName())
&& (symmetrical == r.isSymmetrical())
&& (transitive == r.isTransitive());
}
public String toString() {
if (symmetrical) {
return forwardNavigationName + " / " + backNavigationName;
} else {
return forwardNavigationName;
}
}
}
|
41,254
|
Bug 41254 revise asm and create interfaces
| null |
resolved fixed
|
f1deb9c
|
AspectJ
|
https://github.com/eclipse/org.aspectj
|
eclipse/org.aspectj
|
java
| null | null | null | 2003-08-08T11:02:53Z
| 2003-08-07T12:40:00Z
|
asm/src/org/aspectj/asm/RelationNode.java
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.asm;
import java.util.List;
/**
* @author Mik Kersten
*/
public class RelationNode extends StructureNode {
private Relation relation;
/**
* Used during de-externalization.
*/
public RelationNode() { }
public RelationNode(Relation relation, String name, List children) {
super(name, relation.getAssociationName(), children);
this.relation = relation;
}
public Relation getRelation() {
return relation;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.