Skip to content

Commit

Permalink
Fix #440
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Sep 24, 2016
1 parent bd5bde9 commit 1644e96
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ public static boolean hasTernNature(IProject project) {
@Override
protected void doLoad() throws IOException {
try {



disposeServer();
TernProjectLifecycleManager.getManager().fireTernProjectLifeCycleListenerChanged(this,
LifecycleEventType.onLoadBefore);
Expand All @@ -211,13 +210,13 @@ protected void doLoad() throws IOException {
// the tern project is loaded on the first time, load default
// modules and save .tern-project.
initAdaptedNaturesInfos();

} finally {
TernProjectLifecycleManager.getManager().fireTernProjectLifeCycleListenerChanged(this,
LifecycleEventType.onLoadAfter);
}
}

@Override
protected void onLintersChanged() {
TernProjectLifecycleManager.getManager().fireTernProjectLifeCycleListenerChanged(this,
Expand Down Expand Up @@ -376,7 +375,7 @@ public void handleException(Throwable t) {
/**
* Save IDE informations in the JSON file .tern-project.
*/
private void saveIDEInfos() {
private void saveIDEInfos() {
// script path
if (scriptPaths.size() > 0) {
JsonObject ide = new JsonObject();
Expand Down Expand Up @@ -662,7 +661,8 @@ public boolean visit(IResource resource) throws CoreException {
case IResource.PROJECT:
return true;
case IResource.FILE:
ITernModule module = TernModuleHelper.createModule(resource.getName(), projectRepository, defaultRepository);
ITernModule module = TernModuleHelper.createModule(resource.getName(), projectRepository,
defaultRepository);
if (module != null) {
modules.add(module);
}
Expand Down Expand Up @@ -700,7 +700,10 @@ public void dispose() throws CoreException {
}

protected static IDETernProject getTernProject(IProject project) throws CoreException {
return (IDETernProject) project.getSessionProperty(TERN_PROJECT);
if (project.isAccessible()) {
return (IDETernProject) project.getSessionProperty(TERN_PROJECT);
}
return null;
}

@Override
Expand Down Expand Up @@ -780,7 +783,7 @@ private boolean checkInScopeResource(IResource resource, IScopeContext context)
// none script path, we consider that resource is in the scope?
return true;
}

// Loop for each tern script path
int resourceType = resource.getType();
IPath path = resource.getFullPath();
Expand All @@ -791,12 +794,14 @@ private boolean checkInScopeResource(IResource resource, IScopeContext context)
// script path is an Eclipse Project or Folder
s = (IIDETernScriptPath) scriptPath;
if (s.isBelongToContainer(path)) {
// the resource path belongs to the Project/folder of the tern script path
// the resource path belongs to the Project/folder of the
// tern script path
if (!s.isInScope(path, resourceType)) {
// the tern script exclude or don't include the resource
return false;
} else if (resourceType == IResource.FILE) {
// None exclusion, check if the parent folder exclude the file
// None exclusion, check if the parent folder exclude
// the file
parent = resource.getParent();
while ((parent.getType() & IResource.PROJECT) == 0) {
if (context.isInclude(parent)) {
Expand All @@ -809,7 +814,7 @@ private boolean checkInScopeResource(IResource resource, IScopeContext context)
parent = parent.getParent();
}
}
// The parent folder of the resource
// The parent folder of the resource
context.addInclude(resource.getParent());
return true;
}
Expand All @@ -834,7 +839,7 @@ private List<ITernScriptPath> getSortedScriptPaths() {
@Override
public IIDETernScriptPathReporter getScriptPathReporter() {
// Uncomment to have trace for include/exclude files.
return null; //SysErrScriptPathReporter.INSTANCE;
return null; // SysErrScriptPathReporter.INSTANCE;
}

}

0 comments on commit 1644e96

Please sign in to comment.