mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't highlight the entire expression and add test
This commit is contained in:
+1
-1
@@ -1037,7 +1037,7 @@ non.synchronized.method.overrides.synchronized.method.problem.descriptor=Unsynch
|
||||
public.field.accessed.in.synchronized.context.problem.descriptor=Non-private field <code>#ref</code> accessed in synchronized context #loc
|
||||
field.accessed.synchronized.and.unsynchronized.problem.descriptor=Field <code>#ref</code> is accessed in both synchronized and unsynchronized contexts #loc
|
||||
extended.for.statement.problem.descriptor=Extended <code>#ref</code> statement #loc
|
||||
object.allocation.in.loop.problem.descriptor=Object allocation <code>#ref</code> in loop #loc
|
||||
object.allocation.in.loop.problem.descriptor=Object allocation <code>new #ref()</code> in loop #loc
|
||||
instantiating.object.to.get.class.object.problem.descriptor=Instantiating object to get Class object #loc
|
||||
field.may.be.static.problem.descriptor=Field <code>#ref</code> may be 'static' #loc
|
||||
method.may.be.static.problem.descriptor=Method <code>#ref()</code> may be 'static' #loc
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class ObjectAllocationInLoopInspection extends BaseInspection {
|
||||
if (isAllocatedOnlyOnce(expression)) {
|
||||
return;
|
||||
}
|
||||
registerError(expression);
|
||||
registerNewExpressionError(expression);
|
||||
}
|
||||
|
||||
private static boolean isAllocatedOnlyOnce(
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.igtest.performance.object_allocation_in_loop;
|
||||
|
||||
class ObjectAllocationInLoop {
|
||||
|
||||
void m() {
|
||||
while (true) {
|
||||
new <warning descr="Object allocation 'new Object()' in loop">Object</warning>();
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ig.performance;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.siyeh.ig.LightInspectionTestCase;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class ObjectAllocationInLoopInspectionTest extends LightInspectionTestCase {
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new ObjectAllocationInLoopInspection();
|
||||
}
|
||||
|
||||
public void testObjectAllocationInLoop() { doTest(); }
|
||||
}
|
||||
Reference in New Issue
Block a user