[Title] Adds bugfixed JSDT plugins. This also fixes performance problem.
authorWooyoung Cho <wooyoung1.cho@samsung.com>
Mon, 2 Jul 2012 02:49:41 +0000 (11:49 +0900)
committerWooyoung Cho <wooyoung1.cho@samsung.com>
Mon, 2 Jul 2012 02:49:41 +0000 (11:49 +0900)
This is copied from base branch of sdk/ide/jsdt-eplugin.git
Its commit ID is 05fa30c48aeacb54e48b07c47d743acccddd42fc.

Increases package version from 1.0.7 to 1.0.8
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#] #5633
[Problem]
[Cause]
[Solution]
[TestCase]

org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/codeassist/impl/Engine.java
org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Parser.java
package/pkginfo.manifest

index 445d729..bc96304 100644 (file)
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.wst.jsdt.internal.codeassist.impl;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.wst.jsdt.core.compiler.CharOperation;
@@ -60,6 +61,9 @@ public abstract class Engine implements ITypeRequestor, ITypeRequestor2 {
        public int importCacheCount = 0;
        public int onDemandImportCacheCount = 0;
        public char[] currentPackageName = null;
+       
+       // astInUse is a map from CU to AST and keeps the AST's that is being currently used by resolving mechanism.
+       private static HashMap astInUse = new HashMap(); 
 
        public Engine(Map settings){
                this.options = new AssistOptions(settings);
@@ -87,11 +91,35 @@ public abstract class Engine implements ITypeRequestor, ITypeRequestor2 {
                lookupEnvironment.buildTypeBindings(parsedUnit, accessRestriction);
                lookupEnvironment.completeTypeBindings(parsedUnit, true);
        }
-       public void accept(ICompilationUnit unit, char[][] typeNames, AccessRestriction accessRestriction) {
-               CompilationUnitDeclaration parsedUnit =  doParse(unit,accessRestriction);
 
-               lookupEnvironment.buildTypeBindings(parsedUnit, typeNames, accessRestriction);
-               lookupEnvironment.completeTypeBindings(parsedUnit, typeNames, true);            
+       public void accept(ICompilationUnit unit, char[][] typeNames, AccessRestriction accessRestriction) {
+               CompilationUnitDeclaration parsedUnit;
+               boolean astAdded = false;
+               CompilationUnitScope oldScope = null;
+               
+               // If the AST is already in memory(namely, it's being used for finding other bindings),
+               // use it instead of parsing again. This reduces performance problem of redundant parsing.
+               if (astInUse.containsKey(unit)) {
+                       parsedUnit = (CompilationUnitDeclaration) astInUse.get(unit);
+               } else {
+                       parsedUnit = doParse(unit,accessRestriction);
+                       astInUse.put(unit, parsedUnit);
+                       astAdded = true;
+               }
+               // keeps the scope object of parsedUnit because it will be overwritten in buildTypeBindings()
+               oldScope = parsedUnit.scope;
+               
+               try {
+                       lookupEnvironment.buildTypeBindings(parsedUnit, typeNames, accessRestriction);
+                       lookupEnvironment.completeTypeBindings(parsedUnit, typeNames, true);
+               } finally {
+                       // If the AST is added in the current frame, remove it and it'll be GC'ed.
+                       if(astAdded) {
+                               astInUse.remove(unit);
+                       }
+                       // restore scope object
+                       parsedUnit.scope = oldScope;
+               }
        }
 
        /**
index 6e112fc..87b20fa 100644 (file)
@@ -3887,7 +3887,7 @@ protected void consumeStatementDo() {
                        this.expressionStack[this.expressionPtr--],
                        statement,
                        this.intStack[this.intPtr--],
-                       this.endStatementPosition);
+                       this.scanner.startPosition - 1);
 }
 protected void consumeStatementExpressionList() {
        // StatementExpressionList ::= StatementExpressionList ',' StatementExpression
@@ -3999,7 +3999,7 @@ protected void consumeStatementLabel() {
                        this.identifierStack[this.identifierPtr],
                        statement,
                        this.identifierPositionStack[this.identifierPtr--],
-                       this.endStatementPosition);
+                       this.scanner.startPosition - 1);
        this.identifierLengthPtr--;
 }
 protected void consumeStatementReturn() {
index b6ef351..5427f55 100644 (file)
@@ -1,5 +1,5 @@
 Package:base-ide-product
-Version:1.0.7
+Version:1.0.8
 OS:linux
 Build-host-os:linux
 Build-dependency:indigo-pde [linux]
@@ -8,7 +8,7 @@ Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung
 Description:Make base IDE. This also includes patched eclipse plugins.
 
 Package:base-ide-product
-Version:1.0.7
+Version:1.0.8
 OS:windows
 Build-host-os:linux
 Build-dependency:indigo-winpde [windows]
@@ -17,7 +17,7 @@ Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung
 Description:Make base IDE. This also includes patched eclipse plugins.
 
 Package:base-ide-product
-Version:1.0.7
+Version:1.0.8
 OS:darwin
 Build-host-os:linux
 Build-dependency:indigo-macpde [darwin]