Author: scabanovich
Date: 2009-12-03 12:35:51 -0500 (Thu, 03 Dec 2009)
New Revision: 19032
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-03
17:29:43 UTC (rev 19031)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -32,7 +32,9 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.internal.core.scanner.CDIBuilderDelegate;
+import org.jboss.tools.cdi.internal.core.scanner.FileSet;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.ProjectHome;
@@ -161,7 +163,10 @@
protected void fullBuild(final IProgressMonitor monitor)
throws CoreException {
try {
- getProject().accept(getResourceVisitor());
+ CDIResourceVisitor rv = getResourceVisitor();
+ getProject().accept(rv);
+ FileSet fs = rv.fileSet;
+
} catch (CoreException e) {
CDICorePlugin.getDefault().logError(e);
}
@@ -169,7 +174,10 @@
protected void incrementalBuild(IResourceDelta delta,
IProgressMonitor monitor) throws CoreException {
+ CDIResourceVisitor rv = getResourceVisitor();
delta.accept(new SampleDeltaVisitor());
+ FileSet fs = rv.fileSet;
+ builderDelegate.build(fs, getCDICoreNature());
}
protected void clean(IProgressMonitor monitor) throws CoreException {
@@ -199,6 +207,7 @@
}
class CDIResourceVisitor implements IResourceVisitor {
+ FileSet fileSet = new FileSet();
IPath[] outs = new IPath[0];
IPath[] srcs = new IPath[0];
IPath webinf = null;
@@ -249,14 +258,21 @@
if(srcs[i].isPrefixOf(path)) {
if(f.getName().endsWith(".java")) {
ICompilationUnit unit = EclipseUtil.getCompilationUnit(f);
- builderDelegate.build(f, unit, getCDICoreNature());
+ IType[] ts = unit.getTypes();
+ if(ts == null || ts.length == 0) {
+ fileSet.getNonModelFiles().add(f);
+ } else if(findPublicAnnotation(ts) != null) {
+ fileSet.getAnnotations().put(f, unit);
+ } else if(findPublicInterface(ts) != null) {
+ fileSet.getInterfaces().put(f, unit);
+ }
}
return false;
}
}
if(webinf != null && webinf.isPrefixOf(path)) {
if(f.getName().equals("beans.xml")) {
- //TODO
+ fileSet.setBeanXML(f);
}
}
}
@@ -288,5 +304,21 @@
}
+ static IType findPublicAnnotation(IType[] ts) throws JavaModelException {
+ for (IType t: ts) {
+ if(t.isAnnotation()) {
+ return t;
+ }
+ }
+ return null;
+ }
+ static IType findPublicInterface(IType[] ts) throws JavaModelException {
+ for (IType t: ts) {
+ if(t.isInterface()) {
+ return t;
+ }
+ }
+ return null;
+ }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java 2009-12-03
17:29:43 UTC (rev 19031)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -10,9 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.core;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.ICompilationUnit;
+import org.jboss.tools.cdi.internal.core.scanner.FileSet;
/**
* Builder delegate performs build for specific kind of cdi project.
@@ -30,7 +29,6 @@
public Class<? extends ICDIProject> getProjectImplementationClass();
- public void build(IFile file, ICompilationUnit unit, CDICoreNature projectNature);
- public void build(IFile file, CDICoreNature projectNature);
-
+ public void build(FileSet fileSet, CDICoreNature projectNature);
+
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -0,0 +1,37 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+
+public class AnnotatedTypeDeclaration {
+ List<AnnotationDeclaration> annotations = new
ArrayList<AnnotationDeclaration>();
+ String qualifiedName;
+ IType type;
+
+ public AnnotatedTypeDeclaration() {
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ try {
+ init();
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+
+ void init() throws CoreException {
+ qualifiedName = type.getFullyQualifiedName();
+ IAnnotation[] ts = type.getAnnotations();
+ for (int i = 0; i < annotations.size(); i++) {
+ AnnotationDeclaration a = new AnnotationDeclaration();
+ a.setDeclaration(ts[i], type);
+ annotations.add(a);
+ }
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -0,0 +1,56 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+
+public class AnnotationDeclaration implements IAnnotationDeclaration {
+ IAnnotation annotation;
+ int startPosition = -1;
+ int length = 0;
+ String annotationTypeName = null;
+
+ public AnnotationDeclaration() {}
+
+ public void setDeclaration(IAnnotation annotation, IType declaringType) {
+ this.annotation = annotation;
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ startPosition = range.getOffset();
+ length = range.getLength();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ String name = annotation.getElementName();
+ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
+ }
+
+ public IAnnotation getDeclaration() {
+ return annotation;
+ }
+
+ public IMember getParentMember() {
+ return (IMember)annotation.getParent();
+ }
+
+ public IType getType() {
+ return getParentMember().getDeclaringType();
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public int getStartPosition() {
+ return startPosition;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2009-12-03
17:29:43 UTC (rev 19031)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -1,5 +1,7 @@
package org.jboss.tools.cdi.internal.core.scanner;
+import java.util.Map;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IAnnotation;
@@ -10,7 +12,6 @@
import org.jboss.tools.cdi.core.ICDIBuilderDelegate;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
public class CDIBuilderDelegate implements ICDIBuilderDelegate {
@@ -27,33 +28,21 @@
return CDIProject.class;
}
- public void build(IFile file, CDICoreNature projectNature) {
- IProject project = projectNature.getProject();
+ public void build(FileSet fileSet, CDICoreNature projectNature) {
+ Map<IFile, ICompilationUnit> as = fileSet.getAnnotations();
+ for (IFile f: as.keySet()) {
+
+ }
-
- }
-
- public void build(IFile file, ICompilationUnit unit, CDICoreNature projectNature) {
- if(unit != null) {
- try {
- IType[] types = unit.getTypes();
- if(types != null) {
- for (IType type: types) {
- if(type.isAnnotation()) {
- IAnnotation[] as = type.getAnnotations();
- for (IAnnotation a: as) {
- String name = a.getElementName();
- String qName = EclipseJavaUtil.resolveType(type, name);
- System.out.println(qName);
- }
- }
- }
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- } else {
+ Map<IFile, ICompilationUnit> is = fileSet.getInterfaces();
+ for (IFile f: is.keySet()) {
}
+
+ Map<IFile, ICompilationUnit> cs = fileSet.getClasses();
+ for (IFile f: cs.keySet()) {
+
+ }
+
}
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java 2009-12-03
17:35:51 UTC (rev 19032)
@@ -0,0 +1,41 @@
+package org.jboss.tools.cdi.internal.core.scanner;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+
+public class FileSet {
+ Set<IFile> nonmodel = new HashSet<IFile>();
+ Map<IFile, ICompilationUnit> annotations = new HashMap<IFile,
ICompilationUnit>();
+ Map<IFile, ICompilationUnit> interfaces = new HashMap<IFile,
ICompilationUnit>();
+ Map<IFile, ICompilationUnit> classes = new HashMap<IFile,
ICompilationUnit>();
+ IFile beansXML = null;
+
+ public Set<IFile> getNonModelFiles() {
+ return nonmodel;
+ }
+
+ public Map<IFile, ICompilationUnit> getAnnotations() {
+ return annotations;
+ }
+
+ public Map<IFile, ICompilationUnit> getInterfaces() {
+ return interfaces;
+ }
+
+ public Map<IFile, ICompilationUnit> getClasses() {
+ return classes;
+ }
+
+ public IFile getBeanXML() {
+ return beansXML;
+ }
+
+ public void setBeanXML(IFile f) {
+ beansXML = f;
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain