Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 95-101
Link Here
|
95 |
public org.eclipse.jdt.internal.compiler.ast.ASTNode get(Binding binding); |
95 |
public org.eclipse.jdt.internal.compiler.ast.ASTNode get(Binding binding); |
96 |
} |
96 |
} |
97 |
|
97 |
|
98 |
private static final String ARGUMENTS_DELIMITER = "#"; //$NON-NLS-1$ |
98 |
private static final char ARGUMENTS_DELIMITER = '#'; |
99 |
|
99 |
|
100 |
private static final String EMPTY_ARGUMENT = " "; //$NON-NLS-1$ |
100 |
private static final String EMPTY_ARGUMENT = " "; //$NON-NLS-1$ |
101 |
|
101 |
|
Lines 1058-1064
Link Here
|
1058 |
if(arguments[j].length() == 0) { |
1058 |
if(arguments[j].length() == 0) { |
1059 |
args.append(EMPTY_ARGUMENT); |
1059 |
args.append(EMPTY_ARGUMENT); |
1060 |
} else { |
1060 |
} else { |
1061 |
args.append(arguments[j]); |
1061 |
encodeArgument(arguments[j], args); |
1062 |
} |
1062 |
} |
1063 |
} |
1063 |
} |
1064 |
|
1064 |
|
Lines 1066-1081
Link Here
|
1066 |
} |
1066 |
} |
1067 |
|
1067 |
|
1068 |
/** |
1068 |
/** |
|
|
1069 |
* Encode the argument by doubling the '#' if present into the argument value. |
1070 |
* |
1071 |
* <p>This stores the encoded argument into the given buffer.</p> |
1072 |
* |
1073 |
* @param argument the given argument |
1074 |
* @param buffer the buffer in which the encoded argument is stored |
1075 |
*/ |
1076 |
private static void encodeArgument(String argument, StringBuffer buffer) { |
1077 |
for (int i = 0, max = argument.length(); i < max; i++) { |
1078 |
char charAt = argument.charAt(i); |
1079 |
switch(charAt) { |
1080 |
case ARGUMENTS_DELIMITER : |
1081 |
buffer.append(ARGUMENTS_DELIMITER).append(ARGUMENTS_DELIMITER); |
1082 |
break; |
1083 |
default: |
1084 |
buffer.append(charAt); |
1085 |
} |
1086 |
} |
1087 |
} |
1088 |
|
1089 |
/** |
1069 |
* Separate all the arguments of a String made by getProblemArgumentsForMarker |
1090 |
* Separate all the arguments of a String made by getProblemArgumentsForMarker |
1070 |
*/ |
1091 |
*/ |
1071 |
public static String[] getProblemArgumentsFromMarker(String argumentsString){ |
1092 |
public static String[] getProblemArgumentsFromMarker(String argumentsString){ |
1072 |
if (argumentsString == null) return null; |
1093 |
if (argumentsString == null) { |
|
|
1094 |
return null; |
1095 |
} |
1073 |
int index = argumentsString.indexOf(':'); |
1096 |
int index = argumentsString.indexOf(':'); |
1074 |
if(index == -1) |
1097 |
if(index == -1) |
1075 |
return null; |
1098 |
return null; |
1076 |
|
1099 |
|
1077 |
int length = argumentsString.length(); |
1100 |
int length = argumentsString.length(); |
1078 |
int numberOfArg; |
1101 |
int numberOfArg = 0; |
1079 |
try{ |
1102 |
try{ |
1080 |
numberOfArg = Integer.parseInt(argumentsString.substring(0 , index)); |
1103 |
numberOfArg = Integer.parseInt(argumentsString.substring(0 , index)); |
1081 |
} catch (NumberFormatException e) { |
1104 |
} catch (NumberFormatException e) { |
Lines 1083-1104
Link Here
|
1083 |
} |
1106 |
} |
1084 |
argumentsString = argumentsString.substring(index + 1, length); |
1107 |
argumentsString = argumentsString.substring(index + 1, length); |
1085 |
|
1108 |
|
1086 |
String[] args = new String[length]; |
1109 |
return decodeArgumentString(numberOfArg, argumentsString); |
1087 |
int count = 0; |
1110 |
} |
1088 |
|
1111 |
|
1089 |
StringTokenizer tokenizer = new StringTokenizer(argumentsString, ARGUMENTS_DELIMITER); |
1112 |
private static String[] decodeArgumentString(int length, String argumentsString) { |
1090 |
while(tokenizer.hasMoreTokens()) { |
1113 |
// decode the argumentString knowing that '#' is doubled if part of the argument value |
1091 |
String argument = tokenizer.nextToken(); |
1114 |
if (length == 0) { |
1092 |
if(argument.equals(EMPTY_ARGUMENT)) |
1115 |
if (argumentsString.length() != 0) { |
1093 |
argument = ""; //$NON-NLS-1$ |
1116 |
return null; |
1094 |
args[count++] = argument; |
1117 |
} |
|
|
1118 |
return CharOperation.NO_STRINGS; |
1095 |
} |
1119 |
} |
1096 |
|
1120 |
String[] result = new String[length]; |
1097 |
if(count != numberOfArg) |
1121 |
int count = 0; |
|
|
1122 |
StringBuffer buffer = new StringBuffer(); |
1123 |
for (int i = 0, max = argumentsString.length(); i < max; i++) { |
1124 |
char current = argumentsString.charAt(i); |
1125 |
switch(current) { |
1126 |
case ARGUMENTS_DELIMITER : |
1127 |
/* check the next character. If this is also ARGUMENTS_DELIMITER then only put one into the |
1128 |
* decoded argument and proceed with the next character |
1129 |
*/ |
1130 |
if ((i + 1) == max) { |
1131 |
return null; |
1132 |
} |
1133 |
char next = argumentsString.charAt(i + 1); |
1134 |
if (next == ARGUMENTS_DELIMITER) { |
1135 |
buffer.append(ARGUMENTS_DELIMITER); |
1136 |
i++; // proceed with the next character |
1137 |
} else { |
1138 |
// this means the current argument is over |
1139 |
String currentArgumentContents = String.valueOf(buffer); |
1140 |
if (EMPTY_ARGUMENT.equals(currentArgumentContents)) { |
1141 |
currentArgumentContents = org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING; |
1142 |
} |
1143 |
result[count++] = currentArgumentContents; |
1144 |
if (count > length) { |
1145 |
// too many elements - ill-formed |
1146 |
return null; |
1147 |
} |
1148 |
buffer.delete(0, buffer.length()); |
1149 |
} |
1150 |
break; |
1151 |
default : |
1152 |
buffer.append(current); |
1153 |
} |
1154 |
} |
1155 |
// process last argument |
1156 |
String currentArgumentContents = String.valueOf(buffer); |
1157 |
if (EMPTY_ARGUMENT.equals(currentArgumentContents)) { |
1158 |
currentArgumentContents = org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING; |
1159 |
} |
1160 |
result[count++] = currentArgumentContents; |
1161 |
if (count > length) { |
1162 |
// too many elements - ill-formed |
1098 |
return null; |
1163 |
return null; |
1099 |
|
1164 |
} |
1100 |
System.arraycopy(args, 0, args = new String[count], 0, count); |
1165 |
buffer.delete(0, buffer.length()); |
1101 |
return args; |
1166 |
return result; |
1102 |
} |
1167 |
} |
1103 |
|
1168 |
|
1104 |
/** |
1169 |
/** |
Lines 1382-1388
Link Here
|
1382 |
|
1447 |
|
1383 |
} |
1448 |
} |
1384 |
} else { |
1449 |
} else { |
1385 |
parameterSignatures = new String[0]; |
1450 |
parameterSignatures = CharOperation.NO_STRINGS; |
1386 |
} |
1451 |
} |
1387 |
return (JavaElement) declaringType.getMethod(String.valueOf(methodDeclaration.selector), parameterSignatures); |
1452 |
return (JavaElement) declaringType.getMethod(String.valueOf(methodDeclaration.selector), parameterSignatures); |
1388 |
} |
1453 |
} |