Permalink
Browse files

Fix testcases for proxy of external modules

  • Loading branch information...
jakobc committed Mar 27, 2013
1 parent f99a2e3 commit 797fd888a06670ce0aac10001ec63abc8d242041
@@ -0,0 +1 @@
+/ebin
@@ -0,0 +1 @@
+/ebin
@@ -0,0 +1 @@
+/ebin
@@ -0,0 +1 @@
+/ebin
@@ -13,8 +13,10 @@
*
*/
public interface IErlExternalRoot extends IErlExternal, IErlElement, IParent,
- IOpenable {
+ IOpenable {
- List<IErlElement> internalGetChildren();
+ List<IErlElement> internalGetChildren();
+
+ void removeExternal();
}
@@ -215,7 +215,8 @@ public void close() throws ErlModelException {
super.close();
}
- protected void removeExternal() {
+ @Override
+ public void removeExternal() {
ErlModelManager.getErlangModel().removeExternal(
externalIncludes + "|" + externalModules + "|"
+ projectIncludes);
@@ -50,4 +50,9 @@ public boolean buildStructure(final IProgressMonitor pm)
throws ErlModelException {
return ((Openable) original).buildStructure(pm);
}
+
+ @Override
+ public void removeExternal() {
+ original.removeExternal();
+ }
}
@@ -129,4 +129,7 @@ public boolean hasIncludes() {
public List<IErlElement> internalGetChildren() {
return super.internalGetChildren();
}
+
+ public void removeExternal() {
+ }
}
@@ -130,8 +130,14 @@ public boolean parse(final IErlModule module, final String scannerName,
module.setComments(moduleComments);
}
fixFunctionComments(module);
- final String cached = res.arity() > 2 ? ((OtpErlangAtom) res
- .elementAt(2)).atomValue() : "reparsed";
+ String cached = "reparsed";
+ if (res.arity() > 2) {
+ final OtpErlangObject res2 = res.elementAt(2);
+ if (res2 instanceof OtpErlangAtom) {
+ final OtpErlangAtom atom = (OtpErlangAtom) res2;
+ cached = atom.atomValue();
+ }
+ }
ErlLogger.debug("Parsed %d forms and %d comments (%s)",
forms != null ? forms.arity() : 0,
comments != null ? comments.arity() : 0, cached);
@@ -1178,8 +1178,13 @@ public IErlExternalRoot getExternal(final String key) {
@Override
public void removeExternal(final String key) {
final Integer integer = externalRefCounts.get(key);
- if (integer == null || integer.intValue() == 0) {
- externals.remove(key).dispose();
+ if (integer != null) {
+ if (integer.intValue() == 1) {
+ externals.remove(key);
+ externalRefCounts.remove(key);
+ } else {
+ externalRefCounts.put(key, integer - 1);
+ }
}
}
@@ -755,6 +755,7 @@ public void setIncludeDirs(final Collection<IPath> includeDirs)
public void setSourceDirs(final Collection<IPath> sourceDirs)
throws BackingStoreException {
getModelCache().removeProject(this);
+ removeExternals();
final IErlangProjectProperties properties = getProperties();
properties.setSourceDirs(sourceDirs);
properties.store();
@@ -765,6 +766,7 @@ public void setSourceDirs(final Collection<IPath> sourceDirs)
public void setExternalModulesFile(final String absolutePath)
throws BackingStoreException {
getModelCache().removeProject(this);
+ removeExternals();
final IErlangProjectProperties properties = getProperties();
properties.setExternalModulesFile(absolutePath);
properties.store();
@@ -775,6 +777,7 @@ public void setExternalModulesFile(final String absolutePath)
public void setExternalIncludesFile(final String absolutePath)
throws BackingStoreException {
getModelCache().removeProject(this);
+ removeExternals();
final IErlangProjectProperties properties = getProperties();
properties.setExternalIncludesFile(absolutePath);
properties.store();
@@ -954,6 +957,28 @@ public boolean visit(final IErlElement element)
Kind.MODULE);
} catch (final ErlModelException e) {
}
+ removeExternals();
+ super.dispose();
+ }
+
+ public void removeExternals() {
+ try {
+ accept(new IErlElementVisitor() {
+
+ @Override
+ public boolean visit(final IErlElement element)
+ throws ErlModelException {
+ if (element instanceof IErlExternalRoot) {
+ final IErlExternalRoot externalRoot = (IErlExternalRoot) element;
+ externalRoot.removeExternal();
+ }
+ element.dispose();
+ return false;
+ }
+ }, EnumSet.of(AcceptFlags.CHILDREN_FIRST, AcceptFlags.LEAFS_ONLY),
+ Kind.EXTERNAL);
+ } catch (final ErlModelException e) {
+ }
super.dispose();
}

0 comments on commit 797fd88

Please sign in to comment.