1.1 --- a/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlMethodAnnotationUtil.java Wed May 15 16:06:28 2013 +0200
1.2 +++ b/PLSQL/Annotation/src/org/netbeans/modules/plsql/annotation/PlsqlMethodAnnotationUtil.java Wed May 15 16:07:35 2013 +0200
1.3 @@ -66,504 +66,519 @@
1.4 */
1.5 public class PlsqlMethodAnnotationUtil {
1.6
1.7 - static int hasReturn = 0;
1.8 - private static final int HAS_RETURNS = 1;
1.9 - private static final int NO_RETURNS = 2;
1.10 - private static Comparator<PlsqlBlock> comparator = new Comparator<PlsqlBlock>() {
1.11 - @Override
1.12 - public int compare(PlsqlBlock o1, PlsqlBlock o2) {
1.13 - Integer o1pos, o2pos;
1.14 - if (o1.getStartOffset() > -1 && o2.getStartOffset() > -1) {
1.15 - o1pos = new Integer(o1.getStartOffset());
1.16 - o2pos = new Integer(o2.getStartOffset());
1.17 - } else {
1.18 - o1pos = new Integer(o1.getEndOffset());
1.19 - o2pos = new Integer(o2.getEndOffset());
1.20 - }
1.21 - return o1pos.compareTo(o2pos);
1.22 - }
1.23 - };
1.24 + static int hasReturn = 0;
1.25 + private static final int HAS_RETURNS = 1;
1.26 + private static final int NO_RETURNS = 2;
1.27 + private static Comparator<PlsqlBlock> comparator = new Comparator<PlsqlBlock>() {
1.28 + @Override
1.29 + public int compare(PlsqlBlock o1, PlsqlBlock o2) {
1.30 + Integer o1pos, o2pos;
1.31 + if (o1.getStartOffset() > -1 && o2.getStartOffset() > -1) {
1.32 + o1pos = new Integer(o1.getStartOffset());
1.33 + o2pos = new Integer(o2.getStartOffset());
1.34 + } else {
1.35 + o1pos = new Integer(o1.getEndOffset());
1.36 + o2pos = new Integer(o2.getEndOffset());
1.37 + }
1.38 + return o1pos.compareTo(o2pos);
1.39 + }
1.40 + };
1.41
1.42 - public static int getOffsetToInsert(final Document doc, final int startOffset, final int endOffset) {
1.43 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.44 - @SuppressWarnings("unchecked")
1.45 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.46 - int offset = -1;
1.47 + public static int getOffsetToInsert(final Document doc, final int startOffset, final int endOffset) {
1.48 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.49 + @SuppressWarnings("unchecked")
1.50 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.51 + int offset = -1;
1.52
1.53 - if (ts != null) {
1.54 - ts.move(startOffset);
1.55 - Token<PlsqlTokenId> token = ts.token();
1.56 - while (ts.moveNext() && ts.offset() < endOffset) {
1.57 - token = ts.token();
1.58 - if ((token.id() == PlsqlTokenId.KEYWORD)
1.59 - && (token.text().toString().equalsIgnoreCase("BEGIN"))) {
1.60 - if (ts.moveNext()) {
1.61 - offset = ts.offset();
1.62 - }
1.63 - break;
1.64 + if (ts != null) {
1.65 + ts.move(startOffset);
1.66 + Token<PlsqlTokenId> token = ts.token();
1.67 + while (ts.moveNext() && ts.offset() < endOffset) {
1.68 + token = ts.token();
1.69 + if ((token.id() == PlsqlTokenId.KEYWORD)
1.70 + && (token.text().toString().equalsIgnoreCase("BEGIN"))) {
1.71 + if (ts.moveNext()) {
1.72 + offset = ts.offset();
1.73 + }
1.74 + break;
1.75 + }
1.76 }
1.77 - }
1.78 - }
1.79 - return offset;
1.80 - }
1.81 + }
1.82 + return offset;
1.83 + }
1.84
1.85 - public static PlsqlBlock findMatchingMethod(final List<PlsqlBlock> blockHier, final Document source,
1.86 - final Document dest, final PlsqlBlock sourceBlock) {
1.87 - PlsqlBlock match = null;
1.88 - final List<PlsqlBlock> matchList = new ArrayList<PlsqlBlock>();
1.89 - PlsqlParserUtil.findMatchingDefBlocks(blockHier, sourceBlock.getName(), matchList);
1.90 + public static PlsqlBlock findMatchingMethod(final List<PlsqlBlock> blockHier, final Document source,
1.91 + final Document dest, final PlsqlBlock sourceBlock) {
1.92 + PlsqlBlock match = null;
1.93 + final List<PlsqlBlock> matchList = new ArrayList<PlsqlBlock>();
1.94 + PlsqlParserUtil.findMatchingDefBlocks(blockHier, sourceBlock.getName(), matchList);
1.95
1.96 - //There are several methods with the same name. Have to check the signature
1.97 - final List<String> usageParams = PlsqlParserUtil.fetchMethodDefParamTypes(source, sourceBlock.getStartOffset());
1.98 + //There are several methods with the same name. Have to check the signature
1.99 + final List<String> usageParams = PlsqlParserUtil.fetchMethodDefParamTypes(source, sourceBlock.getStartOffset());
1.100
1.101 - //Take PlsqlBlock one by one and compare the parameters
1.102 - for (int x = 0; x < matchList.size(); x++) {
1.103 - final PlsqlBlock block = matchList.get(x);
1.104 - if (!(block.getParent() != null && sourceBlock.getParent() != null ? block.getParent().getName().equalsIgnoreCase(sourceBlock.getParent().getName()) : true)) {
1.105 - continue; //If the parent block name is not the same this is not a match
1.106 - }
1.107 -
1.108 - final List<String> params = PlsqlParserUtil.fetchMethodDefParamTypes(dest, block.getStartOffset());
1.109 - final int defaultNo = PlsqlParserUtil.fetchDefaultParams(dest, block.getStartOffset());
1.110 - if (PlsqlParserUtil.compareParameters(usageParams, params, defaultNo)) {
1.111 - match = block;
1.112 - break;
1.113 - }
1.114 - }
1.115 -
1.116 - return match;
1.117 - }
1.118 -
1.119 - public static String getMethodSpecification(final Document doc, final PlsqlBlock block) {
1.120 - String methodSpec = "";
1.121 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.122 - @SuppressWarnings("unchecked")
1.123 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.124 -
1.125 - if (ts != null) {
1.126 - ts.move(block.getStartOffset());
1.127 - Token<PlsqlTokenId> token = ts.token();
1.128 - while (ts.moveNext() && block.getEndOffset() > ts.offset()) {
1.129 - token = ts.token();
1.130 - if (token.text().toString().equalsIgnoreCase("IS")) {
1.131 - break;
1.132 - }
1.133 - methodSpec = methodSpec + token.toString();
1.134 - }
1.135 - }
1.136 - return methodSpec.trim();
1.137 - }
1.138 -
1.139 - public static PlsqlBlock findMethod(final List<PlsqlBlock> specBlockHier, final String packageName, final String methodName) {
1.140 - PlsqlBlock match = null;
1.141 - if (!packageName.equals("")) {
1.142 - PlsqlBlock packageBlock = getPackageBody(specBlockHier, PlsqlBlockType.PACKAGE_BODY, packageName);
1.143 - if (packageBlock != null) {
1.144 - for (int i = 0; i < packageBlock.getChildCount(); i++) {
1.145 - final PlsqlBlock temp = packageBlock.getChildBlocks().get(i);
1.146 - if (temp.getName().equals(methodName)) {
1.147 - match = temp;
1.148 - break;
1.149 - }
1.150 - }
1.151 - }
1.152 - }
1.153 - return match;
1.154 - }
1.155 -
1.156 - public static PlsqlBlock getPackageBody(final List<PlsqlBlock> specBlockHier, final PlsqlBlockType blockType, final String packageName) {
1.157 - PlsqlBlock packageBlock = null;
1.158 - for (int i = 0; i < specBlockHier.size(); i++) {
1.159 - final PlsqlBlock temp = specBlockHier.get(i);
1.160 - if (temp.getType() == blockType && temp.getName().equalsIgnoreCase(packageName)) {
1.161 - packageBlock = temp;
1.162 - break;
1.163 - }
1.164 - }
1.165 - return packageBlock;
1.166 - }
1.167 -
1.168 - public static int getOffsetToInsert(final Document doc, final List<PlsqlBlock> specBlockHier, final String packageName, final PlsqlBlock searchBlock, final int searchPlace) throws BadLocationException {
1.169 - int offset = -1;
1.170 - //Get package block
1.171 - if (!packageName.equals("")) {
1.172 - PlsqlBlock packageBlock = getPackageBody(specBlockHier, PlsqlBlockType.PACKAGE, packageName);
1.173 -
1.174 - if (packageBlock != null) {
1.175 - for (int i = 0; i < packageBlock.getChildCount(); i++) {
1.176 - final PlsqlBlock temp = packageBlock.getChildBlocks().get(i);
1.177 - if (!temp.getType().equals(PlsqlBlockType.COMMENT) && (temp.getType().equals(PlsqlBlockType.FUNCTION_DEF) || temp.getType().equals(PlsqlBlockType.PROCEDURE_DEF))) {
1.178 - if (temp.getName().contains(searchBlock.getName())) {
1.179 - if (searchPlace == -1) {
1.180 - offset = temp.getStartOffset();
1.181 - } else {
1.182 - offset = packageBlock.getChildBlocks().get(i + 1).getStartOffset() - 1;
1.183 - }
1.184 - break;
1.185 - }
1.186 - } else if (temp.getType().equals(PlsqlBlockType.COMMENT) && searchBlock.getType().equals(PlsqlBlockType.COMMENT)) {
1.187 -
1.188 - //Get block content and check; comments can be merged to one comment block
1.189 - final String text = doc.getText(temp.getStartOffset(), temp.getEndOffset() - temp.getStartOffset());
1.190 - int index = text.indexOf(searchBlock.getName());
1.191 - if (index != -1) {
1.192 - index = text.indexOf("\n", index);
1.193 - if (index != -1) {
1.194 - index = text.indexOf("\n", index + 1);
1.195 - if (index != -1) {
1.196 - offset = temp.getStartOffset() + index;
1.197 - } else {
1.198 - offset = temp.getEndOffset();
1.199 - }
1.200 -
1.201 - break;
1.202 - }
1.203 - }
1.204 - }
1.205 + //Take PlsqlBlock one by one and compare the parameters
1.206 + for (int x = 0; x < matchList.size(); x++) {
1.207 + final PlsqlBlock block = matchList.get(x);
1.208 + if (!(block.getParent() != null && sourceBlock.getParent() != null ? block.getParent().getName().equalsIgnoreCase(sourceBlock.getParent().getName()) : true)) {
1.209 + continue; //If the parent block name is not the same this is not a match
1.210 }
1.211
1.212 - //If the comment is not found insert some where
1.213 - if (offset == -1) {
1.214 - offset = packageBlock.getChildBlocks().get(0).getEndOffset();
1.215 + final List<String> params = PlsqlParserUtil.fetchMethodDefParamTypes(dest, block.getStartOffset());
1.216 + final int defaultNo = PlsqlParserUtil.fetchDefaultParams(dest, block.getStartOffset());
1.217 + if (PlsqlParserUtil.compareParameters(usageParams, params, defaultNo)) {
1.218 + match = block;
1.219 + break;
1.220 }
1.221 - }
1.222 - }
1.223 + }
1.224
1.225 - return offset;
1.226 - }
1.227 + return match;
1.228 + }
1.229
1.230 - public static boolean changeParam(final Document doc, final int offset, final String methodName) {
1.231 - if (PlsqlAnnotationUtil.isFileReadOnly(doc)) {
1.232 - JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "File is read-only", "Error", JOptionPane.ERROR_MESSAGE);
1.233 - return false;
1.234 - }
1.235 + public static String getMethodSpecification(final Document doc, final PlsqlBlock block) {
1.236 + String methodSpec = "";
1.237 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.238 + @SuppressWarnings("unchecked")
1.239 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.240
1.241 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.242 - @SuppressWarnings("unchecked")
1.243 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.244 + if (ts != null) {
1.245 + ts.move(block.getStartOffset());
1.246 + Token<PlsqlTokenId> token = ts.token();
1.247 + while (ts.moveNext() && block.getEndOffset() > ts.offset()) {
1.248 + token = ts.token();
1.249 + if (token.text().toString().equalsIgnoreCase("IS")) {
1.250 + break;
1.251 + }
1.252 + methodSpec = methodSpec + token.toString();
1.253 + }
1.254 + }
1.255 + return methodSpec.trim();
1.256 + }
1.257
1.258 - if (ts != null) {
1.259 - ts.move(offset);
1.260 - ts.movePrevious();
1.261 - Token<PlsqlTokenId> token = ts.token();
1.262 - while (token.id() == PlsqlTokenId.WHITESPACE && ts.movePrevious()) {
1.263 + public static PlsqlBlock findMethod(final List<PlsqlBlock> specBlockHier, final String packageName, final String methodName) {
1.264 + PlsqlBlock match = null;
1.265 + if (!packageName.equals("")) {
1.266 + PlsqlBlock packageBlock = getPackageBody(specBlockHier, PlsqlBlockType.PACKAGE_BODY, packageName);
1.267 + if (packageBlock != null) {
1.268 + for (int i = 0; i < packageBlock.getChildCount(); i++) {
1.269 + final PlsqlBlock temp = packageBlock.getChildBlocks().get(i);
1.270 + if (temp.getName().equals(methodName)) {
1.271 + match = temp;
1.272 + break;
1.273 + }
1.274 + }
1.275 + }
1.276 + }
1.277 + return match;
1.278 + }
1.279 +
1.280 + public static PlsqlBlock getPackageBody(final List<PlsqlBlock> specBlockHier, final PlsqlBlockType blockType, final String packageName) {
1.281 + PlsqlBlock packageBlock = null;
1.282 + for (int i = 0; i < specBlockHier.size(); i++) {
1.283 + final PlsqlBlock temp = specBlockHier.get(i);
1.284 + if (temp.getType() == blockType && temp.getName().equalsIgnoreCase(packageName)) {
1.285 + packageBlock = temp;
1.286 + break;
1.287 + }
1.288 + }
1.289 + return packageBlock;
1.290 + }
1.291 +
1.292 + public static int getOffsetToInsert(final Document doc, final List<PlsqlBlock> specBlockHier, final String packageName, final PlsqlBlock searchBlock, final int searchPlace) throws BadLocationException {
1.293 + int offset = -1;
1.294 + //Get package block
1.295 + if (!packageName.equals("")) {
1.296 + PlsqlBlock packageBlock = getPackageBody(specBlockHier, PlsqlBlockType.PACKAGE, packageName);
1.297 +
1.298 + if (packageBlock != null) {
1.299 + for (int i = 0; i < packageBlock.getChildCount(); i++) {
1.300 + final PlsqlBlock temp = packageBlock.getChildBlocks().get(i);
1.301 + if (!temp.getType().equals(PlsqlBlockType.COMMENT) && (temp.getType().equals(PlsqlBlockType.FUNCTION_DEF) || temp.getType().equals(PlsqlBlockType.PROCEDURE_DEF))) {
1.302 + if (temp.getName().contains(searchBlock.getName())) {
1.303 + if (searchPlace == -1) {
1.304 + offset = temp.getStartOffset();
1.305 + } else {
1.306 + offset = packageBlock.getChildBlocks().get(i + 1).getStartOffset() - 1;
1.307 + }
1.308 + break;
1.309 + }
1.310 + } else if (temp.getType().equals(PlsqlBlockType.COMMENT) && searchBlock.getType().equals(PlsqlBlockType.COMMENT)) {
1.311 +
1.312 + //Get block content and check; comments can be merged to one comment block
1.313 + final String text = doc.getText(temp.getStartOffset(), temp.getEndOffset() - temp.getStartOffset());
1.314 + int index = text.indexOf(searchBlock.getName());
1.315 + if (index != -1) {
1.316 + index = text.indexOf("\n", index);
1.317 + if (index != -1) {
1.318 + index = text.indexOf("\n", index + 1);
1.319 + if (index != -1) {
1.320 + offset = temp.getStartOffset() + index;
1.321 + } else {
1.322 + offset = temp.getEndOffset();
1.323 + }
1.324 +
1.325 + break;
1.326 + }
1.327 + }
1.328 + }
1.329 + }
1.330 +
1.331 + //If the comment is not found insert some where
1.332 + if (offset == -1) {
1.333 + offset = packageBlock.getChildBlocks().get(0).getEndOffset();
1.334 + }
1.335 + }
1.336 + }
1.337 +
1.338 + return offset;
1.339 + }
1.340 +
1.341 + public static boolean changeParam(final Document doc, final int offset, final String methodName) {
1.342 + if (PlsqlAnnotationUtil.isFileReadOnly(doc)) {
1.343 + JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "File is read-only", "Error", JOptionPane.ERROR_MESSAGE);
1.344 + return false;
1.345 + }
1.346 +
1.347 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.348 + @SuppressWarnings("unchecked")
1.349 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.350 +
1.351 + if (ts != null) {
1.352 + ts.move(offset);
1.353 + ts.movePrevious();
1.354 + Token<PlsqlTokenId> token = ts.token();
1.355 + while (token.id() == PlsqlTokenId.WHITESPACE && ts.movePrevious()) {
1.356 + token = ts.token();
1.357 + }
1.358 + //We have the token now
1.359 + if (PlsqlFileAnnotationUtil.changeLineOfOffset(doc, ts.offset(), token.toString(), "'" + methodName + "'")) {
1.360 + return true;
1.361 + }
1.362 + }
1.363 + return false;
1.364 + }
1.365 +
1.366 + public static int isReturnExist(final Document doc, final PlsqlBlock block) {
1.367 + hasReturn = 0;
1.368 + boolean isMissing = isReturn(doc, block);
1.369 +
1.370 + if (!isMissing) {
1.371 + if (hasReturn == HAS_RETURNS) {
1.372 + return HAS_RETURNS;
1.373 + } else {
1.374 + return NO_RETURNS;
1.375 + }
1.376 + } else {
1.377 + return 0;
1.378 + }
1.379 + }
1.380 +
1.381 + public static boolean isReturn(final Document doc, final PlsqlBlock block) {
1.382 + boolean isReturn = false;
1.383 + final List<PlsqlBlock> children = block.getChildBlocks();
1.384 + Collections.sort(children, comparator);
1.385 +
1.386 + int startOffset = findBlockImplStart(doc, block);
1.387 + for (PlsqlBlock child : children) {
1.388 + if (child.getType() != PlsqlBlockType.CURSOR
1.389 + && child.getType() != PlsqlBlockType.CUSTOM_FOLD
1.390 + && startOffset < child.getStartOffset()) {
1.391 + if (!isReturnMissing(startOffset, child.getStartOffset(), doc, true)) {
1.392 + isReturn = true;
1.393 + break;
1.394 + }
1.395 + }
1.396 + startOffset = child.getEndOffset();
1.397 + }
1.398 +
1.399 + if (!isReturn) {
1.400 + isReturn = checkReturnInChildren(children, doc);
1.401 + }
1.402 +
1.403 + //Return not complete in child blocks, check for default return at the end
1.404 + //check for exception block, it is assumed that there will be no child blocks after EXCEPTION
1.405 + if (children.size() > 0) {
1.406 + startOffset = children.get(children.size() - 1).getEndOffset();
1.407 + }
1.408 +
1.409 + isReturn = !isReturnMissing(startOffset, block.getEndOffset(), doc, !isReturn);
1.410 +
1.411 + return isReturn;
1.412 + }
1.413 +
1.414 + private static int checkExceptionBlock(final Document doc, final PlsqlBlock block) {
1.415 +
1.416 + int startOffset = findBlockImplStart(doc, block);
1.417 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.418 + @SuppressWarnings("unchecked")
1.419 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.420 +
1.421 + if (ts != null) {
1.422 + ts.move(startOffset);
1.423 + Token<PlsqlTokenId> token = ts.token();
1.424 + while (ts.moveNext() && ts.offset() < block.getEndOffset()) {
1.425 + token = ts.token();
1.426 + if (token.toString().equalsIgnoreCase("EXCEPTION")) {
1.427 + return ts.offset();
1.428 + }
1.429 + }
1.430 + }
1.431 + return 0;
1.432 + }
1.433 +
1.434 + private static boolean checkReturnInChildren(final List<PlsqlBlock> children, final Document doc) {
1.435 + boolean isConstrusctReturn = false;
1.436 +
1.437 + for (PlsqlBlock child : children) {
1.438 + if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("IF"))
1.439 + || (child.getType() == PlsqlBlockType.CASE && child.getName().toUpperCase(Locale.ENGLISH).startsWith("CASE"))) {
1.440 + isConstrusctReturn = false;
1.441 + isConstrusctReturn = isReturn(doc, child);
1.442 + } else if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("ELSIF"))
1.443 + || (child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("WHEN"))) {
1.444 + if (isConstrusctReturn) {
1.445 + isConstrusctReturn = isReturn(doc, child);
1.446 + }
1.447 + } else if ((child.getType() == PlsqlBlockType.IF || child.getType() == PlsqlBlockType.CASE)
1.448 + && child.getName().equalsIgnoreCase("ELSE")) {
1.449 + if (isConstrusctReturn) {
1.450 + isConstrusctReturn = isReturn(doc, child);
1.451 + //If is returning and else if also returning
1.452 + if (isConstrusctReturn) {
1.453 + return true;
1.454 + }
1.455 + }
1.456 + }
1.457 + }
1.458 +
1.459 + return false;
1.460 + }
1.461 +
1.462 + private static boolean isReturnMissing(final int startOffset, final int endOffset, final Document doc, boolean isReturnMissing) {
1.463 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.464 + @SuppressWarnings("unchecked")
1.465 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.466 +
1.467 + if (ts != null) {
1.468 + ts.move(startOffset);
1.469 + Token<PlsqlTokenId> token = ts.token();
1.470 + boolean isException = false;
1.471 +
1.472 + while (ts.moveNext() && ts.offset() < endOffset) {
1.473 + token = ts.token();
1.474 +
1.475 + if (token.toString().equalsIgnoreCase("RETURN")
1.476 + || token.toString().equalsIgnoreCase("RAISE")) {
1.477 + if (moveToReturnEnd(ts, endOffset)) {
1.478 + isReturnMissing = false;
1.479 + hasReturn = HAS_RETURNS;
1.480 + }
1.481 + } else if (token.toString().equalsIgnoreCase("ERROR_SYS")
1.482 + || token.toString().equalsIgnoreCase("APPLICATION_SEARCH_SYS")) {
1.483 + if (ts.moveNext()) {
1.484 + token = ts.token();
1.485 + if (token.id() == PlsqlTokenId.DOT) {
1.486 + if (ts.moveNext()) {
1.487 + token = ts.token();
1.488 + if (!token.toString().toLowerCase(Locale.ENGLISH).startsWith("check")) {
1.489 + if (moveToReturnEnd(ts, endOffset)) {
1.490 + isReturnMissing = false;
1.491 + hasReturn = HAS_RETURNS;
1.492 + }
1.493 + }
1.494 + }
1.495 + }
1.496 + }
1.497 + } else if (token.toString().equalsIgnoreCase("EXCEPTION")) {
1.498 + isException = true;
1.499 + } else if (token.toString().equalsIgnoreCase("WHEN") && isException) {
1.500 + if (!isReturnMissing) {
1.501 + if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) { //Exception name
1.502 + if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) {
1.503 + token = ts.token();
1.504 + if (token.toString().equalsIgnoreCase("THEN")) {
1.505 + isReturnMissing = true;
1.506 + }
1.507 + }
1.508 + }
1.509 + } else {
1.510 + //return missing in above WHEN
1.511 + break;
1.512 + }
1.513 + }
1.514 + }
1.515 + }
1.516 +
1.517 + return isReturnMissing;
1.518 + }
1.519 +
1.520 + public static boolean getUnreachableOffsets(final Document doc, final PlsqlBlock block, final List<Integer> lstUnreachable) throws BadLocationException {
1.521 + final List<PlsqlBlock> children = block.getChildBlocks();
1.522 + Collections.sort(children, comparator);
1.523 + boolean isConstrusctReturn = false;
1.524 + boolean isChildReturn = false;
1.525 + boolean isReturn = false;
1.526 + boolean isException = false;
1.527 + int startOffset = findBlockImplStart(doc, block);
1.528 + for (PlsqlBlock child : children) {
1.529 + if (child.getType() != PlsqlBlockType.CURSOR
1.530 + && child.getType() != PlsqlBlockType.CUSTOM_FOLD) {
1.531 + if (startOffset < child.getStartOffset()) {
1.532 + if (getUnreachableOffsets(startOffset, child.getStartOffset(), doc, lstUnreachable, isReturn, isException)) {
1.533 + isReturn = true;
1.534 + } else {
1.535 + isReturn = false;
1.536 + }
1.537 + }
1.538 +
1.539 + isChildReturn = getUnreachableOffsets(doc, child, lstUnreachable);
1.540 +
1.541 + if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("IF"))
1.542 + || (child.getType() == PlsqlBlockType.CASE && child.getName().toUpperCase(Locale.ENGLISH).startsWith("CASE"))) {
1.543 + isConstrusctReturn = isChildReturn;
1.544 + } else if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("ELSIF"))
1.545 + || (child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("WHEN"))) {
1.546 + if (isConstrusctReturn) {
1.547 + isConstrusctReturn = isChildReturn;
1.548 + }
1.549 + } else if ((child.getType() == PlsqlBlockType.IF || child.getType() == PlsqlBlockType.CASE)
1.550 + && child.getName().equalsIgnoreCase("ELSE")) {
1.551 + if (isConstrusctReturn) {
1.552 + isConstrusctReturn = isChildReturn;
1.553 + if (isConstrusctReturn) {
1.554 + isReturn = true;
1.555 + }
1.556 + }
1.557 + }
1.558 + }
1.559 + startOffset = child.getEndOffset();
1.560 + }
1.561 + if (checkExceptionBlock(doc, block) < startOffset) {
1.562 + isException = true;
1.563 + }
1.564 + isConstrusctReturn = getUnreachableOffsets(startOffset, block.getEndOffset(), doc, lstUnreachable, isReturn, isException);
1.565 + if (!isReturn) {
1.566 + isReturn = isConstrusctReturn;
1.567 + }
1.568 +
1.569 + return isReturn;
1.570 + }
1.571 +
1.572 + private static boolean getUnreachableOffsets(final int startOffset, final int endOffset, final Document doc, final List<Integer> lstUnreachable, boolean isReturn, boolean isException) throws BadLocationException {
1.573 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.574 + @SuppressWarnings("unchecked")
1.575 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.576 + int endLineCount = 0;
1.577 + String previous = null;
1.578 + if (ts != null) {
1.579 + ts.move(startOffset);
1.580 + Token<PlsqlTokenId> token = ts.token();
1.581 + boolean isRaised = false;
1.582 +
1.583 + while (ts.moveNext() && ts.offset() < endOffset) {
1.584 + token = ts.token();
1.585 +
1.586 + if (token.toString().equalsIgnoreCase("RETURN")) {
1.587 + if (moveToReturnEnd(ts, endOffset)) {
1.588 + isReturn = true;
1.589 + }
1.590 + } else if (token.toString().equalsIgnoreCase("RAISE")) {
1.591 + if (moveToReturnEnd(ts, endOffset)) {
1.592 + isRaised = true;
1.593 + }
1.594 + } else if (token.toString().equalsIgnoreCase("EXCEPTION")) {
1.595 + isException = true;
1.596 + isReturn = false;
1.597 + isRaised = false;
1.598 + } else if (token.toString().equalsIgnoreCase("WHEN") && isException) {
1.599 + isReturn = false;
1.600 + isRaised = false;
1.601 + if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) { //Exception name
1.602 + if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) {
1.603 + token = ts.token();
1.604 + if (token.toString().equalsIgnoreCase("THEN") || token.toString().equalsIgnoreCase("OR")) {
1.605 + isReturn = false;
1.606 + isRaised = false;
1.607 + endLineCount = 0;
1.608 + }
1.609 + }
1.610 + }
1.611 + } else if ((isReturn || isRaised) && token.toString().contains("\n")) {
1.612 + endLineCount++;
1.613 + } else if (endLineCount > 0 && token.toString().toUpperCase(Locale.ENGLISH).contains("END") || isRaised) {
1.614 + endLineCount = 0;
1.615 + } else if (endLineCount > 0 && token.toString().contains(";")) {
1.616 + lstUnreachable.add(ts.offset());
1.617 + }
1.618 +
1.619 + if (token.toString().contains(";") && (previous != null && previous.equals("END"))) {
1.620 + isException = false;
1.621 + isReturn = false;
1.622 + isRaised = false;
1.623 + }
1.624 +
1.625 + previous = token.toString();
1.626 + }
1.627 + }
1.628 + return isReturn;
1.629 + }
1.630 +
1.631 + private static int findBlockImplStart(final Document doc, final PlsqlBlock block) {
1.632 + int startOffset = block.getStartOffset();
1.633 + final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.634 + @SuppressWarnings("unchecked")
1.635 + final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.636 +
1.637 + if (ts != null) {
1.638 + ts.move(startOffset);
1.639 + Token<PlsqlTokenId> token = ts.token();
1.640 + while (ts.moveNext() && ts.offset() < block.getEndOffset()) {
1.641 + token = ts.token();
1.642 +
1.643 + if (token.toString().equalsIgnoreCase("BEGIN")) {
1.644 + startOffset = ts.offset();
1.645 + break;
1.646 + }
1.647 + }
1.648 + }
1.649 +
1.650 + return startOffset;
1.651 + }
1.652 +
1.653 + private static boolean moveToReturnEnd(final TokenSequence<PlsqlTokenId> ts, final int endOffset) {
1.654 + Token<PlsqlTokenId> token = ts.token();
1.655 + while (ts.moveNext() && ts.offset() < endOffset) {
1.656 token = ts.token();
1.657 - }
1.658 - //We have the token now
1.659 - if (PlsqlFileAnnotationUtil.changeLineOfOffset(doc, ts.offset(), token.toString(), "'" + methodName + "'")) {
1.660 - return true;
1.661 - }
1.662 - }
1.663 - return false;
1.664 - }
1.665 + if (token.toString().equals(";")) {
1.666 + return true;
1.667 + }
1.668 + }
1.669
1.670 - public static int isReturnExist(final Document doc, final PlsqlBlock block) {
1.671 - hasReturn = 0;
1.672 - boolean isMissing = isReturn(doc, block);
1.673 + return false;
1.674 + }
1.675
1.676 - if (!isMissing) {
1.677 - if (hasReturn == HAS_RETURNS) {
1.678 - return HAS_RETURNS;
1.679 - } else {
1.680 - return NO_RETURNS;
1.681 - }
1.682 - } else {
1.683 - return 0;
1.684 - }
1.685 - }
1.686 + public static PlsqlBlock findMatchingImpl(final List<PlsqlBlock> blockHier, final Document source,
1.687 + final Document dest, final PlsqlBlock sourceBlock) {
1.688 + PlsqlBlock match = null;
1.689 + final List<PlsqlBlock> matchList = new ArrayList<PlsqlBlock>();
1.690 + PlsqlParserUtil.findMatchingImplBlocks(blockHier, sourceBlock.getName(), matchList);
1.691
1.692 - public static boolean isReturn(final Document doc, final PlsqlBlock block) {
1.693 - boolean isReturn = false;
1.694 - final List<PlsqlBlock> children = block.getChildBlocks();
1.695 - Collections.sort(children, comparator);
1.696 + //There are several methods with the same name. Have to check the signature
1.697 + final List<String> usageParams = PlsqlParserUtil.fetchMethodDefParamTypes(source, sourceBlock.getStartOffset());
1.698
1.699 - int startOffset = findBlockImplStart(doc, block);
1.700 - for (PlsqlBlock child : children) {
1.701 - if (child.getType() != PlsqlBlockType.CURSOR
1.702 - && child.getType() != PlsqlBlockType.CUSTOM_FOLD
1.703 - && startOffset < child.getStartOffset()) {
1.704 - if (!isReturnMissing(startOffset, child.getStartOffset(), doc, true)) {
1.705 - isReturn = true;
1.706 - break;
1.707 + //Take PlsqlBlock one by one and compare the parameters
1.708 + for (int x = 0; x < matchList.size(); x++) {
1.709 + final PlsqlBlock block = matchList.get(x);
1.710 + if (!(block.getParent() != null && sourceBlock.getParent() != null ? block.getParent().getName().equals(sourceBlock.getParent().getName()) : true)) {
1.711 + continue; //If the parent block name is not the same this is not a match
1.712 }
1.713 - }
1.714 - startOffset = child.getEndOffset();
1.715 - }
1.716 + final List<String> params = PlsqlParserUtil.fetchMethodDefParamTypes(dest, block.getStartOffset());
1.717 + final int defaultNo = PlsqlParserUtil.fetchDefaultParams(dest, block.getStartOffset());
1.718 + if (PlsqlParserUtil.compareParameters(usageParams, params, defaultNo)) {
1.719 + match = block;
1.720 + break;
1.721 + }
1.722 + }
1.723
1.724 - if (!isReturn) {
1.725 - isReturn = checkReturnInChildren(children, doc);
1.726 - }
1.727 -
1.728 - //Return not complete in child blocks, check for default return at the end
1.729 - //check for exception block, it is assumed that there will be no child blocks after EXCEPTION
1.730 - if (children.size() > 0) {
1.731 - startOffset = children.get(children.size() - 1).getEndOffset();
1.732 - }
1.733 -
1.734 - isReturn = !isReturnMissing(startOffset, block.getEndOffset(), doc, !isReturn);
1.735 -
1.736 - return isReturn;
1.737 - }
1.738 -
1.739 - private static boolean checkReturnInChildren(final List<PlsqlBlock> children, final Document doc) {
1.740 - boolean isConstrusctReturn = false;
1.741 -
1.742 - for (PlsqlBlock child : children) {
1.743 - if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("IF"))
1.744 - || (child.getType() == PlsqlBlockType.CASE && child.getName().toUpperCase(Locale.ENGLISH).startsWith("CASE"))) {
1.745 - isConstrusctReturn = false;
1.746 - isConstrusctReturn = isReturn(doc, child);
1.747 - } else if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("ELSIF"))
1.748 - || (child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("WHEN"))) {
1.749 - if (isConstrusctReturn) {
1.750 - isConstrusctReturn = isReturn(doc, child);
1.751 - }
1.752 - } else if ((child.getType() == PlsqlBlockType.IF || child.getType() == PlsqlBlockType.CASE)
1.753 - && child.getName().equalsIgnoreCase("ELSE")) {
1.754 - if (isConstrusctReturn) {
1.755 - isConstrusctReturn = isReturn(doc, child);
1.756 - //If is returning and else if also returning
1.757 - if (isConstrusctReturn) {
1.758 - return true;
1.759 - }
1.760 - }
1.761 - }
1.762 - }
1.763 -
1.764 - return false;
1.765 - }
1.766 -
1.767 - private static boolean isReturnMissing(final int startOffset, final int endOffset, final Document doc, boolean isReturnMissing) {
1.768 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.769 - @SuppressWarnings("unchecked")
1.770 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.771 -
1.772 - if (ts != null) {
1.773 - ts.move(startOffset);
1.774 - Token<PlsqlTokenId> token = ts.token();
1.775 - boolean isException = false;
1.776 -
1.777 - while (ts.moveNext() && ts.offset() < endOffset) {
1.778 - token = ts.token();
1.779 -
1.780 - if (token.toString().equalsIgnoreCase("RETURN")
1.781 - || token.toString().equalsIgnoreCase("RAISE")) {
1.782 - if (moveToReturnEnd(ts, endOffset)) {
1.783 - isReturnMissing = false;
1.784 - hasReturn = HAS_RETURNS;
1.785 - }
1.786 - } else if (token.toString().equalsIgnoreCase("ERROR_SYS")
1.787 - || token.toString().equalsIgnoreCase("APPLICATION_SEARCH_SYS")) {
1.788 - if (ts.moveNext()) {
1.789 - token = ts.token();
1.790 - if (token.id() == PlsqlTokenId.DOT) {
1.791 - if (ts.moveNext()) {
1.792 - token = ts.token();
1.793 - if (!token.toString().toLowerCase(Locale.ENGLISH).startsWith("check")) {
1.794 - if (moveToReturnEnd(ts, endOffset)) {
1.795 - isReturnMissing = false;
1.796 - hasReturn = HAS_RETURNS;
1.797 - }
1.798 - }
1.799 - }
1.800 - }
1.801 - }
1.802 - } else if (token.toString().equalsIgnoreCase("EXCEPTION")) {
1.803 - isException = true;
1.804 - } else if (token.toString().equalsIgnoreCase("WHEN") && isException) {
1.805 - if (!isReturnMissing) {
1.806 - if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) { //Exception name
1.807 - if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) {
1.808 - token = ts.token();
1.809 - if (token.toString().equalsIgnoreCase("THEN")) {
1.810 - isReturnMissing = true;
1.811 - }
1.812 - }
1.813 - }
1.814 - } else {
1.815 - //return missing in above WHEN
1.816 - break;
1.817 - }
1.818 - }
1.819 - }
1.820 - }
1.821 -
1.822 - return isReturnMissing;
1.823 - }
1.824 -
1.825 - public static boolean getUnreachableOffsets(final Document doc, final PlsqlBlock block, final List<Integer> lstUnreachable) throws BadLocationException {
1.826 - final List<PlsqlBlock> children = block.getChildBlocks();
1.827 - Collections.sort(children, comparator);
1.828 - boolean isConstrusctReturn = false;
1.829 - boolean isChildReturn = false;
1.830 - boolean isReturn = false;
1.831 -
1.832 - int startOffset = findBlockImplStart(doc, block);
1.833 - for (PlsqlBlock child : children) {
1.834 - if (child.getType() != PlsqlBlockType.CURSOR
1.835 - && child.getType() != PlsqlBlockType.CUSTOM_FOLD) {
1.836 - if (startOffset < child.getStartOffset()) {
1.837 - if (getUnreachableOffsets(startOffset, child.getStartOffset(), doc, lstUnreachable, isReturn)) {
1.838 - isReturn = true;
1.839 - }
1.840 - }
1.841 -
1.842 - isChildReturn = getUnreachableOffsets(doc, child, lstUnreachable);
1.843 -
1.844 - if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("IF"))
1.845 - || (child.getType() == PlsqlBlockType.CASE && child.getName().toUpperCase(Locale.ENGLISH).startsWith("CASE"))) {
1.846 - isConstrusctReturn = isChildReturn;
1.847 - } else if ((child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("ELSIF"))
1.848 - || (child.getType() == PlsqlBlockType.IF && child.getName().toUpperCase(Locale.ENGLISH).startsWith("WHEN"))) {
1.849 - if (isConstrusctReturn) {
1.850 - isConstrusctReturn = isChildReturn;
1.851 - }
1.852 - } else if ((child.getType() == PlsqlBlockType.IF || child.getType() == PlsqlBlockType.CASE)
1.853 - && child.getName().equalsIgnoreCase("ELSE")) {
1.854 - if (isConstrusctReturn) {
1.855 - isConstrusctReturn = isChildReturn;
1.856 - if (isConstrusctReturn) {
1.857 - isReturn = true;
1.858 - }
1.859 - }
1.860 - }
1.861 - }
1.862 - startOffset = child.getEndOffset();
1.863 - }
1.864 -
1.865 - isConstrusctReturn = getUnreachableOffsets(startOffset, block.getEndOffset(), doc, lstUnreachable, isReturn);
1.866 - if (!isReturn) {
1.867 - isReturn = isConstrusctReturn;
1.868 - }
1.869 -
1.870 - return isReturn;
1.871 - }
1.872 -
1.873 - private static boolean getUnreachableOffsets(final int startOffset, final int endOffset, final Document doc, final List<Integer> lstUnreachable, boolean isReturn) throws BadLocationException {
1.874 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.875 - @SuppressWarnings("unchecked")
1.876 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.877 - int endLineCount = 0;
1.878 -
1.879 - if (ts != null) {
1.880 - ts.move(startOffset);
1.881 - Token<PlsqlTokenId> token = ts.token();
1.882 - boolean isException = false;
1.883 - boolean isRaised = false;
1.884 -
1.885 - while (ts.moveNext() && ts.offset() < endOffset) {
1.886 - token = ts.token();
1.887 -
1.888 - if (token.toString().equalsIgnoreCase("RETURN")) {
1.889 - if (moveToReturnEnd(ts, endOffset)) {
1.890 - isReturn = true;
1.891 - }
1.892 - } else if (token.toString().equalsIgnoreCase("RAISE")) {
1.893 - if (moveToReturnEnd(ts, endOffset)) {
1.894 - isRaised = true;
1.895 - }
1.896 - } else if (token.toString().equalsIgnoreCase("ERROR_SYS")) {
1.897 - if (ts.moveNext()) {
1.898 - token = ts.token();
1.899 - if (token.id() == PlsqlTokenId.DOT) {
1.900 - if (ts.moveNext()) {
1.901 - token = ts.token();
1.902 - if (!token.toString().toLowerCase(Locale.ENGLISH).startsWith("check")) {
1.903 - if (moveToReturnEnd(ts, endOffset)) {
1.904 - isReturn = true;
1.905 - isRaised = true;
1.906 - }
1.907 - }
1.908 - }
1.909 - }
1.910 - }
1.911 - } else if (token.toString().equalsIgnoreCase("EXCEPTION")) {
1.912 - isException = true;
1.913 - return isReturn;
1.914 - } else if (token.toString().equalsIgnoreCase("WHEN") && isException) {
1.915 - if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) { //Exception name
1.916 - if (PlsqlParserUtil.getNextNonWhitespace(ts, true)) {
1.917 - token = ts.token();
1.918 - if (token.toString().equalsIgnoreCase("THEN")) {
1.919 - isReturn = false;
1.920 - isRaised = true;
1.921 - endLineCount = 0;
1.922 - }
1.923 - }
1.924 - }
1.925 - } else if ((isReturn || isRaised) && token.toString().contains("\n")) {
1.926 - endLineCount++;
1.927 - } else if (endLineCount > 0 && token.toString().toUpperCase(Locale.ENGLISH).contains("END")
1.928 - && (NbEditorUtilities.getLine(doc, ts.offset(), false).getLineNumber()
1.929 - == NbEditorUtilities.getLine(doc, endOffset, false).getLineNumber() || isRaised)) {
1.930 - //avoid END of blocks being unreachable statements
1.931 - endLineCount = 0;
1.932 - } else if (endLineCount > 0 && token.toString().contains(";")) {
1.933 - lstUnreachable.add(ts.offset());
1.934 - }
1.935 - }
1.936 - }
1.937 -
1.938 - return isReturn;
1.939 - }
1.940 -
1.941 - private static int findBlockImplStart(final Document doc, final PlsqlBlock block) {
1.942 - int startOffset = block.getStartOffset();
1.943 - final TokenHierarchy tokenHierarchy = TokenHierarchy.get(doc);
1.944 - @SuppressWarnings("unchecked")
1.945 - final TokenSequence<PlsqlTokenId> ts = tokenHierarchy.tokenSequence(PlsqlTokenId.language());
1.946 -
1.947 - if (ts != null) {
1.948 - ts.move(startOffset);
1.949 - Token<PlsqlTokenId> token = ts.token();
1.950 - while (ts.moveNext() && ts.offset() < block.getEndOffset()) {
1.951 - token = ts.token();
1.952 -
1.953 - if (token.toString().equalsIgnoreCase("BEGIN")) {
1.954 - startOffset = ts.offset();
1.955 - break;
1.956 - }
1.957 - }
1.958 - }
1.959 -
1.960 - return startOffset;
1.961 - }
1.962 -
1.963 - private static boolean moveToReturnEnd(final TokenSequence<PlsqlTokenId> ts, final int endOffset) {
1.964 - Token<PlsqlTokenId> token = ts.token();
1.965 - while (ts.moveNext() && ts.offset() < endOffset) {
1.966 - token = ts.token();
1.967 - if (token.toString().equals(";")) {
1.968 - return true;
1.969 - }
1.970 - }
1.971 -
1.972 - return false;
1.973 - }
1.974 -
1.975 - public static PlsqlBlock findMatchingImpl(final List<PlsqlBlock> blockHier, final Document source,
1.976 - final Document dest, final PlsqlBlock sourceBlock) {
1.977 - PlsqlBlock match = null;
1.978 - final List<PlsqlBlock> matchList = new ArrayList<PlsqlBlock>();
1.979 - PlsqlParserUtil.findMatchingImplBlocks(blockHier, sourceBlock.getName(), matchList);
1.980 -
1.981 - //There are several methods with the same name. Have to check the signature
1.982 - final List<String> usageParams = PlsqlParserUtil.fetchMethodDefParamTypes(source, sourceBlock.getStartOffset());
1.983 -
1.984 - //Take PlsqlBlock one by one and compare the parameters
1.985 - for (int x = 0; x < matchList.size(); x++) {
1.986 - final PlsqlBlock block = matchList.get(x);
1.987 - if (!(block.getParent() != null && sourceBlock.getParent() != null ? block.getParent().getName().equals(sourceBlock.getParent().getName()) : true)) {
1.988 - continue; //If the parent block name is not the same this is not a match
1.989 - }
1.990 - final List<String> params = PlsqlParserUtil.fetchMethodDefParamTypes(dest, block.getStartOffset());
1.991 - final int defaultNo = PlsqlParserUtil.fetchDefaultParams(dest, block.getStartOffset());
1.992 - if (PlsqlParserUtil.compareParameters(usageParams, params, defaultNo)) {
1.993 - match = block;
1.994 - break;
1.995 - }
1.996 - }
1.997 -
1.998 - return match;
1.999 - }
1.1000 + return match;
1.1001 + }
1.1002 }