org.eclipse.wst.jsdt.core_1.1.102.v201111090634_patch

16:49:04.466 INFO  jd.cli.Main - Decompiling org.eclipse.wst.jsdt.core_1.1.102.v201111090634_patch.jar
package org.eclipse.wst.jsdt.core;

import org.eclipse.wst.jsdt.internal.core.util.KeyToSignature;

public final class BindingKey
{
  private String key;
  
  public BindingKey(String key)
  {
    this.key = key;
  }
  
  public static String createArrayTypeBindingKey(String typeKey, int arrayDimension)
  {
    StringBuffer buffer = new StringBuffer();
    while (arrayDimension-- > 0) {
      buffer.append('[');
    }
    buffer.append(typeKey);
    return buffer.toString();
  }
  
  public static String createTypeBindingKey(String typeName)
  {
    return Signature.createTypeSignature(typeName.replace('.', '/'), true);
  }
  
  public String toSignature()
  {
    KeyToSignature keyToSignature = new KeyToSignature(key, 0);
    keyToSignature.parse();
    return signature.toString();
  }
  
  public String toString()
  {
    return key;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.BindingKey
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import java.util.EventObject;

public class BufferChangedEvent
  extends EventObject
{
  private int length;
  private int offset;
  private String text;
  private static final long serialVersionUID = 655379473891745999L;
  
  public BufferChangedEvent(IBuffer buffer, int offset, int length, String text)
  {
    super(buffer);
    this.offset = offset;
    this.length = length;
    this.text = text;
  }
  
  public IBuffer getBuffer()
  {
    return (IBuffer)source;
  }
  
  public int getLength()
  {
    return length;
  }
  
  public int getOffset()
  {
    return offset;
  }
  
  public String getText()
  {
    return text;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.BufferChangedEvent
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import org.eclipse.wst.jsdt.internal.codeassist.InternalCompletionContext;

public final class CompletionContext
  extends InternalCompletionContext
{
  public static final int TOKEN_KIND_UNKNOWN = 0;
  public static final int TOKEN_KIND_NAME = 1;
  public static final int TOKEN_KIND_STRING_LITERAL = 2;
  
  public boolean isInJsdoc()
  {
    return javadoc != 0;
  }
  
  public boolean isInJsdocText()
  {
    return (javadoc & 0x4) != 0;
  }
  
  public boolean isInJsdocFormalReference()
  {
    return (javadoc & 0x40) != 0;
  }
  
  public char[][] getExpectedTypesSignatures()
  {
    return expectedTypesSignatures;
  }
  
  public char[][] getExpectedTypesKeys()
  {
    return expectedTypesKeys;
  }
  
  public char[] getToken()
  {
    return token;
  }
  
  public int getTokenKind()
  {
    return tokenKind;
  }
  
  public int getTokenStart()
  {
    return tokenStart;
  }
  
  public int getTokenEnd()
  {
    return tokenEnd;
  }
  
  public int getOffset()
  {
    return offset;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    
    buffer.append("completion offset=");
    buffer.append(offset);
    buffer.append('\n');
    
    buffer.append("completion range=[");
    buffer.append(tokenStart);
    buffer.append(", ");
    buffer.append(tokenEnd);
    buffer.append("]\n");
    
    buffer.append("completion token=");
    String string = "null";
    if (token == null)
    {
      buffer.append(string);
    }
    else
    {
      buffer.append('"');
      buffer.append(token);
      buffer.append('"');
    }
    buffer.append('\n');
    
    buffer.append("expectedTypesSignatures=");
    if (expectedTypesSignatures == null)
    {
      buffer.append(string);
    }
    else
    {
      buffer.append('{');
      for (int i = 0; i < expectedTypesSignatures.length; i++)
      {
        if (i > 0) {
          buffer.append(',');
        }
        buffer.append(expectedTypesSignatures[i]);
      }
      buffer.append('}');
    }
    buffer.append('\n');
    
    buffer.append("expectedTypesKeys=");
    if (expectedTypesSignatures == null)
    {
      buffer.append(string);
    }
    else
    {
      buffer.append('{');
      for (int i = 0; i < expectedTypesKeys.length; i++)
      {
        if (i > 0) {
          buffer.append(',');
        }
        buffer.append(expectedTypesKeys[i]);
      }
      buffer.append('}');
    }
    buffer.append('\n');
    
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.CompletionContext
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

public final class CompletionFlags
{
  public static final int Default = 0;
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.CompletionFlags
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
import org.eclipse.wst.jsdt.internal.codeassist.InternalCompletionProposal;

public final class CompletionProposal
  extends InternalCompletionProposal
{
  private boolean updateCompletion = false;
  public static final int ANONYMOUS_CLASS_DECLARATION = 1;
  public static final int FIELD_REF = 2;
  public static final int KEYWORD = 3;
  public static final int LABEL_REF = 4;
  public static final int LOCAL_VARIABLE_REF = 5;
  public static final int METHOD_REF = 6;
  public static final int METHOD_DECLARATION = 7;
  public static final int PACKAGE_REF = 8;
  public static final int TYPE_REF = 9;
  public static final int VARIABLE_DECLARATION = 10;
  public static final int POTENTIAL_METHOD_DECLARATION = 11;
  public static final int METHOD_NAME_REFERENCE = 12;
  public static final int JSDOC_FIELD_REF = 14;
  public static final int JSDOC_METHOD_REF = 15;
  public static final int JSDOC_TYPE_REF = 16;
  public static final int JSDOC_PARAM_REF = 18;
  public static final int JSDOC_BLOCK_TAG = 19;
  public static final int JSDOC_INLINE_TAG = 20;
  public static final int FIELD_IMPORT = 21;
  public static final int METHOD_IMPORT = 22;
  public static final int TYPE_IMPORT = 23;
  public static final int CONSTRUCTOR_INVOCATION = 26;
  protected static final int FIRST_KIND = 1;
  protected static final int LAST_KIND = 26;
  private int completionKind;
  private int completionLocation;
  private int tokenStart = 0;
  private int tokenEnd = 0;
  private char[] completion = CharOperation.NO_CHAR;
  private int replaceStart = 0;
  private int replaceEnd = 0;
  private int relevance = 1;
  private char[] declarationSignature = null;
  private char[] declarationKey = null;
  private char[] name = null;
  private char[] signature = null;
  private char[] key = null;
  private CompletionProposal[] requiredProposals;
  private int flags = 0;
  private int additionalFlags = 0;
  private char[][] parameterNames = null;
  private boolean parameterNamesComputed = false;
  private int sourceStart = -1;
  private int sourceEnd = -1;
  
  public static CompletionProposal create(int kind, int completionOffset)
  {
    return new CompletionProposal(kind, completionOffset);
  }
  
  CompletionProposal(int kind, int completionLocation)
  {
    if ((kind < 1) || 
      (kind > 26)) {
      throw new IllegalArgumentException();
    }
    if ((completion == null) || (completionLocation < 0))
    {
      if ((completion == null) || (completionLocation != -1)) {
        throw new IllegalArgumentException();
      }
      completionLocation = 0;
    }
    completionKind = kind;
    this.completionLocation = completionLocation;
  }
  
  public int getAdditionalFlags()
  {
    return additionalFlags;
  }
  
  public void setAdditionalFlags(int additionalFlags)
  {
    this.additionalFlags = additionalFlags;
  }
  
  public int getKind()
  {
    return completionKind;
  }
  
  public int getCompletionLocation()
  {
    return completionLocation;
  }
  
  public int getTokenStart()
  {
    return tokenStart;
  }
  
  public int getTokenEnd()
  {
    return tokenEnd;
  }
  
  public void setTokenRange(int startIndex, int endIndex)
  {
    if ((startIndex < 0) || (endIndex < startIndex)) {
      throw new IllegalArgumentException();
    }
    tokenStart = startIndex;
    tokenEnd = endIndex;
  }
  
  public char[] getCompletion()
  {
    if (completionKind == 7)
    {
      findParameterNames(null);
      if (updateCompletion)
      {
        updateCompletion = false;
        if (parameterNames != null)
        {
          int length = parameterNames.length;
          StringBuffer completionBuffer = new StringBuffer(completion.length);
          
          int start = 0;
          int end = CharOperation.indexOf('%', completion);
          
          completionBuffer.append(completion, start, end - start);
          for (int i = 0; i < length; i++)
          {
            completionBuffer.append(parameterNames[i]);
            start = end + 1;
            end = CharOperation.indexOf('%', completion, start);
            if (end > -1) {
              completionBuffer.append(completion, start, end - start);
            } else {
              completionBuffer.append(completion, start, completion.length - start);
            }
          }
          int nameLength = completionBuffer.length();
          completion = new char[nameLength];
          completionBuffer.getChars(0, nameLength, completion, 0);
        }
      }
    }
    return completion;
  }
  
  public void setCompletion(char[] completion)
  {
    this.completion = completion;
  }
  
  public int getReplaceStart()
  {
    return replaceStart;
  }
  
  public int getReplaceEnd()
  {
    return replaceEnd;
  }
  
  public void setReplaceRange(int startIndex, int endIndex)
  {
    if ((startIndex < 0) || (endIndex < startIndex)) {
      throw new IllegalArgumentException();
    }
    replaceStart = startIndex;
    replaceEnd = endIndex;
  }
  
  public int getRelevance()
  {
    return relevance;
  }
  
  public void setRelevance(int rating)
  {
    if (rating <= 0) {
      throw new IllegalArgumentException();
    }
    relevance = rating;
  }
  
  public char[] getDeclarationSignature()
  {
    return declarationSignature;
  }
  
  public char[] getDeclarationKey()
  {
    return declarationKey;
  }
  
  public void setDeclarationSignature(char[] signature)
  {
    declarationSignature = signature;
  }
  
  public void setDeclarationKey(char[] key)
  {
    declarationKey = key;
  }
  
  public char[] getName()
  {
    return name;
  }
  
  public void setName(char[] name)
  {
    this.name = name;
  }
  
  public char[] getSignature()
  {
    return signature;
  }
  
  public char[] getKey()
  {
    return key;
  }
  
  public char[] getDeclarationTypeName()
  {
    return declarationTypeName;
  }
  
  public void setSignature(char[] signature)
  {
    this.signature = signature;
  }
  
  public void setKey(char[] key)
  {
    this.key = key;
  }
  
  public int getFlags()
  {
    return flags;
  }
  
  public void setFlags(int flags)
  {
    this.flags = flags;
  }
  
  public CompletionProposal[] getRequiredProposals()
  {
    return requiredProposals;
  }
  
  public void setRequiredProposals(CompletionProposal[] proposals)
  {
    requiredProposals = proposals;
  }
  
  public char[][] findParameterNames(IProgressMonitor monitor)
  {
    if (!parameterNamesComputed)
    {
      parameterNamesComputed = true;
      switch (completionKind)
      {
      case 1: 
        try
        {
          parameterNames = findMethodParameterNames(
            declarationPackageName, 
            declarationTypeName, 
            CharOperation.lastSegment(declarationTypeName, '.'), 
            Signature.getParameterTypes(originalSignature == null ? signature : originalSignature));
        }
        catch (IllegalArgumentException localIllegalArgumentException1)
        {
          if (parameterTypeNames != null) {
            parameterNames = createDefaultParameterNames(parameterTypeNames.length);
          } else {
            parameterNames = null;
          }
        }
      case 6: 
        try
        {
          parameterNames = findMethodParameterNames(
            declarationPackageName, 
            declarationTypeName, 
            name, 
            Signature.getParameterTypes(originalSignature == null ? signature : originalSignature));
        }
        catch (IllegalArgumentException localIllegalArgumentException2)
        {
          if (parameterTypeNames != null) {
            parameterNames = createDefaultParameterNames(parameterTypeNames.length);
          } else {
            parameterNames = null;
          }
        }
      case 7: 
        try
        {
          parameterNames = findMethodParameterNames(
            declarationPackageName, 
            declarationTypeName, 
            name, 
            Signature.getParameterTypes(originalSignature == null ? signature : originalSignature));
        }
        catch (IllegalArgumentException localIllegalArgumentException3)
        {
          if (parameterTypeNames != null) {
            parameterNames = createDefaultParameterNames(parameterTypeNames.length);
          } else {
            parameterNames = null;
          }
        }
        if (parameterNames != null) {
          updateCompletion = true;
        }
        break;
      }
    }
    return parameterNames;
  }
  
  public void setParameterNames(char[][] parameterNames)
  {
    this.parameterNames = parameterNames;
    parameterNamesComputed = true;
  }
  
  public boolean hasParameters()
  {
    return (parameterNames != null) && (parameterNames.length > 0);
  }
  
  public char[][] getParamaterNames()
  {
    return parameterNames;
  }
  
  public char[][] getParameterTypeNames()
  {
    return parameterTypeNames;
  }
  
  public int getAccessibility()
  {
    return accessibility;
  }
  
  public boolean isConstructor()
  {
    return isConstructor;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append('[');
    switch (completionKind)
    {
    case 1: 
      buffer.append("ANONYMOUS_CLASS_DECLARATION");
      break;
    case 2: 
      buffer.append("FIELD_REF");
      break;
    case 3: 
      buffer.append("KEYWORD");
      break;
    case 4: 
      buffer.append("LABEL_REF");
      break;
    case 5: 
      buffer.append("LOCAL_VARIABLE_REF");
      break;
    case 7: 
      buffer.append("FUNCTION_DECLARATION");
      if (isConstructor) {
        buffer.append("<CONSTRUCTOR>");
      }
      break;
    case 6: 
      buffer.append("FUNCTION_REF");
      if (isConstructor) {
        buffer.append("<CONSTRUCTOR>");
      }
      break;
    case 8: 
      buffer.append("PACKAGE_REF");
      break;
    case 9: 
      buffer.append("TYPE_REF");
      break;
    case 10: 
      buffer.append("VARIABLE_DECLARATION");
      break;
    case 11: 
      buffer.append("POTENTIAL_METHOD_DECLARATION");
      break;
    case 12: 
      buffer.append("METHOD_IMPORT");
      break;
    case 19: 
      buffer.append("JSDOC_BLOCK_TAG");
      break;
    case 20: 
      buffer.append("JSDOC_INLINE_TAG");
      break;
    case 14: 
      buffer.append("JSDOC_FIELD_REF");
      break;
    case 15: 
      buffer.append("JSDOC_METHOD_REF");
      break;
    case 16: 
      buffer.append("JSDOC_TYPE_REF");
      break;
    case 18: 
      buffer.append("JSDOC_PARAM_REF");
      break;
    case 21: 
      buffer.append("FIELD_IMPORT");
      break;
    case 22: 
      buffer.append("METHOD_IMPORT");
      break;
    case 23: 
      buffer.append("TYPE_IMPORT");
      break;
    case 13: 
    case 17: 
    default: 
      buffer.append("PROPOSAL");
    }
    buffer.append("]{completion:");
    if (completion != null) {
      buffer.append(completion);
    }
    buffer.append(", declSign:");
    if (declarationSignature != null) {
      buffer.append(declarationSignature);
    }
    buffer.append(", sign:");
    if (signature != null) {
      buffer.append(signature);
    }
    buffer.append(", declKey:");
    if (declarationKey != null) {
      buffer.append(declarationKey);
    }
    buffer.append(", key:");
    if (key != null) {
      buffer.append(key);
    }
    buffer.append(", name:");
    if (name != null) {
      buffer.append(name);
    }
    buffer.append(", [");
    buffer.append(replaceStart);
    buffer.append(',');
    buffer.append(replaceEnd);
    buffer.append("], relevance=");
    buffer.append(relevance);
    buffer.append('}');
    return buffer.toString();
  }
  
  public void setLocalDeclarationSourceRange(int sourceStart, int sourceEnd)
  {
    this.sourceStart = sourceStart;
    this.sourceEnd = sourceEnd;
  }
  
  public int getLocalDeclarationSourceStart()
  {
    return sourceStart;
  }
  
  public int getLocalDeclarationSourceEnd()
  {
    return sourceEnd;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.CompletionProposal
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import org.eclipse.wst.jsdt.core.compiler.IProblem;

public abstract class CompletionRequestor
{
  private int ignoreSet = 0;
  private String[] favoriteReferences;
  private int[] requiredProposalAllowSet = null;
  
  public boolean isIgnored(int completionProposalKind)
  {
    if ((completionProposalKind < 1) || 
      (completionProposalKind > 26)) {
      throw new IllegalArgumentException("Unknown kind of completion proposal: " + completionProposalKind);
    }
    return (ignoreSet & 1 << completionProposalKind) != 0;
  }
  
  public void setIgnored(int completionProposalKind, boolean ignore)
  {
    if ((completionProposalKind < 1) || 
      (completionProposalKind > 26)) {
      throw new IllegalArgumentException("Unknown kind of completion proposal: " + completionProposalKind);
    }
    if (ignore) {
      ignoreSet |= 1 << completionProposalKind;
    } else {
      ignoreSet &= (1 << completionProposalKind ^ 0xFFFFFFFF);
    }
  }
  
  public boolean isAllowingRequiredProposals(int proposalKind, int requiredProposalKind)
  {
    if ((proposalKind < 1) || 
      (proposalKind > 26)) {
      throw new IllegalArgumentException("Unknown kind of completion proposal: " + requiredProposalKind);
    }
    if ((requiredProposalKind < 1) || 
      (requiredProposalKind > 26)) {
      throw new IllegalArgumentException("Unknown required kind of completion proposal: " + requiredProposalKind);
    }
    if (requiredProposalAllowSet == null) {
      return false;
    }
    return (requiredProposalAllowSet[proposalKind] & 1 << requiredProposalKind) != 0;
  }
  
  public void setAllowsRequiredProposals(int proposalKind, int requiredProposalKind, boolean allow)
  {
    if ((proposalKind < 1) || 
      (proposalKind > 26)) {
      throw new IllegalArgumentException("Unknown kind of completion proposal: " + requiredProposalKind);
    }
    if ((requiredProposalKind < 1) || 
      (requiredProposalKind > 26)) {
      throw new IllegalArgumentException("Unknown required kind of completion proposal: " + requiredProposalKind);
    }
    if (requiredProposalAllowSet == null) {
      requiredProposalAllowSet = new int[27];
    }
    if (allow) {
      requiredProposalAllowSet[proposalKind] |= 1 << requiredProposalKind;
    } else {
      requiredProposalAllowSet[proposalKind] &= (1 << requiredProposalKind ^ 0xFFFFFFFF);
    }
  }
  
  public String[] getFavoriteReferences()
  {
    return favoriteReferences;
  }
  
  public void setFavoriteReferences(String[] favoriteImports)
  {
    favoriteReferences = favoriteImports;
  }
  
  public void beginReporting() {}
  
  public void endReporting() {}
  
  public void completionFailure(IProblem problem) {}
  
  public abstract void accept(CompletionProposal paramCompletionProposal);
  
  public void acceptContext(CompletionContext context) {}
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.CompletionRequestor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import org.eclipse.wst.jsdt.core.compiler.CharOperation;

class CorrectionEngine$1
  extends CompletionRequestor
{
  CorrectionEngine$1(CorrectionEngine paramCorrectionEngine) {}
  
  public void accept(CompletionProposal proposal)
  {
    switch (proposal.getKind())
    {
    case 9: 
      if ((this$0.filter & 0x1) != 0)
      {
        char[] completionName = proposal.getCompletion();
        this$0.correctionRequestor.acceptClass(
          proposal.getDeclarationSignature(), 
          Signature.getSignatureSimpleName(proposal.getSignature()), 
          CharOperation.subarray(completionName, this$0.prefixLength, completionName.length), 
          proposal.getFlags(), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      else if ((this$0.filter & 0x4) != 0)
      {
        char[] packageName = proposal.getDeclarationSignature();
        char[] className = Signature.getSignatureSimpleName(proposal.getSignature());
        char[] fullName = CharOperation.concat(packageName, className, '.');
        this$0.correctionRequestor.acceptClass(
          packageName, 
          className, 
          CharOperation.subarray(fullName, this$0.prefixLength, fullName.length), 
          proposal.getFlags(), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      break;
    case 2: 
      if ((this$0.filter & 0x10) != 0)
      {
        char[] declaringSignature = proposal.getDeclarationSignature();
        char[] signature = proposal.getSignature();
        this$0.correctionRequestor.acceptField(
          Signature.getSignatureQualifier(declaringSignature), 
          Signature.getSignatureSimpleName(declaringSignature), 
          proposal.getName(), 
          Signature.getSignatureQualifier(signature), 
          Signature.getSignatureSimpleName(signature), 
          proposal.getName(), 
          proposal.getFlags(), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      break;
    case 5: 
      if ((this$0.filter & 0x20) != 0)
      {
        char[] signature = proposal.getSignature();
        this$0.correctionRequestor.acceptLocalVariable(
          proposal.getName(), 
          Signature.getSignatureQualifier(signature), 
          Signature.getSignatureSimpleName(signature), 
          proposal.getFlags(), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      break;
    case 6: 
      if ((this$0.filter & 0x8) != 0)
      {
        char[] declaringSignature = proposal.getDeclarationSignature();
        char[] signature = proposal.getSignature();
        char[][] parameterTypeSignatures = Signature.getParameterTypes(signature);
        int length = parameterTypeSignatures.length;
        char[][] parameterPackageNames = new char[length][];
        char[][] parameterTypeNames = new char[length][];
        for (int i = 0; i < length; i++)
        {
          parameterPackageNames[i] = Signature.getSignatureQualifier(parameterTypeSignatures[i]);
          parameterTypeNames[i] = Signature.getSignatureSimpleName(parameterTypeSignatures[i]);
        }
        char[] returnTypeSignature = Signature.getReturnType(signature);
        this$0.correctionRequestor.acceptMethod(
          Signature.getSignatureQualifier(declaringSignature), 
          Signature.getSignatureSimpleName(declaringSignature), 
          proposal.getName(), 
          parameterPackageNames, 
          parameterTypeNames, 
          proposal.findParameterNames(null), 
          Signature.getSignatureQualifier(returnTypeSignature), 
          Signature.getSignatureSimpleName(returnTypeSignature), 
          proposal.getName(), 
          proposal.getFlags(), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      break;
    case 8: 
      if ((this$0.filter & 0x5) != 0)
      {
        char[] packageName = proposal.getDeclarationSignature();
        this$0.correctionRequestor.acceptPackage(
          packageName, 
          CharOperation.subarray(packageName, this$0.prefixLength, packageName.length), 
          this$0.correctionStart, 
          this$0.correctionEnd);
      }
      break;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.jsdt.core.CorrectionEngine.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.jsdt.core;

import java.util.Map;
import org.eclipse.core.resources.IMarker;
import org.eclipse.wst.jsdt.core.compiler.CharOperation;
import org.eclipse.wst.jsdt.core.compiler.IProblem;
import org.eclipse.wst.jsdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.wst.jsdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.wst.jsdt.internal.compiler.problem.ProblemReporter;
import org.eclipse.wst.jsdt.internal.core.util.Messages;
import org.eclipse.wst.jsdt.internal.core.util.Util;

public class CorrectionEngine
  implements ProblemReasons
{
  protected int correctionStart;
  protected int correctionEnd;
  protected int prefixLength;
  protected IJavaScriptUnit compilationUnit;
  protected ICorrectionRequestor correctionRequestor;
  protected static final int CLASSES = 1;
  protected static final int IMPORT = 4;
  protected static final int METHOD = 8;
  protected static final int FIELD = 16;
  protected static final int LOCAL = 32;
  protected int filter;
  
  public CorrectionEngine(Map setting) {}
  
  public void computeCorrections(IMarker marker, IJavaScriptUnit targetUnit, int positionOffset, ICorrectionRequestor requestor)
    throws JavaScriptModelException
  {
    IJavaScriptElement element = targetUnit == null ? JavaScriptCore.create(marker.getResource()) : targetUnit;
    if (!(element instanceof IJavaScriptUnit)) {
      return;
    }
    IJavaScriptUnit unit = (IJavaScriptUnit)element;
    
    int id = marker.getAttribute("id", -1);
    String[] args = Util.getProblemArgumentsFromMarker(marker.getAttribute("arguments", ""));
    int start = marker.getAttribute("charStart", -1);
    int end = marker.getAttribute("charEnd", -1);
    
    computeCorrections(unit, id, start + positionOffset, end + positionOffset, args, requestor);
  }
  
  public void computeCorrections(IProblem problem, IJavaScriptUnit targetUnit, ICorrectionRequestor requestor)
    throws JavaScriptModelException
  {
    if (requestor == null) {
      throw new IllegalArgumentException(Messages.correction_nullUnit);
    }
    computeCorrections(
      targetUnit, problem.getID(), 
      problem.getSourceStart(), 
      problem.getSourceEnd(), 
      problem.getArguments(), 
      requestor);
  }
  
  private void computeCorrections(IJavaScriptUnit unit, int id, int start, int end, String[] arguments, ICorrectionRequestor requestor)
  {
    if ((id == -1) || (arguments == null) || (start == -1) || (end == -1)) {
      return;
    }
    if (requestor == null) {
      throw new IllegalArgumentException(Messages.correction_nullRequestor);
    }
    correctionRequestor = requestor;
    correctionStart = start;
    correctionEnd = end;
    compilationUnit = unit;
    
    String argument = null;
    try
    {
      switch (id)
      {
      case 268435846: 
        filter = 4;
        argument = arguments[0];
        break;
      case 16777218: 
        filter = 1;
        argument = arguments[0];
        break;
      case 67108964: 
      case 67108973: 
        filter = 8;
        argument = arguments[1];
        break;
      case 33554502: 
        filter = 16;
        argument = arguments[0];
        break;
      case 570425394: 
        filter = 48;
        argument = arguments[0];
      }
    }
    catch (ArrayIndexOutOfBoundsException localArrayIndexOutOfBoundsException)
    {
      return;
    }
    if (argument != null) {
      correct(argument.toCharArray());
    }
  }
  
  protected CompletionRequestor completionRequestor = new CompletionRequestor()
  {
    public void accept(CompletionProposal proposal)
    {
      switch (proposal.getKind())
      {
      case 9: 
        if ((filter & 0x1) != 0)
        {
          char[] completionName = proposal.getCompletion();
          correctionRequestor.acceptClass(
            proposal.getDeclarationSignature(), 
            Signature.getSignatureSimpleName(proposal.getSignature()), 
            CharOperation.subarray(completionName, prefixLength, completionName.length), 
            proposal.getFlags(), 
            correctionStart, 
            correctionEnd);
        }
        else if ((filter & 0x4) != 0)
        {
          char[] packageName = proposal.getDeclarationSignature();
          char[] className = Signature.getSignatureSimpleName(proposal.getSignature());
          char[] fullName = CharOperation.concat(packageName, className, '.');
          correctionRequestor.acceptClass(
            packageName, 
            className, 
            CharOperation.subarray(fullName, prefixLength, fullName.length), 
            proposal.getFlags(), 
            correctionStart, 
            correctionEnd);
        }
        break;
      case 2: 
        if ((filter & 0x10) != 0)
        {
          char[] declaringSignature = proposal.getDeclarationSignature();
          char[] signature = proposal.getSignature();
          correctionRequestor.acceptField(
            Signature.getSignatureQualifier(declaringSignature), 
            Signature.getSignatureSimpleName(declaringSignature), 
            proposal.getName(), 
            Signature.getSignatureQualifier(signature), 
            Signature.getSignatureSimpleName(signature), 
            proposal.getName(), 
            proposal.getFlags(), 
            correctionStart, 
            correctionEnd);
        }
        break;
      case 5: 
        if ((filter & 0x20) != 0)
        {
          char[] signature = proposal.getSignature();
          correctionRequestor.acceptLocalVariable(
            proposal.getName(), 
            Signature.getSignatureQualifier(signature), 
            Signature.getSignatureSimpleName(signature), 
            proposal.getFlags(), 
            correctionStart, 
            correctionEnd);
        }
        break;
      case 6: 
        if ((filter & 0x8) != 0)
        {
          char[] declaringSignature = proposal.getDeclarationSignature();
          char[] signature = proposal.getSignature();
          char[][] parameterTypeSignatures = Signature.getParameterTypes(signature);
          int length = parameterTypeSignatures.length;
          char[][] parameterPackageNames = new char[length][];
          char[][] parameterTypeNames = new char[length][];
          for (int i = 0; i < length; i++)
          {
            parameterPackageNames[i] = Signature.getSignatureQualifier(parameterTypeSignatures[i]);
            parameterTypeNames[i] = Signature.getSignatureSimpleName(parameterTypeSignatures[i]);
          }
          char[] returnTypeSignature = Signature.getReturnType(signature);
          correctionRequestor.acceptMethod(
            Signature.getSignatureQualifier(declaringSignature), 
            Signature.getSignatureSimpleName(declaringSignature), 
            proposal.getName(), 
            parameterPackageNames, 
            parameterTypeNames, 
            proposal.findParameterNames(null), 
            Signature.getSignatureQualifier(returnTypeSignature), 
            Signature.getSignatureSimpleName(returnTypeSignature), 
            proposal.getName(), 
            proposal.getFlags(), 
            correctionStart, 
            correctionEnd);
        }
        break;
      case 8: 
        if ((filter & 0x5) != 0)
        {
          char[] packageName = proposal.getDeclarationSignature();
          correctionRequestor.acceptPackage(
            packageName, 
            CharOperation.subarray(packageName, prefixLength, packageName.length), 
            correctionStart, 
            correctionEnd);
        }
        break;
      }
    }
  };
  
  /* Error */
  private void correct(char[] argument)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 147	org/eclipse/wst/jsdt/core/CorrectionEngine:compilationUnit	Lorg/eclipse/wst/jsdt/core/IJavaScriptUnit;
    //   4: invokeinterface 164 1 0
    //   9: astore_2
    //   10: new 168	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner
    //   13: dup
    //   14: invokespecial 170	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:<init>	()V
    //   17: astore_3
    //   18: aload_3
    //   19: aload_2
    //   20: invokevirtual 151	java/lang/String:toCharArray	()[C
    //   23: invokevirtual 171	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:setSource	([C)V
    //   26: aload_3
    //   27: aload_0
    //   28: getfield 143	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionStart	I
    //   31: aload_0
    //   32: getfield 145	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionEnd	I
    //   35: invokevirtual 174	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:resetTo	(II)V
    //   38: iconst_0
    //   39: istore 4
    //   41: getstatic 178	org/eclipse/wst/jsdt/core/compiler/CharOperation:NO_CHAR	[C
    //   44: astore 5
    //   46: aload_3
    //   47: invokevirtual 184	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:getNextToken	()I
    //   50: istore 4
    //   52: iload 4
    //   54: bipush 70
    //   56: if_icmpne +4 -> 60
    //   59: return
    //   60: aload_3
    //   61: invokevirtual 187	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:getCurrentTokenSource	()[C
    //   64: astore 6
    //   66: aload 5
    //   68: aload 6
    //   70: invokestatic 190	org/eclipse/wst/jsdt/core/compiler/CharOperation:concat	([C[C)[C
    //   73: astore 5
    //   75: aload 5
    //   77: aload_1
    //   78: invokestatic 194	org/eclipse/wst/jsdt/core/compiler/CharOperation:prefixEquals	([C[C)Z
    //   81: ifne +4 -> 85
    //   84: return
    //   85: aload_1
    //   86: aload 5
    //   88: invokestatic 198	org/eclipse/wst/jsdt/core/compiler/CharOperation:equals	([C[C)Z
    //   91: ifeq -45 -> 46
    //   94: aload_0
    //   95: aload_3
    //   96: getfield 201	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:startPosition	I
    //   99: putfield 143	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionStart	I
    //   102: aload_0
    //   103: aload_3
    //   104: getfield 204	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:currentPosition	I
    //   107: putfield 145	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionEnd	I
    //   110: aload_0
    //   111: bipush 46
    //   113: aload_1
    //   114: invokestatic 207	org/eclipse/wst/jsdt/core/compiler/CharOperation:lastIndexOf	(C[C)I
    //   117: iconst_1
    //   118: iadd
    //   119: putfield 211	org/eclipse/wst/jsdt/core/CorrectionEngine:prefixLength	I
    //   122: aload_0
    //   123: getfield 143	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionStart	I
    //   126: istore 6
    //   128: aload_3
    //   129: iload 6
    //   131: aload_0
    //   132: getfield 145	org/eclipse/wst/jsdt/core/CorrectionEngine:correctionEnd	I
    //   135: invokevirtual 174	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:resetTo	(II)V
    //   138: iload 6
    //   140: istore 7
    //   142: iconst_0
    //   143: istore 8
    //   145: goto +23 -> 168
    //   148: aload_3
    //   149: invokevirtual 213	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:getNextCharAsJavaIdentifierPart	()Z
    //   152: ifeq +22 -> 174
    //   155: iload 7
    //   157: istore 6
    //   159: aload_3
    //   160: getfield 204	org/eclipse/wst/jsdt/internal/compiler/parser/Scanner:currentPosition	I
    //   163: istore 7
    //   165: iinc 8 1
    //   168: iload 8
    //   170: iconst_4
    //   171: if_icmplt -23 -> 148
    //   174: invokestatic 217	org/eclipse/wst/jsdt/core/JavaScriptCore:getOptions	()Ljava/util/Hashtable;
    //   177: astore 8
    //   179: new 221	java/util/Hashtable
    //   182: dup
    //   183: aload 8
    //   185: invokespecial 223	java/util/Hashtable:<init>	(Ljava/util/Map;)V
    //   188: astore 9
    //   190: aload 9
    //   192: ldc -31
    //   194: ldc -29
    //   196: invokevirtual 229	java/util/Hashtable:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   199: pop
    //   200: aload 9
    //   202: invokestatic 233	org/eclipse/wst/jsdt/core/JavaScriptCore:setOptions	(Ljava/util/Hashtable;)V
    //   205: aload_0
    //   206: getfield 147	org/eclipse/wst/jsdt/core/CorrectionEngine:compilationUnit	Lorg/eclipse/wst/jsdt/core/IJavaScriptUnit;
    //   209: iload 6
    //   211: aload_0
    //   212: getfield 40	org/eclipse/wst/jsdt/core/CorrectionEngine:completionRequestor	Lorg/eclipse/wst/jsdt/core/CompletionRequestor;
    //   215: invokeinterface 237 3 0
    //   220: goto +13 -> 233
    //   223: astore 10
    //   225: aload 8
    //   227: invokestatic 233	org/eclipse/wst/jsdt/core/JavaScriptCore:setOptions	(Ljava/util/Hashtable;)V
    //   230: aload 10
    //   232: athrow
    //   233: aload 8
    //   235: invokestatic 233	org/eclipse/wst/jsdt/core/JavaScriptCore:setOptions	(Ljava/util/Hashtable;)V
    //   238: goto +7 -> 245
    //   241: pop
    //   242: return
    //   243: pop
    //   244: return
    //   245: return
    // Line number table:
    //   Java source line #237	-> byte code offset #0
    //   Java source line #238	-> byte code offset #10
    //   Java source line #239	-> byte code offset #18
    //   Java source line #241	-> byte code offset #26
    //   Java source line #242	-> byte code offset #38
    //   Java source line #243	-> byte code offset #41
    //   Java source line #247	-> byte code offset #46
    //   Java source line #248	-> byte code offset #52
    //   Java source line #250	-> byte code offset #60
    //   Java source line #252	-> byte code offset #66
    //   Java source line #253	-> byte code offset #75
    //   Java source line #254	-> byte code offset #84
    //   Java source line #256	-> byte code offset #85
    //   Java source line #257	-> byte code offset #94
    //   Java source line #258	-> byte code offset #102
    //   Java source line #259	-> byte code offset #110
    //   Java source line #266	-> byte code offset #122
    //   Java source line #267	-> byte code offset #128
    //   Java source line #268	-> byte code offset #138
    //   Java source line #270	-> byte code offset #142
    //   Java source line #271	-> byte code offset #148
    //   Java source line #272	-> byte code offset #155
    //   Java source line #273	-> byte code offset #159
    //   Java source line #270	-> byte code offset #165
    //   Java source line #278	-> byte code offset #174
    //   Java source line #280	-> byte code offset #179
    //   Java source line #281	-> byte code offset #190
    //   Java source line #282	-> byte code offset #200
    //   Java source line #284	-> byte code offset #205
    //   Java source line #285	-> byte code offset #209
    //   Java source line #286	-> byte code offset #211
    //   Java source line #284	-> byte code offset #215
    //   Java source line #288	-> byte code offset #223
    //   Java source line #289	-> byte code offset #225
    //   Java source line #290	-> byte code offset #230
    //   Java source line #289	-> byte code offset #233
    //   Java source line #291	-> byte code offset #241
    //   Java source line #292	-> byte code offset #242
    //   Java source line #293	-> byte code offset #243
    //   Java source line #294	-> byte code offset #244
    //   Java source line #296	-> byte code offset #245
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	246	0	this	CorrectionEngine
    //   0	246	1	argument	char[]
    //   9	11	2	source	String
    //   17	143	3	scanner	org.eclipse.wst.jsdt.internal.compiler.parser.Scanner
    //   39	14	4	token	int
    //   44	43	5	argumentSource	char[]
    //   64	5	6	tokenSource	char[]
    //   126	84	6	completionPosition	int
    //   140	24	7	position	int
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd