[jbosstools-commits] JBoss Tools SVN: r43667 - trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Sep 13 16:15:14 EDT 2012


Author: scabanovich
Date: 2012-09-13 16:15:14 -0400 (Thu, 13 Sep 2012)
New Revision: 43667

Modified:
   trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java
   trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/TypeDeclaration.java
Log:
JBIDE-12446
https://issues.jboss.org/browse/JBIDE-12446


Modified: trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java	2012-09-13 19:46:59 UTC (rev 43666)
+++ trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java	2012-09-13 20:15:14 UTC (rev 43667)
@@ -24,6 +24,7 @@
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jdt.core.Signature;
 import org.jboss.tools.common.core.CommonCorePlugin;
+import org.jboss.tools.common.java.TypeDeclaration.Lazy;
 
 /**
  * 
@@ -50,6 +51,7 @@
 
 	public static interface PositionProvider {
 		ISourceRange getRange(String superTypeName);
+		boolean isLoaded();
 	}
 
 	PositionProvider provider = null;
@@ -196,12 +198,25 @@
 				superType = getFactory().getParametedType(type, this, sc);
 				if(superType != null) {
 					if(provider != null) {
-						String scn = type.getSuperclassName();
-						if(scn != null && provider.getRange(scn) != null) {
-							ISourceRange r = provider.getRange(scn);
-							superType = new TypeDeclaration(superType, type.getResource(), r.getOffset(), r.getLength());
-						}
-						
+						final String scn = type.getSuperclassName();
+						if(scn != null) {
+							if(provider.isLoaded() && provider.getRange(scn) != null) {
+								ISourceRange r = provider.getRange(scn);
+								superType = new TypeDeclaration(superType, type.getResource(), r.getOffset(), r.getLength());
+							} else if(!provider.isLoaded()) {
+								Lazy lazy = new Lazy() {
+									@Override
+									public void init(TypeDeclaration d) {
+										ISourceRange r = provider.getRange(scn);
+										if(r != null) {
+											d.init(r.getOffset(), r.getLength());
+										}
+									}
+								};
+								superType = new TypeDeclaration(superType, type.getResource(), lazy);
+							}
+
+						}						
 					}
 					inheritedTypes.add(superType);
 				}
@@ -213,10 +228,23 @@
 				ParametedType t = getFactory().getParametedType(type, this, p);
 				if(t != null) {
 					if(provider != null) {
-						String scn = type.getSuperInterfaceNames()[i];
-						if(scn != null && provider.getRange(scn) != null) {
-							ISourceRange r = provider.getRange(scn);
-							t = new TypeDeclaration(t, type.getResource(), r.getOffset(), r.getLength());
+						final String scn = type.getSuperInterfaceNames()[i];
+						if(scn != null) {
+							if(provider.isLoaded() && provider.getRange(scn) != null) {
+								ISourceRange r = provider.getRange(scn);
+								t = new TypeDeclaration(t, type.getResource(), r.getOffset(), r.getLength());
+							} else if(!provider.isLoaded()) {
+								Lazy lazy = new Lazy() {
+									@Override
+									public void init(TypeDeclaration d) {
+										ISourceRange r = provider.getRange(scn);
+										if(r != null) {
+											d.init(r.getOffset(), r.getLength());
+										}
+									}
+								};
+								t = new TypeDeclaration(t, type.getResource(), lazy);
+							}
 						}
 						
 					}

Modified: trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/TypeDeclaration.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/TypeDeclaration.java	2012-09-13 19:46:59 UTC (rev 43666)
+++ trunk/common/plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/TypeDeclaration.java	2012-09-13 20:15:14 UTC (rev 43667)
@@ -21,7 +21,17 @@
 	IResource resource;
 	int length;
 	int startPosition;
+	Lazy lazy = null;
+	
+	public static interface Lazy {
+		void init(TypeDeclaration d);
+	}
 
+	public TypeDeclaration(ParametedType type, IResource resource, Lazy lazy) {
+		this(type, resource, 0, 0);
+		this.lazy = lazy;
+	}
+
 	public TypeDeclaration(ParametedType type, IResource resource, int startPosition, int length) {
 		this.setFactory(type.getFactory());
 		this.type = type.getType();
@@ -42,13 +52,32 @@
 		isLower = type.isLower;
 		isUpper = type.isUpper;
 		isVariable = type.isVariable;
+		if(type instanceof TypeDeclaration) {
+			this.lazy = ((TypeDeclaration)type).lazy;
+		}
 	}
 
+	public void init(int startPosition, int length) {
+		this.startPosition = startPosition;
+		this.length = length;
+	}
+
+	private void init() {
+		if(lazy != null) {
+			synchronized (this) {
+				lazy.init(this);
+				lazy = null;
+			}
+		}
+	}
+
 	public int getLength() {
+		init();
 		return length;
 	}
 
 	public int getStartPosition() {
+		init();
 		return startPosition;
 	}
 



More information about the jbosstools-commits mailing list