40943: Binary weaving should copy non-Java resources from "-inja... 36071: 1.1 rc1 should copy resources similar to java compiler 40826: ajbrowser does not report errors properly 40774: task list icons don't show in ajbrowsertags/V1_1_1
@@ -161,4 +161,9 @@ public class BrowserProperties implements ProjectPropertiesAdapter { | |||
public Set getAspectPath( ) { // XXX unimplemented | |||
return null; | |||
} | |||
public Map getSourcePathResources() { | |||
return null; | |||
} | |||
} |
@@ -15,22 +15,13 @@ | |||
package org.aspectj.tools.ajbrowser; | |||
import java.awt.BorderLayout; | |||
import java.awt.event.MouseAdapter; | |||
import java.awt.event.MouseEvent; | |||
import java.awt.event.MouseListener; | |||
import javax.swing.DefaultListModel; | |||
import javax.swing.JList; | |||
import javax.swing.JPanel; | |||
import javax.swing.JScrollPane; | |||
import org.aspectj.ajde.Ajde; | |||
import org.aspectj.ajde.TaskListManager; | |||
import org.aspectj.ajde.ui.swing.CompilerMessage; | |||
import org.aspectj.ajde.ui.swing.CompilerMessagesCellRenderer; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.ISourceLocation; | |||
import org.aspectj.bridge.Message; | |||
import java.awt.event.*; | |||
import javax.swing.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajde.ui.swing.*; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.bridge.IMessage.Kind; | |||
/** | |||
@@ -45,11 +36,11 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { | |||
private JList list = new JList(); | |||
private DefaultListModel listModel = new DefaultListModel(); | |||
private BorderLayout borderLayout1 = new BorderLayout(); | |||
private boolean hasWarning = false; | |||
private boolean hasWarning = false; | |||
public CompilerMessagesPanel() { | |||
try { | |||
jbInit(); | |||
jbInit(); | |||
} | |||
catch(Exception e) { | |||
e.printStackTrace(); | |||
@@ -61,10 +52,8 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { | |||
if (e.getClickCount() >= 1) { | |||
int index = list.locationToIndex(e.getPoint()); | |||
if (listModel.getSize() >= index && index != -1) { | |||
CompilerMessage cm = (CompilerMessage)listModel.getElementAt(index); | |||
if ((null != cm) && (null != cm.message)) { | |||
displayMessage(cm.message); | |||
} | |||
IMessage message = (IMessage)listModel.getElementAt(index); | |||
Ajde.getDefault().getEditorAdapter().showSourceLine(message.getISourceLocation(), true); | |||
} | |||
} | |||
} | |||
@@ -72,50 +61,29 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { | |||
list.addMouseListener(mouseListener); | |||
list.setCellRenderer(new CompilerMessagesCellRenderer()); | |||
} | |||
public void addSourcelineTask( | |||
String message, | |||
ISourceLocation sourceLocation, | |||
Kind kind) { | |||
addSourcelineTask(new Message(message, kind, null, sourceLocation)); | |||
} | |||
/** | |||
* called when user double-clicks on a message. | |||
*/ | |||
protected void displayMessage(IMessage message) { | |||
ISourceLocation loc = message.getISourceLocation(); | |||
BrowserManager.getDefault().getEditorManager().showSourceLine(loc, true); | |||
// show dialog with stack trace if thrown | |||
Throwable thrown = message.getThrown(); | |||
if (null != thrown) { | |||
Ajde.getDefault().getErrorHandler().handleError(message.getMessage(), thrown); | |||
} | |||
} | |||
public void addSourcelineTask(IMessage message) { | |||
listModel.addElement(new CompilerMessage(message)); | |||
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) { | |||
hasWarning = true; | |||
} | |||
BrowserManager.getDefault().showMessages(); | |||
public void addSourcelineTask(IMessage message) { | |||
listModel.addElement(message); | |||
checkIfWarning(message.getKind()); | |||
} | |||
public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) { | |||
listModel.addElement(new Message(message, kind, null, sourceLocation)); | |||
checkIfWarning(kind); | |||
} | |||
public void addProjectTask(String message, IMessage.Kind kind) { | |||
IMessage m = new Message(message, kind, null, null); | |||
listModel.addElement(new CompilerMessage(m)); | |||
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) { | |||
hasWarning = true; | |||
} | |||
BrowserManager.getDefault().showMessages(); | |||
listModel.addElement(new Message(message, kind, null, null)); | |||
checkIfWarning(kind); | |||
} | |||
public boolean hasWarning() { | |||
return hasWarning; | |||
} | |||
private void checkIfWarning(Kind kind) { | |||
if (kind.equals(IMessage.WARNING)) hasWarning = true; | |||
} | |||
public void clearTasks() { | |||
listModel.clear(); | |||
hasWarning = false; | |||
} | |||
private void jbInit() throws Exception { | |||
@@ -123,6 +91,11 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager { | |||
this.add(jScrollPane1, BorderLayout.CENTER); | |||
jScrollPane1.getViewport().add(list, null); | |||
} | |||
public boolean hasWarning() { | |||
return hasWarning; | |||
} | |||
} | |||
@@ -16,8 +16,7 @@ | |||
package org.aspectj.ajde; | |||
import java.util.List; | |||
import java.util.Set; | |||
import java.util.*; | |||
/** | |||
* @author Mik Kersten | |||
@@ -69,6 +68,16 @@ public interface ProjectPropertiesAdapter { | |||
*/ | |||
public Set getInJars(); | |||
/** | |||
* Get the set of non-Java resources for this compilation. | |||
* Set members should be of type java.io.File. | |||
* An empty set or null is acceptable for this option. | |||
* From -injars. | |||
* | |||
* @return map from unique resource name to absolute path to source resource (String to File) | |||
*/ | |||
public Map getSourcePathResources(); | |||
/** | |||
* Get the output jar file for the compilation results. | |||
* Return null to leave classfiles unjar'd in output directory |
@@ -488,6 +488,7 @@ public class CompilerAdapter { | |||
join(config.getSourceRoots(), properties.getSourceRoots()); | |||
join(config.getInJars(), properties.getInJars()); | |||
config.setSourcePathResources(properties.getSourcePathResources()); | |||
join(config.getAspectpath(), properties.getAspectPath()); | |||
} | |||
@@ -1,34 +0,0 @@ | |||
/* ******************************************************************* | |||
* 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 org.aspectj.bridge.IMessage; | |||
import org.aspectj.util.LangUtil; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
public class CompilerMessage { | |||
public final IMessage message; | |||
public CompilerMessage(IMessage message) { | |||
LangUtil.throwIaxIfNull(message, "message"); | |||
this.message = message; | |||
} | |||
public String toString() { | |||
return message.toString(); | |||
} | |||
} |
@@ -36,7 +36,7 @@ public class CompilerMessagesCellRenderer extends JLabel implements ListCellRend | |||
boolean cellHasFocus) { | |||
String label = "<no message>"; | |||
String detail = null; | |||
IMessage.Kind kind = IMessage.INFO; | |||
IMessage.Kind kind = IMessage.ERROR; | |||
if (value instanceof IMessage) { | |||
IMessage cm = (IMessage) value; | |||
label = cm.getMessage(); |
@@ -0,0 +1 @@ | |||
test=test |
@@ -0,0 +1,2 @@ | |||
Main.java | |||
test/TestProperties.java |
@@ -0,0 +1,22 @@ | |||
import java.io.IOException; | |||
/* | |||
* Created on 30-Jul-03 | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
/** | |||
* @author websterm | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
public class Main { | |||
public static void main(String[] args) throws IOException { | |||
String propsName = (args.length > 0)? args[0] : "test.props"; | |||
new test.TestProperties().load(propsName); | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
/* | |||
* Created on 30-Jul-03 | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
package aspects; | |||
/** | |||
* @author websterm | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
public aspect Logging { | |||
pointcut methods () : | |||
execution(* *..*(..)) && !within(Logging); | |||
before () : methods () { | |||
System.err.println("> " + thisJoinPoint.getSignature().toLongString()); | |||
} | |||
after () : methods () { | |||
System.err.println("< " + thisJoinPoint.getSignature().toLongString()); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* Created on 30-Jul-03 | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
package test; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.Properties; | |||
/** | |||
* @author websterm | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
public class TestProperties { | |||
public void load (String name) throws IOException { | |||
InputStream in = getClass().getResourceAsStream(name); | |||
// System.out.println("? load() in=" + in); | |||
Properties props = new Properties(); | |||
props.load(in); | |||
in.close(); | |||
props.list(System.out); | |||
} | |||
} |
@@ -0,0 +1 @@ | |||
test=test |
@@ -0,0 +1,27 @@ | |||
/* | |||
* Created on 30-Jul-03 | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
package aspects; | |||
/** | |||
* @author websterm | |||
* | |||
* To change this generated comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
public aspect Logging { | |||
pointcut methods () : | |||
execution(* *..*(..)) && !within(Logging); | |||
before () : methods () { | |||
System.err.println("> " + thisJoinPoint.getSignature().toLongString()); | |||
} | |||
after () : methods () { | |||
System.err.println("< " + thisJoinPoint.getSignature().toLongString()); | |||
} | |||
} |
@@ -57,7 +57,7 @@ aspect AdviceNamingCoverage { | |||
after(): named() { } | |||
after(int i, int j) returning: namedWithArgs(i, j) { } | |||
after() throwing: named() { } | |||
after(): named() { } | |||
after(): named() { } | |||
before(): named() { } | |||
@@ -65,7 +65,7 @@ aspect AdviceNamingCoverage { | |||
int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); } | |||
before(): named() { } | |||
before(int i): call(* *.mumble()) && named() && namedWithOneArg(i) { } | |||
before(int i): call(* XXX.mumble()) && named() && namedWithOneArg(i) { } | |||
before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { } | |||
before(): call(* *.mumble()) { } |
@@ -28,6 +28,7 @@ public class AjdeTests extends TestCase { | |||
suite.addTestSuite(VersionTest.class); | |||
suite.addTestSuite(CompilerMessagesTest.class); | |||
suite.addTestSuite(AsmDeclarationsTest.class); | |||
suite.addTestSuite(ResourceCopyTestCase.class); | |||
//$JUnit-END$ | |||
return suite; |
@@ -32,6 +32,7 @@ public class NullIdeManager { | |||
private static NullIdeManager ideManager = null; | |||
private NullIdeTaskListManager taskListManager = null; | |||
private NullIdeProperties projectProperties = null; | |||
public static NullIdeManager getIdeManager() { | |||
if ( null == ideManager ) { | |||
@@ -43,7 +44,7 @@ public class NullIdeManager { | |||
public void init(String testProjectPath) { | |||
try { | |||
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false); | |||
ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath); | |||
projectProperties = new NullIdeProperties(testProjectPath); | |||
taskListManager = new NullIdeTaskListManager(); | |||
EditorAdapter ajdeEditor = new NullIdeEditorAdapter(); | |||
IdeUIAdapter uiAdapter = new NullIdeUIAdapter(); | |||
@@ -53,7 +54,7 @@ public class NullIdeManager { | |||
AjdeUIManager.getDefault().init( | |||
ajdeEditor, | |||
taskListManager, | |||
browserProjectProperties, | |||
projectProperties, | |||
preferencesAdapter, | |||
uiAdapter, | |||
new IconRegistry(), |
@@ -14,9 +14,11 @@ | |||
package org.aspectj.ajde; | |||
import java.io.File; | |||
import java.io.*; | |||
import java.util.*; | |||
import org.aspectj.util.FileUtil; | |||
/** | |||
* @author Mik Kersten | |||
*/ | |||
@@ -102,6 +104,23 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { | |||
public Set getInJars( ) { | |||
return inJars; | |||
} | |||
public Map getSourcePathResources() { | |||
File srcBase = new File(getProjectSourcePath()); | |||
File[] fromResources = FileUtil.listFiles(srcBase, new FileFilter() { | |||
public boolean accept(File pathname) { | |||
String name = pathname.getName().toLowerCase(); | |||
return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"); | |||
} | |||
}); | |||
Map map = new HashMap(); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase); | |||
map.put(normPath, fromResources[i]); | |||
} | |||
return map; | |||
} | |||
public void setOutJar( String jar ){ this.outJar = jar; } | |||
@@ -0,0 +1,196 @@ | |||
/* | |||
* Created on 31-Jul-2003 | |||
* | |||
* To change the template for this generated file go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
package org.aspectj.ajde; | |||
import java.io.*; | |||
import java.util.*; | |||
import java.util.zip.*; | |||
import org.aspectj.util.FileUtil; | |||
/** | |||
* @author websterm | |||
* | |||
* To change the template for this generated type comment go to | |||
* Window>Preferences>Java>Code Generation>Code and Comments | |||
*/ | |||
public class ResourceCopyTestCase extends AjdeTestCase { | |||
public static final String PROJECT_DIR = "bug-36071"; | |||
public static final String srcDir = PROJECT_DIR + "/src"; | |||
public static final String binDir = PROJECT_DIR + "/bin"; | |||
public static final String injar1 = "testdata/bug-40943/input1.jar"; | |||
public static final String injar2 = "testdata/bug-40943/input2.jar"; | |||
public static final String outjar = "testdata/bug-40943/output.jar"; | |||
/** | |||
* Constructor for JarResourceCopyTestCase. | |||
* @param arg0 | |||
*/ | |||
public ResourceCopyTestCase(String arg0) { | |||
super(arg0); | |||
} | |||
/* | |||
* Ensure the output directpry in clean | |||
*/ | |||
protected void setUp() throws Exception { | |||
super.setUp(PROJECT_DIR); | |||
FileUtil.deleteContents(new File(binDir)); | |||
} | |||
public void testSrcToBin () { | |||
doSynchronousBuild("config.lst"); | |||
assertTrue(new java.io.File("testdata/bug-36071").getAbsolutePath(), compareDirs("src", "bin")); | |||
} | |||
// public void testInjarsToBin () { | |||
// List args = new ArrayList(); | |||
// args.add("-injars"); | |||
// args.add(injar1); | |||
// | |||
// args.add("-d"); | |||
// args.add(binDir); | |||
// | |||
// args.add("-classpath"); | |||
// args.add("../runtime/bin"); | |||
// | |||
// args.add("testdata/bug-40943/aspects/Logging.java"); | |||
// | |||
// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); | |||
// | |||
// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJarToDirs(injar1,binDir)); | |||
// } | |||
// | |||
// public void testInjarsToOutjar () { | |||
// List args = new ArrayList(); | |||
// args.add("-injars"); | |||
// args.add(injar1); | |||
// | |||
// args.add("-outjar"); | |||
// args.add(outjar); | |||
// | |||
// args.add("-classpath"); | |||
// args.add("../runtime/bin"); | |||
// | |||
// args.add("testdata/bug-40943/aspects/Logging.java"); | |||
// | |||
// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); | |||
// | |||
// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar)); | |||
// } | |||
// | |||
// | |||
// public void test2InjarsToOutjar () { | |||
// System.err.println("? test2InjarsToOutjar()"); | |||
// List args = new ArrayList(); | |||
// args.add("-injars"); | |||
// args.add(injar1 + ";" + injar2); | |||
// | |||
// args.add("-outjar"); | |||
// args.add(outjar); | |||
// | |||
// args.add("-classpath"); | |||
// args.add("../runtime/bin"); | |||
// | |||
// args.add("testdata/bug-40943/aspects/Logging.java"); | |||
// | |||
// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS); | |||
// | |||
// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar)); | |||
// } | |||
/* | |||
* Ensure -outjar conatins all non-Java resouces from injars | |||
*/ | |||
public boolean compareDirs (String indirName, String outdirName) { | |||
File srcBase = openFile(indirName); | |||
File binBase = openFile(outdirName); | |||
File[] fromResources = FileUtil.listFiles(srcBase,aspectjResourceFileFilter); | |||
File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter); | |||
HashSet resources = new HashSet(); | |||
for (int i = 0; i < fromResources.length; i++) { | |||
resources.add(FileUtil.normalizedPath(fromResources[i],srcBase)); | |||
} | |||
for (int i = 0; i < toResources.length; i++) { | |||
String fileName = FileUtil.normalizedPath(toResources[i],binBase); | |||
boolean b = resources.remove(fileName); | |||
assertTrue(fileName,b); | |||
} | |||
assertTrue(resources.toString(), resources.isEmpty()); | |||
return true; | |||
} | |||
/* | |||
* Ensure -outjar conatins all non-Java resouces from injars | |||
*/ | |||
public boolean compareJarToDirs (String injarName , String outdirName) { | |||
File baseDir = new File(binDir); | |||
System.err.println("? compareJarToDirs() baseDir='" + baseDir + "'"); | |||
File[] files = FileUtil.listFiles(baseDir,aspectjResourceFileFilter); | |||
for (int i = 0; i < files.length; i++) { | |||
System.err.println("? compareJarToDirs() name='" + files[i] + "'"); | |||
} | |||
return false; | |||
} | |||
/* | |||
* Ensure -outjar conatins all non-Java resouces from injars | |||
*/ | |||
public boolean compareJars (String injarName , String outjarName) { | |||
HashSet resources = new HashSet(); | |||
try { | |||
File injarFile = new File(injarName); | |||
File outjarFile = new File(outjarName); | |||
assertTrue("outjar older than injar",(outjarFile.lastModified() > injarFile.lastModified())); | |||
ZipInputStream injar = new ZipInputStream(new java.io.FileInputStream(injarFile)); | |||
ZipEntry entry; | |||
while (null != (entry = injar.getNextEntry())) { | |||
String fileName = entry.getName(); | |||
if (!fileName.endsWith(".class")) { | |||
resources.add(fileName); | |||
} | |||
injar.closeEntry(); | |||
} | |||
injar.close(); | |||
ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile)); | |||
while (null != (entry = outjar.getNextEntry())) { | |||
String fileName = entry.getName(); | |||
if (!fileName.endsWith(".class")) { | |||
boolean b = resources.remove(fileName); | |||
assertTrue(fileName,b); | |||
} | |||
outjar.closeEntry(); | |||
} | |||
outjar.close(); | |||
assertTrue(resources.toString(),resources.isEmpty()); | |||
} | |||
catch (IOException ex) { | |||
fail(ex.toString()); | |||
} | |||
return true; | |||
} | |||
public static final FileFilter aspectjResourceFileFilter = new FileFilter() { | |||
public boolean accept(File pathname) { | |||
String name = pathname.getName().toLowerCase(); | |||
return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"); | |||
} | |||
}; | |||
} |