[jbosstools-commits] JBoss Tools SVN: r43668 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl: definition and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 13 16:21:38 EDT 2012
Author: scabanovich
Date: 2012-09-13 16:21:38 -0400 (Thu, 13 Sep 2012)
New Revision: 43668
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java
Log:
JBIDE-12446
https://issues.jboss.org/browse/JBIDE-12446
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2012-09-13 20:15:14 UTC (rev 43667)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2012-09-13 20:21:38 UTC (rev 43668)
@@ -199,8 +199,7 @@
Collection<IQualifierDeclaration> result = new ArrayList<IQualifierDeclaration>();
Set<IQualifier> qs = new HashSet<IQualifier>();
for(IAnnotationDeclaration a: definition.getAnnotations()) {
- int k = getCDIProject().getNature().getDefinitions().getAnnotationKind(a.getType());
- if(k > 0 && (k & AnnotationDefinition.QUALIFIER) > 0 && a instanceof IQualifierDeclaration) {
+ if(a instanceof IQualifierDeclaration) {
IQualifierDeclaration q = (IQualifierDeclaration)a;
result.add(q);
if(q.getQualifier() != null) qs.add(q.getQualifier());
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2012-09-13 20:15:14 UTC (rev 43667)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2012-09-13 20:21:38 UTC (rev 43668)
@@ -28,6 +28,7 @@
import org.jboss.tools.common.java.ParametedType;
import org.jboss.tools.common.java.ParametedTypeFactory;
import org.jboss.tools.common.java.TypeDeclaration;
+import org.jboss.tools.common.java.TypeDeclaration.Lazy;
/**
*
@@ -54,8 +55,8 @@
return (IJavaElement)getDefinition().getMember();
}
- public static TypeDeclaration getTypeDeclaration(AbstractMemberDefinition definition, ParametedTypeFactory typeFactory) {
- IJavaElement member = (IJavaElement)definition.getMember();
+ public static TypeDeclaration getTypeDeclaration(final AbstractMemberDefinition definition, ParametedTypeFactory typeFactory) {
+ final IJavaElement member = (IJavaElement)definition.getMember();
try {
String returnType = null;
IMember currentMember = null;
@@ -72,36 +73,48 @@
if(returnType != null) {
ParametedType p = typeFactory.getParametedType(currentMember, returnType);
if(p != null) {
-
- int offset = -1;
- int length = 0;
- String content = definition.getTypeDefinition().getContent();
- if(content != null) {
- ISourceRange sr = ((ISourceReference)member).getSourceRange();
- ISourceRange nr = ((ISourceReference)member).getNameRange();
- if(sr != null && nr != null && sr.getOffset() < nr.getOffset() && nr.getOffset() < content.length()) {
- String start = content.substring(sr.getOffset(), nr.getOffset());
- int off = -1;
- int off0 = -1;
- int bc = 0;
- for (int i = start.length() - 1; i >= 0; i--) {
- char ch = start.charAt(i);
- if(ch == '>') bc++; else if(ch == '<') bc--;
- if(Character.isWhitespace(ch)) {
- if(off >= 0 && bc <= 0) break;
- } else if(Character.isJavaIdentifierPart(ch) || ch == '.' || ch == '$' || ch == '<' || ch == '>') {
- off = i;
- if(off0 < 0) off0 = i + 1;
+ Lazy lazy = new Lazy() {
+ @Override
+ public void init(TypeDeclaration d) {
+ int offset = -1;
+ int length = 0;
+ String content = definition.getTypeDefinition().getContent();
+ if(content != null) {
+ ISourceRange sr = null;
+ ISourceRange nr = null;
+ try {
+ sr = ((ISourceReference)member).getSourceRange();
+ nr = ((ISourceReference)member).getNameRange();
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
}
+ if(sr != null && nr != null && sr.getOffset() < nr.getOffset() && nr.getOffset() < content.length()) {
+ String start = content.substring(sr.getOffset(), nr.getOffset());
+ int off = -1;
+ int off0 = -1;
+ int bc = 0;
+ for (int i = start.length() - 1; i >= 0; i--) {
+ char ch = start.charAt(i);
+ if(ch == '>') bc++; else if(ch == '<') bc--;
+ if(Character.isWhitespace(ch)) {
+ if(off >= 0 && bc <= 0) break;
+ } else if(Character.isJavaIdentifierPart(ch) || ch == '.' || ch == '$' || ch == '<' || ch == '>') {
+ off = i;
+ if(off0 < 0) off0 = i + 1;
+ }
+ }
+ if(off >= 0) {
+ offset = sr.getOffset() + off;
+ length = off0 - off;
+ }
+ }
}
- if(off >= 0) {
- offset = sr.getOffset() + off;
- length = off0 - off;
- }
+ d.init(offset, length);
}
- }
+ };
- return new TypeDeclaration(p, member.getResource(), offset, length);
+
+ return new TypeDeclaration(p, member.getResource(), lazy);
}
}
} catch (JavaModelException e) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2012-09-13 20:15:14 UTC (rev 43667)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2012-09-13 20:21:38 UTC (rev 43668)
@@ -41,7 +41,10 @@
public Collection<ITypeDeclaration> getAllTypeDeclarations() {
Collection<ITypeDeclaration> result = new ArrayList<ITypeDeclaration>(1);
- if(typeDeclaration != null && typeDeclaration.getStartPosition() > 0) {
+ if(typeDeclaration != null/* && typeDeclaration.getStartPosition() > 0*/) {
+ //Request for start position invokes initialization,
+ //if this check removal causes issues, they should be solved
+ //in another way than checking position validness at this moment.
result.add(typeDeclaration);
}
return result;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2012-09-13 20:15:14 UTC (rev 43667)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2012-09-13 20:21:38 UTC (rev 43668)
@@ -61,7 +61,10 @@
public Collection<ITypeDeclaration> getAllTypeDeclarations() {
Collection<ITypeDeclaration> result = new ArrayList<ITypeDeclaration>(1);
- if(typeDeclaration != null && typeDeclaration.getStartPosition() > 0) {
+ if(typeDeclaration != null/* && typeDeclaration.getStartPosition() > 0*/) {
+ //Request for start position invokes initialization,
+ //if this check removal causes issues, they should be solved
+ //in another way than checking position validness at this moment.
result.add(typeDeclaration);
}
return result;
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2012-09-13 20:15:14 UTC (rev 43667)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2012-09-13 20:21:38 UTC (rev 43668)
@@ -36,9 +36,6 @@
protected String qualifiedName;
protected IType type;
protected ParametedType parametedType = null;
-
- protected String content = null;
-
protected boolean isVetoed = false;
public AbstractTypeDefinition() {}
@@ -124,10 +121,10 @@
public String getContent() {
if(type == null || type.isBinary()) return null;
- if(content == null && resource instanceof IFile && resource.getName().endsWith(".java")) {
- content = FileUtil.getContentFromEditorOrFile((IFile)resource);
+ if(resource instanceof IFile && resource.getName().endsWith(".java")) {
+ return FileUtil.getContentFromEditorOrFile((IFile)resource);
}
- return content;
+ return null;
}
class PositionProviderImpl implements ParametedType.PositionProvider {
@@ -135,7 +132,7 @@
void init() throws CoreException {
map = new HashMap<String, ISourceRange>();
- getContent();
+ String content = getContent();
if(content == null) return;
//Any disagreement between content and range means that content is obsolete
@@ -163,6 +160,10 @@
}
}
+ public boolean isLoaded() {
+ return map != null;
+ }
+
public ISourceRange getRange(String superTypeName) {
if(map == null) {
try {
More information about the jbosstools-commits
mailing list